Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(plugins): migrate built-in plugins to desktop repository (#274)

Mao Mr37891c006329
diff --git a/.gitignore b/.gitignore
index bad780bb..514bedc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
node_modules
dist
+.build-plugins-tmp
src-tauri/target
src-tauri/gen
src-tauri/resources/node
diff --git a/docs/BUILTIN_PLUGINS.md b/docs/BUILTIN_PLUGINS.md
index a3e895de..9a9fb296 100644
--- a/docs/BUILTIN_PLUGINS.md
+++ b/docs/BUILTIN_PLUGINS.md
@@ -1,38 +1,52 @@
# Built-in (Internal) Plugins
-Built-in plugins(内置插件)are plugins bundled with the installed desktop app and treated as part of the application itself. They are declared in `src-tauri/resources/internal-plugins.json`, fetched at build time by `scripts/prebuild.ts` into `src-tauri/resources/internal-plugins/<id>/`, shipped with the installer via `bundle.resources`, and auto-installed (and auto-healed) at service start by `src-tauri/src/service/plugin/internal.rs`.
+Built-in plugins(内置插件)are plugins bundled with the installed desktop app and treated as part of the application itself. Their source is the monorepo workspace packages under `packages/`; at build time `scripts/build-plugins.ts` uses `pnpm deploy` to pack the plugins listed in `packages/dsh-tauri-bundle/package.json` into `src-tauri/resources/node_modules/<name>`, which is shipped with the installer via `bundle.resources`, and them auto-installed (and auto-healed) at service start by `src-tauri/src/service/plugin/internal.rs`.
-Examples today: `dsh-tauri`, `dsh-tauri-ui`, `dsh-tauri-worktree`, `dsh-tauri-panel`, and `dsh-tauri-panel-extension`.
+Examples today: `dsh-tauri`, `dsh-tauri-ui`, `dsh-tauri-worktree`, `dsh-tauri-panel`, `dsh-tauri-panel-extension`, `dsh-tauri-session`, and `dsh-tauri-rightclick`.
## Built-in vs. normal preset plugin
| | Normal preset plugin | Built-in (internal) plugin |
| --- | --- | --- |
| Manifest | `preset-plugins.json` | `internal-plugins.json` |
-| Source | npm / GitHub, installed at first-launch onboarding | Bundled in the installer, auto-installed at startup |
+| Source | npm / GitHub, installed at first-launch onboarding | Workspace package under `packages/`, bundled in the installer, auto-installed at startup |
| Shown in the first-launch checklist | Yes (`recommended` / `fix` / `defaultChecked` chips) | No — they are mandatory (filtered out in `installed.rs`) |
| User can uninstall | Yes | Effectively no — restored on the next launch |
| Version source | Resolved at install time from the declared `spec` | Bundled artifact shipped with the app |
## How the mechanism works
-**Build time** — `scripts/prebuild.ts` is run automatically by `pnpm build` (the `prebuild` script, which Tauri invokes as its `beforeBuildCommand` = `pnpm build`). For each entry in `internal-plugins.json` it produces `src-tauri/resources/internal-plugins/<id>/`:
+**Build time** — `scripts/build-plugins.ts` is run automatically by `pnpm build` (the `prebuild` script, which pnpm runs automatically before `build`). It:
-- `github:owner/repo` — `git clone --depth 1` → `pnpm install` → `pnpm run build` (if a `build` script exists) → copy the build output plus `package.json`.
-- `name[@version]` (npm, incl. scoped `@scope/name`) — `pnpm add <spec> --ignore-scripts` in a temporary project → copy `node_modules/<name>/`.
+1. builds every runtime plugin package (`dsh-tauri-bundle` and `dsh-tauri-tsdown` are excluded),
+2. runs `pnpm --filter dsh-tauri-bundle deploy --prod --config.inject-workspace-packages=true <temp>` to pack only the plugins listed in `dsh-tauri-bundle`'s `dependencies` (plus their real production closure) into a temporary directory — the injected deploy avoids dragging the whole workspace's UI stack into the bundle,
+3. verifies each bundled package, then materializes the temporary `node_modules` (dereferencing any links) into `src-tauri/resources/node_modules`.
+
+The built-in plugin set is the workspace packages that contain a `dsh` object in their `package.json`. `packages/dsh-tauri-bundle` is a private aggregation package whose `dependencies` enumerate exactly which of those should be bundled; the running plugin packages are TS modules that declare their dsh manifest and a `main` entry.
**Runtime** — before the harness service launches, `service::plugin::internal::ensure` checks each internal plugin: ① it is declared in the current profile's `package.json` `dependencies`, ② the declared dependency value still points at the current bundled dir (`link:<abspath>`), ③ `node_modules/<package>` actually exists. If any check fails (missing / path changed / user removed it / `node_modules` wiped), it forces a reinstall through the normal install flow with a `link:` spec.
## Add a new built-in plugin
-### 1. Declare it in `src-tauri/resources/internal-plugins.json`
+### 1. Create (or reuse) a workspace package under `packages/`
+
+The package must be a workspace member (implicit via `pnpm-workspace.yaml`'s `packages: ['packages/*']`) and:
+
+- its `package.json` has a `main` field pointing at the built entry (e.g. `./dist/index.js`),
+- its `package.json` has a non-empty `dsh` object (the runtime plugin manifest),
+- it is **not** `private: true` (private packages — the bundler `dsh-tauri-bundle`, the tooling `dsh-tauri-tsdown`, and the demo placeholder `dsh-tauri-panel-placeholder` — are not built-in plugins),
+- it declares a `build` script (e.g. `tsdown`) so `build:plugins` can produce its `dist`.
-Append an entry:
+### 2. Declare it in `packages/dsh-tauri-bundle/package.json`
+
+Add it to that package's `dependencies` as `workspace:*`. This is the source both for `pnpm deploy` (what gets bundled) and for release `internal-plugins.json` (what gets self-healed).
+
+### 3. Add a release manifest entry in `src-tauri/resources/internal-plugins.json`
```json
{
"id": "dsh-my-plugin",
- "spec": "github:you/dsh-my-plugin",
+ "spec": "dsh-my-plugin",
"name": "DSH My Plugin",
"description": "What the plugin does",
"repoUrl": "https://github.com/you/dsh-my-plugin"
@@ -41,46 +55,44 @@ Append an entry:
Field reference:
-- `id` — unique preset id (the repo jump / lookup key; also the default npm package name used for install-state detection). Ids must be unique across the list (enforced by the `preset_json_ids_are_unique` unit test).
-- `spec` — the source. Either `github:owner/repo` (source form) or an npm package spec `name[@version]` (published form, skips the build). Omit `@version` to resolve the registry's latest release at build time, which avoids manifest-only version bumps. This is what `prebuild.ts` feeds to git/pnpm.
+- `id` — unique preset id (the repo jump / lookup key; also the default npm package name used for install-state detection). Ids must be unique across the list (enforced by the `plugin_manifest_ids_are_unique_across_files` unit test).
+- `spec` — the install dependency key. For built-in plugins it must match the package's real npm name (usually the same as the id, or a scoped `@scope/name`).
- `name`, `description`, `repoUrl` — display metadata. `repoUrl` is used for the repo-jump link in the UI.
- `package` — optional. When the real npm package name differs from `id` (typical for scoped `@scope/name`), declare it here; it is used for install-state detection and self-heal matching. Defaults to `id`.
- Chip flags `recommended` / `fix` / `defaultChecked` — not meaningful for internal plugins (they never appear in the checklist) but harmless to keep.
-### 2. Bundle it at build time
+### 4. Bundle it at build time
-No manual step. `pnpm tauri build` runs `pnpm build` → `pnpm prebuild` → `tsx scripts/prebuild.ts`, which reads the internal manifest and produces `src-tauri/resources/internal-plugins/<id>/`. The build machine needs `git` and `pnpm` on PATH and network access to GitHub (for `github:` sources) and npm (for package-name sources).
+No manual step. `pnpm tauri build` runs `pnpm build`, whose `prebuild` runs `pnpm build:plugins` (`tsx scripts/build-plugins.ts`) and packs all `dsh-tauri-bundle` dependencies into `src-tauri/resources/node_modules/`. The build machine needs `pnpm` on PATH; the plugin packages are local, so no network access to GitHub/npm is required for the runtime plugins themselves.
The bundled directory is shipped with the installer via `bundle.resources` (`"resources": ["resources/**/*"]` in `src-tauri/tauri.conf.json`).
-The plugin's `package.json` should declare a `files` whitelist so prebuild copies only the runtime-necessary files; when absent it copies the whole directory minus `node_modules` / `.git` / `.npmrc` etc. `package.json` is always copied last so it is guaranteed present (it is the package-name/entry source for `pnpm add link:<dir>`).
-
-### 3. Runtime auto-install handles the rest
+### 5. Runtime auto-install handles the rest
On startup, `service::plugin::internal::ensure` verifies the plugin is installed and that the installed spec points at the bundled dir; if not, it reinstalls automatically. No UI work and no onboarding checkbox — a user can never be left without a built-in plugin.
## Development (debug) iteration
-For fast iteration in a debug build, set the `DEV_INTERNAL_PLUGINS_DIR` key in the repo-root `.env` (see `.env.example`) to a local directory holding the plugin sources. For each internal plugin the runtime looks up `<dir>/<id>`; if present, that local source dir becomes the install target (a pnpm directory junction), so editing the source and restarting the service hot-reloads the plugin — no sub-plugin git commit and no `prebuild`.
+In a debug build the runtime discovers built-in plugins directly from the workspace: any non-private `packages/*` package whose `package.json` has a `dsh` object is automatically an internal plugin. `bundled_plugin_dir` maps its id to that source directory, so the install target is the plugin source (a pnpm directory junction) — editing the source and restarting the service hot-reloads the plugin. No `.env`, no sub-plugin git commit, and no build-time bundling.
Rules:
-- `.env` is gitignored and local-only; the key is only read in `debug_assertions` builds (release always uses the packaged dir).
-- If the id is missing in `<dir>`, the plugin is skipped rather than falling back to the packaged dir, so the misconfiguration is noticed explicitly.
-- Setting it empty or deleting the key disables the override (falls back to the packaged `resources/internal-plugins/<id>`).
+- Discovery reads `package.json` only; it ignores directories without a `dsh` object, directories with an unparseable manifest, and `private: true` packages.
+- The plugin id is the real `package.name`, not the directory name; ids are deduplicated (a second package declaring the same name is skipped with a `DEV_INTERNAL_PLUGIN_DUPLICATE` warning).
+- If a release-only plugin id is missing from `packages/`, the runtime falls back to the packaged `resources/node_modules/<name>`.
## Gotchas
- **Why `link:` and not `file:`** — pnpm resolves `file:D:/...` (a Windows drive-absolute path) as a *relative* path and fails (`scandir <cwd>\D:\... ENOENT`), while `link:<abspath>` resolves the absolute path correctly and creates a directory junction. `bundled_dep_spec` also strips the Windows `\\?\` verbatim prefix via `dunce::simplified` so the junction is not corrupted; otherwise the self-heal reinstalls on every launch (an infinite loop). The spec is compared case-insensitively on Windows, tolerating `link:`/`file:` mix and trailing-slash differences.
- **Paths with spaces** — the install dir (e.g. `G:\Deepseek Harness Desktop\...`) often contains spaces; `dsh plugin add` passes the spec through a shell, so `install.rs` wraps such specs in embedded double quotes (`shell_quote_spec`). Don't remove that.
-- **prebuild fails loudly** — `scripts/prebuild.ts` exits non-zero on any failure so the build breaks rather than shipping a broken internal plugin. If a bundled dir is still missing at runtime in a release build, the log emits `INTERNAL_PLUGIN_BUNDLE_MISSING`.
-- **Build machine access** — prebuild needs network access to GitHub/npm and `git`/`pnpm` on PATH; it only uses Node built-ins (no new deps).
+- **build:plugins fails loudly** — `scripts/build-plugins.ts` exits non-zero on any failure so the build breaks rather than shipping a broken internal plugin. If a bundled dir is still missing at runtime in a release build, the log emits `INTERNAL_PLUGIN_BUNDLE_MISSING`.
- **Keep ids unique** — the manifest unit tests require unique ids. Publishing and version-bumping the plugin itself happens in its own repo, outside this one.
## Reference
-- `src-tauri/resources/internal-plugins.json` — the internal plugin manifest you edit.
-- `scripts/prebuild.ts` — build-time bundling (git / npm sources).
-- `src-tauri/src/service/plugin/preset.rs` — manifest parsing, bundled-dir discovery, and the `link:` spec builder.
+- `packages/dsh-tauri-bundle/package.json` — declares which workspace packages are bundled (via `dependencies`).
+- `scripts/build-plugins.ts` — build-time bundling (builds plugin packages, `pnpm deploy` into `resources/node_modules`).
+- `src-tauri/resources/internal-plugins.json` — the release internal plugin manifest.
+- `src-tauri/src/service/plugin/preset.rs` — manifest parsing, dev `packages/*` discovery, bundled-dir resolution, and the `link:` spec builder.
- `src-tauri/src/service/plugin/internal.rs` — runtime self-heal.
- `src-tauri/src/service/plugin/install.rs` — the install orchestration reused by the self-heal.
diff --git a/docs/BUILTIN_PLUGINS.zh.md b/docs/BUILTIN_PLUGINS.zh.md
index d609d2f1..5b4a8961 100644
--- a/docs/BUILTIN_PLUGINS.zh.md
+++ b/docs/BUILTIN_PLUGINS.zh.md
@@ -1,38 +1,52 @@
# 内置插件(Internal Plugins)
-内置插件(built-in plugin)是指随安装包分发、被视作应用本身一部分的插件。它们在 `src-tauri/resources/internal-plugins.json` 中声明,由 `scripts/prebuild.ts` 在构建期拉取到 `src-tauri/resources/internal-plugins/<id>/`,随 `bundle.resources` 一并打进安装包,并在服务启动时由 `src-tauri/src/service/plugin/internal.rs` 自动安装(并自愈)。
+内置插件(built-in plugin)是指随安装包分发、被视作应用本身一部分的插件。它们来源于本仓库 workspace 里 `packages/` 下的插件包;构建期由 `scripts/build-plugins.ts` 用 `pnpm deploy` 把 `packages/dsh-tauri-bundle/package.json` 中声明的插件打包到 `src-tauri/resources/node_modules/<name>`,随 `bundle.resources` 一并打进安装包,并在服务启动时由 `src-tauri/src/service/plugin/internal.rs` 自动安装(并自愈)。
-目前的内置插件:`dsh-tauri`、`dsh-tauri-ui`、`dsh-tauri-worktree`、`dsh-tauri-panel`、`dsh-tauri-panel-extension`。
+目前的内置插件:`dsh-tauri`、`dsh-tauri-ui`、`dsh-tauri-worktree`、`dsh-tauri-panel`、`dsh-tauri-panel-extension`、`dsh-tauri-session`、`dsh-tauri-rightclick`。
## 内置插件 vs. 普通预装插件
| | 普通预装插件 | 内置(internal)插件 |
| --- | --- | --- |
| 清单 | `preset-plugins.json` | `internal-plugins.json` |
-| 来源 | npm / GitHub,首次引导时安装 | 随安装包分发,启动时自动安装 |
+| 来源 | npm / GitHub,首次引导时安装 | `packages/` 下的 workspace 包,随安装包分发,启动时自动安装 |
| 出现在首次引导清单 | 是(`recommended` / `fix` / `defaultChecked` chip) | 否——它们“必装”,在 `installed.rs` 里被过滤掉 |
| 用户可卸载 | 可以 | 基本不行——下次启动自动恢复 |
| 版本来源 | 安装时按声明的 `spec` 解析 | 随安装包分发的捆绑产物 |
## 机制是怎么运作的
-**构建期** — `scripts/prebuild.ts` 由 `pnpm build` 自动触发(`prebuild` 脚本,而 Tauri 的 `beforeBuildCommand` 恰好是 `pnpm build`)。对 `internal-plugins.json` 中的每个条目,它产出 `src-tauri/resources/internal-plugins/<id>/`:
+**构建期** — `scripts/build-plugins.ts` 由 `pnpm build` 自动触发(`prebuild` 脚本,pnpm 会在 `build` 前自动运行)。它:
-- `github:owner/repo` — `git clone --depth 1` → `pnpm install` → `pnpm run build`(存在 `build` 脚本时)→ 拷贝构建产物与 `package.json`。
-- `name[@version]`(npm 包名,含 scoped `@scope/name`)— 在临时工程里 `pnpm add <spec> --ignore-scripts` → 拷贝 `node_modules/<name>/`。
+1. 先构建每个运行插件包(排除 `dsh-tauri-bundle` 与 `dsh-tauri-tsdown`),
+2. 再执行 `pnpm --filter dsh-tauri-bundle deploy --prod --config.inject-workspace-packages=true <临时目录>`,只把 `dsh-tauri-bundle` 的 `dependencies` 里列出的插件及其真实生产闭包打包到临时目录(注入式 deploy 避免把整个 workspace 的 UI 栈混进产物),
+3. 逐个校验打包产物,然后把临时 `node_modules` 解引用复制(materialize)到 `src-tauri/resources/node_modules`。
+
+内置插件集合 = 那些在 `package.json` 里带 `dsh` 对象的 workspace 包。`packages/dsh-tauri-bundle` 是一个 private 聚合包,它的 `dependencies` 明确列举了要打包哪些;运行插件是声明了 dsh 清单与 `main` 入口的 TS 模块。
**运行期** — 在 harness 服务启动前,`service::plugin::internal::ensure` 逐个核对内部插件:① 它是否在当前档案的 `package.json` `dependencies` 中声明;② 声明值是否仍指向当前捆绑目录(`link:<绝对路径>`);③ `node_modules/<package>` 是否真实存在。任一不满足(缺失 / 路径变更 / 用户卸载 / node_modules 被清空)→ 走常规安装流程,用 `link:` 依赖强制重装。
## 添加一个新的内置插件
-### 1. 在 `src-tauri/resources/internal-plugins.json` 中声明
+### 1. 在 `packages/` 下创建(或复用)一个 workspace 包
+
+该包必须是 workspace 成员(由 `pnpm-workspace.yaml` 的 `packages: ['packages/*']` 隐式包含),并且:
+
+- 它的 `package.json` 有 `main` 字段指向构建产物(如 `./dist/index.js`);
+- 它的 `package.json` 有非空 `dsh` 对象(运行期插件清单);
+- 它**不是** `private: true`(私有包——打包器 `dsh-tauri-bundle`、工具包 `dsh-tauri-tsdown`、演示占位插件 `dsh-tauri-panel-placeholder`——都不是内置插件);
+- 它声明了 `build` 脚本(如 `tsdown`),让 `build:plugins` 能产出其 `dist`。
-追加一条:
+### 2. 在 `packages/dsh-tauri-bundle/package.json` 中声明
+
+把它加到该包的 `dependencies`,值为 `workspace:*`。这既是 `pnpm deploy`(打包哪些)的来源,也是 release `internal-plugins.json`(哪些参与自愈)的来源。
+
+### 3. 在 `src-tauri/resources/internal-plugins.json` 中追加 release 清单条目
```json
{
"id": "dsh-my-plugin",
- "spec": "github:you/dsh-my-plugin",
+ "spec": "dsh-my-plugin",
"name": "DSH My Plugin",
"description": "插件做什么",
"repoUrl": "https://github.com/you/dsh-my-plugin"
@@ -41,46 +55,44 @@
字段说明:
-- `id` — 预设唯一 id(仓库跳转 / 查找键;也是未显式声明 `package` 时的默认包名,用于“已安装”检测)。清单内 id 必须唯一(由 `preset_json_ids_are_unique` 单测保证)。
-- `spec` — 来源。要么 `github:owner/repo`(源码形态),要么 npm 包规格 `name[@version]`(已发布产物形态,跳过构建)。省略 `@version` 时会在构建期解析 registry 中的最新正式版本,避免仅为升级插件而修改清单版本号。这是 `prebuild.ts` 喂给 git/pnpm 的值。
+- `id` — 预设唯一 id(仓库跳转 / 查找键;也是未显式声明 `package` 时的默认包名,用于“已安装”检测)。清单内 id 必须唯一(由 `plugin_manifest_ids_are_unique_across_files` 单测保证)。
+- `spec` — 安装依赖键。内置插件必须匹配包的真实 npm 包名(通常与 id 相同,或 scoped `@scope/name`)。
- `name`、`description`、`repoUrl` — 展示元数据;`repoUrl` 供界面“仓库跳转”链接使用。
- `package` — 可选。当真实 npm 包名与 `id` 不一致(常见于 scoped 包 `@scope/name`)时在这里声明;用于“已安装”检测与自愈对账。缺省回落 `id`。
- chip 标记 `recommended` / `fix` / `defaultChecked` — 对内置插件无意义(它们不进清单),保留也无妨。
-### 2. 构建期打包
+### 4. 构建期打包
-无需手工操作。`pnpm tauri build` 会执行 `pnpm build` → `pnpm prebuild` → `tsx scripts/prebuild.ts`,读取内部插件清单并产出 `src-tauri/resources/internal-plugins/<id>/`。构建机需要 PATH 上有 `git` 与 `pnpm`,并能访问 GitHub(`github:` 来源)与 npm registry(包名来源)。
+无需手工操作。`pnpm tauri build` 会执行 `pnpm build`,其 `prebuild` 运行 `pnpm build:plugins`(`tsx scripts/build-plugins.ts`),把 `dsh-tauri-bundle` 的所有依赖打包进 `src-tauri/resources/node_modules/`。构建机需要 PATH 上有 `pnpm`;插件包是本地 workspace,因此运行插件本身无需访问 GitHub/npm(零网络拉取)。
捆绑目录通过 `bundle.resources` 随安装包分发(`src-tauri/tauri.conf.json` 中的 `"resources": ["resources/**/*"]`)。
-插件的 `package.json` 最好声明 `files` 白名单,让 prebuild 只拷贝运行必需文件;未声明时则拷贝整目录但排除 `node_modules` / `.git` / `.npmrc` 等。`package.json` 恒在最后拷贝,保证一定存在(它是 `pnpm add link:<目录>` 的包名/入口来源)。
-
-### 3. 运行期自动安装接管后续
+### 5. 运行期自动安装接管后续
启动时 `service::plugin::internal::ensure` 核对插件已安装且安装 spec 指向捆绑目录;不满足则自动重装。无需任何前端/引导改动——用户不可能缺内置插件。
## 开发(debug)迭代
-想在 debug 构建里快速迭代,可在仓库根 `.env`(参考 `.env.example`)里设置 `DEV_INTERNAL_PLUGINS_DIR`,指向存放插件源码的本地目录。对每个内置插件,运行时会查找 `<dir>/<id>`;命中则以该本地源码目录为安装目标(pnpm 目录联接,改源码后重启服务即热更新)——无需提交子插件 git、无需跑 prebuild。
+在 debug 构建里,运行期直接从 workspace 发现内置插件:任何非私有的 `packages/*` 包,只要其 `package.json` 带 `dsh` 对象,就自动成为内置插件。`bundled_plugin_dir` 把它的 id 映射到该源码目录,安装目标即插件源码(pnpm 目录联接,改源码后重启服务即热更新)——无需 `.env`、无需提交子插件 git、无需构建期打包。
规则:
-- `.env` 已被 `.gitignore` 忽略,仅本地生效;该键只在 `debug_assertions` 构建读取(release 恒用随包目录)。
-- 若 `<dir>` 缺该 id,则跳过(不回落随包目录),让开发者显式感知配置错误。
-- 置空或删除该键 = 关闭覆盖(回落随包分发的 `resources/internal-plugins/<id>`)。
+- 发现只读 `package.json`;忽略没有 `dsh` 对象的目录、清单无法解析的目录以及 `private: true` 的包。
+- 插件 id 是真实的 `package.name`,而不是目录名;id 会去重(第二个声明重名的包会被跳过并记 `DEV_INTERNAL_PLUGIN_DUPLICATE` 告警)。
+- 若某 release 专属插件 id 在 `packages/` 下缺失,运行期回落随包分发的 `resources/node_modules/<name>`。
## 常见坑
- **为什么用 `link:` 而不是 `file:`** — pnpm 会把 `file:D:/...`(Windows 盘符绝对路径)当**相对路径**解析而失败(`scandir <cwd>\D:\... ENOENT`),`link:<绝对路径>` 才正确按绝对路径解析并建立目录联接。`bundled_dep_spec` 还会用 `dunce::simplified` 归一化 Windows `\\?\` verbatim 前缀,避免生成坏联接;否则自愈每轮都重装(死循环)。该 spec 在 Windows 上大小写不敏感比对,并容忍 `link:`/`file:` 混写与尾部斜杠差异。
- **路径含空格** — 应用安装目录(如 `G:\Deepseek Harness Desktop\...`)常含空格;`dsh plugin add` 经 shell 传参,`install.rs` 用 `shell_quote_spec` 给这类 spec 加内嵌双引号,不要去掉。
-- **prebuild 响亮失败** — `scripts/prebuild.ts` 任何失败都会以非零退出码终止构建,宁可不发也不要发出损坏的内置插件。若 release 运行期仍缺捆绑目录,日志会记 `INTERNAL_PLUGIN_BUNDLE_MISSING`。
-- **构建机访问** — prebuild 需要访问 GitHub/npm,PATH 上要有 `git`/`pnpm`;它只用 Node 内置模块(零新增依赖)。
+- **build:plugins 响亮失败** — `scripts/build-plugins.ts` 任何失败都会以非零退出码终止构建,宁可不发也不要发出损坏的内置插件。若 release 运行期仍缺捆绑目录,日志会记 `INTERNAL_PLUGIN_BUNDLE_MISSING`。
- **id 保持唯一** — 清单单测要求 id 唯一。插件自身的发布与版本号变更在其自己的仓库进行,不在本仓库内。
## 参考
-- `src-tauri/resources/internal-plugins.json` — 你要编辑的内部插件清单。
-- `scripts/prebuild.ts` — 构建期打包(git / npm 两种来源)。
-- `src-tauri/src/service/plugin/preset.rs` — 清单解析、捆绑目录发现、`link:` spec 构造。
+- `packages/dsh-tauri-bundle/package.json` — 声明要打包的 workspace 包(通过 `dependencies`)。
+- `scripts/build-plugins.ts` — 构建期打包(构建插件包,`pnpm deploy` 到 `resources/node_modules`)。
+- `src-tauri/resources/internal-plugins.json` — release 内部插件清单。
+- `src-tauri/src/service/plugin/preset.rs` — 清单解析、dev `packages/*` 发现、捆绑目录解析、`link:` spec 构造。
- `src-tauri/src/service/plugin/internal.rs` — 运行期自愈。
- `src-tauri/src/service/plugin/install.rs` — 自愈复用的安装编排。
diff --git a/docs/WORKTREE.md b/docs/spec/WORKTREE.md
similarity index 100%
rename from docs/WORKTREE.md
rename to docs/spec/WORKTREE.md
diff --git a/eslint.config.mjs b/eslint.config.mjs
index ea1678e5..e66fd2cf 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -9,4 +9,12 @@ export default antfu({
'AGENTS.md',
'docs',
],
+}, {
+ // 插件包是库包而非应用壳:client 侧文件按 host/client 双面设计,
+ // 同一文件常同时导出组件与工具函数,react-refresh 的“只导出组件”约束
+ // 不适用于库包,故仅在 packages 下关闭该规则。
+ files: ['packages/**/*.{ts,tsx,jsx,mts,cts}'],
+ rules: {
+ 'react-refresh/only-export-components': 'off',
+ },
})
diff --git a/package.json b/package.json
index d3d4ad0c..de9ba9dd 100644
--- a/package.json
+++ b/package.json
@@ -7,10 +7,12 @@
"description": "Desktop application for DeepSeek Harness (dsh) — one-click local install and launch, no Node.js setup required.",
"scripts": {
"dev": "vite",
- "prebuild": "tsx scripts/prebuild.ts",
- "build": "tsc && vite build && pnpm prebuild",
+ "dev:desktop": "pnpm dev:plugins & tauri dev",
+ "dev:plugins": "pnpm --filter \"./packages/*\" -r --parallel run dev",
+ "prebuild": "tsx scripts/build-plugins.ts",
+ "build": "tsc && vite build",
"preview": "vite preview",
- "tauri": "tsx scripts/predev.ts",
+ "tauri": "tauri",
"release": "bumpp --pr",
"test": "vitest",
"lint": "eslint",
@@ -20,49 +22,56 @@
"icons": "tauri icon public/favicon.svg && tsx scripts/rebuild-macos-icon.ts"
},
"dependencies": {
- "@gravity-ui/icons": "^2.21.0",
- "@hairy/react-lib": "^1.52.0",
- "@hairy/utils": "^1.52.0",
- "@heroui/react": "^3.2.4",
- "@heroui/styles": "^3.2.4",
- "@overlastic/react": "^0.9.0",
- "@tanstack/react-query": "^5.101.4",
- "@tauri-apps/api": "^2.11.1",
- "@tauri-apps/plugin-clipboard-manager": "^2.3.2",
- "i18next": "^26.3.6",
- "react": "^19.2.8",
- "react-dom": "^19.2.8",
- "react-i18next": "^17.0.11",
- "react-if-lite": "^0.1.0",
- "react-use": "^17.6.1",
- "tailwind-variants": "^3.3.1",
- "valtio-define": "^1.4.1"
+ "@gravity-ui/icons": "catalog:runtime",
+ "@hairy/react-lib": "catalog:runtime",
+ "@hairy/utils": "catalog:utils",
+ "@heroui/react": "catalog:runtime",
+ "@heroui/styles": "catalog:runtime",
+ "@overlastic/react": "catalog:runtime",
+ "@tanstack/react-query": "catalog:runtime",
+ "@tauri-apps/api": "catalog:tauri",
+ "@tauri-apps/plugin-clipboard-manager": "catalog:tauri",
+ "i18next": "catalog:runtime",
+ "react": "catalog:runtime",
+ "react-dom": "catalog:runtime",
+ "react-i18next": "catalog:runtime",
+ "react-if-lite": "catalog:runtime",
+ "react-use": "catalog:runtime",
+ "tailwind-variants": "catalog:runtime",
+ "valtio-define": "catalog:runtime"
},
"devDependencies": {
- "@antfu/eslint-config": "^9.3.0",
- "@eslint-react/eslint-plugin": "^5.18.6",
- "@tailwindcss/postcss": "4.1.11",
- "@tailwindcss/vite": "4.1.11",
- "@tauri-apps/cli": "^2.11.4",
- "@types/node": "^22.10.0",
- "@types/react": "^19.2.18",
- "@types/react-dom": "^19.2.4",
- "@vitejs/plugin-react": "^4.6.0",
- "babel-plugin-react-compiler": "^1.0.0",
- "bumpp": "12.2.1",
- "changelogithub": "15.0.5",
- "citty": "^0.2.2",
- "consola": "^3.4.2",
- "dotenv": "^17.4.2",
- "eslint": "^10.8.1",
- "eslint-plugin-react-refresh": "^0.5.4",
- "knip": "^6.32.2",
- "pathe": "^2.0.3",
- "tailwindcss": "4.1.11",
- "tinyexec": "^1.3.0",
- "tsx": "^4.23.12",
- "typescript": "~5.8.3",
- "vite": "^7.0.4",
- "vitest": "^4.1.11"
+ "@antfu/eslint-config": "catalog:lint",
+ "@deepseek-ai/cordis": "catalog:dsh",
+ "@deepseek-ai/dsh-client-runtime": "catalog:dsh",
+ "@deepseek-ai/dsh-client-ui-layout": "catalog:dsh",
+ "@deepseek-ai/dsh-client-ui-primitives": "catalog:dsh",
+ "@deepseek-ai/dsh-client-ui-renderer": "catalog:dsh",
+ "@deepseek-ai/dsh-skill-filesystem": "catalog:dsh",
+ "@eslint-react/eslint-plugin": "catalog:lint",
+ "@tailwindcss/postcss": "catalog:build",
+ "@tailwindcss/vite": "catalog:build",
+ "@tauri-apps/cli": "catalog:tauri",
+ "@types/node": "catalog:types",
+ "@types/react": "catalog:types",
+ "@types/react-dom": "catalog:types",
+ "@vitejs/plugin-react": "catalog:build",
+ "babel-plugin-react-compiler": "catalog:build",
+ "bumpp": "catalog:release",
+ "changelogithub": "catalog:release",
+ "citty": "catalog:utils",
+ "consola": "catalog:utils",
+ "dotenv": "catalog:utils",
+ "eslint": "catalog:lint",
+ "eslint-plugin-react-refresh": "catalog:lint",
+ "knip": "catalog:lint",
+ "pathe": "catalog:utils",
+ "publint": "catalog:cli",
+ "tailwindcss": "catalog:build",
+ "tinyexec": "catalog:utils",
+ "tsx": "catalog:build",
+ "typescript": "catalog:cli",
+ "vite": "catalog:build",
+ "vitest": "catalog:testing"
}
}
diff --git a/packages/AGENTS.md b/packages/AGENTS.md
new file mode 100644
index 00000000..eb8807b1
--- /dev/null
+++ b/packages/AGENTS.md
@@ -0,0 +1,210 @@
+# AGENTS.md
+
+## 项目概览
+
+DeepSeek Harness 的 Tauri 插件 workspace,采用 host half / client half 架构。
+
+- `packages/*/src/*.ts`:宿主侧服务实现。
+- `packages/*/src/index.ts`:宿主侧能力、工具、HTTP 路由和系统上下文。
+- `packages/*/src/types.ts`:宿主侧类型定义。
+- `packages/*/src/constants.ts`:宿主侧常量定义。
+- `packages/*/src/client/*.ts`:浏览器侧插件、slot 组件和 DOM 集成。
+- `packages/*/src/client/types.ts`:该插件客户端共享类型的唯一集中位置。
+- `packages/*/src/client/constants.ts`:该插件客户端共享常量的唯一集中位置。
+- `packages/*/src/client/icons.ts`:该插件客户端共享图标的唯一集中位置,图标只从 github.com/gravity-ui/icons 中获取。
+- `packages/*/src/client/styles.ts`:该插件客户端 css-render 样式树和样式挂载函数。
+
+## 基本技术约定
+
+- 使用 TypeScript,保持 strict 类型检查。
+- 使用 ESM,所有包保留 `"type": "module"`。
+- 使用 pnpm;依赖版本优先通过 `pnpm-workspace.yaml` 的命名 catalog 管理。
+- 使用 `@antfu/eslint-config`,不引入 Prettier。
+- 提交前运行 `pnpm run lint --fix`,不要新增独立的 `lint:fix` script。
+- 完成非平凡改动后必须运行 lint、typecheck、test 和相关 build。
+- 优先使用相对路径导入;只有仓库已经配置并使用的别名才能继续使用。
+- 类型和常量必须显式导入,避免隐式或自动导入。
+- React 组件文件统一使用全小写 kebab-case(`xx-xx.tsx`),例如 `extension-panel.tsx`、`markdown-preview.tsx`;不得使用 PascalCase 文件名。
+- 函数尽量声明明确返回类型;复杂 inline 类型应提取为命名类型。
+- 注释解释设计原因,不重复描述代码表面行为。
+
+## 客户端类型集中规则
+
+每个插件的客户端共享类型统一放在该插件的 `src/client/types.ts`:
+
+```ts
+// src/client/types.ts
+export interface SettingsSidebarProps {
+ // ...
+}
+
+export type SelectorHook<T> = <S>(selector: (state: T) => S) => S
+```
+
+组件、服务和工具文件不得重复声明跨文件使用的 `interface` 或 `type`。使用 type-only import:
+
+```ts
+import type { SelectorHook, SettingsSidebarProps } from './types'
+```
+
+仅在为了兼容既有公开 API 时,才允许从原文件 re-export 类型:
+
+```ts
+export type { NavBridgeHandlers } from './types'
+```
+
+纯组件内部且绝不跨文件使用的极小类型可以保留在组件文件中,但新增类型默认应先考虑放入 `types.ts`。
+
+## 客户端常量集中规则
+
+每个插件的客户端共享常量统一放在该插件的 `src/client/constants.ts`:
+
+- slot 名称、注册 id、registrant、order 和 priority
+- CSS style id、class name、CSS custom property 名称
+- API prefix、storage key、事件 source/type、命令名称
+- 动画时长、尺寸边界、默认值和正则表达式
+- locale namespace 和稳定协议标识
+
+示例:
+
+```ts
+// src/client/constants.ts
+export const PANEL_PROTOCOL_SERVICE = 'panel.protocol'
+export const PANEL_ACTION_SLOT = 'sidebar.panel.action'
+export const PANEL_STYLE_ID = 'dsh-tauri-panel-styles'
+```
+
+组件文件只消费常量,不重复写共享字符串或数字。真正只使用一次且不表达协议的局部值可以保留在实现文件中。
+
+## 样式与 css-render 规则
+
+所有客户端自定义样式使用 [`css-render`](https://css-render.vercel.app/):
+
+- 不使用 React 静态 inline styles。
+- 不使用 `style.textContent`、手写 `<style>` 注入或 `raw` CSS 字符串绕过 css-render 对象树。
+- CSS 规则拆成 `CssRender().c(selector, properties, children)` 节点。
+- css-render 样式只允许在插件 `apply()` 生命周期中挂载。
+- 样式挂载函数命名为 `mount<Name>Styles`,返回 `() => void` disposer。
+- 样式安装和卸载必须由 `ctx.effect()` 管理。
+- 如果 style id 已由其他生命周期挂载,当前调用不得取得其所有权,也不得在 disposer 中卸载它。
+- hover、focus、active、disabled 等状态优先使用 CSS selector 或 modifier class。
+- 仅保留真正动态的几何值作为 CSS custom property,例如拖拽宽度。
+- 所有动态样式必须可在插件卸载时恢复,不得在 React render 中挂载全局样式。
+- style id 和 class name 使用插件前缀,跨插件协议使用的 class 名称必须保持兼容。
+
+标准模式:
+
+```ts
+export function mountPanelStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+
+ const cssr = CssRender()
+ if (cssr.find(PANEL_STYLE_ID) !== null)
+ return () => {}
+
+ const style = cssr.c([
+ cssr.c('.dshp-panel', {
+ display: 'flex',
+ }),
+ ])
+ style.mount({ id: PANEL_STYLE_ID, head: true })
+ return () => style.unmount({ id: PANEL_STYLE_ID })
+}
+```
+
+## 客户端 apply 与生命周期规则
+
+每个客户端插件的 `apply()` 应按以下顺序组织:
+
+1. 注册或安装 locale、运行时状态和协议服务。
+2. 通过 `ctx.effect()` 挂载 css-render 样式,并返回 disposer。
+3. 注册 slot 组件和 UI 行为。
+4. 通过 `ctx.effect()` 管理 MutationObserver、事件监听、定时器、hydration 和 DOM 补丁。
+
+命名按职责区分:
+
+- `mount*Styles`:挂载 css-render 样式并返回 disposer。
+- `install*`:安装 locale、服务、observer、hydration 等运行时能力。
+- `register*`:注册 slot、组件或协议条目。
+- `apply`:插件唯一的总装配入口。
+
+每个 effect 必须拥有对应清理逻辑:
+
+- 取消 MutationObserver。
+- 移除 event listener。
+- 清理 timeout、interval 和未执行的 animation frame。
+- 取消或忽略过期异步请求。
+- 卸载当前实例实际拥有的样式。
+- 恢复被临时修改的宿主 DOM 状态。
+
+## Slot 与组件协议规则
+
+slot 注册必须保持稳定且可追踪:
+
+```ts
+ctx.slots.register(
+ {
+ name: SLOT_NAME,
+ id: COMPONENT_ID,
+ registrant: PLUGIN_NAME,
+ order: COMPONENT_ORDER,
+ priority: COMPONENT_PRIORITY,
+ inject: sessionId => ({ sessionId }),
+ },
+ Component,
+)
+```
+
+- `name`、`id`、`registrant` 使用 `constants.ts` 中的稳定常量。
+- props 结构在 `types.ts` 中定义,不在多个组件间复制。
+- 组件协议的 public props 必须有可访问名称和明确类型。
+- 缺少可选 renderer patch 时必须 graceful fallback,不得白屏。
+- 不得依赖生成的 CSS module hash;优先使用稳定 slot、ARIA 属性和插件前缀 class。
+- 跨插件协议的 class、slot、service key 修改时必须同步更新所有消费者和文档。
+
+## 宿主侧规则
+
+- Git、文件系统、进程和宿主 API 只能放在 host half。
+- HTTP route 必须严格限制方法;变更操作必须校验来源、参数和 session 归属。
+- 破坏性 Git 操作必须检查每一步结果,失败时保留可恢复 binding/ledger。
+- 不得用 `process.cwd()` 作为未知 session 的静默 fallback。
+- ledger 和 checkout context 使用原子写入;load-modify-save 需要考虑并发更新。
+- 不得静默覆盖用户已有分支或未提交改动。
+- 用户输入的 branch/ref 必须使用 Git 权威校验,不要仅依赖自制正则。
+
+## 退级策略
+
+当功能需要当前官方 dsh 发行版未提供的宿主能力时,按从最优到最差的顺序规划**退级阶梯**:
+
+1. **官方公开 API** —— `ctx.sessions`、`ctx.workspaceRegistry`、`ctx.sessionPersistence`、`ctx.agents`、`ctx.webServer`、`ctx.tools`、`ctx.systemPrompt`,客户端 `ctx.slots` / `ctx.sessions` / `ctx.workspaces`。务必对照**已安装** dsh 版本的 `.d.ts` 核实签名,绝不臆断 API 存在。
+2. **桌面壳补丁** —— 官方 API 缺失时,桌面壳(桌面应用外壳)在启动前对捆绑的 dsh 核心做补丁(见 `src-tauri/src/service/workflow/*_patch.rs` 模式),以锚点校验、幂等、带单元测试的方式暴露窄面补充能力(例如 `SessionStore.remove(id)`)。插件侧做能力探测,缺失时报错。
+2. **DOM 补丁** —— 客户端半区可通过 MutationObserver + capture 监听改写官方 DOM(portal 菜单、侧边栏行),使用稳定的 `aria-label` / `role` 选择器,绝不用生成的 CSS module 哈希。
+3. **功能禁用 / 降级模式** —— 以上都不适用时禁用功能并输出明确日志,绝不静默半工作。
+
+## 测试与验证
+
+- Vitest 测试使用 `describe` / `it` / `expect`,禁止恒真占位测试。
+- `foo.ts` 的测试命名为同目录 `foo.test.ts`。
+- 优先测试纯函数、状态转换、HTTP 方法/授权边界、storage 原子性和公开协议。
+- UI 测试应验证 fallback、slot 注册、ARIA 状态和卸载清理。
+- 完成改动后运行:
+
+```bash
+pnpm run lint --fix
+pnpm run typecheck
+pnpm run test -- --run
+pnpm run build
+```
+
+## 交付检查清单
+
+- [ ] 新增共享类型已放入对应 `src/client/types.ts`。
+- [ ] 新增共享常量已放入对应 `src/client/constants.ts`。
+- [ ] 样式全部由 css-render 对象节点生成。
+- [ ] 样式只在 `apply()` 的 effect 中挂载。
+- [ ] 样式 disposer、observer、listener、timer 均已清理。
+- [ ] slot 协议使用稳定 id、registrant 和显式 props 类型。
+- [ ] 没有静默覆盖用户数据或 Git 分支。
+- [ ] lint、typecheck、test、build 均通过。
+- [ ] 相关 README、协议文档和导出契约已同步。
diff --git a/packages/dsh-tauri-bundle/package.json b/packages/dsh-tauri-bundle/package.json
new file mode 100644
index 00000000..70d2c472
--- /dev/null
+++ b/packages/dsh-tauri-bundle/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "dsh-tauri-bundle",
+ "version": "0.6.7",
+ "private": true,
+ "dependencies": {
+ "dsh-tauri": "workspace:*",
+ "dsh-tauri-panel": "workspace:*",
+ "dsh-tauri-panel-extension": "workspace:*",
+ "dsh-tauri-panel-placeholder": "workspace:*",
+ "dsh-tauri-rightclick": "workspace:*",
+ "dsh-tauri-session": "workspace:*",
+ "dsh-tauri-ui": "workspace:*",
+ "dsh-tauri-worktree": "workspace:*"
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/README.md b/packages/dsh-tauri-panel-extension/README.md
new file mode 100644
index 00000000..9fd4f9bf
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/README.md
@@ -0,0 +1,36 @@
+# dsh-tauri-panel-extension
+
+`dsh-tauri-panel-extension` 为 [`dsh-tauri-panel`](../dsh-tauri-panel) 增加侧栏“扩展”入口,在会话内容区提供技能与 MCP 管理。
+
+## 界面预览
+
+## 功能
+
+- 技能列表、搜索、来源筛选、启停、查看/编辑和打开目录。
+- “新建技能”关闭扩展面板、打开当前工作区的空白会话,并预填 `/skill-creator `(不会自动提交)。
+- “导入仓库”通过 GitHub 地址导入技能仓库;仓库技能优先显示,并提供可点击的 GitHub 图标。
+- MCP 服务器增删改、启停、从 Claude Code/Codex 导入及重启提示。
+- 不包含上游设置页标题“技能与 MCP”和市场模块。
+
+宿主 API 使用同源前缀 `/dsh-tauri-panel-extension/*`,仓库状态保存在 `$DSH_HOME/dsh-tauri-panel-extension`。
+
+## 上游来源
+
+实现基于 [`qinyre/dsh-plugin-capabilities`](https://github.com/qinyre/dsh-plugin-capabilities) commit `3412f8ddf0a92bdc89a3bab104b480f8745ebfc1` 修改,详见 [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md)。开发源以 Git submodule 固定在 `../../soruce/dsh-plugin-capabilities`。
+
+## 逻辑变更
+
+相对上游 commit `3412f8d` 的具体逻辑变更:
+
+- 呈现层从设置页 section 改为侧栏“扩展”面板条目:通过 `sidebar.panel.action` 槽与 `panel.protocol`(含新增的 `closePanelContent` 关闭 API)接入,内容渲染在会话内容区替换视图。
+- 移除“技能与 MCP”标题与市场(Market)模块,仅保留“技能”“MCP”两个标签页。
+- “新建技能”不再于面板内弹窗创建,改为:关闭扩展面板 → 打开当前工作区的空白会话 → 预填 `/skill-creator `(不自动提交),将创建流程交给 [`skill-creator`](./skills/skill-creator/SKILL.md) 技能承载。
+- 技能仓库 UI 从上游完整的仓库管理区(本地/GitHub roots 添加移除、来源分组展示)收敛为“导入仓库”按钮 + 对话框;导入的仓库技能排序优先,并展示可点击的 GitHub 图标链接(仓库地址由宿主端从注册的 root 派生,客户端不持有)。
+- 仓库导入沿用上游的 GitHub codeload tarball 方案(不依赖 git 可执行文件),新增 `parseGitHubSource` 支持 `owner/repo`、完整 URL、`.git` 后缀及 `#ref`/`/tree/<ref>` 分支定位,并探测单技能/扁平/嵌套三种仓库结构。
+- API 前缀与状态目录改为 `/dsh-tauri-panel-extension/*` 与 `$DSH_HOME/dsh-tauri-panel-extension`,与上游插件同时安装时不冲突;路由与方法授权机制与上游一致。
+- 客户端实现遵循本仓库工程约束:上游 raw CSS 字符串整树迁移为 css-render 结构化节点(仅在 `apply()` effect 中挂载)、共享类型与常量集中到 `src/client/types.ts`/`constants.ts`、图标仅取 gravity-ui。
+- MCP 管理与上游保持一致(增删改、启停、从 Claude Code/Codex 导入、重启提示),新增 JSON/表单双模式编辑器作为增量。
+
+## 许可证
+
+[MIT](../../LICENSE.md) © [Hairyf](https://github.com/hairyf)
diff --git a/packages/dsh-tauri-panel-extension/THIRD_PARTY_NOTICES.md b/packages/dsh-tauri-panel-extension/THIRD_PARTY_NOTICES.md
new file mode 100644
index 00000000..d650fdf9
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/THIRD_PARTY_NOTICES.md
@@ -0,0 +1,15 @@
+# Third-party notices
+
+Substantial portions of the Skills and MCP manager are adapted from
+[`qinyre/dsh-plugin-capabilities`](https://github.com/qinyre/dsh-plugin-capabilities)
+at commit `3412f8ddf0a92bdc89a3bab104b480f8745ebfc1`.
+
+Copyright (c) 2026 qinyre. Used and modified under the MIT License. The full
+upstream source and license are retained as the Git submodule at
+`../../soruce/dsh-plugin-capabilities`.
+
+The packaged `skills/skill-creator` files originate from
+[`anthropics/skills`](https://github.com/anthropics/skills) under Apache-2.0;
+its `LICENSE.txt` is retained. The packaged `skills/find-skills` files originate
+from [`vercel-labs/skills`](https://github.com/vercel-labs/skills) under MIT;
+its `LICENSE` is retained.
diff --git a/packages/dsh-tauri-panel-extension/cordis.patch.yml b/packages/dsh-tauri-panel-extension/cordis.patch.yml
new file mode 100644
index 00000000..fab4ce68
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-panel-extension
+ name: dsh-tauri-panel-extension
diff --git a/packages/dsh-tauri-panel-extension/package.json b/packages/dsh-tauri-panel-extension/package.json
new file mode 100644
index 00000000..200653c2
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/package.json
@@ -0,0 +1,76 @@
+{
+ "name": "dsh-tauri-panel-extension",
+ "type": "module",
+ "version": "0.6.7",
+ "description": "Skills and MCP management in the DSH Tauri extension panel.",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "skills",
+ "mcp",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "THIRD_PARTY_NOTICES.md",
+ "cordis.patch.yml",
+ "dist",
+ "skills"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "@deepseek-ai/dsh-client-ui-primitives",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*",
+ "smol-toml": "catalog:utils",
+ "yaml": "catalog:testing"
+ },
+ "devDependencies": {
+ "@deepseek-ai/cordis": "catalog:dsh",
+ "@deepseek-ai/dsh-skill-filesystem": "catalog:dsh",
+ "dompurify": "catalog:ui",
+ "dsh-tauri-tsdown": "workspace:*",
+ "marked": "catalog:ui",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/src/agents.ts b/packages/dsh-tauri-panel-extension/src/agents.ts
new file mode 100644
index 00000000..5cb50041
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/agents.ts
@@ -0,0 +1,156 @@
+/**
+ * Foreign-agent config readers: MCP servers from Claude Code (~/.claude.json,
+ * ~/.claude/settings.json) and Codex (~/.codex/config.toml). Pure reads of
+ * well-known paths; anything missing or malformed yields an empty list.
+ */
+
+import type { McpTransport } from './mcp.ts'
+import { existsSync, readFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import { parse as parseToml } from 'smol-toml'
+
+/** One MCP server discovered in a foreign agent's config. */
+export interface ImportedServer {
+ agent: 'claude-code' | 'codex'
+ name: string
+ transport: McpTransport
+ command?: string
+ args?: string[]
+ env?: Record<string, string>
+ url?: string
+ headers?: Record<string, string>
+}
+
+/** Keep only string-valued entries of a record (configs may hold numbers). */
+function stringEntries(value: unknown): Record<string, string> | undefined {
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
+ return undefined
+ const out: Record<string, string> = {}
+ for (const [key, entry] of Object.entries(value)) {
+ if (typeof entry === 'string')
+ out[key] = entry
+ }
+ return Object.keys(out).length > 0 ? out : undefined
+}
+
+function stringArray(value: unknown): string[] | undefined {
+ if (!Array.isArray(value))
+ return undefined
+ const out = value.filter((entry): entry is string => typeof entry === 'string')
+ return out.length > 0 ? out : undefined
+}
+
+/** Map one Claude mcpServers entry; returns null for unsupported shapes (sse). */
+function mapClaudeEntry(name: string, entry: unknown): ImportedServer | null {
+ if (typeof entry !== 'object' || entry === null)
+ return null
+ const record = entry as Record<string, unknown>
+ const type = typeof record.type === 'string' ? record.type : 'stdio'
+ if (type === 'stdio' || (type === 'stdio' && record.command !== undefined)) {
+ if (typeof record.command !== 'string' || record.command === '')
+ return null
+ return {
+ agent: 'claude-code',
+ name,
+ transport: 'stdio',
+ command: record.command,
+ args: stringArray(record.args),
+ env: stringEntries(record.env),
+ }
+ }
+ if (type === 'http' || type === 'streamable-http') {
+ if (typeof record.url !== 'string' || record.url === '')
+ return null
+ return {
+ agent: 'claude-code',
+ name,
+ transport: 'streamable-http',
+ url: record.url,
+ headers: stringEntries(record.headers),
+ }
+ }
+ // 'sse' and anything else: dsh's mcp-client speaks stdio + streamable-http only.
+ return null
+}
+
+/** MCP servers from Claude Code's user-scope config files. */
+export function scanClaudeMcp(home: string = homedir()): ImportedServer[] {
+ const merged: Record<string, unknown> = {}
+ for (const file of [join(home, '.claude', 'settings.json'), join(home, '.claude.json')]) {
+ if (!existsSync(file))
+ continue
+ try {
+ const parsed = JSON.parse(readFileSync(file, 'utf8')) as { mcpServers?: unknown }
+ if (typeof parsed.mcpServers === 'object' && parsed.mcpServers !== null) {
+ Object.assign(merged, parsed.mcpServers)
+ }
+ }
+ catch {
+ // Broken or partial config: skip the file, keep earlier merges.
+ }
+ }
+ const out: ImportedServer[] = []
+ for (const [name, entry] of Object.entries(merged)) {
+ const mapped = mapClaudeEntry(name, entry)
+ if (mapped !== null)
+ out.push(mapped)
+ }
+ return out
+}
+
+/** MCP servers from Codex's config.toml ([mcp_servers.<name>] tables). */
+export function scanCodexMcp(home: string = homedir()): ImportedServer[] {
+ const file = join(home, '.codex', 'config.toml')
+ if (!existsSync(file))
+ return []
+ let root: Record<string, unknown>
+ try {
+ root = parseToml(readFileSync(file, 'utf8')) as Record<string, unknown>
+ }
+ catch {
+ return []
+ }
+ const table = root.mcp_servers
+ if (typeof table !== 'object' || table === null)
+ return []
+ const out: ImportedServer[] = []
+ for (const [name, entry] of Object.entries(table)) {
+ if (typeof entry !== 'object' || entry === null)
+ continue
+ const record = entry as Record<string, unknown>
+ if (typeof record.command === 'string' && record.command !== '') {
+ out.push({
+ agent: 'codex',
+ name,
+ transport: 'stdio',
+ command: record.command,
+ args: stringArray(record.args),
+ env: stringEntries(record.env),
+ })
+ }
+ else if (typeof record.url === 'string' && record.url !== '') {
+ out.push({ agent: 'codex', name, transport: 'streamable-http', url: record.url })
+ }
+ }
+ return out
+}
+
+/** All foreign-agent MCP servers, deduplicated by (agent, name). */
+export function scanAllMcp(home: string = homedir()): ImportedServer[] {
+ const seen = new Set<string>()
+ return [...scanClaudeMcp(home), ...scanCodexMcp(home)]
+ .filter((server) => {
+ const key = `${server.agent}/${server.name}`
+ if (seen.has(key))
+ return false
+ seen.add(key)
+ return true
+ })
+}
+
+/** Other agents' skill roots that exist on this machine. */
+export function agentSkillRoots(home: string = homedir()): string[] {
+ return [join(home, '.claude', 'skills'), join(home, '.codex', 'skills')]
+ .filter(path => existsSync(path))
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/constants.ts b/packages/dsh-tauri-panel-extension/src/client/constants.ts
new file mode 100644
index 00000000..f4f56a67
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/constants.ts
@@ -0,0 +1,32 @@
+export const PLUGIN_ID = 'dsh-tauri-panel-extension'
+export const API_PREFIX = '/dsh-tauri-panel-extension'
+export const LOCALE_NAMESPACE = 'dsh-tauri-panel-extension'
+export const PANEL_PROTOCOL_NAME = 'panel.protocol'
+export const PANEL_SLOT_NAME = 'sidebar.panel.action'
+export const CONVERSATION_INPUT_LEFT_SLOT = 'conversation.input.left'
+export const PANEL_ID = 'dsh-tauri-panel-extension'
+export const PANEL_ACTION_ID = 'dsh-tauri-panel-extension.action'
+export const PANEL_ACTION_ORDER = 40
+export const PANEL_ACTION_PRIORITY = 0
+export const INPUT_PREFILL_ID = 'dsh-tauri-panel-extension.skill-prefill'
+export const INPUT_PREFILL_ORDER = 40
+export const INPUT_PREFILL_PRIORITY = 0
+export const STYLE_ID = 'dsh-tauri-panel-extension-styles'
+export const SKILL_CREATOR_DRAFT = '/skill-creator '
+export const SKILL_REFRESH_INTERVAL_MS = 300
+export const SKILL_REFRESH_TIMEOUT_MS = 5_000
+export const IMPORT_REFRESH_DELAYS_MS = [250, 750, 1_500] as const
+export const MCP_RESTART_INITIAL_DELAY_MS = 3_000
+export const MCP_RESTART_POLL_INTERVAL_MS = 1_500
+export const MCP_RESTART_TIMEOUT_MS = 60_000
+export const GITHUB_REPOSITORY_PATTERN = /^(?:https?:\/\/github\.com\/)?[\w.-]+\/[\w.-]+\/?$/i
+
+export const SOURCE_LOCALE_KEYS: Readonly<Record<string, string>> = {
+ 'project-dsh': 'sourceProjectDsh',
+ 'project-agents': 'sourceProjectAgents',
+ 'user-dsh': 'sourceUserDsh',
+ 'user-agents': 'sourceUserAgents',
+ 'runtime': 'sourceRuntime',
+ 'bundled': 'sourceBundled',
+ 'custom': 'sourceCustom',
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/extension-panel.tsx b/packages/dsh-tauri-panel-extension/src/client/extension-panel.tsx
new file mode 100644
index 00000000..7809388a
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/extension-panel.tsx
@@ -0,0 +1,137 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import type { ReactElement } from 'react'
+import type { ConversationInputLeftProps, ExtensionRuntimeContext, McpInjected, PanelProtocol, SkillsInjected, Translate } from './types'
+import { compat } from 'dsh-tauri/client'
+import { useEffect, useId, useRef, useState } from 'react'
+import { CONVERSATION_INPUT_LEFT_SLOT, INPUT_PREFILL_ID, INPUT_PREFILL_ORDER, INPUT_PREFILL_PRIORITY, LOCALE_NAMESPACE, PANEL_ACTION_ID, PANEL_ACTION_ORDER, PANEL_ACTION_PRIORITY, PANEL_ID, PANEL_PROTOCOL_NAME, PANEL_SLOT_NAME, PLUGIN_ID, SKILL_CREATOR_DRAFT } from './constants'
+import { IconExtension } from './icons'
+import { McpTab } from './mcp-tab'
+import { SkillsTab } from './skills-tab'
+import { chooseWorkspace } from './workspace'
+
+const pendingPrefills = new Set<string>()
+
+function SkillCreatorPrefill({ sessionId, inputActions }: ConversationInputLeftProps): null {
+ useEffect(() => {
+ if (!pendingPrefills.delete(sessionId))
+ return
+ inputActions.setDraft(SKILL_CREATOR_DRAFT)
+ }, [inputActions, sessionId])
+ return null
+}
+
+export function registerSkillCreatorPrefill(ctx: ClientContext): void {
+ ctx.effect(() => {
+ pendingPrefills.clear()
+ const disposeSlot = ctx.slots.inject(CONVERSATION_INPUT_LEFT_SLOT as never, () => ctx.slots.register({
+ name: CONVERSATION_INPUT_LEFT_SLOT,
+ id: INPUT_PREFILL_ID,
+ registrant: PLUGIN_ID,
+ order: INPUT_PREFILL_ORDER,
+ priority: INPUT_PREFILL_PRIORITY,
+ inject: (sessionId: string) => ({ sessionId }),
+ } as never, SkillCreatorPrefill))
+ return () => {
+ pendingPrefills.clear()
+ disposeSlot()
+ }
+ }, `${PLUGIN_ID}: skill creator prefill`)
+}
+
+export function ExtensionPanel({ t, skills, mcp, createSkill }: { t: Translate, skills: SkillsInjected, mcp: McpInjected, createSkill: () => Promise<void> }): ReactElement {
+ const tabsId = useId()
+ const tabRefs = useRef<Array<HTMLButtonElement | null>>([])
+ const rows = [{ id: 'skills', label: t('skillsTab') }, { id: 'mcp', label: t('mcpTab') }]
+ const [activeId, setActiveId] = useState('skills')
+ const [visited, setVisited] = useState<ReadonlySet<string>>(() => new Set(['skills']))
+ useEffect(() => setVisited(previous => previous.has(activeId) ? previous : new Set([...previous, activeId])), [activeId])
+
+ return (
+ <div className="dpte-section">
+ <div className="dpte-tabs" role="tablist" aria-label={t('extension')}>
+ {rows.map((row, index) => {
+ const selected = row.id === activeId
+ return (
+ <button
+ key={row.id}
+ ref={(element) => { tabRefs.current[index] = element }}
+ id={`${tabsId}-tab-${row.id}`}
+ type="button"
+ role="tab"
+ className="dpte-tab"
+ aria-selected={selected}
+ aria-controls={`${tabsId}-panel-${row.id}`}
+ data-active={selected ? 'true' : undefined}
+ tabIndex={selected ? 0 : -1}
+ onClick={() => setActiveId(row.id)}
+ onKeyDown={(event) => {
+ let next: number
+ if (event.key === 'ArrowRight')
+ next = (index + 1) % rows.length
+ else if (event.key === 'ArrowLeft')
+ next = (index - 1 + rows.length) % rows.length
+ else if (event.key === 'Home')
+ next = 0
+ else if (event.key === 'End')
+ next = rows.length - 1
+ else return
+ event.preventDefault()
+ setActiveId(rows[next]?.id ?? 'skills')
+ tabRefs.current[next]?.focus()
+ }}
+ >
+ {row.label}
+ </button>
+ )
+ })}
+ </div>
+ {rows.filter(row => row.id === activeId || visited.has(row.id)).map((row) => {
+ const selected = row.id === activeId
+ return <div key={row.id} id={`${tabsId}-panel-${row.id}`} className="dpte-tabPanel" role="tabpanel" aria-labelledby={`${tabsId}-tab-${row.id}`} hidden={!selected}>{row.id === 'skills' ? <SkillsTab t={t} injected={skills} createSkill={createSkill} /> : <McpTab t={t} injected={mcp} />}</div>
+ })}
+ </div>
+ )
+}
+
+export function installExtensionPanel(ctx: ClientContext, t: Translate, skills: SkillsInjected, mcp: McpInjected): void {
+ ctx.slots.inject(PANEL_SLOT_NAME as never, () => {
+ let registration: (() => void) | undefined
+ let retryTimer: number | undefined
+
+ const attemptRegistration = (): void => {
+ if (registration)
+ return
+ const protocol = ctx.reflect.get(PANEL_PROTOCOL_NAME) as PanelProtocol | undefined
+ if (!protocol)
+ return
+ const runtime = compat(ctx) as unknown as ExtensionRuntimeContext
+ const createSkill = async (): Promise<void> => {
+ const id = chooseWorkspace(runtime)
+ if (id === undefined)
+ throw new Error(t('workspaceUnavailable'))
+ const sessionId = await runtime.workspaces.connectWorkspace?.(id)
+ if (!sessionId)
+ throw new Error(t('workspaceUnavailable'))
+ pendingPrefills.add(sessionId)
+ protocol.closePanelContent()
+ runtime.sessions.open(sessionId)
+ }
+ const Content = (): ReactElement => <ExtensionPanel t={t} skills={skills} mcp={mcp} createSkill={createSkill} />
+ const Action = (): ReactElement => <protocol.ActionItem id={PANEL_ID} icon={<IconExtension />} onClick={() => protocol.renderPanelContent({ id: PANEL_ID, render: Content, locale: LOCALE_NAMESPACE })}>{t('extension')}</protocol.ActionItem>
+ registration = ctx.slots.register({ name: PANEL_SLOT_NAME, id: PANEL_ACTION_ID, registrant: PLUGIN_ID, order: PANEL_ACTION_ORDER, priority: PANEL_ACTION_PRIORITY, locale: LOCALE_NAMESPACE, inject: () => ({}) } as never, Action)
+ if (retryTimer !== undefined) {
+ window.clearInterval(retryTimer)
+ retryTimer = undefined
+ }
+ }
+
+ attemptRegistration()
+ if (!registration)
+ retryTimer = window.setInterval(attemptRegistration, 50)
+ return () => {
+ if (retryTimer !== undefined)
+ window.clearInterval(retryTimer)
+ registration?.()
+ }
+ })
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/icons.tsx b/packages/dsh-tauri-panel-extension/src/client/icons.tsx
new file mode 100644
index 00000000..f4f2120b
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/icons.tsx
@@ -0,0 +1,51 @@
+import type { ReactElement } from 'react'
+import type { IconProps } from './types'
+
+/**
+ * Gravity UI Icons `puzzle.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/puzzle.svg
+ * License: MIT, © 2022 YANDEX LLC.
+ */
+export function IconExtension({ size, className }: IconProps): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width={size || '1em'} height={size || '1em'} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true">
+ <path fill="currentColor" fillRule="evenodd" d="M5.731 4H4.5A1.5 1.5 0 0 0 3 5.5v.377a2.72 2.72 0 0 1 0 5.246v.377A1.5 1.5 0 0 0 4.5 13h.377a2.72 2.72 0 0 1 5.246 0h.377a1.5 1.5 0 0 0 1.5-1.5v-1.232l1-.353a1.501 1.501 0 0 0 0-2.83l-1-.354V5.5A1.5 1.5 0 0 0 10.5 4H9.269l-.354-1a1.501 1.501 0 0 0-2.83 0zM8.9 14.5l-.204-1.02a1.22 1.22 0 0 0-2.392 0L6.1 14.5H4.5a3 3 0 0 1-3-3V9.9l1.02-.204a1.22 1.22 0 0 0 0-2.392L1.5 7.1V5.5a3 3 0 0 1 3-3h.17a3.001 3.001 0 0 1 5.66 0h.17a3 3 0 0 1 3 3v.17a3.001 3.001 0 0 1 0 5.66v.17a3 3 0 0 1-3 3z" clipRule="evenodd" />
+ </svg>
+ )
+}
+
+/**
+ * Gravity UI Icons `graduation-cap.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/graduation-cap.svg
+ * License: MIT, © 2022 YANDEX LLC.
+ */
+export function IconSkill({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M6.836 3.202 1.74 5.386a.396.396 0 0 0 0 .728l5.096 2.184a2.5 2.5 0 0 0 .985.202h.358a2.5 2.5 0 0 0 .985-.202l5.096-2.184a.396.396 0 0 0 0-.728L9.164 3.202A2.5 2.5 0 0 0 8.179 3h-.358a2.5 2.5 0 0 0-.985.202M1.5 7.642l1.5.644v3.228a2 2 0 0 0 1.106 1.789l.806.403a7 7 0 0 0 6.193.033l.909-.442a2 2 0 0 0 1.125-1.798V8.226l1.712-.734a1.896 1.896 0 0 0 0-3.484L9.755 1.823A4 4 0 0 0 8.179 1.5h-.358a4 4 0 0 0-1.576.323L1.15 4.008A1.9 1.9 0 0 0 0 5.75v4.5a.75.75 0 0 0 1.5 0zm3 3.872V8.929l1.745.748A4 4 0 0 0 7.821 10h.358a4 4 0 0 0 1.576-.323l1.884-.808v2.63a.5.5 0 0 1-.282.45l-.909.442a5.5 5.5 0 0 1-4.865-.027l-.807-.403a.5.5 0 0 1-.276-.447" clipRule="evenodd" /></svg>
+}
+
+/**
+ * Gravity UI Icons `arrows-rotate-right.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/arrows-rotate-right.svg
+ * License: MIT, © 2022 YANDEX LLC.
+ */
+export function IconRefresh({ size = 14, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" d="M13.78 2.22a.75.75 0 0 1 0 1.06l-1.03 1.03A6.25 6.25 0 1 1 8 1.75a.75.75 0 0 1 0 1.5 4.75 4.75 0 1 0 3.72 1.8l-1.19 1.2A.75.75 0 0 1 9.25 5.72V2.5a.75.75 0 0 1 .75-.75h3.25a.75.75 0 0 1 .53.47" /></svg>
+}
+
+/**
+ * Gravity UI Icons `logo-github.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/logo-github.svg
+ * License: MIT, © 2022 YANDEX LLC.
+ */
+export function IconGitHub({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M8 .75a7.25 7.25 0 0 0-2.29 14.13c.36.07.5-.16.5-.35v-1.39c-2.04.44-2.47-.87-2.47-.87-.33-.85-.81-1.08-.81-1.08-.67-.45.05-.44.05-.44.73.05 1.12.75 1.12.75.66 1.12 1.72.8 2.14.61.07-.47.26-.8.47-.98-1.63-.18-3.34-.81-3.34-3.63 0-.8.29-1.46.75-1.97-.07-.19-.32-.93.08-1.94 0 0 .61-.2 1.99.75A6.9 6.9 0 0 1 8 4.06c.62 0 1.23.08 1.81.24 1.38-.95 1.99-.75 1.99-.75.4 1.01.15 1.75.08 1.94.46.51.75 1.17.75 1.97 0 2.82-1.72 3.44-3.35 3.62.26.23.5.67.5 1.35v2.1c0 .19.13.42.5.35A7.25 7.25 0 0 0 8 .75" clipRule="evenodd" /></svg>
+}
+
+/**
+ * Gravity UI Icons `plug-connection.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/plug-connection.svg
+ * License: MIT, © 2022 YANDEX LLC.
+ */
+export function IconMcp({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M15.53 1.53A.75.75 0 0 0 14.47.47l-1.29 1.29a4.24 4.24 0 0 0-5.423.483l-.58.58a.96.96 0 0 0 0 1.354l4.646 4.646a.96.96 0 0 0 1.354 0l.58-.58a4.24 4.24 0 0 0 .484-5.423zm-8.5 4.94a.75.75 0 0 1 0 1.06L5.78 8.78l1.44 1.44 1.25-1.25a.75.75 0 0 1 1.06 1.06l-1.25 1.25.543.543a.96.96 0 0 1 0 1.354l-.58.58a4.24 4.24 0 0 1-5.423.484l-1.29 1.29A.75.75 0 0 1 .47 14.47l1.29-1.29a4.24 4.24 0 0 1 .483-5.423l.58-.58a.96.96 0 0 1 1.354 0l.543.543 1.25-1.25a.75.75 0 0 1 1.06 0M3.5 8.62l-.197.197a2.743 2.743 0 0 0 3.879 3.879l.197-.197zm9.197-1.439-.197.197L8.621 3.5l.197-.197a2.743 2.743 0 0 1 3.879 3.879" clipRule="evenodd" /></svg>
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/index.ts b/packages/dsh-tauri-panel-extension/src/client/index.ts
new file mode 100644
index 00000000..8014170a
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/index.ts
@@ -0,0 +1,64 @@
+import type { ExtensionClientContext, McpInjected, McpRow, SkillRowView, SkillsInjected, Translate } from './types'
+import { compat } from 'dsh-tauri/client'
+import { API_PREFIX, LOCALE_NAMESPACE, PLUGIN_ID } from './constants'
+import { installExtensionPanel, registerSkillCreatorPrefill } from './extension-panel'
+import { installExtensionLocale } from './locale'
+import { mountExtensionStyles } from './styles'
+
+async function fetchJson<T>(path: string, init?: RequestInit): Promise<T> {
+ const response = await fetch(`${API_PREFIX}${path}`, init)
+ const body = await response.json() as T & { error?: string }
+ if (!response.ok)
+ throw new Error(body.error ?? `HTTP ${response.status}`)
+ return body
+}
+
+function post<T>(path: string, body: unknown): Promise<T> {
+ return fetchJson<T>(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
+}
+
+function createSkillsInjected(): SkillsInjected {
+ return {
+ list: () => fetchJson<{ skills: SkillRowView[] }>('/skills'),
+ get: name => fetchJson(`/skill?name=${encodeURIComponent(name)}`),
+ save: input => post('/skill/save', input),
+ remove: name => post('/skill/delete', { name }),
+ policy: (name, enabled) => post('/skill/policy', { name, enabled }),
+ open: target => post('/open', target),
+ importRepository: url => post('/roots/add', { kind: 'git', url }),
+ }
+}
+
+function createMcpInjected(): McpInjected {
+ return {
+ list: () => fetchJson<{ servers: McpRow[] }>('/mcp'),
+ save: input => post('/mcp/save', input),
+ toggle: (id, disabled) => post('/mcp/toggle', { id, disabled }),
+ remove: id => post('/mcp/remove', { id }),
+ scanImport: () => fetchJson('/import/scan'),
+ applyImport: items => post('/import/apply', { items }),
+ restart: async () => {
+ if (window.dshDesktop !== undefined) {
+ window.dshDesktop.restartSidecar?.()
+ return
+ }
+ try {
+ await post('/restart', {})
+ }
+ catch { /* The connection normally closes while the host restarts. */ }
+ },
+ desktop: typeof window !== 'undefined' && window.dshDesktop !== undefined,
+ }
+}
+
+export const name = PLUGIN_ID
+export const inject = ['slots', 'locale', 'sessions', 'workspaces']
+
+export function apply(ctx: ExtensionClientContext): void {
+ const cx = compat(ctx)
+ installExtensionLocale(ctx)
+ ctx.effect(() => mountExtensionStyles(), `${PLUGIN_ID}: styles`)
+ const t = ctx.locale.bind(LOCALE_NAMESPACE) as Translate
+ registerSkillCreatorPrefill(ctx)
+ installExtensionPanel(cx as ExtensionClientContext, t, createSkillsInjected(), createMcpInjected())
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/locale.ts b/packages/dsh-tauri-panel-extension/src/client/locale.ts
new file mode 100644
index 00000000..7e1e946c
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/locale.ts
@@ -0,0 +1,211 @@
+import type { ExtensionClientContext } from './types'
+import { LOCALE_NAMESPACE, PLUGIN_ID } from './constants'
+
+const zh: Record<string, string> = {
+ extension: '扩展',
+ skillsTab: '技能',
+ mcpTab: 'MCP',
+ skillsTitle: '技能管理',
+ skillsIntro: '查看与编辑 dsh 发现的技能;用户级与仓库技能可就地管理。卡片开关控制技能是否加载。',
+ newSkill: '新建技能',
+ importRepository: '导入仓库',
+ importRepositoryTitle: '导入 GitHub 技能仓库',
+ importRepositoryHint: '输入 GitHub URL 或 owner/repo。',
+ importRepositoryPlaceholder: 'owner/repo',
+ importRepositoryInvalid: '请输入有效的 GitHub URL 或 owner/repo。',
+ importRepositorySuccess: '仓库已导入,正在刷新技能列表。',
+ workspaceUnavailable: '没有可用工作区,无法启动技能创建器。请先打开或连接一个工作区。',
+ skillCreatorFailed: '无法启动技能创建器',
+ editSkill: '编辑技能',
+ viewSkill: '查看技能',
+ skillName: '名称(kebab-case)',
+ skillDescription: '描述',
+ skillWhenToUse: '使用时机(可选)',
+ skillContent: '正文(Markdown)',
+ skillPreview: 'Markdown 预览',
+ skillPlainText: '纯文本',
+ modelInvocable: '允许模型调用',
+ userInvocable: '允许用户 / 调用',
+ save: '保存',
+ cancel: '取消',
+ delete: '删除',
+ edit: '编辑',
+ view: '查看',
+ close: '关闭',
+ emptySkills: '还没有发现任何技能',
+ loading: '载入中…',
+ source: '来源',
+ sourceProjectDsh: '项目',
+ sourceProjectAgents: '项目',
+ sourceUserDsh: '用户',
+ sourceUserAgents: '用户',
+ sourceRuntime: '运行时',
+ sourceBundled: '内置',
+ sourceCustom: '自定义',
+ confirmDelete: '确认删除技能?',
+ deleteWarn: '将删除整个用户技能目录,此操作不可撤销。',
+ saved: '已保存,稍候即可在会话中使用。',
+ searchSkills: '搜索技能名称或描述',
+ filterAll: '全部',
+ noMatch: '没有匹配的技能',
+ refresh: '刷新',
+ skillDisabled: '已停用',
+ skillUserOnly: '仅用户可用',
+ skillModelOnly: '仅模型可用',
+ skillEnabled: '已启用,稍候在列表中生效。',
+ skillDisabledMsg: '已停用:模型与 / 命令都不会加载它。',
+ toggleSkill: '切换技能加载',
+ toggleSkillHint: '停用会同时禁止模型与用户调用;开启恢复默认策略。',
+ openFolder: '打开目录',
+ openUserSkills: '打开技能目录',
+ repository: '仓库',
+ githubRepository: '在 GitHub 打开仓库',
+ mcpTitle: 'MCP 服务器',
+ mcpIntro: '管理 profile 中的 MCP 服务器。新增、修改或删除后需要重启 dsh 才生效。',
+ addServer: '添加服务器',
+ editServer: '编辑服务器',
+ serverName: '服务器名(工具名前缀)',
+ transport: '传输方式',
+ transportStdio: 'stdio(本地命令)',
+ transportHttp: 'streamable-http(URL)',
+ command: '命令',
+ args: '参数(每行一个)',
+ envPairs: '环境变量(每行 KEY=VALUE)',
+ url: 'URL',
+ headersPairs: '请求头(每行 KEY: VALUE)',
+ disabled: '已停用',
+ enabled: '启用中',
+ toggle: '停用/启用',
+ confirmRemove: '确认移除该服务器?',
+ removeWarn: '将从 profile 配置中移除这一行,重启后其工具不再出现。',
+ emptyMcp: '还没有配置 MCP 服务器',
+ importServers: '从其他 Agent 导入',
+ importIntro: '扫描 Claude Code 与 Codex 的 MCP 配置,勾选后导入。',
+ importEmpty: '没有发现可导入的 MCP 服务器',
+ importSelectAll: '全选',
+ importExisting: '已存在',
+ importSelected: '导入选中项',
+ restartNeeded: '配置已写入,重启 dsh 后生效。',
+ restartDesktopHint: '重启由桌面应用负责。',
+ restartOtherHint: '请关闭当前 dsh 进程后重新运行。',
+ restartNow: '重启服务',
+ restart: '重启',
+ restartConfirmTitle: '重启 dsh?',
+ restartConfirmBody: '重启会中断正在进行的回合,未保存的输入可能丢失。',
+ restarting: '正在重启,恢复后将自动刷新页面…',
+ restartPortHint: '若页面长时间未恢复,端口可能已变化。',
+ failed: '操作失败',
+ editorJsonTab: '添加 JSON',
+ editorFormTab: '表单填写',
+ formatPaste: '粘贴 JSON 配置(mcpServers 包装或单条目均可)',
+ formatFill: '解析并切换到表单',
+ pasteTransportMismatch: '该行传输方式已锁定,与粘贴配置不一致。',
+}
+
+const en: Record<string, string> = {
+ extension: 'Extensions',
+ skillsTab: 'Skills',
+ mcpTab: 'MCP',
+ skillsTitle: 'Skills',
+ skillsIntro: 'View and manage discovered skills, including user and repository skills. Each card switch controls loading.',
+ newSkill: 'New skill',
+ importRepository: 'Import repository',
+ importRepositoryTitle: 'Import GitHub skill repository',
+ importRepositoryHint: 'Enter a GitHub URL or owner/repo.',
+ importRepositoryPlaceholder: 'owner/repo',
+ importRepositoryInvalid: 'Enter a valid GitHub URL or owner/repo.',
+ importRepositorySuccess: 'Repository imported; refreshing skills.',
+ workspaceUnavailable: 'No workspace is available. Open or connect a workspace before creating a skill.',
+ skillCreatorFailed: 'Could not start skill creator',
+ editSkill: 'Edit skill',
+ viewSkill: 'View skill',
+ skillName: 'Name (kebab-case)',
+ skillDescription: 'Description',
+ skillWhenToUse: 'When to use (optional)',
+ skillContent: 'Body (Markdown)',
+ skillPreview: 'Markdown preview',
+ skillPlainText: 'Plain text',
+ modelInvocable: 'Model-invocable',
+ userInvocable: 'User-invocable (/)',
+ save: 'Save',
+ cancel: 'Cancel',
+ delete: 'Delete',
+ edit: 'Edit',
+ view: 'View',
+ close: 'Close',
+ emptySkills: 'No skills discovered yet',
+ loading: 'Loading…',
+ source: 'Source',
+ sourceProjectDsh: 'project',
+ sourceProjectAgents: 'project',
+ sourceUserDsh: 'user',
+ sourceUserAgents: 'user',
+ sourceRuntime: 'runtime',
+ sourceBundled: 'bundled',
+ sourceCustom: 'custom',
+ confirmDelete: 'Delete this skill?',
+ deleteWarn: 'Removes the whole user skill directory. This cannot be undone.',
+ saved: 'Saved; it will become available shortly.',
+ searchSkills: 'Search name or description',
+ filterAll: 'All',
+ noMatch: 'No skills match',
+ refresh: 'Refresh',
+ skillDisabled: 'disabled',
+ skillUserOnly: 'user-only',
+ skillModelOnly: 'model-only',
+ skillEnabled: 'Enabled; the list reflects it shortly.',
+ skillDisabledMsg: 'Disabled for both model and slash commands.',
+ toggleSkill: 'Toggle skill loading',
+ toggleSkillHint: 'Disable model and user invocation; enabling restores defaults.',
+ openFolder: 'Open folder',
+ openUserSkills: 'Open skills folder',
+ repository: 'repository',
+ githubRepository: 'Open repository on GitHub',
+ mcpTitle: 'MCP servers',
+ mcpIntro: 'Manage MCP server rows in this profile. Changes apply after a dsh restart.',
+ addServer: 'Add server',
+ editServer: 'Edit server',
+ serverName: 'Server name (tool prefix)',
+ transport: 'Transport',
+ transportStdio: 'stdio (local command)',
+ transportHttp: 'streamable-http (URL)',
+ command: 'Command',
+ args: 'Arguments (one per line)',
+ envPairs: 'Environment (KEY=VALUE per line)',
+ url: 'URL',
+ headersPairs: 'Headers (KEY: VALUE per line)',
+ disabled: 'Disabled',
+ enabled: 'Enabled',
+ toggle: 'Enable/disable',
+ confirmRemove: 'Remove this server?',
+ removeWarn: 'Removes this profile row; tools disappear after restart.',
+ emptyMcp: 'No MCP servers configured yet',
+ importServers: 'Import from other agents',
+ importIntro: 'Scan Claude Code and Codex MCP configs and import selected entries.',
+ importEmpty: 'No importable MCP servers found',
+ importSelectAll: 'Select all',
+ importExisting: 'already here',
+ importSelected: 'Import selected',
+ restartNeeded: 'Configuration written; restart dsh to apply.',
+ restartDesktopHint: 'The desktop app owns restarts.',
+ restartOtherHint: 'Close this dsh process and run it again.',
+ restartNow: 'Restart service',
+ restart: 'Restart',
+ restartConfirmTitle: 'Restart dsh?',
+ restartConfirmBody: 'Restarting interrupts running turns and may lose unsaved input.',
+ restarting: 'Restarting; the page reloads when the host returns…',
+ restartPortHint: 'If recovery takes too long, the port may have changed.',
+ failed: 'Operation failed',
+ editorJsonTab: 'Add JSON',
+ editorFormTab: 'Fill form',
+ formatPaste: 'Paste a JSON config (wrapper or bare entry)',
+ formatFill: 'Parse and switch to form',
+ pasteTransportMismatch: 'The row transport is locked and differs from the pasted config.',
+}
+
+export function installExtensionLocale(ctx: ExtensionClientContext): void {
+ ctx.effect(() => [
+ ctx.locale.register(LOCALE_NAMESPACE, 'zh', zh),
+ ctx.locale.register(LOCALE_NAMESPACE, 'en', en),
+ ], `${PLUGIN_ID}: locale`)
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/markdown-preview.tsx b/packages/dsh-tauri-panel-extension/src/client/markdown-preview.tsx
new file mode 100644
index 00000000..384067b2
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/markdown-preview.tsx
@@ -0,0 +1,13 @@
+import type { ReactElement } from 'react'
+import DOMPurify from 'dompurify'
+import { marked } from 'marked'
+import { useMemo } from 'react'
+
+function parseMarkdown(text: string): string {
+ return DOMPurify.sanitize(marked.parse(text, { async: false, gfm: true, breaks: false }) as string)
+}
+
+export function MarkdownPreview(props: { text: string }): ReactElement {
+ const html = useMemo(() => parseMarkdown(props.text), [props.text])
+ return <div className="dpte-mdBody" dangerouslySetInnerHTML={{ __html: html }} />
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/mcp-tab.tsx b/packages/dsh-tauri-panel-extension/src/client/mcp-tab.tsx
new file mode 100644
index 00000000..3ae34409
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/mcp-tab.tsx
@@ -0,0 +1,685 @@
+/**
+ * Settings → Plugins “MCP” tab: manage the profile's mcp-client rows.
+ * Mutations rewrite the profile patch and need a dsh restart — the banner
+ * hands the restart to the desktop shell when one is present.
+ */
+
+import type { ReactElement } from 'react'
+import type { McpEditorMode, McpEditorState, McpImportItem, McpRow, McpTabProps, ParsedMcpJson } from './types'
+import { Button, Modal, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
+import { useEffect, useRef, useState } from 'react'
+import { MCP_RESTART_INITIAL_DELAY_MS, MCP_RESTART_POLL_INTERVAL_MS, MCP_RESTART_TIMEOUT_MS } from './constants'
+import { IconMcp, IconRefresh } from './icons'
+
+/** Group import candidates by source agent, known agents first. */
+export function importGroups(items: McpImportItem[]): Array<{ agent: string, label: string, items: Array<{ item: McpImportItem, index: number }> }> {
+ const label = (agent: string): string => agent === 'claude-code' ? 'Claude Code' : agent === 'codex' ? 'Codex' : agent
+ const order = ['claude-code', 'codex']
+ const agents = [...new Set(items.map(item => item.server.agent))]
+ .sort((a, b) => {
+ const rank = (agent: string): number => {
+ const at = order.indexOf(agent)
+ return at === -1 ? order.length : at
+ }
+ return rank(a) - rank(b) || a.localeCompare(b)
+ })
+ return agents.map(agent => ({
+ agent,
+ label: label(agent),
+ items: items.map((item, index) => ({ item, index })).filter(({ item }) => item.server.agent === agent),
+ }))
+}
+
+/** KEY=VALUE / KEY: VALUE lines to a map. */
+function parsePairs(text: string, separator: ':' | '='): Record<string, string> {
+ const map: Record<string, string> = {}
+ for (const line of text.split(/\r?\n/)) {
+ const trimmed = line.trim()
+ if (trimmed === '' || trimmed.startsWith('#'))
+ continue
+ const at = trimmed.indexOf(separator)
+ if (at <= 0)
+ continue
+ map[trimmed.slice(0, at).trim()] = trimmed.slice(at + 1).trim()
+ }
+ return map
+}
+
+function mapToPairs(map: Record<string, string> | undefined, separator: string): string {
+ if (map === undefined)
+ return ''
+ return Object.entries(map).map(([key, value]) => `${key}${separator}${value.includes('\n') ? JSON.stringify(value) : value}`).join('\n')
+}
+
+/**
+ * Parse one MCP server from pasted JSON: a bare entry, a dsh row, or a
+ * `{"mcpServers": {…}}` wrapper (first entry wins). Returns the reason on bad input.
+ */
+export function parseMcpJson(text: string): ParsedMcpJson | { error: string } {
+ let parsed: unknown
+ try {
+ parsed = JSON.parse(text)
+ }
+ catch {
+ return { error: 'not valid JSON' }
+ }
+ if (typeof parsed !== 'object' || parsed === null)
+ return { error: 'expected a JSON object' }
+ let record = parsed as Record<string, unknown>
+ let nameFromWrapper: string | undefined
+ const wrapped = record.mcpServers ?? record.mcp_servers ?? record.servers
+ if (typeof wrapped === 'object' && wrapped !== null && !Array.isArray(wrapped)) {
+ const first = Object.entries(wrapped as Record<string, unknown>)[0]
+ if (first === undefined)
+ return { error: 'mcpServers object is empty' }
+ nameFromWrapper = first[0]
+ if (typeof first[1] !== 'object' || first[1] === null)
+ return { error: 'server entry is not an object' }
+ record = first[1] as Record<string, unknown>
+ }
+ const stringMap = (value: unknown): Record<string, string> | undefined => {
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
+ return undefined
+ const out: Record<string, string> = {}
+ for (const [key, entry] of Object.entries(value)) {
+ if (typeof entry === 'string')
+ out[key] = entry
+ }
+ return Object.keys(out).length > 0 ? out : undefined
+ }
+ const args = Array.isArray(record.args) && record.args.every(entry => typeof entry === 'string')
+ ? record.args as string[]
+ : undefined
+ const command = typeof record.command === 'string' ? record.command : undefined
+ const url = typeof record.url === 'string' ? record.url : undefined
+ const declared = typeof record.type === 'string' ? record.type : typeof record.transport === 'string' ? record.transport : undefined
+ const httpDeclared = declared === 'http' || declared === 'streamable-http' || declared === 'sse'
+ const transport: 'stdio' | 'streamable-http' = command !== undefined && !httpDeclared
+ ? 'stdio'
+ : url !== undefined ? 'streamable-http' : httpDeclared ? 'streamable-http' : 'stdio'
+ if (transport === 'stdio' && command === undefined)
+ return { error: 'stdio config needs a "command" field' }
+ if (transport === 'streamable-http' && url === undefined)
+ return { error: 'http config needs a "url" field' }
+ const serverName = nameFromWrapper
+ ?? (typeof record.serverName === 'string' ? record.serverName : undefined)
+ ?? (typeof record.name === 'string' && record.name !== '@deepseek-ai/dsh-mcp-client' ? record.name : undefined)
+ const env = stringMap(record.env)
+ const headers = stringMap(record.headers)
+ return {
+ ...(serverName !== undefined ? { serverName } : {}),
+ transport,
+ ...(command !== undefined ? { command } : {}),
+ ...(args !== undefined ? { args } : {}),
+ ...(env !== undefined ? { env } : {}),
+ ...(url !== undefined ? { url } : {}),
+ ...(headers !== undefined ? { headers } : {}),
+ }
+}
+
+export function McpTab(props: McpTabProps): ReactElement {
+ const { t, injected } = props
+ const [servers, setServers] = useState<McpRow[] | null>(null)
+ const [editor, setEditor] = useState<McpEditorState | null>(null)
+ const [confirmId, setConfirmId] = useState<string | null>(null)
+ const [importOpen, setImportOpen] = useState(false)
+ const [importItems, setImportItems] = useState<McpImportItem[] | null>(null)
+ const [busy, setBusy] = useState(false)
+ const [pending, setPending] = useState(false)
+ const [restartConfirm, setRestartConfirm] = useState(false)
+ const [restarting, setRestarting] = useState(false)
+ const [outcome, setOutcome] = useState<{ ok: boolean, text: string } | null>(null)
+ const [formError, setFormError] = useState<string | null>(null)
+ const [reload, setReload] = useState(0)
+ const [editorMode, setEditorMode] = useState<McpEditorMode>('json')
+ const [pasteJson, setPasteJson] = useState('')
+ const [pasteError, setPasteError] = useState<string | null>(null)
+ const restartTimers = useRef<Set<number>>(new Set())
+
+ useEffect(() => () => {
+ for (const timer of restartTimers.current) window.clearTimeout(timer)
+ restartTimers.current.clear()
+ }, [])
+
+ const scheduleRestartPoll = (callback: () => void, delay: number): void => {
+ const timer = window.setTimeout(() => {
+ restartTimers.current.delete(timer)
+ callback()
+ }, delay)
+ restartTimers.current.add(timer)
+ }
+
+ const openImport = async (): Promise<void> => {
+ setImportOpen(true)
+ setImportItems(null)
+ try {
+ const body = await injected.scanImport()
+ const existing = new Set(body.existing)
+ setImportItems(body.servers.map(server => ({
+ server,
+ existing: existing.has(server.name),
+ checked: !existing.has(server.name),
+ })))
+ }
+ catch (error) {
+ setImportItems([])
+ setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ }
+ }
+
+ const doImport = async (): Promise<void> => {
+ if (importItems === null)
+ return
+ const items = importItems.filter(item => item.checked && !item.existing).map(item => ({ agent: item.server.agent, name: item.server.name }))
+ setBusy(true)
+ try {
+ const body = await injected.applyImport(items)
+ const failed = body.results.filter(item => !item.ok)
+ setOutcome(failed.length === 0
+ ? null
+ : { ok: false, text: `${t('failed')}: ${failed.map(item => `${item.name} (${item.error})`).join(', ')}` })
+ setImportOpen(false)
+ setPending(true)
+ setReload(value => value + 1)
+ }
+ catch (error) {
+ setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ }
+ finally {
+ setBusy(false)
+ }
+ }
+
+ const reloadList = (showPending: boolean): void => {
+ setReload(value => value + 1)
+ if (showPending)
+ setPending(true)
+ }
+
+ useEffect(() => {
+ let current = true
+ void injected.list().then(
+ (body) => {
+ if (current)
+ setServers(body.servers)
+ },
+ (error: Error) => {
+ if (current) {
+ setServers([])
+ setOutcome({ ok: false, text: `${t('failed')}: ${String(error.message ?? error)}` })
+ }
+ },
+ )
+ return () => {
+ current = false
+ }
+ }, [injected, reload, t])
+
+ const openCreate = (): void => {
+ setFormError(null)
+ setPasteError(null)
+ setPasteJson('')
+ setEditorMode('json')
+ setEditor({ id: '', serverName: '', transport: 'stdio', command: '', args: '', env: '', url: '', headers: '' })
+ }
+
+ const openEdit = (row: McpRow): void => {
+ setFormError(null)
+ setPasteError(null)
+ setPasteJson('')
+ setEditorMode('form')
+ setEditor({
+ id: row.id,
+ serverName: row.serverName,
+ transport: row.transport,
+ command: row.command ?? '',
+ args: (row.args ?? []).join('\n'),
+ env: mapToPairs(row.env, '='),
+ url: row.url ?? '',
+ headers: mapToPairs(row.headers, ':'),
+ })
+ }
+
+ /** Fill the form from pasted JSON (mcpServers wrapper, bare entry, dsh row). */
+ const doPasteFill = (): void => {
+ if (editor === null || pasteJson.trim() === '')
+ return
+ const parsed = parseMcpJson(pasteJson)
+ if ('error' in parsed) {
+ setPasteError(parsed.error)
+ return
+ }
+ // Existing rows keep their identity (serverName + transport); a pasted
+ // config of the other transport cannot apply to them.
+ const lockIdentity = editor.id !== ''
+ if (lockIdentity && parsed.transport !== editor.transport) {
+ setPasteError(t('pasteTransportMismatch'))
+ return
+ }
+ setPasteError(null)
+ setFormError(null)
+ setEditor({
+ ...editor,
+ ...(parsed.serverName !== undefined && !lockIdentity ? { serverName: parsed.serverName } : {}),
+ ...(!lockIdentity ? { transport: parsed.transport } : {}),
+ ...(parsed.transport === 'stdio'
+ ? {
+ command: parsed.command ?? editor.command,
+ args: (parsed.args ?? []).join('\n'),
+ env: mapToPairs(parsed.env, '='),
+ }
+ : {
+ url: parsed.url ?? editor.url,
+ headers: mapToPairs(parsed.headers, ':'),
+ }),
+ })
+ setEditorMode('form')
+ }
+
+ const doSave = async (): Promise<void> => {
+ if (editor === null)
+ return
+ let input: Record<string, unknown>
+ if (editorMode === 'json') {
+ const parsed = parseMcpJson(pasteJson)
+ if ('error' in parsed) {
+ setPasteError(parsed.error)
+ return
+ }
+ input = {
+ id: editor.id,
+ serverName: parsed.serverName?.trim() ?? '',
+ transport: parsed.transport,
+ ...(parsed.transport === 'stdio'
+ ? { command: parsed.command ?? '', args: parsed.args ?? [], env: parsed.env ?? {} }
+ : { url: parsed.url ?? '', headers: parsed.headers ?? {} }),
+ }
+ }
+ else {
+ input = {
+ id: editor.id,
+ serverName: editor.serverName.trim(),
+ transport: editor.transport,
+ ...(editor.transport === 'stdio'
+ ? {
+ command: editor.command.trim(),
+ args: editor.args.split(/\r?\n/).map(line => line.trim()).filter(line => line !== ''),
+ env: parsePairs(editor.env, '='),
+ }
+ : {
+ url: editor.url.trim(),
+ headers: parsePairs(editor.headers, ':'),
+ }),
+ }
+ }
+ setBusy(true)
+ setFormError(null)
+ setPasteError(null)
+ try {
+ await injected.save(input)
+ setEditor(null)
+ setOutcome(null)
+ reloadList(true)
+ }
+ catch (error) {
+ setFormError(String(error instanceof Error ? error.message : error))
+ }
+ finally {
+ setBusy(false)
+ }
+ }
+
+ const doToggle = async (row: McpRow): Promise<void> => {
+ setBusy(true)
+ try {
+ await injected.toggle(row.id, !row.disabled)
+ setOutcome(null)
+ reloadList(true)
+ }
+ catch (error) {
+ setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ }
+ finally {
+ setBusy(false)
+ }
+ }
+
+ const doRemove = async (): Promise<void> => {
+ if (confirmId === null)
+ return
+ setBusy(true)
+ try {
+ await injected.remove(confirmId)
+ setOutcome(null)
+ reloadList(true)
+ }
+ catch (error) {
+ setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ }
+ finally {
+ setBusy(false)
+ setConfirmId(null)
+ }
+ }
+
+ const doRestart = (): void => {
+ setRestartConfirm(false)
+ setRestarting(true)
+ void injected.restart()
+ // 桌面模式:壳层重启完成后会重载窗口。独立模式:轮询本源,恢复即刷新。
+ if (injected.desktop)
+ return
+ const deadline = Date.now() + MCP_RESTART_TIMEOUT_MS
+ const poll = (): void => {
+ if (Date.now() > deadline)
+ return
+ scheduleRestartPoll(() => {
+ void injected.list().then(
+ () => { window.location.reload() },
+ () => { poll() },
+ )
+ }, MCP_RESTART_POLL_INTERVAL_MS)
+ }
+ scheduleRestartPoll(poll, MCP_RESTART_INITIAL_DELAY_MS)
+ }
+
+ const restartBanner = (
+ <div className="dpte-banner" data-kind="info" role="status">
+ <StateDot state="ongoing" size={10} />
+ <div className="dpte-bannerBody">
+ <span>{restarting ? t('restarting') : t('restartNeeded')}</span>
+ <span className="dpte-bannerHint">
+ {restarting
+ ? (!injected.desktop && t('restartPortHint'))
+ : injected.desktop
+ ? (
+ <>
+ {t('restartDesktopHint')}
+ {' '}
+ <Button variant="outline" size="sm" onClick={() => setRestartConfirm(true)}>{t('restartNow')}</Button>
+ </>
+ )
+ : t('restartOtherHint')}
+ </span>
+ </div>
+ </div>
+ )
+
+ return (
+ <div className="dpte-section">
+ <div className="dpte-head">
+ <IconMcp />
+ <h3>{t('mcpTitle')}</h3>
+ <span className="dpte-spacer" />
+ <Button variant="ghost" size="sm" disabled={restarting} onClick={() => setRestartConfirm(true)}>{t('restart')}</Button>
+ <Button variant="ghost" size="sm" onClick={() => void openImport()}>{t('importServers')}</Button>
+ <Button variant="primary" size="sm" onClick={openCreate}>{t('addServer')}</Button>
+ </div>
+ <p className="dpte-intro">{t('mcpIntro')}</p>
+
+ {outcome !== null && (
+ <div className="dpte-banner" data-kind={outcome.ok ? 'ok' : 'error'} role="status">
+ <StateDot state={outcome.ok ? 'done' : 'error'} size={10} />
+ <div className="dpte-bannerBody"><span>{outcome.text}</span></div>
+ </div>
+ )}
+ {(pending || restarting) && restartBanner}
+
+ <div className="dpte-listHead">
+ <h3>{t('mcpTab')}</h3>
+ {servers !== null && <span className="dpte-count">{servers.length}</span>}
+ <span className="dpte-spacer" />
+ <button type="button" className="dpte-refresh" aria-label={t('view')} title={t('view')} disabled={busy} onClick={() => setReload(value => value + 1)}>
+ <IconRefresh />
+ </button>
+ </div>
+
+ {servers === null && <p className="dpte-empty">{t('loading')}</p>}
+ {servers !== null && servers.length === 0 && <p className="dpte-empty">{t('emptyMcp')}</p>}
+ {servers !== null && servers.length > 0 && (
+ <ul className="dpte-cards">
+ {servers.map(row => (
+ <li className="dpte-card" key={row.id}>
+ <div className="dpte-cardTop">
+ <strong className="dpte-cardTitle" title={row.id}>{row.serverName}</strong>
+ <span className="dpte-tag">{row.transport}</span>
+ <span className="dpte-tag" data-kind={row.disabled ? 'off' : undefined}>{row.disabled ? t('disabled') : t('enabled')}</span>
+ </div>
+ <p className="dpte-cardDesc">
+ {row.transport === 'stdio' ? `${row.command ?? ''} ${(row.args ?? []).join(' ')}` : row.url ?? ''}
+ </p>
+ <div className="dpte-cardRow">
+ <span className="dpte-spacer" />
+ <Button variant="ghost" size="sm" disabled={busy} onClick={() => void doToggle(row)}>{t('toggle')}</Button>
+ <Button variant="ghost" size="sm" disabled={busy} onClick={() => openEdit(row)}>{t('edit')}</Button>
+ <Button variant="ghost" size="sm" disabled={busy} onClick={() => setConfirmId(row.id)}>{t('delete')}</Button>
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ <Modal
+ open={editor !== null}
+ onClose={() => setEditor(null)}
+ title={editor !== null && editor.id !== '' ? t('editServer') : t('addServer')}
+ className="dpte-modalForm"
+ contentClassName="dpte-modalScroll"
+ >
+ {editor !== null && (
+ <div className="dpte-form">
+ <div className="dpte-editorTabs" role="tablist" aria-label={t('addServer')}>
+ {(['json', 'form'] as const).map(mode => (
+ <button
+ key={mode}
+ type="button"
+ role="tab"
+ className="dpte-editorTab"
+ aria-selected={editorMode === mode}
+ data-active={editorMode === mode ? 'true' : undefined}
+ onClick={() => setEditorMode(mode)}
+ >
+ {t(mode === 'json' ? 'editorJsonTab' : 'editorFormTab')}
+ </button>
+ ))}
+ </div>
+ {editorMode === 'json'
+ ? (
+ <div className="dpte-form" role="tabpanel">
+ <label className="dpte-label">
+ <span>{t('formatPaste')}</span>
+ <textarea
+ className="dpte-textarea dpte-jsonEditor"
+ placeholder={'{\n "mcpServers": {\n "name": { "command": "npx", "args": ["-y", "@example/mcp-server"] }\n }\n}\n'}
+ value={pasteJson}
+ onChange={event => setPasteJson(event.target.value)}
+ />
+ </label>
+ {pasteError !== null && <p className="dpte-formError">{pasteError}</p>}
+ <div className="dpte-cardRow">
+ <Button variant="outline" size="sm" disabled={pasteJson.trim() === ''} onClick={doPasteFill}>{t('formatFill')}</Button>
+ </div>
+ </div>
+ )
+ : (
+ <div className="dpte-form" role="tabpanel">
+ <label className="dpte-label">
+ <span>{t('serverName')}</span>
+ <input
+ className="dpte-input"
+ value={editor.serverName}
+ disabled={editor.id !== ''}
+ onChange={event => setEditor({ ...editor, serverName: event.target.value })}
+ />
+ </label>
+ <label className="dpte-label">
+ <span>{t('transport')}</span>
+ <select
+ className="dpte-select"
+ value={editor.transport}
+ disabled={editor.id !== ''}
+ onChange={event => setEditor({ ...editor, transport: event.target.value as McpEditorState['transport'] })}
+ >
+ <option value="stdio">{t('transportStdio')}</option>
+ <option value="streamable-http">{t('transportHttp')}</option>
+ </select>
+ </label>
+ {editor.transport === 'stdio'
+ ? (
+ <>
+ <label className="dpte-label">
+ <span>{t('command')}</span>
+ <input className="dpte-input" value={editor.command} onChange={event => setEditor({ ...editor, command: event.target.value })} />
+ </label>
+ <label className="dpte-label">
+ <span>{t('args')}</span>
+ <textarea className="dpte-textarea" data-short="true" value={editor.args} onChange={event => setEditor({ ...editor, args: event.target.value })} />
+ </label>
+ <label className="dpte-label">
+ <span>{t('envPairs')}</span>
+ <textarea className="dpte-textarea" data-short="true" value={editor.env} onChange={event => setEditor({ ...editor, env: event.target.value })} />
+ </label>
+ </>
+ )
+ : (
+ <>
+ <label className="dpte-label">
+ <span>{t('url')}</span>
+ <input className="dpte-input" value={editor.url} onChange={event => setEditor({ ...editor, url: event.target.value })} />
+ </label>
+ <label className="dpte-label">
+ <span>{t('headersPairs')}</span>
+ <textarea className="dpte-textarea" data-short="true" value={editor.headers} onChange={event => setEditor({ ...editor, headers: event.target.value })} />
+ </label>
+ </>
+ )}
+ </div>
+ )}
+ {formError !== null && <p className="dpte-formError">{formError}</p>}
+ <div className="dpte-cardRow">
+ <span className="dpte-spacer" />
+ <Button variant="ghost" onClick={() => setEditor(null)}>{t('cancel')}</Button>
+ <Button variant="primary" disabled={busy} onClick={() => void doSave()}>{t('save')}</Button>
+ </div>
+ </div>
+ )}
+ </Modal>
+
+ <Modal
+ open={confirmId !== null}
+ onClose={() => setConfirmId(null)}
+ title={t('confirmRemove')}
+ description={confirmId ?? undefined}
+ footer={(
+ <>
+ <Button variant="ghost" onClick={() => setConfirmId(null)}>{t('cancel')}</Button>
+ <Button variant="primary" disabled={busy} onClick={() => void doRemove()}>{t('delete')}</Button>
+ </>
+ )}
+ >
+ <p>{t('removeWarn')}</p>
+ </Modal>
+
+ <Modal
+ open={restartConfirm}
+ onClose={() => setRestartConfirm(false)}
+ title={t('restartConfirmTitle')}
+ footer={(
+ <>
+ <Button variant="ghost" onClick={() => setRestartConfirm(false)}>{t('cancel')}</Button>
+ <Button variant="primary" onClick={doRestart}>{t('restartNow')}</Button>
+ </>
+ )}
+ >
+ <p>{t('restartConfirmBody')}</p>
+ </Modal>
+
+ <Modal
+ open={importOpen}
+ onClose={() => setImportOpen(false)}
+ title={t('importServers')}
+ className="dpte-modalWide"
+ >
+ <div className="dpte-form">
+ <p className="dpte-intro">{t('importIntro')}</p>
+ {importItems === null && <p className="dpte-empty">{t('loading')}</p>}
+ {importItems !== null && importItems.length === 0 && <p className="dpte-empty">{t('importEmpty')}</p>}
+ {importItems !== null && importItems.length > 0 && (
+ <div className="dpte-importScroll">
+ {importGroups(importItems).map((group) => {
+ const selectable = group.items
+ .filter(({ item }) => !item.existing)
+ .map(({ index }) => index)
+ const allChecked = selectable.length > 0
+ && selectable.every(index => importItems[index].checked)
+ return (
+ <section className="dpte-importGroup" key={group.agent}>
+ <div className="dpte-importHead">
+ <span className="dpte-tag" data-kind="source">{group.label}</span>
+ <span className="dpte-importCount">{group.items.length}</span>
+ {selectable.length > 0 && (
+ <label className="dpte-importAll">
+ <input
+ type="checkbox"
+ checked={allChecked}
+ onChange={(event) => {
+ const next = importItems.slice()
+ for (const index of selectable) next[index] = { ...next[index], checked: event.target.checked }
+ setImportItems(next)
+ }}
+ />
+ {t('importSelectAll')}
+ </label>
+ )}
+ </div>
+ <ul className="dpte-cards dpte-cardsSingle">
+ {group.items.map(({ item, index }) => {
+ const command = item.server.transport === 'stdio'
+ ? `${item.server.command ?? ''} ${(item.server.args ?? []).join(' ')}`.trim()
+ : item.server.url ?? ''
+ return (
+ <li className={`dpte-card${item.existing ? ' dpte-cardMuted' : ''}`} key={`${item.server.agent}/${item.server.name}`}>
+ <div className="dpte-cardTop">
+ <label className={`dpte-importChoice${item.existing ? ' dpte-importChoiceDisabled' : ''}`}>
+ <input
+ type="checkbox"
+ checked={item.checked}
+ disabled={item.existing}
+ onChange={(event) => {
+ const next = importItems.slice()
+ next[index] = { ...item, checked: event.target.checked }
+ setImportItems(next)
+ }}
+ />
+ <strong className="dpte-cardTitle" title={item.server.name}>{item.server.name}</strong>
+ </label>
+ <span className="dpte-tag">{item.server.transport}</span>
+ {item.existing && <span className="dpte-tag">{t('importExisting')}</span>}
+ </div>
+ <p className="dpte-cardDesc" title={command}>{command}</p>
+ </li>
+ )
+ })}
+ </ul>
+ </section>
+ )
+ })}
+ </div>
+ )}
+ {formError !== null && <p className="dpte-formError">{formError}</p>}
+ <div className="dpte-cardRow">
+ <span className="dpte-spacer" />
+ <Button variant="ghost" onClick={() => setImportOpen(false)}>{t('cancel')}</Button>
+ <Button
+ variant="primary"
+ disabled={busy || importItems === null || !importItems.some(item => item.checked && !item.existing)}
+ onClick={() => void doImport()}
+ >
+ {t('importSelected')}
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ </div>
+ )
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/skills-tab.tsx b/packages/dsh-tauri-panel-extension/src/client/skills-tab.tsx
new file mode 100644
index 00000000..a8e73133
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/skills-tab.tsx
@@ -0,0 +1,358 @@
+import type { ReactElement } from 'react'
+import type { OpenTarget, SkillEditorState, SkillRowView, SkillsTabProps } from './types'
+import { Button, Modal, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { GITHUB_REPOSITORY_PATTERN, IMPORT_REFRESH_DELAYS_MS, SKILL_REFRESH_INTERVAL_MS, SKILL_REFRESH_TIMEOUT_MS, SOURCE_LOCALE_KEYS } from './constants'
+import { IconGitHub, IconRefresh, IconSkill } from './icons'
+import { MarkdownPreview } from './markdown-preview'
+
+function policyTag(skill: SkillRowView): { key?: string, off: boolean } {
+ const { modelInvocable, userInvocable } = skill.invocation
+ if (!modelInvocable && !userInvocable)
+ return { key: 'skillDisabled', off: true }
+ if (!modelInvocable)
+ return { key: 'skillUserOnly', off: false }
+ if (!userInvocable)
+ return { key: 'skillModelOnly', off: false }
+ return { off: false }
+}
+
+function normalizeRepository(value: string): string | null {
+ const normalized = value.trim().replace(/\/$/, '')
+ if (!GITHUB_REPOSITORY_PATTERN.test(normalized))
+ return null
+ return normalized.startsWith('http') ? normalized : `https://github.com/${normalized}`
+}
+
+export function SkillsTab({ t, injected, createSkill }: SkillsTabProps): ReactElement {
+ const [skills, setSkills] = useState<SkillRowView[] | null>(null)
+ const [editor, setEditor] = useState<SkillEditorState | null>(null)
+ const [preview, setPreview] = useState(false)
+ const [confirmName, setConfirmName] = useState<string | null>(null)
+ const [busy, setBusy] = useState(false)
+ const [outcome, setOutcome] = useState<{ ok: boolean, text: string } | null>(null)
+ const [formError, setFormError] = useState<string | null>(null)
+ const [reload, setReload] = useState(0)
+ const [query, setQuery] = useState('')
+ const [sourceFilter, setSourceFilter] = useState('all')
+ const [importOpen, setImportOpen] = useState(false)
+ const [repositoryUrl, setRepositoryUrl] = useState('')
+ const timers = useRef<Set<number>>(new Set())
+ const mounted = useRef(true)
+
+ useEffect(() => () => {
+ mounted.current = false
+ for (const timer of timers.current) window.clearTimeout(timer)
+ }, [])
+
+ useEffect(() => {
+ let current = true
+ void injected.list().then(
+ (body) => {
+ if (current)
+ setSkills(body.skills)
+ },
+ (error: unknown) => {
+ if (current) {
+ setSkills([])
+ setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` })
+ }
+ },
+ )
+ return () => {
+ current = false
+ }
+ }, [injected, reload, t])
+
+ const later = (callback: () => void, delay: number): void => {
+ const timer = window.setTimeout(() => {
+ timers.current.delete(timer)
+ if (mounted.current)
+ callback()
+ }, delay)
+ timers.current.add(timer)
+ }
+
+ const refreshUntil = (predicate: (rows: SkillRowView[]) => boolean): void => {
+ const deadline = Date.now() + SKILL_REFRESH_TIMEOUT_MS
+ const tick = (): void => {
+ if (Date.now() > deadline)
+ return
+ later(() => void injected.list().then((body) => {
+ if (!mounted.current)
+ return
+ setSkills(body.skills)
+ if (!predicate(body.skills))
+ tick()
+ }, tick), SKILL_REFRESH_INTERVAL_MS)
+ }
+ tick()
+ }
+
+ const openExisting = async (skill: SkillRowView): Promise<void> => {
+ setBusy(true)
+ try {
+ const body = await injected.get(skill.name)
+ setPreview(!skill.editable)
+ setEditor({ mode: skill.editable ? 'edit' : 'view', name: skill.name, description: skill.description, whenToUse: skill.whenToUse ?? '', modelInvocable: skill.invocation.modelInvocable, userInvocable: skill.invocation.userInvocable, content: body.content })
+ }
+ catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ finally { setBusy(false) }
+ }
+
+ const doSave = async (): Promise<void> => {
+ if (editor === null)
+ return
+ const name = editor.name.trim()
+ setBusy(true)
+ setFormError(null)
+ try {
+ await injected.save({ name, description: editor.description, whenToUse: editor.whenToUse.trim() || undefined, modelInvocable: editor.modelInvocable, userInvocable: editor.userInvocable, content: editor.content })
+ setEditor(null)
+ setOutcome({ ok: true, text: t('saved') })
+ refreshUntil(rows => rows.some(row => row.name === name))
+ }
+ catch (error) { setFormError(error instanceof Error ? error.message : String(error)) }
+ finally { setBusy(false) }
+ }
+
+ const doDelete = async (): Promise<void> => {
+ if (confirmName === null)
+ return
+ const name = confirmName
+ setBusy(true)
+ try {
+ await injected.remove(name)
+ setOutcome({ ok: true, text: t('saved') })
+ refreshUntil(rows => !rows.some(row => row.name === name))
+ }
+ catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ finally {
+ setBusy(false)
+ setConfirmName(null)
+ }
+ }
+
+ const doToggle = async (skill: SkillRowView): Promise<void> => {
+ const enabled = skill.invocation.modelInvocable || skill.invocation.userInvocable
+ setBusy(true)
+ try {
+ await injected.policy(skill.name, !enabled)
+ setOutcome({ ok: true, text: t(enabled ? 'skillDisabledMsg' : 'skillEnabled') })
+ refreshUntil((rows) => {
+ const row = rows.find(item => item.name === skill.name)
+ return row !== undefined && row.invocation.modelInvocable === !enabled && row.invocation.userInvocable === !enabled
+ })
+ }
+ catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ finally { setBusy(false) }
+ }
+
+ const doOpen = async (target: OpenTarget): Promise<void> => {
+ try {
+ await injected.open(target)
+ }
+ catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ }
+
+ const doCreate = async (): Promise<void> => {
+ setBusy(true)
+ try {
+ await createSkill()
+ }
+ catch (error) { setOutcome({ ok: false, text: `${t('skillCreatorFailed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ finally {
+ if (mounted.current)
+ setBusy(false)
+ }
+ }
+
+ const doImport = async (): Promise<void> => {
+ const url = normalizeRepository(repositoryUrl)
+ if (url === null) {
+ setFormError(t('importRepositoryInvalid'))
+ return
+ }
+ setBusy(true)
+ setFormError(null)
+ try {
+ await injected.importRepository(url)
+ setOutcome({ ok: true, text: t('importRepositorySuccess') })
+ setImportOpen(false)
+ setRepositoryUrl('')
+ for (const delay of IMPORT_REFRESH_DELAYS_MS) {
+ await new Promise<void>(resolve => later(resolve, delay))
+ if (!mounted.current)
+ return
+ setSkills((await injected.list()).skills)
+ }
+ }
+ catch (error) { setFormError(error instanceof Error ? error.message : String(error)) }
+ finally {
+ if (mounted.current)
+ setBusy(false)
+ }
+ }
+
+ const needle = query.trim().toLowerCase()
+ const filtered = useMemo(() => (skills ?? []).map((skill, index) => ({ skill, index })).filter(({ skill }) => (sourceFilter === 'all' || skill.source === sourceFilter) && (needle === '' || skill.name.toLowerCase().includes(needle) || skill.description.toLowerCase().includes(needle))).sort((a, b) => Number(b.skill.repository !== undefined) - Number(a.skill.repository !== undefined) || a.index - b.index).map(({ skill }) => skill), [needle, skills, sourceFilter])
+ const sources = skills === null ? [] : [...new Set(skills.map(skill => skill.source))]
+ const readOnly = editor?.mode === 'view'
+
+ return (
+ <div className="dpte-section">
+ <div className="dpte-head">
+ <IconSkill />
+ <h3>{t('skillsTitle')}</h3>
+ <span className="dpte-spacer" />
+ <Button variant="ghost" size="sm" onClick={() => void doOpen({ target: 'user-skills' })}>{t('openUserSkills')}</Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={busy}
+ onClick={() => {
+ setFormError(null)
+ setImportOpen(true)
+ }}
+ >
+ {t('importRepository')}
+ </Button>
+ <Button variant="primary" size="sm" disabled={busy} onClick={() => void doCreate()}>{t('newSkill')}</Button>
+
+ </div>
+ <p className="dpte-intro">{t('skillsIntro')}</p>
+ {outcome && (
+ <div className="dpte-banner" data-kind={outcome.ok ? 'ok' : 'error'} role="status">
+ <StateDot state={outcome.ok ? 'done' : 'error'} size={10} />
+ <div className="dpte-bannerBody">{outcome.text}</div>
+ </div>
+ )}
+ <div className="dpte-listHead">
+ <h3>{t('skillsTab')}</h3>
+ {skills && (
+ <span className="dpte-count">
+ {filtered.length}
+ /
+ {skills.length}
+ </span>
+ )}
+ <span className="dpte-spacer" />
+ <input className="dpte-search" type="search" placeholder={t('searchSkills')} aria-label={t('searchSkills')} value={query} onChange={event => setQuery(event.target.value)} />
+ <button type="button" className="dpte-refresh" aria-label={t('refresh')} title={t('refresh')} disabled={busy} onClick={() => setReload(value => value + 1)}><IconRefresh /></button>
+ </div>
+ {sources.length > 1 && <div className="dpte-chips" role="group" aria-label={t('source')}>{[{ id: 'all', label: t('filterAll') }, ...sources.map(source => ({ id: source, label: t(SOURCE_LOCALE_KEYS[source] ?? 'sourceCustom') }))].map(chip => <button key={chip.id} type="button" className="dpte-chip" data-active={sourceFilter === chip.id ? 'true' : undefined} onClick={() => setSourceFilter(chip.id)}>{chip.label}</button>)}</div>}
+ {skills === null && <p className="dpte-empty">{t('loading')}</p>}
+ {skills !== null && filtered.length === 0 && <p className="dpte-empty">{skills.length === 0 ? t('emptySkills') : t('noMatch')}</p>}
+ {filtered.length > 0 && (
+ <ul className="dpte-cards">
+ {filtered.map((skill) => {
+ const tag = policyTag(skill)
+ return (
+ <li className="dpte-card" key={`${skill.source}/${skill.name}`}>
+ <div className="dpte-cardTop">
+ <strong className="dpte-cardTitle" title={skill.name}>{skill.name}</strong>
+ <span className="dpte-tag" data-kind="source">{t(SOURCE_LOCALE_KEYS[skill.source] ?? 'sourceCustom')}</span>
+ {tag.key && <span className="dpte-tag" data-kind={tag.off ? 'off' : undefined}>{t(tag.key)}</span>}
+ </div>
+ <p className="dpte-cardDesc" title={skill.description}>{skill.description}</p>
+ <div className="dpte-cardRow">
+ {skill.policyEditable && <button type="button" className="dpte-switch" role="switch" aria-checked={skill.invocation.modelInvocable || skill.invocation.userInvocable} aria-label={t('toggleSkill')} title={t('toggleSkillHint')} disabled={busy} onClick={() => void doToggle(skill)}><span className="dpte-switchKnob" /></button>}
+ {skill.dir && <button type="button" className="dpte-link" onClick={() => void doOpen({ target: 'skill', name: skill.name })}>{t('openFolder')}</button>}
+ <span className="dpte-spacer" />
+ {skill.repository?.githubUrl && <a className="dpte-iconLink" href={skill.repository.githubUrl} target="_blank" rel="noreferrer" aria-label={t('githubRepository')} title={t('githubRepository')}><IconGitHub /></a>}
+ <Button variant="ghost" size="sm" disabled={busy} onClick={() => void openExisting(skill)}>{skill.editable ? t('edit') : t('view')}</Button>
+ {skill.removable && <Button variant="ghost" size="sm" disabled={busy} onClick={() => setConfirmName(skill.name)}>{t('delete')}</Button>}
+ </div>
+ </li>
+ )
+ })}
+ </ul>
+ )}
+
+ <Modal open={editor !== null} onClose={() => setEditor(null)} title={editor?.mode === 'edit' ? t('editSkill') : t('viewSkill')} className="dpte-modalForm" contentClassName="dpte-modalScroll">
+ {editor && (
+ <div className="dpte-form">
+ <label className="dpte-label">
+ <span>{t('skillName')}</span>
+ <input className="dpte-input" value={editor.name} disabled />
+ </label>
+ <label className="dpte-label">
+ <span>{t('skillDescription')}</span>
+ <input className="dpte-input" value={editor.description} disabled={readOnly} onChange={event => setEditor({ ...editor, description: event.target.value })} />
+ </label>
+ <label className="dpte-label">
+ <span>{t('skillWhenToUse')}</span>
+ <input className="dpte-input" value={editor.whenToUse} disabled={readOnly} onChange={event => setEditor({ ...editor, whenToUse: event.target.value })} />
+ </label>
+ <div className="dpte-checks">
+ <label>
+ <input type="checkbox" checked={editor.modelInvocable} disabled={readOnly} onChange={event => setEditor({ ...editor, modelInvocable: event.target.checked })} />
+ {t('modelInvocable')}
+ </label>
+ <label>
+ <input type="checkbox" checked={editor.userInvocable} disabled={readOnly} onChange={event => setEditor({ ...editor, userInvocable: event.target.checked })} />
+ {t('userInvocable')}
+ </label>
+ </div>
+ <div className="dpte-label">
+ <div className="dpte-cardRow">
+ <span>{t('skillContent')}</span>
+ <span className="dpte-spacer" />
+ <div className="dpte-segments" role="tablist" aria-label={t('skillContent')}>
+ <button type="button" role="tab" aria-selected={preview} className="dpte-segment" data-active={preview ? 'true' : undefined} onClick={() => setPreview(true)}>{t('skillPreview')}</button>
+ <button type="button" role="tab" aria-selected={!preview} className="dpte-segment" data-active={!preview ? 'true' : undefined} onClick={() => setPreview(false)}>{readOnly ? t('skillPlainText') : t('edit')}</button>
+ </div>
+ </div>
+ {preview ? <div className="dpte-mdPreview"><MarkdownPreview text={editor.content} /></div> : <textarea className="dpte-textarea" value={editor.content} readOnly={readOnly} onChange={event => setEditor({ ...editor, content: event.target.value })} />}
+ </div>
+ {formError && <p className="dpte-formError">{formError}</p>}
+ <div className="dpte-cardRow">
+ <span className="dpte-spacer" />
+ <Button variant="ghost" onClick={() => setEditor(null)}>{readOnly ? t('close') : t('cancel')}</Button>
+ {!readOnly && <Button variant="primary" disabled={busy} onClick={() => void doSave()}>{t('save')}</Button>}
+ </div>
+ </div>
+ )}
+ </Modal>
+ <Modal
+ open={confirmName !== null}
+ onClose={() => setConfirmName(null)}
+ title={t('confirmDelete')}
+ description={confirmName ?? undefined}
+ footer={(
+ <>
+ <Button variant="ghost" onClick={() => setConfirmName(null)}>{t('cancel')}</Button>
+ <Button variant="primary" disabled={busy} onClick={() => void doDelete()}>{t('delete')}</Button>
+ </>
+ )}
+ >
+ <p>{t('deleteWarn')}</p>
+ </Modal>
+ <Modal open={importOpen} onClose={() => setImportOpen(false)} title={t('importRepositoryTitle')} className="dpte-modalWide">
+ <div className="dpte-form">
+ <p className="dpte-intro">{t('importRepositoryHint')}</p>
+ <label className="dpte-label">
+ <span>{t('repository')}</span>
+ <input
+ autoFocus
+ className="dpte-input"
+ placeholder={t('importRepositoryPlaceholder')}
+ value={repositoryUrl}
+ onChange={event => setRepositoryUrl(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter')
+ void doImport()
+ }}
+ />
+ </label>
+ {formError && <p className="dpte-formError">{formError}</p>}
+ <div className="dpte-cardRow">
+ <span className="dpte-spacer" />
+ <Button variant="ghost" disabled={busy} onClick={() => setImportOpen(false)}>{t('cancel')}</Button>
+ <Button variant="primary" disabled={busy || repositoryUrl.trim() === ''} onClick={() => void doImport()}>{t('importRepository')}</Button>
+ </div>
+ </div>
+ </Modal>
+ </div>
+ )
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/styles.ts b/packages/dsh-tauri-panel-extension/src/client/styles.ts
new file mode 100644
index 00000000..491c0aa6
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/styles.ts
@@ -0,0 +1,113 @@
+import { CssRender } from 'dsh-tauri/client'
+import { STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+const primary = 'var(--dsw-alias-label-primary)'
+const secondary = 'var(--dsw-alias-label-secondary)'
+const tertiary = 'var(--dsw-alias-label-tertiary)'
+const border = 'var(--dsw-alias-border-l2)'
+const business = 'var(--dsw-alias-state-business-primary)'
+const layer1 = 'var(--dsw-alias-bg-layer-1)'
+const layer3 = 'var(--dsw-alias-bg-layer-3)'
+const hover = 'var(--dsw-alias-interactive-bg-hover)'
+
+const styles = c([
+ c('.dpte-section', { display: 'flex', flexDirection: 'column', gap: '14px', width: '100%', maxWidth: '760px', color: primary }),
+ c('.dpte-tabs', { display: 'flex', alignItems: 'flex-end', gap: '22px', borderBottom: `1px solid ${border}`, marginTop: '2px' }),
+ c('.dpte-tab', { position: 'relative', border: '0', padding: '7px 1px 9px', background: 'transparent', color: tertiary, font: 'inherit', fontSize: '13px', lineHeight: '20px', cursor: 'pointer' }),
+ c('.dpte-tab:hover,.dpte-tab[data-active=\'true\']', { color: primary }),
+ c('.dpte-tab[data-active=\'true\']::after,.dpte-tab:focus-visible::after', { position: 'absolute', right: '0', bottom: '-1px', left: '0', height: '2px', borderRadius: '2px 2px 0 0', background: primary, content: '\'\'' }),
+ c('.dpte-tab:focus-visible', { outline: `2px solid ${business}`, outlineOffset: '2px', borderRadius: '2px', color: primary }),
+ c('.dpte-tabPanel', { minWidth: '0', paddingTop: '2px' }),
+ c('.dpte-head', { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' }),
+ c('.dpte-head h3,.dpte-listHead h3', { margin: '0', fontSize: '13px', lineHeight: '20px', fontWeight: '600' }),
+ c('.dpte-head>svg', { flex: 'none', color: tertiary }),
+ c('.dpte-intro,.dpte-empty', { margin: '0', fontSize: '13px', lineHeight: '20px', color: tertiary }),
+ c('.dpte-listHead', { display: 'flex', alignItems: 'baseline', gap: '7px', padding: '0 2px', marginTop: '2px' }),
+ c('.dpte-count', { fontSize: '12px', lineHeight: '18px', color: tertiary, fontVariantNumeric: 'tabular-nums' }),
+ c('.dpte-spacer', { flex: '1' }),
+ c('.dpte-refresh,.dpte-iconLink', { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: '26px', height: '26px', border: '0', borderRadius: '6px', background: 'transparent', color: tertiary, cursor: 'pointer', textDecoration: 'none' }),
+ c('.dpte-refresh:hover,.dpte-iconLink:hover', { background: hover, color: primary }),
+ c('.dpte-refresh:focus-visible,.dpte-iconLink:focus-visible', { outline: `2px solid ${business}`, outlineOffset: '-2px' }),
+ c('.dpte-cards', { display: 'grid', gridTemplateColumns: 'repeat(2,minmax(0,1fr))', alignItems: 'stretch', gap: '10px', margin: '0', padding: '0', listStyle: 'none' }),
+ c('.dpte-cardsSingle', { gridTemplateColumns: 'minmax(0,1fr)' }),
+ c('.dpte-card', { display: 'flex', flexDirection: 'column', gap: '8px', minWidth: '0', border: `1px solid ${border}`, borderRadius: '10px', background: layer3, padding: '12px 14px' }),
+ c('.dpte-card:hover', { background: hover }),
+ c('.dpte-cardMuted', { opacity: '.55' }),
+ c('.dpte-cardTop,.dpte-cardRow', { display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'wrap' }),
+ c('.dpte-cardTitle', { flex: '1', minWidth: '0', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', fontSize: '14px', lineHeight: '20px', fontWeight: '600', fontFamily: 'var(--ds-font-family-code)' }),
+ c('.dpte-cardDesc', { margin: '0', fontSize: '12px', lineHeight: '18px', color: secondary, display: '-webkit-box', WebkitLineClamp: '2', WebkitBoxOrient: 'vertical', overflow: 'hidden' }),
+ c('.dpte-tag', { display: 'inline-flex', alignItems: 'center', minHeight: '20px', borderRadius: '5px', padding: '1px 6px', background: layer1, color: secondary, fontSize: '11px', lineHeight: '16px', whiteSpace: 'nowrap' }),
+ c('.dpte-tag[data-kind=\'source\']', { background: `color-mix(in srgb,${business} 10%,transparent)`, color: business }),
+ c('.dpte-tag[data-kind=\'off\']', { background: 'color-mix(in srgb,var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-tertiary)) 12%,transparent)', color: secondary }),
+ c('.dpte-banner', { display: 'flex', alignItems: 'flex-start', gap: '8px', border: `1px solid ${border}`, borderRadius: '8px', padding: '10px 12px', background: layer3, fontSize: '13px', lineHeight: '20px' }),
+ c('.dpte-banner[data-kind=\'ok\']', { borderColor: 'color-mix(in srgb,var(--dsw-alias-state-success-primary) 35%,transparent)', background: 'color-mix(in srgb,var(--dsw-alias-state-success-primary) 8%,transparent)' }),
+ c('.dpte-banner[data-kind=\'error\']', { borderColor: 'color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent)', background: 'color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent)' }),
+ c('.dpte-banner[data-kind=\'info\']', { borderColor: `color-mix(in srgb,${business} 35%,transparent)`, background: `color-mix(in srgb,${business} 8%,transparent)` }),
+ c('.dpte-bannerBody', { flex: '1', minWidth: '0', display: 'flex', flexDirection: 'column', gap: '4px' }),
+ c('.dpte-bannerHint', { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', color: secondary, fontSize: '12px', lineHeight: '18px' }),
+ c('.dpte-form', { display: 'flex', flexDirection: 'column', gap: '10px' }),
+ c('.dpte-editorTabs', { display: 'flex', gap: '4px', borderBottom: `1px solid ${border}` }),
+ c('.dpte-editorTab', { position: 'relative', border: '0', padding: '7px 10px 9px', background: 'transparent', color: tertiary, font: 'inherit', fontSize: '13px', lineHeight: '20px', cursor: 'pointer' }),
+ c('.dpte-editorTab:hover,.dpte-editorTab[data-active=\'true\']', { color: primary }),
+ c('.dpte-editorTab[data-active=\'true\']::after', { position: 'absolute', right: '8px', bottom: '-1px', left: '8px', height: '2px', borderRadius: '2px 2px 0 0', background: primary, content: '\'\'' }),
+ c('.dpte-editorTab:focus-visible', { outline: `2px solid ${business}`, outlineOffset: '-2px', borderRadius: '4px', color: primary }),
+ c('.dpte-label', { display: 'flex', flexDirection: 'column', gap: '4px', fontSize: '12px', lineHeight: '18px', color: secondary }),
+ c('.dpte-label>span:first-child', { color: tertiary }),
+ c('.dpte-input,.dpte-textarea,.dpte-select,.dpte-search', { width: '100%', boxSizing: 'border-box', border: `1px solid ${border}`, borderRadius: '8px', padding: '7px 10px', outline: 'none', background: layer1, color: primary, font: 'inherit', fontSize: '13px' }),
+ c('.dpte-search', { width: '200px', padding: '4px 10px', fontSize: '12px', lineHeight: '18px' }),
+ c('.dpte-textarea', { minHeight: '320px', resize: 'vertical', fontFamily: 'var(--ds-font-family-code)', lineHeight: '1.5' }),
+ c('.dpte-textarea[data-short=\'true\']', { minHeight: '96px' }),
+ c('.dpte-jsonEditor', { minHeight: '260px' }),
+ c('.dpte-input:focus-visible,.dpte-textarea:focus-visible,.dpte-select:focus-visible,.dpte-search:focus-visible', { borderColor: business, boxShadow: `0 0 0 2px color-mix(in srgb,${business} 18%,transparent)` }),
+ c('.dpte-checks', { display: 'flex', gap: '16px', fontSize: '13px', lineHeight: '20px' }),
+ c('.dpte-checks label,.dpte-importChoice', { display: 'inline-flex', alignItems: 'center', gap: '8px', cursor: 'pointer', minWidth: '0' }),
+ c('.dpte-importChoiceDisabled', { cursor: 'default' }),
+ c('.dpte-formError', { margin: '0', color: 'var(--dsw-alias-state-error-primary)', fontSize: '12px', lineHeight: '18px' }),
+ c('.dpte-modalWide.dpte-modalWide', { width: 'min(680px,100%)' }),
+ c('.dpte-modalForm.dpte-modalForm', { width: 'min(760px,100%)' }),
+ c('.dpte-modalScroll.dpte-modalScroll', { maxHeight: 'calc(100vh - 160px)', overflowY: 'auto' }),
+ c('.dpte-mdPreview', { minHeight: '320px', maxHeight: '60vh', overflowY: 'auto', border: `1px solid ${border}`, borderRadius: '8px', padding: '8px 12px', background: layer1, fontSize: '13px' }),
+ c('.dpte-mdBody h1,.dpte-mdBody h2,.dpte-mdBody h3,.dpte-mdBody h4', { margin: '14px 0 6px', color: primary, lineHeight: '1.4' }),
+ c('.dpte-mdBody h1', { fontSize: '18px' }),
+ c('.dpte-mdBody h2', { fontSize: '16px' }),
+ c('.dpte-mdBody h3', { fontSize: '14px' }),
+ c('.dpte-mdBody h4', { fontSize: '13px' }),
+ c('.dpte-mdBody p', { margin: '6px 0', lineHeight: '20px' }),
+ c('.dpte-mdBody ul,.dpte-mdBody ol', { margin: '6px 0', paddingLeft: '20px' }),
+ c('.dpte-mdBody code,.dpte-code', { fontFamily: 'var(--ds-font-family-code)', fontSize: '12px', background: layer3, borderRadius: '4px', padding: '1px 5px' }),
+ c('.dpte-mdBody pre,.dpte-code', { margin: '8px 0', padding: '10px 12px', overflowX: 'auto', border: `1px solid ${border}`, borderRadius: '8px', background: layer3 }),
+ c('.dpte-mdBody a,.dpte-link', { color: business }),
+ c('.dpte-importScroll', { display: 'flex', flexDirection: 'column', gap: '14px', maxHeight: 'min(400px,52vh)', overflowY: 'auto', padding: '2px 4px 2px 2px' }),
+ c('.dpte-importGroup', { display: 'flex', flexDirection: 'column', gap: '8px' }),
+ c('.dpte-importHead', { display: 'flex', alignItems: 'center', gap: '8px', padding: '0 2px' }),
+ c('.dpte-importCount', { fontSize: '12px', lineHeight: '18px', color: tertiary }),
+ c('.dpte-importAll', { marginLeft: 'auto', display: 'inline-flex', alignItems: 'center', gap: '6px', fontSize: '12px', color: secondary, cursor: 'pointer' }),
+ c('.dpte-chips', { display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'wrap' }),
+ c('.dpte-chip', { border: `1px solid ${border}`, borderRadius: '999px', padding: '2px 10px', background: 'transparent', color: secondary, font: 'inherit', fontSize: '12px', cursor: 'pointer' }),
+ c('.dpte-chip:hover,.dpte-chip[data-active=\'true\']', { color: business, background: hover }),
+ c('.dpte-switch', { position: 'relative', flex: 'none', width: '30px', height: '18px', border: '0', borderRadius: '999px', background: layer1, boxShadow: `inset 0 0 0 1px ${border}`, cursor: 'pointer' }),
+ c('.dpte-switch[aria-checked=\'true\']', { background: `color-mix(in srgb,${business} 55%,transparent)`, boxShadow: 'none' }),
+ c('.dpte-switchKnob', { position: 'absolute', top: '2px', left: '2px', width: '14px', height: '14px', borderRadius: '50%', background: primary, transition: 'left .15s' }),
+ c('.dpte-switch[aria-checked=\'true\'] .dpte-switchKnob', { left: '14px', background: '#fff' }),
+ c('.dpte-link', { border: '0', padding: '0', background: 'transparent', font: 'inherit', fontSize: '12px', lineHeight: '18px', cursor: 'pointer', textDecoration: 'none' }),
+ c('.dpte-link:hover', { textDecoration: 'underline' }),
+ c('.dpte-segments', { display: 'inline-flex', gap: '4px', border: `1px solid ${border}`, borderRadius: '8px', padding: '3px', background: layer1 }),
+ c('.dpte-segment', { border: '0', borderRadius: '6px', padding: '4px 14px', background: 'transparent', color: secondary, font: 'inherit', fontSize: '12px', cursor: 'pointer' }),
+ c('.dpte-segment[data-active=\'true\']', { background: hover, color: primary, fontWeight: '600' }),
+ c('.dpte-format', { border: `1px solid ${border}`, borderRadius: '8px', padding: '8px 12px', background: layer1 }),
+ c('.dpte-format summary', { fontSize: '12px', color: secondary, cursor: 'pointer' }),
+ c('.dpte-formatHint', { margin: '2px 0 0', fontSize: '12px', color: tertiary }),
+ c('.dpte-code', { fontSize: '11px', lineHeight: '17px', whiteSpace: 'pre' }),
+ c('@media (max-width: 680px)', [c('.dpte-cards', { gridTemplateColumns: 'minmax(0,1fr)' }), c('.dpte-search', { width: '140px' })]),
+])
+
+export function mountExtensionStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(STYLE_ID) !== null)
+ return () => {}
+ styles.mount({ id: STYLE_ID, head: true })
+ return () => styles.unmount({ id: STYLE_ID })
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/types.ts b/packages/dsh-tauri-panel-extension/src/client/types.ts
new file mode 100644
index 00000000..77250709
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/types.ts
@@ -0,0 +1,201 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import type { ComponentType, ReactElement, ReactNode } from 'react'
+
+export interface IconProps {
+ size?: number
+ className?: string
+}
+
+export interface Translate {
+ (key: string): string
+}
+
+export interface ExtensionLocaleService {
+ register: (namespace: string, locale: string, dictionary: Record<string, string>) => () => void
+ bind: (namespace: string) => Translate
+}
+
+export type ExtensionClientContext = ClientContext & { locale: ExtensionLocaleService }
+
+export interface PanelContentSpec {
+ id: string
+ render: ComponentType<{ t?: Translate }>
+ locale?: string
+}
+
+export interface PanelActionItemProps {
+ id: string
+ icon?: ReactElement
+ onClick?: () => void
+ children?: ReactNode
+}
+
+export interface PanelProtocol {
+ ActionItem: (props: PanelActionItemProps) => ReactElement
+ renderPanelContent: (spec: PanelContentSpec) => void
+ closePanelContent: () => void
+}
+
+export interface SkillRepositoryView {
+ id: string
+ label: string
+ kind: 'local' | 'git'
+ githubUrl?: string
+}
+
+export interface SkillRowView {
+ name: string
+ description: string
+ whenToUse?: string
+ invocation: { modelInvocable: boolean, userInvocable: boolean }
+ source: string
+ editable: boolean
+ removable: boolean
+ dir?: string
+ policyEditable: boolean
+ repository?: SkillRepositoryView
+}
+
+export interface SkillEditorState {
+ mode: 'edit' | 'view'
+ name: string
+ description: string
+ whenToUse: string
+ modelInvocable: boolean
+ userInvocable: boolean
+ content: string
+}
+
+export type OpenTarget = { target: 'user-skills' } | { target: 'skill', name: string }
+
+export interface SkillsInjected {
+ list: () => Promise<{ skills: SkillRowView[] }>
+ get: (name: string) => Promise<{ content: string }>
+ save: (input: Record<string, unknown>) => Promise<{ ok: boolean }>
+ remove: (name: string) => Promise<{ ok: boolean }>
+ policy: (name: string, enabled: boolean) => Promise<{ ok: boolean }>
+ open: (target: OpenTarget) => Promise<{ ok: boolean }>
+ importRepository: (url: string) => Promise<{ ok: boolean }>
+}
+
+export interface SkillsTabProps {
+ t: Translate
+ injected: SkillsInjected
+ createSkill: () => Promise<void>
+}
+
+export interface McpRow {
+ id: string
+ serverName: string
+ transport: 'stdio' | 'streamable-http'
+ disabled: boolean
+ command?: string
+ args?: string[]
+ env?: Record<string, string>
+ cwd?: string
+ url?: string
+ headers?: Record<string, string>
+}
+
+export interface ImportedServerView {
+ agent: 'claude-code' | 'codex'
+ name: string
+ transport: 'stdio' | 'streamable-http'
+ command?: string
+ args?: string[]
+ env?: Record<string, string>
+ url?: string
+ headers?: Record<string, string>
+}
+
+export interface McpInjected {
+ list: () => Promise<{ servers: McpRow[] }>
+ save: (input: Record<string, unknown>) => Promise<{ ok: boolean, id: string }>
+ toggle: (id: string, disabled: boolean) => Promise<{ ok: boolean }>
+ remove: (id: string) => Promise<{ ok: boolean }>
+ scanImport: () => Promise<{ servers: ImportedServerView[], existing: string[] }>
+ applyImport: (items: Array<{ agent: string, name: string }>) => Promise<{ ok: boolean, results: Array<{ name: string, ok: boolean, error?: string }> }>
+ restart: () => Promise<void>
+ desktop: boolean
+}
+
+export type McpEditorMode = 'json' | 'form'
+
+export interface McpEditorState {
+ id: string
+ serverName: string
+ transport: 'stdio' | 'streamable-http'
+ command: string
+ args: string
+ env: string
+ url: string
+ headers: string
+}
+
+export interface McpImportItem {
+ server: ImportedServerView
+ existing: boolean
+ checked: boolean
+}
+
+export interface ParsedMcpJson {
+ serverName?: string
+ transport: 'stdio' | 'streamable-http'
+ command?: string
+ args?: string[]
+ env?: Record<string, string>
+ url?: string
+ headers?: Record<string, string>
+}
+
+export interface McpTabProps {
+ t: Translate
+ injected: McpInjected
+}
+
+export interface InputActions {
+ setDraft: (text: string) => void
+}
+
+export interface ConversationInputLeftProps {
+ sessionId: string
+ inputActions: InputActions
+}
+
+export interface SessionListSnapshot {
+ current?: string
+ ids: string[]
+}
+
+export interface WorkspaceListItem {
+ workspaceId?: string
+ id?: string
+ sessionIds?: readonly string[]
+ updatedAt?: number | string
+}
+
+export interface WorkspaceListSnapshot {
+ items?: WorkspaceListItem[]
+ recentWorkspaceId?: string
+}
+
+export interface DesktopBridge {
+ restartSidecar?: () => void
+}
+
+declare global {
+ interface Window {
+ dshDesktop?: DesktopBridge
+ }
+}
+
+export interface ExtensionRuntimeContext {
+ sessions: {
+ list: { getSnapshot: () => SessionListSnapshot }
+ open: (sessionId: string) => void
+ }
+ workspaces: {
+ list: { getSnapshot: () => WorkspaceListSnapshot }
+ connectWorkspace: (workspaceId: string) => Promise<string>
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/src/client/workspace.ts b/packages/dsh-tauri-panel-extension/src/client/workspace.ts
new file mode 100644
index 00000000..fae7ce46
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/client/workspace.ts
@@ -0,0 +1,21 @@
+import type { ExtensionRuntimeContext, WorkspaceListItem } from './types'
+
+function workspaceId(item: WorkspaceListItem): string | undefined {
+ return item.workspaceId ?? item.id
+}
+
+/** Follow DSH's New Session target order: current session, recent workspace, first workspace. */
+export function chooseWorkspace(runtime: ExtensionRuntimeContext): string | undefined {
+ const sessions = runtime.sessions.list.getSnapshot()
+ const workspaces = runtime.workspaces.list.getSnapshot()
+ const items = workspaces.items ?? []
+ const currentItem = sessions.current === undefined
+ ? undefined
+ : items.find(item => item.sessionIds?.includes(sessions.current as string))
+ const currentId = currentItem === undefined ? undefined : workspaceId(currentItem)
+ if (currentId !== undefined)
+ return currentId
+ if (workspaces.recentWorkspaceId !== undefined && items.some(item => workspaceId(item) === workspaces.recentWorkspaceId))
+ return workspaces.recentWorkspaceId
+ return items.map(workspaceId).find((id): id is string => id !== undefined)
+}
diff --git a/packages/dsh-tauri-panel-extension/src/constants.ts b/packages/dsh-tauri-panel-extension/src/constants.ts
new file mode 100644
index 00000000..60f23574
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/constants.ts
@@ -0,0 +1,13 @@
+/**
+ * Adapted from qinyre/dsh-plugin-capabilities.
+ * Copyright (c) 2026 qinyre. Licensed under the MIT License.
+ */
+
+/** Stable host/plugin identifier. */
+export const PLUGIN_NAME = 'dsh-tauri-panel-extension'
+
+/** HTTP namespace exposed to the client half. */
+export const API_PREFIX = `/${PLUGIN_NAME}`
+
+/** Directory owned by this plugin beneath DSH_HOME. */
+export const PLUGIN_STATE_DIRECTORY = PLUGIN_NAME
diff --git a/packages/dsh-tauri-panel-extension/src/index.ts b/packages/dsh-tauri-panel-extension/src/index.ts
new file mode 100644
index 00000000..5acd144f
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/index.ts
@@ -0,0 +1,147 @@
+/**
+ * dsh-tauri-panel-extension host entry: mount the manager's HTTP routes once
+ * the profile composes both the web server and the skill registry, and mount
+ * a host-plane filesystem skill provider so the Settings page sees a live
+ * catalog (the web composition deliberately leaves the host row to presets).
+ * The provider's custom roots also take the user-registered skill
+ * repositories from the plugin state file, and remount whenever those
+ * change — the catalog follows without a dsh restart.
+ */
+
+import type { Context } from '@deepseek-ai/cordis'
+import type { PanelExtensionHost } from './types.ts'
+import { existsSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { agentSkillRoots } from './agents.ts'
+import { PLUGIN_NAME } from './constants.ts'
+import { argvProfile, profileDir } from './profile.ts'
+import { mountPanelExtensionRoutes } from './routes.ts'
+import { loadState } from './state.ts'
+
+export const name = PLUGIN_NAME
+
+/**
+ * The package's own vendored skills (`skills/` at the package root — resolves
+ * identically from src/ under vitest and from lib/ when installed). Scanned as
+ * a custom root, so every session sees them through the registry's global
+ * layer while the files stay zero-copy and travel with plugin installs.
+ */
+export function packagedSkillsDir(): string {
+ return join(dirname(fileURLToPath(import.meta.url)), '..', 'skills')
+}
+
+/** Optional cordis.yml configuration; profile defaults to the booted one. */
+export interface Config {
+ /** Profile whose patch layer holds the MCP rows; defaults to argv or `web`. */
+ profile?: string
+}
+
+export const inject = ['webServer', 'skills', 'connection']
+
+/** The provider plugin's structural shape (name/apply export). */
+interface FilesystemSkillPlugin {
+ name: string
+ apply: (context: Context, config?: unknown) => void
+}
+
+/** Platform loader subset used to resolve DSH-owned packages from its base URL. */
+interface PlatformPluginLoader {
+ import: (name: string) => Promise<unknown>
+ unwrapExports: (exports: unknown) => unknown
+}
+
+export async function loadFilesystemSkillPlugin(loader: PlatformPluginLoader): Promise<FilesystemSkillPlugin> {
+ return loader.unwrapExports(
+ await loader.import('@deepseek-ai/dsh-skill-filesystem'),
+ ) as FilesystemSkillPlugin
+}
+
+/** The disposable fiber `ctx.plugin()` returns, as far as we use it. */
+interface PluginFiber {
+ dispose: () => Promise<void>
+}
+
+export function apply(ctx: Context, config?: Config): void {
+ const profile = config?.profile ?? argvProfile() ?? 'web'
+ ctx.inject(['webServer', 'skills', 'connection'], (hostCtx: Context) => {
+ // The web bundle disables the host-plane `skill-filesystem` row on
+ // purpose (presets own per-session discovery). The Settings manager
+ // mounts its own host-plane provider as a CHILD of this plugin: it dies
+ // with us, registers into the registry's global layer (deployment-level
+ // providers are exactly what that layer is for — agents read the merged
+ // catalog), and preset layers keep their semantics (nearest layer still
+ // wins duplicate names). Custom roots, in scan order: the package's own
+ // vendored skills (read-only, update with the plugin), the user's
+ // registered repositories (local paths and GitHub checkouts, managed
+ // from the Settings page), then other agents' skill roots
+ // (~/.claude/skills, ~/.codex/skills) — zero-copy, live-synced both
+ // ways. Registering or removing a repository remounts the provider with
+ // the new root set; a failed load only means an empty catalog — the
+ // routes keep serving.
+ let providerFiber: PluginFiber | undefined
+ let disposed = false
+ ctx.effect(() => {
+ const disposer = (): void => {
+ disposed = true
+ }
+ let chain: Promise<void> = Promise.resolve()
+ const remountProvider = (): Promise<void> => {
+ // Serialize remounts; concurrent add/remove requests must not
+ // interleave dispose and re-plugin on the same provider.
+ chain = chain.then(async () => {
+ if (disposed)
+ return
+ // Internal Desktop plugins are linked from a resource directory with
+ // no node_modules. Resolve DSH-owned packages through the platform
+ // loader (the same path used by preset rows), not native ESM relative
+ // to this linked plugin's real path.
+ const loader = (hostCtx as Context & { loader: PlatformPluginLoader }).loader
+ const plugin = await loadFilesystemSkillPlugin(loader)
+ if (providerFiber !== undefined) {
+ const old = providerFiber
+ providerFiber = undefined
+ try {
+ await old.dispose()
+ }
+ catch {
+ /* unloading raced us */
+ }
+ }
+ if (disposed)
+ return
+ const roots = [
+ packagedSkillsDir(),
+ ...loadState().skillRoots.flatMap(entry => entry.roots),
+ ...agentSkillRoots(),
+ ].filter(dir => existsSync(dir))
+ try {
+ providerFiber = hostCtx.plugin(plugin, roots.length > 0 ? { customSkillDirs: roots } : {}) as PluginFiber
+ }
+ catch {
+ // Context already disposed: nothing left to mount for.
+ }
+ })
+ chain = chain.catch((error: unknown) => {
+ // A missing runtime provider dependency previously degraded into a
+ // healthy empty catalog in packaged Desktop builds. Keep routes
+ // available, but surface the actual initialization failure.
+ hostCtx.logger.error(
+ `dsh-tauri-panel-extension: failed to mount filesystem skill provider: ${error instanceof Error ? error.message : String(error)}`,
+ )
+ })
+ return chain
+ }
+ void remountProvider()
+
+ ctx.effect(
+ () => mountPanelExtensionRoutes(hostCtx as unknown as PanelExtensionHost, {
+ profileDirPath: profileDir(profile),
+ remountProvider,
+ }),
+ 'dsh-tauri-panel-extension: http routes',
+ )
+ return disposer
+ }, 'dsh-tauri-panel-extension: skill provider')
+ })
+}
diff --git a/packages/dsh-tauri-panel-extension/src/mcp.ts b/packages/dsh-tauri-panel-extension/src/mcp.ts
new file mode 100644
index 00000000..dd12cd4f
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/mcp.ts
@@ -0,0 +1,287 @@
+/**
+ * MCP server rows in the profile's own patch layer: one
+ * `@deepseek-ai/dsh-mcp-client` row per server. The YAML document API keeps
+ * foreign rows and comments intact across edits. Row changes need a dsh
+ * restart to compose — callers surface that as a pending-restart notice.
+ *
+ * The loader's patch grammar distinguishes creates from overrides: a bare
+ * `- id: …` entry only overrides an existing row (target missing → skipped
+ * with a warning), while new rows must live in an anonymous `- insert:`
+ * list. Managed rows therefore always sit inside one insert entry, and any
+ * legacy bare rows (written before this contract was understood) are
+ * absorbed into it on the next write.
+ */
+
+import type { YAMLMap, YAMLSeq } from 'yaml'
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { Document, parseDocument } from 'yaml'
+/** The plugin every managed row instantiates. */
+export const MCP_PLUGIN = '@deepseek-ai/dsh-mcp-client'
+
+/** MCP serverName grammar (dsh-mcp-client's contract). */
+export const SERVER_NAME_RE = /^[\w-]{1,32}$/
+
+/** Transport choices the client supports. */
+export type McpTransport = 'stdio' | 'streamable-http'
+
+/** One managed row, as shown to the browser. */
+export interface McpRow {
+ id: string
+ serverName: string
+ transport: McpTransport
+ disabled: boolean
+ command?: string
+ args?: string[]
+ env?: Record<string, string>
+ cwd?: string
+ url?: string
+ headers?: Record<string, string>
+}
+
+/** Write request for one server row (id empty = create). */
+export type McpInput = Omit<McpRow, 'disabled'> & { disabled?: boolean }
+
+/** Load the profile patch as a YAML document; `[]` for a missing file. */
+function loadPatch(profileDirPath: string): Document {
+ const path = join(profileDirPath, 'cordis.patch.yml')
+ const text = existsSync(path) ? readFileSync(path, 'utf8') : '[]'
+ const doc = parseDocument(text)
+ const contents = doc.contents as YAMLSeq | null
+ // The default-empty file parses as a flow `[]`; the patch layer is
+ // human-edited block YAML, so flip the flag before anything appends.
+ if (contents !== null && contents.flow === true && contents.items.length === 0)
+ contents.flow = false
+ return doc
+}
+
+function savePatch(profileDirPath: string, doc: Document): void {
+ mkdirSync(profileDirPath, { recursive: true })
+ writeFileSync(join(profileDirPath, 'cordis.patch.yml'), String(doc), 'utf8')
+}
+
+/** Wrap a plain value into a YAML node (yaml v2 exposes no standalone createNode). */
+function toNode<T>(value: unknown): T {
+ return new Document(value as never).contents as T
+}
+
+/** The patch row sequence; an empty file's null root becomes an empty seq. */
+function rowSeq(doc: Document): YAMLSeq<YAMLMap> {
+ if (doc.contents === null) {
+ doc.contents = toNode<YAMLSeq<YAMLMap>>([])
+ // An empty seq defaults to flow style (`[]`); the file must stay block.
+ ;(doc.contents as YAMLSeq).flow = false
+ }
+ return doc.contents as YAMLSeq<YAMLMap>
+}
+
+function isSeqNode(value: unknown): value is YAMLSeq<YAMLMap> {
+ return typeof value === 'object' && value !== null && Array.isArray((value as YAMLSeq).items)
+}
+
+/** A patch entry's insert list when it is the anonymous create form. */
+function insertListOf(item: YAMLMap): YAMLSeq<YAMLMap> | undefined {
+ if (item.has('id'))
+ return undefined
+ const node = item.get('insert')
+ return isSeqNode(node) ? node : undefined
+}
+
+/** Every managed row: legacy bare entries (no list) and insert-list rows. */
+function mcpRowItems(doc: Document): { node: YAMLMap, list?: YAMLSeq<YAMLMap> }[] {
+ const found: { node: YAMLMap, list?: YAMLSeq<YAMLMap> }[] = []
+ for (const item of rowSeq(doc).items ?? []) {
+ if (item.get('name') === MCP_PLUGIN)
+ found.push({ node: item })
+ const list = insertListOf(item)
+ for (const row of list?.items ?? []) {
+ if (row.get('name') === MCP_PLUGIN)
+ found.push({ node: row, list })
+ }
+ }
+ return found
+}
+
+/** Map one row node to its browser-facing shape. */
+function rowToMcp(doc: Document, item: YAMLMap): McpRow {
+ // config is a YAMLMap node — materialize it before property access.
+ const configNode = item.get('config') as unknown
+ const plain = (typeof configNode === 'object' && configNode !== null && typeof (configNode as { toJS?: unknown }).toJS === 'function'
+ ? (configNode as { toJS: (document: Document) => unknown }).toJS(doc)
+ : {}) as Record<string, unknown>
+ return {
+ id: String(item.get('id') ?? ''),
+ serverName: String(plain.serverName ?? ''),
+ transport: plain.transport === 'streamable-http' ? 'streamable-http' : 'stdio',
+ disabled: item.get('disabled') === true,
+ ...(typeof plain.command === 'string' && plain.command !== '' ? { command: plain.command } : {}),
+ ...(Array.isArray(plain.args) ? { args: plain.args.map(String) } : {}),
+ ...(isStringMap(plain.env) ? { env: plain.env } : {}),
+ ...(typeof plain.cwd === 'string' && plain.cwd !== '' ? { cwd: plain.cwd } : {}),
+ ...(typeof plain.url === 'string' && plain.url !== '' ? { url: plain.url } : {}),
+ ...(isStringMap(plain.headers) ? { headers: plain.headers } : {}),
+ }
+}
+
+function isStringMap(value: unknown): value is Record<string, string> {
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
+ return false
+ return Object.values(value).every(entry => typeof entry === 'string')
+}
+
+/**
+ * The insert list that owns managed rows, creating it when absent and
+ * absorbing legacy bare rows into it. Absorbed rows were inert under the
+ * loader's override-only reading of bare entries, so the move is not just
+ * cosmetic — it is what makes them compose.
+ */
+function managedInsert(doc: Document): YAMLSeq<YAMLMap> {
+ const seq = rowSeq(doc)
+ const bare: YAMLMap[] = []
+ let target: YAMLSeq<YAMLMap> | undefined
+ for (const item of seq.items ?? []) {
+ if (item.get('name') === MCP_PLUGIN)
+ bare.push(item)
+ const list = insertListOf(item)
+ if (list !== undefined && list.items.some(row => row.get('name') === MCP_PLUGIN))
+ target ??= list
+ }
+ if (target === undefined) {
+ const entry = toNode<YAMLMap>({ insert: [] })
+ seq.add(entry)
+ target = entry.get('insert') as YAMLSeq<YAMLMap>
+ target.flow = false
+ }
+ for (const row of bare) {
+ seq.items.splice(seq.items.indexOf(row), 1)
+ target.add(row)
+ }
+ return target
+}
+
+/** Every id in use: top-level patch entries and rows inside insert lists. */
+function takenIds(doc: Document): Set<string> {
+ const taken = new Set<string>()
+ for (const item of rowSeq(doc).items ?? []) {
+ const id = String(item.get('id') ?? '')
+ if (id !== '')
+ taken.add(id)
+ for (const row of insertListOf(item)?.items ?? []) {
+ const rowId = String(row.get('id') ?? '')
+ if (rowId !== '')
+ taken.add(rowId)
+ }
+ }
+ return taken
+}
+
+/** Read every mcp-client row in the profile layer. */
+export function listMcp(profileDirPath: string): McpRow[] {
+ const doc = loadPatch(profileDirPath)
+ return mcpRowItems(doc).map(({ node }) => rowToMcp(doc, node))
+}
+
+/** Validate one write request; returns the rejection reason or null. */
+export function validateMcpInput(input: McpInput): string | null {
+ if (!SERVER_NAME_RE.test(input.serverName))
+ return 'serverName must be 1-32 chars of A-Z a-z 0-9 _ -'
+ // The route casts raw JSON to McpInput; a create request may omit `id`.
+ const id = input.id ?? ''
+ if (id.includes('/') || id.includes('..'))
+ return 'invalid id'
+ if (input.transport === 'stdio') {
+ if (input.command === undefined || input.command.trim() === '')
+ return 'stdio transport requires a command'
+ }
+ else if (input.url === undefined || !/^https?:\/\//.test(input.url)) {
+ return 'http transport requires an http(s) url'
+ }
+ return null
+}
+
+/** Add or replace one server row. Returns the (possibly deduplicated) id. */
+export function upsertMcp(profileDirPath: string, input: McpInput): string {
+ const inputId = input.id ?? ''
+ const doc = loadPatch(profileDirPath)
+ const list = managedInsert(doc)
+
+ const existing = inputId !== ''
+ ? mcpRowItems(doc).find(({ node }) => String(node.get('id') ?? '') === inputId)
+ : undefined
+
+ let id = inputId !== '' ? inputId : `mcp-${input.serverName}`
+ if (existing === undefined) {
+ const taken = takenIds(doc)
+ let suffix = 2
+ while (taken.has(id)) id = `mcp-${input.serverName}-${suffix++}`
+ }
+
+ const config: Record<string, unknown> = input.transport === 'stdio'
+ ? {
+ serverName: input.serverName,
+ transport: input.transport,
+ command: input.command,
+ ...(input.args !== undefined && input.args.length > 0 ? { args: input.args } : {}),
+ ...(input.env !== undefined && Object.keys(input.env).length > 0 ? { env: input.env } : {}),
+ ...(input.cwd !== undefined && input.cwd !== '' ? { cwd: input.cwd } : {}),
+ }
+ : {
+ serverName: input.serverName,
+ transport: input.transport,
+ url: input.url,
+ ...(input.headers !== undefined && Object.keys(input.headers).length > 0 ? { headers: input.headers } : {}),
+ }
+ const row: Record<string, unknown> = { id, name: MCP_PLUGIN, config }
+ if (input.disabled === true)
+ row.disabled = true
+
+ const node = toNode<YAMLMap>(row)
+ if (existing === undefined) {
+ list.add(node)
+ }
+ else if (existing.list !== undefined) {
+ existing.list.items.splice(existing.list.items.indexOf(existing.node), 1, node)
+ }
+ else {
+ // Bare rows were absorbed above; reaching here means a foreign-shaped row.
+ rowSeq(doc).items.splice(rowSeq(doc).items.indexOf(existing.node), 1, node)
+ }
+
+ savePatch(profileDirPath, doc)
+ return id
+}
+
+/** Flip one row's disabled flag (absent = enabled). Returns false when missing. */
+export function setMcpDisabled(profileDirPath: string, id: string, disabled: boolean): boolean {
+ const doc = loadPatch(profileDirPath)
+ managedInsert(doc)
+ const hit = mcpRowItems(doc).find(({ node }) => String(node.get('id') ?? '') === id)
+ if (hit === undefined)
+ return false
+ if (disabled)
+ hit.node.set('disabled', true)
+ else hit.node.delete('disabled')
+ savePatch(profileDirPath, doc)
+ return true
+}
+
+/** Remove one server row. Returns false when missing. */
+export function removeMcp(profileDirPath: string, id: string): boolean {
+ const doc = loadPatch(profileDirPath)
+ managedInsert(doc)
+ const hit = mcpRowItems(doc).find(({ node }) => String(node.get('id') ?? '') === id)
+ if (hit === undefined || hit.list === undefined)
+ return false
+ hit.list.items.splice(hit.list.items.indexOf(hit.node), 1)
+
+ // An insert entry left with no rows is dead weight; drop it when the
+ // insert list is all it holds.
+ const seq = rowSeq(doc)
+ const owner = (seq.items ?? []).find(item => insertListOf(item) === hit.list)
+ if (owner !== undefined && hit.list.items.length === 0 && owner.items.length === 1) {
+ seq.items.splice(seq.items.indexOf(owner), 1)
+ }
+
+ savePatch(profileDirPath, doc)
+ return true
+}
diff --git a/packages/dsh-tauri-panel-extension/src/opener.ts b/packages/dsh-tauri-panel-extension/src/opener.ts
new file mode 100644
index 00000000..0fcfa5a8
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/opener.ts
@@ -0,0 +1,38 @@
+/**
+ * Open a directory in the OS file manager, from the dsh sidecar process.
+ * Spawned detached with all stdio ignored — a GUI file manager needs no
+ * pipes, and explorer.exe reports failure through exit codes we must not
+ * await (it exits non-zero even on success in several Windows versions).
+ */
+
+import { spawn } from 'node:child_process'
+import { statSync } from 'node:fs'
+import process from 'node:process'
+
+/** Open one directory; resolves true when a launcher was started. */
+export function openDirectory(dir: string): boolean {
+ try {
+ if (!statSync(dir).isDirectory())
+ return false
+ }
+ catch {
+ return false
+ }
+ if (process.platform === 'win32') {
+ // explorer 对正斜杠路径会静默回落到默认文件夹(实测打开成了「文档」),必须喂反斜杠。
+ dir = dir.split('/').join('\\')
+ }
+ const launcher = process.platform === 'win32' ? 'explorer' : process.platform === 'darwin' ? 'open' : 'xdg-open'
+ try {
+ // GUI 启动器不能带 windowsHide:该 flag 把 SW_HIDE 写进 STARTUPINFO,explorer 的
+ // 首个窗口据此创建为隐藏——实机表现是「打开目录」点了没反应,窗口其实开了。
+ const child = spawn(launcher, [dir], { detached: true, stdio: 'ignore' })
+ // 启动器解析失败时 'error' 异步到达;没有监听会升级成 uncaughtException 炸掉 sidecar。
+ child.once('error', () => {})
+ child.unref()
+ return true
+ }
+ catch {
+ return false
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/src/profile.ts b/packages/dsh-tauri-panel-extension/src/profile.ts
new file mode 100644
index 00000000..53b52a92
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/profile.ts
@@ -0,0 +1,19 @@
+/** Profile discovery (pure reads; same contract as dsh-plugin-install). */
+
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import process from 'node:process'
+
+/** Profile that boots this UI: `--profile <name>` on the CLI invocation. */
+export function argvProfile(argv: readonly string[] = process.argv): string | undefined {
+ const flag = argv.indexOf('--profile')
+ if (flag !== -1 && flag + 1 < argv.length && !argv[flag + 1].startsWith('-'))
+ return argv[flag + 1]
+ return undefined
+}
+
+/** Directory of a profile under DSH_HOME (default `~/.dsh`). */
+export function profileDir(profile: string, dshHome: string | undefined = process.env.DSH_HOME): string {
+ const home = dshHome ?? join(homedir(), '.dsh')
+ return join(home, 'profiles', profile)
+}
diff --git a/packages/dsh-tauri-panel-extension/src/repos.ts b/packages/dsh-tauri-panel-extension/src/repos.ts
new file mode 100644
index 00000000..65e9c53d
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/repos.ts
@@ -0,0 +1,240 @@
+/**
+ * Custom skill repositories the user registers from the Settings page:
+ * a local directory (scanned in place, zero-copy) or a GitHub repo (tarball
+ * download into the plugin's state dir, no git dependency). Detection adapts
+ * to the three layouts skill collections actually use — one skill at the
+ * repo root, skills as immediate children, or a nested `skills/`-style
+ * folder — and registers the matching scan roots for the filesystem
+ * provider.
+ */
+
+import type { SkillRootEntry } from './state.ts'
+import { Buffer } from 'node:buffer'
+import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, symlinkSync } from 'node:fs'
+import { basename, join, resolve } from 'node:path'
+import process from 'node:process'
+import { removeTree } from './rmtree.ts'
+import { addSkillRoot, findRootByUrl, materialDirFor, newEntryId } from './state.ts'
+import { extractTarGz } from './tar.ts'
+
+/** One GitHub source, parsed from whatever URL shape the user pasted. */
+export interface GitHubSource {
+ owner: string
+ repo: string
+ ref?: string
+ /** `owner/repo`, the display label and dedupe key. */
+ label: string
+ /** Canonical browser URL exposed to the client as clickable metadata. */
+ githubUrl: string
+ tarballUrl: string
+}
+
+const GITHUB_URL_RE = /^(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/(?:tree|archive)\/([^/#?]+?)(?:\.tar\.gz)?)?(?:#([^/?#]+))?(?:[/?#].*)?$/
+const GITHUB_SHORT_RE = /^([\w.-]+)\/([\w.-]+)$/
+
+/** Parse a GitHub reference; returns null for anything unrecognizable. */
+export function parseGitHubSource(input: string): GitHubSource | null {
+ const trimmed = input.trim()
+ if (trimmed === '')
+ return null
+ let owner = ''
+ let repo = ''
+ let ref: string | undefined
+ let match = GITHUB_URL_RE.exec(trimmed)
+ if (match !== null) {
+ // Capture order: owner, repo, /tree/<ref>, #<ref>.
+ const treeRef = match[3] !== undefined ? match[3] : undefined
+ const hashRef = match[4] !== undefined ? match[4] : undefined
+ owner = match[1]
+ repo = match[2]
+ ref = treeRef ?? hashRef
+ }
+ else {
+ match = GITHUB_SHORT_RE.exec(trimmed)
+ if (match === null) {
+ return null
+ }
+ ;[, owner, repo] = match
+ ref = undefined
+ }
+ // `owner/repo/tree/<ref>` may URL-encode slashes in the ref — keep as-is;
+ // codeload addresses refs by name, branches with slashes included.
+ const decodedRef = ref !== undefined ? decodeURIComponent(ref) : undefined
+ const label = `${owner}/${repo}`
+ const encodedRef = decodedRef?.split('/').map(segment => encodeURIComponent(segment)).join('/')
+ const githubUrl = `https://github.com/${owner}/${repo}${encodedRef === undefined ? '' : `/tree/${encodedRef}`}`
+ const tarballUrl = `https://codeload.github.com/${owner}/${repo}/tar.gz/${decodedRef ?? 'HEAD'}`
+ return { owner, repo, ref: decodedRef, label, githubUrl, tarballUrl }
+}
+
+/** Where skill layouts were found inside one checkout. */
+export interface DetectedRoots {
+ /** Scan roots to register (empty + single=false means “no skills”). */
+ roots: string[]
+ /** The checkout itself is one skill (SKILL.md at its root). */
+ single: boolean
+}
+
+/** A plausible flat skill file: markdown with frontmatter. */
+function looksLikeSkillFile(file: string): boolean {
+ try {
+ return readFileSync(file, 'utf8').startsWith('---')
+ }
+ catch {
+ return false
+ }
+}
+
+/** Does one directory directly hold skills (bundle children or flat .md)? */
+function holdsSkills(dir: string): boolean {
+ let entries: string[]
+ try {
+ entries = readdirSync(dir)
+ }
+ catch {
+ return false
+ }
+ if (existsSync(join(dir, 'SKILL.md')))
+ return true
+ for (const name of entries) {
+ if (name.endsWith('.md') && looksLikeSkillFile(join(dir, name)))
+ return true
+ }
+ for (const name of entries) {
+ const child = join(dir, name)
+ try {
+ if (statSync(child).isDirectory() && existsSync(join(child, 'SKILL.md')))
+ return true
+ }
+ catch {
+ // racing deletion or unreadable entry: ignore
+ }
+ }
+ return false
+}
+
+/**
+ * Find the scan roots for one checkout: the checkout itself when its
+ * immediate children are skills, plus any child directory that only makes
+ * sense as a collection wrapper (`skills/`, `document-skills/`, …). A
+ * checkout with SKILL.md at its own root is one single skill — the caller
+ * must give the provider its PARENT as the scan root.
+ */
+export function detectSkillRoots(checkout: string): DetectedRoots {
+ if (existsSync(join(checkout, 'SKILL.md')))
+ return { roots: [], single: true }
+ const roots: string[] = []
+ if (holdsSkills(checkout))
+ roots.push(checkout)
+ let entries: string[]
+ try {
+ entries = readdirSync(checkout)
+ }
+ catch {
+ return { roots, single: false }
+ }
+ for (const name of entries) {
+ if (name.startsWith('.'))
+ continue
+ const child = join(checkout, name)
+ try {
+ if (!statSync(child).isDirectory())
+ continue
+ }
+ catch {
+ continue
+ }
+ if (existsSync(join(child, 'SKILL.md')))
+ continue // already covered by the parent root
+ if (holdsSkills(child))
+ roots.push(child)
+ }
+ return { roots, single: false }
+}
+
+/** Register a local directory as a skill repository. */
+export async function addLocalRepo(path: string, dshHome?: string): Promise<SkillRootEntry> {
+ const resolved = resolve(path.trim().replace(/^"|"$/g, ''))
+ if (!existsSync(resolved) || !statSync(resolved).isDirectory()) {
+ throw new Error(`not a directory: ${resolved}`)
+ }
+ const detected = detectSkillRoots(resolved)
+ if (!detected.single && detected.roots.length === 0) {
+ throw new Error('no SKILL.md found under that path (expected a skill folder or a folder of skill folders)')
+ }
+ if (detected.single) {
+ // One skill living at the given path: the provider scans a ROOT, so wrap
+ // the path in a dedicated directory holding a single link to it.
+ const id = newEntryId('local')
+ const material = materialDirFor(id, dshHome)
+ removeTree(material)
+ mkdirSync(material, { recursive: true })
+ try {
+ symlinkSync(resolved, join(material, 'skill'), process.platform === 'win32' ? 'junction' : 'dir')
+ }
+ catch {
+ removeTree(material)
+ throw new Error('single-skill local folders need a directory link; try adding their parent folder instead')
+ }
+ return addSkillRoot({ id, kind: 'local', label: basename(resolved), path: resolved, roots: [material], materialDir: material }, dshHome)
+ }
+ return addSkillRoot({ id: newEntryId('local'), kind: 'local', label: basename(resolved), path: resolved, roots: detected.roots }, dshHome)
+}
+
+/** Download cap for a repo tarball. */
+const TARBALL_MAX_BYTES = 256 * 1024 * 1024
+
+/** Register a GitHub repo: tarball download → extract → detect → persist. */
+export async function addGitRepo(
+ url: string,
+ options: { dshHome?: string, fetcher?: typeof fetch } = {},
+): Promise<SkillRootEntry> {
+ const source = parseGitHubSource(url)
+ if (source === null)
+ throw new Error('expected a GitHub repository URL or owner/repo')
+ const existing = findRootByUrl(source.githubUrl, options.dshHome) ?? findRootByUrl(source.label, options.dshHome)
+ if (existing !== undefined)
+ throw new Error(`${source.label} is already registered`)
+
+ const doFetch = options.fetcher ?? fetch
+ const response = await doFetch(source.tarballUrl, { signal: AbortSignal.timeout(60_000) })
+ if (!response.ok)
+ throw new Error(`download failed (HTTP ${response.status}) for ${source.tarballUrl}`)
+ const archive = Buffer.from(await response.arrayBuffer())
+ if (archive.byteLength > TARBALL_MAX_BYTES)
+ throw new Error('repository tarball too large')
+
+ const id = newEntryId('git')
+ const material = materialDirFor(id, options.dshHome)
+ removeTree(material)
+ const checkout = join(material, 'repo')
+ try {
+ mkdirSync(checkout, { recursive: true })
+ extractTarGz(archive, checkout, { stripComponents: 1 })
+ const detected = detectSkillRoots(checkout)
+ if (!detected.single && detected.roots.length === 0) {
+ throw new Error('no SKILL.md found in that repository')
+ }
+ // A single-skill repo is discovered through the material dir itself; a
+ // collection registers the checkout (plus nested collection wrappers).
+ const roots = detected.single ? [material] : detected.roots
+ return addSkillRoot(
+ { id, kind: 'git', label: source.label, url: source.githubUrl, ref: source.ref, roots, materialDir: material },
+ options.dshHome,
+ )
+ }
+ catch (error) {
+ removeTree(material)
+ throw error
+ }
+}
+
+/** Validate one scan root still exists; entries can go stale on disk. */
+export function rootExists(path: string): boolean {
+ try {
+ return statSync(path).isDirectory()
+ }
+ catch {
+ return false
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/src/restart.ts b/packages/dsh-tauri-panel-extension/src/restart.ts
new file mode 100644
index 00000000..03c1da48
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/restart.ts
@@ -0,0 +1,100 @@
+/**
+ * Self-restart for standalone `dsh web`: relaunch the exact invocation that
+ * booted this host, then stop this process — so MCP row changes compose
+ * without leaving the UI. The desktop shell owns restarts there
+ * (DSH_DESKTOP=1 refuses this path — a supervised sidecar must never
+ * replace itself, or the supervisor respawns a second process).
+ *
+ * The replacement is spawned directly with windowsHide: CREATE_NO_WINDOW
+ * gives it a hidden console its own console children inherit (no popping
+ * windows), unlike a DETACHED_PROCESS spawn which leaves children to create
+ * visible consoles. No helper process and no powershell wrapper — on at
+ * least one machine a node→node→powershell→node chain was silently blocked
+ * by host software before the inner node could even start, while direct
+ * node→node spawns are the most battle-tested pattern there is.
+ */
+
+import type { IncomingMessage } from 'node:http'
+import { spawn } from 'node:child_process'
+import { openSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { dirname, resolve } from 'node:path'
+import process from 'node:process'
+
+/** The boot invocation to replay: entry from argv, execArgv preserved. */
+export function dshLaunch(argv: readonly string[] = process.argv, execArgv: readonly string[] = process.execArgv): {
+ file: string
+ args: string[]
+ cwd: string | undefined
+ viaShell: boolean
+} {
+ const entry = argv[1]
+ if (entry !== undefined && /[\\/](?:bin\.(?:js|ts)|dsh)$/.test(entry)) {
+ // Source launches (`pnpm dsh`) pass a relative entry that the child would
+ // resolve against its OWN cwd — absolutize, and keep cwd near the entry
+ // so execArgv module hooks (tsx/esm) stay resolvable.
+ const abs = resolve(entry)
+ return { file: process.execPath, args: [...execArgv, abs, ...argv.slice(2)], cwd: dirname(abs), viaShell: false }
+ }
+ // Bare `dsh` on Windows is a .cmd shim only a shell can start.
+ return { file: 'dsh', args: [...argv.slice(2)], cwd: undefined, viaShell: process.platform === 'win32' }
+}
+
+/**
+ * Relaunch this exact dsh invocation, then stop this process. The replacement
+ * boots slowly (module loading) while this process dies within 500 ms, so
+ * port handover needs no delay even for fixed-port launches. Replacement
+ * output is logged under tmpdir for post-mortem.
+ */
+export function scheduleRestart(launch: ReturnType<typeof dshLaunch>): {
+ pid: number
+ replacementPid: number | undefined
+ logOut: string
+ logErr: string
+} {
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)
+ const logOut = `${tmpdir()}${tmpdir().endsWith('/') ? '' : '\\'}dsh-tauri-panel-extension-restart-${stamp}.out.log`
+ const logErr = logOut.replace('.out.log', '.err.log')
+ const child = spawn(launch.file, launch.args, {
+ cwd: launch.cwd,
+ stdio: ['ignore', openSync(logOut, 'a'), openSync(logErr, 'a')],
+ env: process.env,
+ shell: launch.viaShell,
+ windowsHide: true,
+ })
+ child.unref()
+ setTimeout(() => process.kill(process.pid, 'SIGTERM'), 500)
+ return { pid: process.pid, replacementPid: child.pid, logOut, logErr }
+}
+
+/**
+ * A restart request is process control: only a direct same-origin loopback
+ * request qualifies. Any forwarding trace means the loopback peer is a
+ * proxy, not the user's browser.
+ */
+export function trustedRestartRequest(request: IncomingMessage, socketAddress?: string): boolean {
+ const address = socketAddress ?? (request.socket.remoteAddress ?? '')
+ if (address !== '127.0.0.1' && address !== '::1' && address !== '::ffff:127.0.0.1')
+ return false
+ if (request.headers.forwarded !== undefined
+ || request.headers['x-forwarded-for'] !== undefined
+ || request.headers['x-real-ip'] !== undefined) {
+ return false
+ }
+ const origin = request.headers.origin
+ const host = request.headers.host
+ if (origin === undefined || host === undefined)
+ return false
+ try {
+ const parsed = new URL(origin)
+ return (parsed.protocol === 'http:' || parsed.protocol === 'https:') && parsed.host === host
+ }
+ catch {
+ return false
+ }
+}
+
+/** Restart ownership: the desktop shell supervises the sidecar and restarts it. */
+export function restartOwnedByShell(env: NodeJS.ProcessEnv = process.env): boolean {
+ return env.DSH_DESKTOP === '1'
+}
diff --git a/packages/dsh-tauri-panel-extension/src/rmtree.ts b/packages/dsh-tauri-panel-extension/src/rmtree.ts
new file mode 100644
index 00000000..c7eaf449
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/rmtree.ts
@@ -0,0 +1,65 @@
+/**
+ * Windows-hardened recursive delete for repository material. The skill
+ * provider watches these trees live, and antivirus or search indexers
+ * briefly hold handles onto freshly written files, so a plain rmSync
+ * races open handles and dies with EPERM. Two mitigations: clear the
+ * read-only attribute first (unlinking a read-only entry fails on
+ * Windows), then retry the removal so short-lived locks run out.
+ */
+
+import type { Dirent } from 'node:fs'
+import { chmodSync, readdirSync, rmSync } from 'node:fs'
+import { join } from 'node:path'
+
+/** Windows lock holders usually let go within a second or two. */
+const RETRIES = { maxRetries: 10, retryDelay: 200 } as const
+
+function clearReadOnly(dir: string): void {
+ let entries: Dirent[]
+ try {
+ entries = readdirSync(dir, { withFileTypes: true })
+ }
+ catch {
+ return // unreadable: rmSync will surface the real error
+ }
+ for (const entry of entries) {
+ const child = join(dir, entry.name)
+ // Links read as neither file nor directory here; chmod would hit the
+ // link TARGET (possibly the user's own folder), so they are skipped —
+ // rmSync removes the link itself without following it.
+ if (entry.isDirectory()) {
+ try {
+ chmodSync(child, 0o777)
+ }
+ catch {
+ /* racing delete */
+ }
+ clearReadOnly(child)
+ }
+ else if (entry.isFile()) {
+ try {
+ chmodSync(child, 0o666)
+ }
+ catch {
+ /* racing delete */
+ }
+ }
+ }
+ try {
+ chmodSync(dir, 0o777)
+ }
+ catch {
+ /* racing delete */
+ }
+}
+
+/** Delete one directory tree (or lone file), tolerating Windows lock races. */
+export function removeTree(path: string): void {
+ try {
+ clearReadOnly(path)
+ }
+ catch {
+ // walk failure: rmSync reports the underlying error anyway
+ }
+ rmSync(path, { recursive: true, force: true, ...RETRIES })
+}
diff --git a/packages/dsh-tauri-panel-extension/src/routes.ts b/packages/dsh-tauri-panel-extension/src/routes.ts
new file mode 100644
index 00000000..d95b9252
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/routes.ts
@@ -0,0 +1,646 @@
+/** HTTP routes bridging the Settings UI to the capabilities manager. */
+
+import type { IncomingMessage, ServerResponse } from 'node:http'
+import type { McpInput } from './mcp.ts'
+import type { SkillInput } from './skills.ts'
+import type { SkillRootEntry } from './state.ts'
+import type { HostSkill, PanelExtensionHost, SkillRepositoryMetadata } from './types.ts'
+import { mkdirSync } from 'node:fs'
+import { isAbsolute, join, relative, resolve, sep } from 'node:path'
+import process from 'node:process'
+import { readJsonBody, sameOrigin, sendJson, withConnectionAuth } from 'dsh-tauri'
+import { scanAllMcp } from './agents.ts'
+import { API_PREFIX } from './constants.ts'
+import { listMcp, removeMcp, setMcpDisabled, upsertMcp, validateMcpInput } from './mcp.ts'
+import { openDirectory } from './opener.ts'
+import { addGitRepo, addLocalRepo, rootExists } from './repos.ts'
+import { dshLaunch, restartOwnedByShell, scheduleRestart, trustedRestartRequest } from './restart.ts'
+import { removeTree } from './rmtree.ts'
+import { deleteSkill, setSkillPolicy, updateSkillFile, userSkillsDir, validateSkillInput, writeSkill } from './skills.ts'
+import { loadState, pluginStateDir, removeSkillRoot } from './state.ts'
+
+/**
+ * A 'custom' skill is writable only when its folder sits inside a root this
+ * plugin manages: the materialized repositories under the plugin state dir,
+ * or a registered local root. Vendored skills shipped inside the plugin
+ * package (under node_modules) are custom-sourced too but stay read-only —
+ * edits there would die with the next plugin update.
+ */
+function customSkillWritable(dir: string, dshHome: string | undefined): boolean {
+ const state = pluginStateDir(dshHome)
+ if (dir === state || dir.startsWith(state + sep))
+ return true
+ return loadState(dshHome).skillRoots.some(entry =>
+ entry.roots.some(root => dir === root || dir.startsWith(root + sep)))
+}
+
+/** Whether the save route may write this catalog row back to disk. */
+function skillWritable(skill: HostSkill, dir: string | undefined, dshHome: string | undefined): boolean {
+ if (dir === undefined)
+ return false
+ if (skill.source === 'user-dsh')
+ return true
+ return skill.source === 'custom' && customSkillWritable(dir, dshHome)
+}
+
+/** One catalog skill as the browser sees it (edit flags and repository metadata added). */
+export type SkillRow = HostSkill & {
+ editable: boolean
+ removable: boolean
+ dir?: string
+ policyEditable: boolean
+ /** Registered root containing this skill, if any. */
+ repository?: SkillRepositoryMetadata
+}
+
+function pathWithin(path: string, parent: string): boolean {
+ const child = resolve(path)
+ const root = resolve(parent)
+ const nested = relative(root, child)
+ return nested === '' || (!nested.startsWith(`..${sep}`) && nested !== '..' && !isAbsolute(nested))
+}
+
+/** Match a catalog row to the registered root that contributed its directory. */
+export function repositoryForSkill(
+ skill: HostSkill,
+ entries: SkillRootEntry[],
+): SkillRepositoryMetadata | undefined {
+ const dir = skill.resourceBase?.kind === 'directory' ? skill.resourceBase.path : undefined
+ if (dir === undefined)
+ return undefined
+ const entry = entries.find(candidate => candidate.roots.some(root => pathWithin(dir, root)))
+ if (entry === undefined)
+ return undefined
+ return {
+ id: entry.id,
+ label: entry.label,
+ kind: entry.kind,
+ ...(entry.kind === 'git' && entry.url !== undefined ? { githubUrl: entry.url } : {}),
+ }
+}
+
+export function toSkillRow(skill: HostSkill, entries: SkillRootEntry[], dshHome: string | undefined): SkillRow {
+ const dir = skill.resourceBase?.kind === 'directory' ? skill.resourceBase.path : undefined
+ const repository = repositoryForSkill(skill, entries)
+ return {
+ ...skill,
+ editable: skillWritable(skill, dir, dshHome),
+ removable: skill.source === 'user-dsh',
+ ...(dir !== undefined ? { dir } : {}),
+ policyEditable: dir !== undefined,
+ ...(repository !== undefined ? { repository } : {}),
+ }
+}
+
+/** Repository skills are first; groups retain the registry's stable order. */
+export function sortSkillRows(rows: SkillRow[]): SkillRow[] {
+ return rows.map((row, index) => ({ row, index }))
+ .sort((left, right) => Number(right.row.repository !== undefined) - Number(left.row.repository !== undefined) || left.index - right.index)
+ .map(item => item.row)
+}
+
+/** One registered repository plus a liveness flag (roots can go stale). */
+function toRootView(entry: SkillRootEntry): SkillRootEntry & { live: boolean } {
+ return { ...entry, live: entry.roots.every(root => rootExists(root)) }
+}
+
+export interface PanelExtensionRoutesConfig {
+ profileDirPath: string
+ /** Remount the host-plane skill provider after root-set changes. */
+ remountProvider: () => Promise<void>
+}
+
+/** Register the manager's routes; returns the disposer removing them all. */
+export function mountPanelExtensionRoutes(host: PanelExtensionHost, config: PanelExtensionRoutesConfig): () => void {
+ const register: PanelExtensionHost['webServer']['register'] = route => host.webServer.register({
+ ...route,
+ handler: withConnectionAuth(host.connection, route.handler, 'dsh-tauri-panel-extension'),
+ })
+ const disposers = [
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/skills`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'GET') {
+ response.writeHead(405, { allow: 'GET' })
+ response.end()
+ return
+ }
+ try {
+ const skills = await host.skills.list()
+ const entries = loadState(process.env.DSH_HOME).skillRoots
+ const rows = skills.map(skill => toSkillRow(skill, entries, process.env.DSH_HOME))
+ sendJson(response, 200, { skills: sortSkillRows(rows) })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/skill`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'GET') {
+ response.writeHead(405, { allow: 'GET' })
+ response.end()
+ return
+ }
+ const url = new URL(request.url ?? '/', 'http://localhost')
+ const name = url.searchParams.get('name') ?? ''
+ try {
+ const definition = await host.skills.get(name)
+ if (definition === undefined) {
+ sendJson(response, 404, { error: 'skill not found' })
+ return
+ }
+ sendJson(response, 200, { name: definition.name, content: definition.content })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/skill/save`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as Partial<SkillInput>
+ const input: SkillInput = {
+ name: typeof body.name === 'string' ? body.name : '',
+ description: typeof body.description === 'string' ? body.description : '',
+ whenToUse: typeof body.whenToUse === 'string' ? body.whenToUse : undefined,
+ modelInvocable: body.modelInvocable !== false,
+ userInvocable: body.userInvocable !== false,
+ content: typeof body.content === 'string' ? body.content : '',
+ }
+ const invalid = validateSkillInput(input)
+ if (invalid !== null) {
+ sendJson(response, 400, { error: invalid })
+ return
+ }
+ // An existing skill edits in place (its own folder, whichever
+ // editable source it comes from — preserving frontmatter keys the
+ // editor does not own); a new name creates in the user root. The
+ // file location is resolved server-side from the catalog, never
+ // taken from the request.
+ const existing = (await host.skills.list()).find(skill => skill.name === input.name)
+ if (existing !== undefined) {
+ const dir = existing.resourceBase?.kind === 'directory' ? existing.resourceBase.path : undefined
+ if (!skillWritable(existing, dir, process.env.DSH_HOME)) {
+ sendJson(response, 403, { error: `skills from source '${existing.source}' are read-only` })
+ return
+ }
+ updateSkillFile(join(dir as string, 'SKILL.md'), input)
+ }
+ else {
+ writeSkill(input)
+ }
+ sendJson(response, 200, { ok: true, name: input.name })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/skill/delete`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { name?: unknown }
+ const name = typeof body.name === 'string' ? body.name : ''
+ const removed = deleteSkill(name)
+ sendJson(response, removed ? 200 : 404, removed ? { ok: true, name } : { error: 'skill not found' })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/skill/policy`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { name?: unknown, enabled?: unknown }
+ if (typeof body.name !== 'string' || typeof body.enabled !== 'boolean') {
+ sendJson(response, 400, { error: 'name and enabled are required' })
+ return
+ }
+ const definition = await host.skills.get(body.name)
+ if (definition === undefined) {
+ sendJson(response, 404, { error: 'skill not found' })
+ return
+ }
+ if (definition.path === undefined) {
+ sendJson(response, 422, { error: 'skill has no file on disk (runtime-registered)' })
+ return
+ }
+ setSkillPolicy(definition.path, body.enabled)
+ sendJson(response, 200, { ok: true })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/open`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { target?: unknown, name?: unknown, id?: unknown }
+ if (typeof body.target !== 'string') {
+ sendJson(response, 400, { error: 'target is required' })
+ return
+ }
+ // Targets are resolved server-side; the browser never supplies a
+ // raw path, so this cannot be turned into an arbitrary open.
+ let dir: string | undefined
+ if (body.target === 'user-skills') {
+ dir = userSkillsDir()
+ // 用户还没建过任何技能时该目录不存在;「打开技能目录」应按需创建而非报错。
+ mkdirSync(dir, { recursive: true })
+ }
+ else if (body.target === 'plugin-state') {
+ dir = pluginStateDir()
+ mkdirSync(dir, { recursive: true })
+ }
+ else if (body.target === 'skill') {
+ if (typeof body.name !== 'string') {
+ sendJson(response, 400, { error: 'name is required' })
+ return
+ }
+ const definition = await host.skills.get(body.name)
+ if (definition === undefined) {
+ sendJson(response, 404, { error: 'skill not found' })
+ return
+ }
+ dir = definition.path !== undefined
+ ? definition.path.replace(/[/\\]SKILL\.md$/, '').replace(/[/\\][^/\\]+\.md$/, '')
+ : definition.resourceBase?.kind === 'directory' ? definition.resourceBase.path : undefined
+ }
+ else if (body.target === 'root') {
+ if (typeof body.id !== 'string') {
+ sendJson(response, 400, { error: 'id is required' })
+ return
+ }
+ const entry = loadState().skillRoots.find(row => row.id === body.id)
+ if (entry === undefined) {
+ sendJson(response, 404, { error: 'repository not found' })
+ return
+ }
+ dir = entry.materialDir ?? entry.path ?? entry.roots[0]
+ }
+ else {
+ sendJson(response, 400, { error: 'unknown target' })
+ return
+ }
+ if (dir === undefined || !openDirectory(dir)) {
+ sendJson(response, 422, { error: 'directory is not available on disk' })
+ return
+ }
+ sendJson(response, 200, { ok: true })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/roots`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'GET') {
+ response.writeHead(405, { allow: 'GET' })
+ response.end()
+ return
+ }
+ sendJson(response, 200, { roots: loadState().skillRoots.map(toRootView) })
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/roots/add`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { kind?: unknown, path?: unknown, url?: unknown }
+ if (body.kind !== 'local' && body.kind !== 'git') {
+ sendJson(response, 400, { error: 'kind must be local or git' })
+ return
+ }
+ const entry = body.kind === 'local'
+ ? typeof body.path === 'string' && body.path.trim() !== ''
+ ? await addLocalRepo(body.path)
+ : undefined
+ : typeof body.url === 'string' && body.url.trim() !== ''
+ ? await addGitRepo(body.url)
+ : undefined
+ if (entry === undefined) {
+ sendJson(response, 400, { error: body.kind === 'local' ? 'path is required' : 'url is required' })
+ return
+ }
+ await config.remountProvider()
+ sendJson(response, 200, { ok: true, root: toRootView(entry) })
+ }
+ catch (error) {
+ sendJson(response, 400, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/roots/remove`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { id?: unknown }
+ if (typeof body.id !== 'string') {
+ sendJson(response, 400, { error: 'id is required' })
+ return
+ }
+ const removed = removeSkillRoot(body.id)
+ if (removed === undefined) {
+ sendJson(response, 404, { error: 'repository not found' })
+ return
+ }
+ // Unwatch before unlink: the provider's directory watchers hold
+ // handles on the material tree, and removing a watched tree on
+ // Windows fails with EPERM (the state is already saved by then,
+ // which is why the repo still disappears despite the error).
+ await config.remountProvider()
+ if (removed.materialDir !== undefined)
+ removeTree(removed.materialDir)
+ sendJson(response, 200, { ok: true })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/mcp`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'GET') {
+ response.writeHead(405, { allow: 'GET' })
+ response.end()
+ return
+ }
+ sendJson(response, 200, { servers: listMcp(config.profileDirPath), restartNeeded: true })
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/mcp/save`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const input = (await readJsonBody(request)) as McpInput
+ const invalid = validateMcpInput(input)
+ if (invalid !== null) {
+ sendJson(response, 400, { error: invalid })
+ return
+ }
+ const id = upsertMcp(config.profileDirPath, input)
+ sendJson(response, 200, { ok: true, id, restartNeeded: true })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/mcp/toggle`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { id?: unknown, disabled?: unknown }
+ if (typeof body.id !== 'string' || typeof body.disabled !== 'boolean') {
+ sendJson(response, 400, { error: 'id and disabled are required' })
+ return
+ }
+ const ok = setMcpDisabled(config.profileDirPath, body.id, body.disabled)
+ sendJson(response, ok ? 200 : 404, ok ? { ok: true, restartNeeded: true } : { error: 'server row not found' })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/mcp/remove`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { id?: unknown }
+ if (typeof body.id !== 'string') {
+ sendJson(response, 400, { error: 'id is required' })
+ return
+ }
+ const ok = removeMcp(config.profileDirPath, body.id)
+ sendJson(response, ok ? 200 : 404, ok ? { ok: true, restartNeeded: true } : { error: 'server row not found' })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/import/scan`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'GET') {
+ response.writeHead(405, { allow: 'GET' })
+ response.end()
+ return
+ }
+ try {
+ sendJson(response, 200, {
+ servers: scanAllMcp(),
+ // Profile serverNames, so the browser can grey out existing ones.
+ existing: listMcp(config.profileDirPath).map(row => row.serverName),
+ })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/import/apply`,
+ handler: async (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ if (!sameOrigin(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ try {
+ const body = (await readJsonBody(request)) as { items?: unknown }
+ const wanted = new Set(
+ (Array.isArray(body.items) ? body.items : [])
+ .filter((item): item is { agent: string, name: string } =>
+ typeof item === 'object' && item !== null && typeof (item as { agent?: unknown }).agent === 'string' && typeof (item as { name?: unknown }).name === 'string')
+ .map(item => `${item.agent}/${item.name}`),
+ )
+ const results: Array<{ name: string, ok: boolean, error?: string }> = []
+ for (const server of scanAllMcp()) {
+ if (!wanted.has(`${server.agent}/${server.name}`))
+ continue
+ const existing = listMcp(config.profileDirPath).some(row => row.serverName === server.name)
+ if (existing) {
+ results.push({ name: server.name, ok: false, error: 'already in profile' })
+ continue
+ }
+ const input: McpInput = {
+ id: '',
+ serverName: server.name,
+ transport: server.transport,
+ ...(server.transport === 'stdio'
+ ? { command: server.command, args: server.args, env: server.env }
+ : { url: server.url, headers: server.headers }),
+ }
+ const invalid = validateMcpInput(input)
+ if (invalid !== null) {
+ results.push({ name: server.name, ok: false, error: invalid })
+ continue
+ }
+ upsertMcp(config.profileDirPath, input)
+ results.push({ name: server.name, ok: true })
+ }
+ sendJson(response, 200, { ok: results.every(item => item.ok), results, restartNeeded: true })
+ }
+ catch (error) {
+ sendJson(response, 500, { error: error instanceof Error ? error.message : String(error) })
+ }
+ },
+ }),
+
+ register({
+ kind: 'exact',
+ path: `${API_PREFIX}/restart`,
+ handler: (request: IncomingMessage, response: ServerResponse) => {
+ if (request.method !== 'POST') {
+ response.writeHead(405, { allow: 'POST' })
+ response.end()
+ return
+ }
+ // 进程控制:仅直接的同源回环请求;桌面模式下重启归壳层所有。
+ if (!trustedRestartRequest(request)) {
+ sendJson(response, 403, { error: 'untrusted origin' })
+ return
+ }
+ if (restartOwnedByShell()) {
+ sendJson(response, 409, { error: 'restart is owned by the desktop shell' })
+ return
+ }
+ const { pid, replacementPid, logOut } = scheduleRestart(dshLaunch())
+ sendJson(response, 200, { ok: true, pid, replacementPid, logOut })
+ },
+ }),
+ ]
+
+ return () => {
+ for (const dispose of disposers)
+ dispose()
+ }
+}
diff --git a/packages/dsh-tauri-panel-extension/src/skills.ts b/packages/dsh-tauri-panel-extension/src/skills.ts
new file mode 100644
index 00000000..5df147ef
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/skills.ts
@@ -0,0 +1,142 @@
+/**
+ * Skill catalog plumbing: frontmatter serialization for user-root SKILL.md
+ * files plus create/update/delete against `$DSH_HOME/skills`. Discovery is the
+ * host's business — the filesystem provider watches the directory, so writes
+ * land in the catalog without any restart.
+ */
+
+import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import process from 'node:process'
+
+/** Host skill name grammar (dsh-skill's SKILL_NAME). */
+export const SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
+
+/** One skill write request from the browser. */
+export interface SkillInput {
+ name: string
+ description: string
+ whenToUse?: string
+ modelInvocable: boolean
+ userInvocable: boolean
+ content: string
+}
+
+/** The user-owned skill root this plugin writes into (provider rank 400). */
+export function userSkillsDir(dshHome: string | undefined = process.env.DSH_HOME): string {
+ return join(dshHome ?? join(homedir(), '.dsh'), 'skills')
+}
+
+/** YAML double-quoted scalar (JSON string syntax is valid YAML 1.2). */
+function quote(value: string): string {
+ return JSON.stringify(value)
+}
+
+/** Frontmatter + body for one skill file. Policy keys only when non-default. */
+export function serializeSkill(input: SkillInput): string {
+ const lines = [
+ `name: ${input.name}`,
+ `description: ${quote(input.description)}`,
+ ]
+ if (input.whenToUse !== undefined && input.whenToUse !== '')
+ lines.push(`whenToUse: ${quote(input.whenToUse)}`)
+ if (!input.modelInvocable)
+ lines.push('disable-model-invocation: true')
+ if (!input.userInvocable)
+ lines.push('user-invocable: false')
+ const body = input.content.replace(/\r\n/g, '\n').trim()
+ return `---\n${lines.join('\n')}\n---\n\n${body}\n`
+}
+
+/** Validate one write request; returns the rejection reason or null. */
+export function validateSkillInput(input: SkillInput): string | null {
+ if (!SKILL_NAME_RE.test(input.name))
+ return 'name must be kebab-case (a-z, 0-9, dashes)'
+ if (input.description.trim() === '')
+ return 'description is required'
+ if (input.description.length > 1024)
+ return 'description too long (max 1024)'
+ if (input.whenToUse !== undefined && input.whenToUse.length > 2048)
+ return 'whenToUse too long (max 2048)'
+ if (input.content.length > 256 * 1024)
+ return 'content too large (max 256 KiB)'
+ return null
+}
+
+/** Directory holding one user skill's SKILL.md; name grammar blocks traversal. */
+function skillDir(name: string, dshHome?: string): string {
+ return join(userSkillsDir(dshHome), name)
+}
+
+/** Create or update a user skill. Returns the written path. */
+export function writeSkill(input: SkillInput, dshHome?: string): string {
+ const dir = skillDir(input.name, dshHome)
+ mkdirSync(dir, { recursive: true })
+ const file = join(dir, 'SKILL.md')
+ writeFileSync(file, serializeSkill(input), 'utf8')
+ return file
+}
+
+/** Delete a user skill directory. Returns false when it does not exist. */
+export function deleteSkill(name: string, dshHome?: string): boolean {
+ if (!SKILL_NAME_RE.test(name))
+ return false
+ const dir = skillDir(name, dshHome)
+ if (!existsSync(dir) || !statSync(dir).isDirectory())
+ return false
+ // Only ever remove the exact directory this name resolves to under the
+ // skills root; the regex already pins it to one safe path segment.
+ rmSync(dir, { recursive: true, force: true })
+ return true
+}
+
+/**
+ * Flip one skill file's load policy by editing only the two invocation keys
+ * in its frontmatter — `disable-model-invocation: true` plus
+ * `user-invocable: false` together take the skill out of both the model and
+ * the human catalogs on every standard-provider surface; enabling removes
+ * both keys (defaults permit both surfaces). Works on any file-backed skill
+ * (user, project, agent, bundled, custom); the rest of the file, including
+ * custom keys, ordering, and body, survives byte-for-byte.
+ */
+export function setSkillPolicy(file: string, enabled: boolean): void {
+ const text = readFileSync(file, 'utf8')
+ const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)
+ if (match === null)
+ throw new Error('skill file has no frontmatter block')
+ const newline = text.includes('\r\n---') ? '\r\n' : '\n'
+ const body = text.slice(match[0].length)
+ const lines = match[1].split(/\r?\n/)
+ const kept = lines.filter(line => !/^(?:disable-model-invocation|user-invocable):/.test(line))
+ if (!enabled)
+ kept.push('disable-model-invocation: true', 'user-invocable: false')
+ writeFileSync(file, `---${newline}${kept.join(newline)}${newline}---${body}`, 'utf8')
+}
+
+/**
+ * Edit an existing skill file in place — for skills that do not live in the
+ * user root (registered custom repositories). Only the keys the editor owns
+ * (name, description, whenToUse, the two invocation flags) are rewritten;
+ * every other frontmatter key — license, allowed-tools, anything a
+ * repository ships — survives in order, like setSkillPolicy. The body is
+ * replaced by the editor's content.
+ */
+export function updateSkillFile(file: string, input: SkillInput): void {
+ const text = readFileSync(file, 'utf8')
+ const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)
+ if (match === null)
+ throw new Error('skill file has no frontmatter block')
+ const newline = text.includes('\r\n---') ? '\r\n' : '\n'
+ const lines = match[1].split(/\r?\n/)
+ const kept = lines.filter(line => !/^(?:name|description|whenToUse|disable-model-invocation|user-invocable):/.test(line))
+ const head = [`name: ${input.name}`, `description: ${quote(input.description)}`]
+ if (input.whenToUse !== undefined && input.whenToUse !== '')
+ head.push(`whenToUse: ${quote(input.whenToUse)}`)
+ if (!input.modelInvocable)
+ kept.push('disable-model-invocation: true')
+ if (!input.userInvocable)
+ kept.push('user-invocable: false')
+ const body = input.content.replace(/\r\n/g, '\n').trim()
+ writeFileSync(file, `---${newline}${[...head, ...kept].join(newline)}${newline}---${newline}${newline}${body}${newline}`, 'utf8')
+}
diff --git a/packages/dsh-tauri-panel-extension/src/state.ts b/packages/dsh-tauri-panel-extension/src/state.ts
new file mode 100644
index 00000000..48e0f74d
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/state.ts
@@ -0,0 +1,127 @@
+/**
+ * Plugin-owned state under `$DSH_HOME/dsh-tauri-panel-extension/`: the custom
+ * skill repositories the user registered from the Settings page. Everything
+ * the provider mounts live (local paths, extracted GitHub checkouts) hangs
+ * off this file, so it stays small, JSON, and hand-recoverable.
+ */
+
+import { randomBytes } from 'node:crypto'
+import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import process from 'node:process'
+import { PLUGIN_STATE_DIRECTORY } from './constants.ts'
+
+/** One user-registered custom skill repository. */
+export interface SkillRootEntry {
+ /** Stable id (used by the remove route and directory names). */
+ id: string
+ /** `local` — a path on this machine; `git` — extracted from a GitHub URL. */
+ kind: 'local' | 'git'
+ /** Display label (repo `owner/name` or the local path's basename). */
+ label: string
+ /** The source URL (git entries). */
+ url?: string
+ /** Branch/tag/ref the tarball was pulled from (git entries). */
+ ref?: string
+ /** Local path the user pointed at (local entries). */
+ path?: string
+ /** Scan roots this entry contributes (single-skill repos get a wrapper dir). */
+ roots: string[]
+ /** Where this entry's downloaded/junctioned material lives, if any. */
+ materialDir?: string
+ addedAt: number
+}
+
+/** On-disk state document. */
+export interface PluginState {
+ skillRoots: SkillRootEntry[]
+}
+
+/** The plugin's own directory under DSH_HOME (default `~/.dsh`). */
+export function pluginStateDir(dshHome: string | undefined = process.env.DSH_HOME): string {
+ return join(dshHome ?? join(homedir(), '.dsh'), PLUGIN_STATE_DIRECTORY)
+}
+
+function statePath(dshHome?: string): string {
+ return join(pluginStateDir(dshHome), 'state.json')
+}
+
+function emptyState(): PluginState {
+ return { skillRoots: [] }
+}
+
+/** Load the state document; missing/corrupt files yield empty state. */
+export function loadState(dshHome?: string): PluginState {
+ const path = statePath(dshHome)
+ if (!existsSync(path))
+ return emptyState()
+ try {
+ const parsed = JSON.parse(readFileSync(path, 'utf8')) as Partial<PluginState>
+ if (!Array.isArray(parsed.skillRoots))
+ return emptyState()
+ const roots = parsed.skillRoots.filter((entry): entry is SkillRootEntry =>
+ typeof entry === 'object' && entry !== null && typeof entry.id === 'string' && Array.isArray(entry.roots))
+ return { skillRoots: roots }
+ }
+ catch {
+ return emptyState()
+ }
+}
+
+/** Persist by atomic rename so readers never observe partial JSON. */
+export function saveState(state: PluginState, dshHome?: string): void {
+ const dir = pluginStateDir(dshHome)
+ const target = statePath(dshHome)
+ const temporary = join(dir, `.state-${process.pid}-${randomBytes(6).toString('hex')}.tmp`)
+ mkdirSync(dir, { recursive: true })
+ try {
+ writeFileSync(temporary, `${JSON.stringify(state, null, 2)}\n`, 'utf8')
+ renameSync(temporary, target)
+ }
+ finally {
+ rmSync(temporary, { force: true })
+ }
+}
+
+/** New unique entry id. */
+export function newEntryId(kind: 'local' | 'git'): string {
+ return `${kind}-${randomBytes(4).toString('hex')}`
+}
+
+/** One entry's downloaded material (git extraction, junction wrappers). */
+export function materialDirFor(entryId: string, dshHome?: string): string {
+ return join(pluginStateDir(dshHome), 'repos', entryId)
+}
+
+/** Append one entry and persist. Returns the stored entry. */
+export function addSkillRoot(entry: Omit<SkillRootEntry, 'addedAt'>, dshHome?: string): SkillRootEntry {
+ const state = loadState(dshHome)
+ const stored: SkillRootEntry = { ...entry, addedAt: Date.now() }
+ state.skillRoots.push(stored)
+ saveState(state, dshHome)
+ return stored
+}
+
+/**
+ * Deregister one entry by id and persist immediately. The material dir is
+ * deliberately NOT deleted here: the skill provider still watches it, and
+ * removing a watched tree on Windows fails with EPERM even though the
+ * state is already saved. The caller unmounts (remountProvider) first,
+ * then runs removeTree over the returned entry's materialDir. Returns the
+ * removed entry, or undefined when the id is unknown.
+ */
+export function removeSkillRoot(id: string, dshHome?: string): SkillRootEntry | undefined {
+ const state = loadState(dshHome)
+ const at = state.skillRoots.findIndex(entry => entry.id === id)
+ if (at === -1)
+ return undefined
+ const [removed] = state.skillRoots.splice(at, 1)
+ saveState(state, dshHome)
+ return removed
+}
+
+/** Find an already registered GitHub source URL (including legacy labels). */
+export function findRootByUrl(url: string, dshHome?: string): SkillRootEntry | undefined {
+ return loadState(dshHome).skillRoots.find(entry => entry.url === url)
+}
diff --git a/packages/dsh-tauri-panel-extension/src/tar.ts b/packages/dsh-tauri-panel-extension/src/tar.ts
new file mode 100644
index 00000000..5a8acc6c
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/tar.ts
@@ -0,0 +1,175 @@
+/**
+ * Minimal pure-JS tar.gz extraction (node zlib + a USTAR/GNU/PAX-path
+ * reader). GitHub codeload tarballs are all we ever unpack — regular files
+ * and directories, no links — so unsupported entry types are skipped rather
+ * than rejected, and every name is checked against escape before it touches
+ * the filesystem. No subprocess: the dsh sidecar must not spawn tar.
+ */
+
+import type { Buffer } from 'node:buffer'
+import { mkdirSync, writeFileSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { gunzipSync } from 'node:zlib'
+
+/** Guard rails for untrusted archives. */
+const LIMITS = {
+ /** Per-entry cap (a skill repo holds markdown and small assets). */
+ entryBytes: 64 * 1024 * 1024,
+ /** Whole-archive content cap. */
+ totalBytes: 256 * 1024 * 1024,
+ /** Entry count cap (also bounds loop time on corrupt input). */
+ entries: 20_000,
+} as const
+
+function octal(block: Buffer, offset: number, length: number): number {
+ const raw = block.toString('utf8', offset, offset + length).replace(/[\0 ]+$/, '')
+ return raw === '' ? 0 : Number.parseInt(raw, 8)
+}
+
+function field(block: Buffer, offset: number, length: number): string {
+ const at = block.indexOf(0, offset)
+ return block.toString('utf8', offset, Math.min(at === -1 ? offset + length : at, offset + length))
+}
+
+/** One parsed tar header. */
+interface TarHeader {
+ name: string
+ size: number
+ type: string
+}
+
+function readHeader(block: Buffer): TarHeader | null {
+ // A zeroed block ends the archive (the checksum of an empty block is 0).
+ if (block.every(byte => byte === 0))
+ return null
+ const checksum = octal(block, 148, 8)
+ let sum = 0
+ for (let at = 0; at < 512; at++) sum += at >= 148 && at < 156 ? 32 : block[at]
+ if (sum !== checksum)
+ return null
+ const magic = block.toString('utf8', 257, 257 + 6)
+ let name = field(block, 0, 100)
+ if (magic.startsWith('ustar')) {
+ const prefix = field(block, 345, 155)
+ if (prefix !== '')
+ name = `${prefix}/${name}`
+ }
+ return { name, size: octal(block, 124, 12), type: block.toString('utf8', 156, 157) }
+}
+
+/** Resolve one entry name under the target, rejecting escapes. */
+function safeJoin(target: string, name: string): string | null {
+ const normalized = name.replace(/\\/g, '/')
+ if (normalized.startsWith('/') || /^[A-Z]:/i.test(normalized))
+ return null
+ const parts: string[] = []
+ for (const part of normalized.split('/')) {
+ if (part === '' || part === '.')
+ continue
+ if (part === '..')
+ return null
+ parts.push(part)
+ }
+ if (parts.length === 0)
+ return null
+ return join(target, ...parts)
+}
+
+/** PAX extended header records (`<len> key=value\n` lines) → key/value map. */
+function paxRecords(content: Buffer): Map<string, string> {
+ const out = new Map<string, string>()
+ let cursor = 0
+ while (cursor < content.length) {
+ const spaceAt = content.indexOf(' ', cursor)
+ if (spaceAt === -1)
+ break
+ const length = Number.parseInt(content.toString('utf8', cursor, spaceAt), 10)
+ if (!Number.isInteger(length) || length <= 0 || cursor + length > content.length)
+ break
+ const record = content.toString('utf8', spaceAt + 1, cursor + length).trimEnd()
+ const eq = record.indexOf('=')
+ if (eq > 0)
+ out.set(record.slice(0, eq), record.slice(eq + 1))
+ cursor += length
+ }
+ return out
+}
+
+/** Number of leading path components to drop (GitHub tarballs wrap one). */
+export interface ExtractOptions {
+ stripComponents?: number
+}
+
+/**
+ * Extract a gzip'd tar buffer into `target` (created when absent). Returns
+ * the entry count written. Throws on structure errors and oversize archives.
+ */
+export function extractTarGz(archive: Buffer, target: string, options: ExtractOptions = {}): number {
+ const tar = gunzipSync(archive)
+ const strip = options.stripComponents ?? 0
+ let offset = 0
+ let written = 0
+ let total = 0
+ let pendingLongName: string | undefined
+ let pendingPath: string | undefined
+ while (offset + 512 <= tar.length) {
+ const header = readHeader(tar.subarray(offset, offset + 512))
+ if (header === null)
+ break
+ offset += 512
+ const contentEnd = offset + header.size
+ if (contentEnd > tar.length)
+ throw new Error('truncated tar entry')
+ const content = tar.subarray(offset, contentEnd)
+ offset += Math.ceil(header.size / 512) * 512
+ if (header.size > LIMITS.entryBytes)
+ throw new Error('tar entry too large')
+ total += header.size
+ if (total > LIMITS.totalBytes)
+ throw new Error('tar archive too large')
+ if (++written > LIMITS.entries)
+ throw new Error('too many tar entries')
+
+ // Metadata entries carry the name for the entry that follows.
+ if (header.type === 'L') {
+ pendingLongName = field(content, 0, content.length)
+ continue
+ }
+ if (header.type === 'x' || header.type === 'X') {
+ pendingPath = paxRecords(content).get('path')
+ continue
+ }
+ if (header.type === 'g')
+ continue // global pax: nothing we need
+
+ let name = pendingLongName ?? pendingPath ?? header.name
+ pendingLongName = undefined
+ pendingPath = undefined
+
+ const parts = name.split('/')
+ if (parts.length <= strip)
+ continue // nothing left after stripping
+ name = parts.slice(strip).join('/')
+ // The stripped top-level directory itself ("pkg/" → "") owns nothing.
+ if (name === '' || name === '/')
+ continue
+
+ // Directories: type '5' or a trailing slash. Symlinks/hardlinks/other
+ // types are skipped — skill repos that depend on them degrade loudly
+ // elsewhere instead of planting links from untrusted input.
+ const isDir = header.type === '5' || ((header.type === '0' || header.type === '\0') && name.endsWith('/'))
+ if (header.type !== '0' && header.type !== '\0' && header.type !== '5')
+ continue
+
+ const resolved = safeJoin(target, name)
+ if (resolved === null)
+ throw new Error(`unsafe tar entry name: ${name}`)
+ if (isDir) {
+ mkdirSync(resolved, { recursive: true })
+ continue
+ }
+ mkdirSync(dirname(resolved), { recursive: true })
+ writeFileSync(resolved, content)
+ }
+ return written
+}
diff --git a/packages/dsh-tauri-panel-extension/src/types.ts b/packages/dsh-tauri-panel-extension/src/types.ts
new file mode 100644
index 00000000..f7f9887a
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/src/types.ts
@@ -0,0 +1,61 @@
+/** Shared types across the capabilities manager modules. */
+
+import type { IncomingMessage, ServerResponse } from 'node:http'
+
+/** The webServer service subset this plugin consumes (structural). */
+export interface WebServerService {
+ register: (route: {
+ kind: 'exact' | 'prefix'
+ path: string
+ handler: (request: IncomingMessage, response: ServerResponse) => void | Promise<void>
+ }) => () => void
+}
+
+/** DSH Connection's browser trust and authentication boundary. */
+export interface ConnectionGate {
+ requestRejection: (request: IncomingMessage) => 401 | 403 | undefined
+}
+
+/** One skill as the host registry reports it (SkillSummary subset). */
+export interface HostSkill {
+ readonly name: string
+ readonly description: string
+ readonly whenToUse?: string
+ readonly invocation: { modelInvocable: boolean, userInvocable: boolean }
+ readonly source: string
+ readonly provider: string
+ /** Provider-specific base (directory skills carry their folder here). */
+ readonly resourceBase?: { kind: 'directory', path: string } | { kind: 'url', url: string } | { kind: 'opaque', description: string }
+}
+
+/** Loaded skill definition subset the routes consume. */
+export interface HostSkillDefinition {
+ readonly name: string
+ readonly content: string
+ readonly path?: string
+ readonly resourceBase?: HostSkill['resourceBase']
+}
+
+/** The skills service subset this plugin consumes (structural). */
+export interface SkillsService {
+ list: (options?: { cwd?: string }) => Promise<HostSkill[]>
+ get: (name: string, options?: { cwd?: string }) => Promise<HostSkillDefinition | undefined>
+}
+
+/** Repository metadata attached to a skill row for client navigation. */
+export interface SkillRepositoryMetadata {
+ /** Stable repository registration id. */
+ id: string
+ /** Human-readable local folder or `owner/repo` label. */
+ label: string
+ kind: 'local' | 'git'
+ /** Canonical clickable GitHub URL; present only for GitHub imports. */
+ githubUrl?: string
+}
+
+/** Host context carrying both services this plugin injects. */
+export interface PanelExtensionHost {
+ webServer: WebServerService
+ skills: SkillsService
+ connection: ConnectionGate
+}
diff --git a/packages/dsh-tauri-panel-extension/tsconfig.json b/packages/dsh-tauri-panel-extension/tsconfig.json
new file mode 100644
index 00000000..32a0dfe3
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/tsconfig.json
@@ -0,0 +1,4 @@
+{
+ "extends": "../../tsconfig.json",
+ "include": ["src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/packages/dsh-tauri-panel-extension/tsdown.config.ts b/packages/dsh-tauri-panel-extension/tsdown.config.ts
new file mode 100644
index 00000000..63fb9220
--- /dev/null
+++ b/packages/dsh-tauri-panel-extension/tsdown.config.ts
@@ -0,0 +1,14 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+// Client-only libraries must be bundled into the classic loader artifact. The
+// DSH client module table only materializes platform seed words and declared
+// client injections, so leaving these imports external makes runtime require()
+// fail even though the packages exist in the host profile.
+export default defineDshConfig({
+ server: {
+ noExternal: ['smol-toml', 'yaml'],
+ },
+ client: {
+ noExternal: ['dompurify', 'marked'],
+ },
+})
diff --git a/packages/dsh-tauri-panel-placeholder/README.md b/packages/dsh-tauri-panel-placeholder/README.md
new file mode 100644
index 00000000..4c4e10a6
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/README.md
@@ -0,0 +1,7 @@
+# dsh-tauri-panel-placeholder
+
+`dsh-tauri-panel-placeholder` 是面板扩展的占位插件。它保留与正式面板包一致的加载形态,适合在开发、演示或等待真实面板实现时使用。
+
+## 当前状态
+
+该包只提供可加载的基础入口,不渲染实际面板,也不注册额外的 host API。需要真实面板时,请改用 [`dsh-tauri-panel`](../dsh-tauri-panel) 或等待后续实现。
diff --git a/packages/dsh-tauri-panel-placeholder/cordis.patch.yml b/packages/dsh-tauri-panel-placeholder/cordis.patch.yml
new file mode 100644
index 00000000..8f20e5bc
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-panel-placeholder
+ name: dsh-tauri-panel-placeholder
diff --git a/packages/dsh-tauri-panel-placeholder/package.json b/packages/dsh-tauri-panel-placeholder/package.json
new file mode 100644
index 00000000..20893896
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "dsh-tauri-panel-placeholder",
+ "type": "module",
+ "version": "0.6.7",
+ "private": true,
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/constants.ts b/packages/dsh-tauri-panel-placeholder/src/client/constants.ts
new file mode 100644
index 00000000..544e4538
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/constants.ts
@@ -0,0 +1,11 @@
+export const PLUGIN_ID = 'dsh-tauri-panel-placeholder'
+export const LOCALE_NAMESPACE = 'placeholder'
+export const PANEL_LOCALE_KEY = 'panel.placeholder'
+export const PANEL_ID = 'placeholder'
+export const PANEL_SLOT_NAME = 'sidebar.panel.action'
+export const PANEL_PROTOCOL_NAME = 'panel.protocol'
+export const PANEL_ORDER = 10
+export const PANEL_PRIORITY = 0
+export const STYLE_ID = 'dsh-tauri-panel-placeholder-styles'
+export const PLACEHOLDER_CENTER_CLASS = 'dshp-placeholderCenter'
+export const PLACEHOLDER_TEXT_CLASS = 'dshp-placeholderText'
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/content.tsx b/packages/dsh-tauri-panel-placeholder/src/client/content.tsx
new file mode 100644
index 00000000..54ef28c9
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/content.tsx
@@ -0,0 +1,22 @@
+import type { ReactElement } from 'react'
+
+/**
+ * content.tsx — 自定义内容区(样板视图):居中占位「自定义内容区」。
+ *
+ * 本插件只负责「内容」,**自包含**(不依赖任何 props/翻译):
+ * - 会话区替换的机制(conversation 槽动态 shadow、点击侧栏别处自动退出)
+ * 由 dsh-tauri-panel 宿主承担——条目 onClick 调 renderPanelContent
+ * (见 ../dsh-tauri-panel/PROTOCOL.md「会话区替换」);
+ * - 宽度约束宿主已包列(.dshp-panelViewColumn:max-width
+ * var(--dsh-chat-content-width, 748px)、width 100%、margin 0 auto、满高),
+ * 此处只做垂直居中占位。
+ */
+export function Content(): ReactElement {
+ return (
+ <div>
+ <p>自定义内容区</p>
+ </div>
+ )
+}
+
+export default Content
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/icons.tsx b/packages/dsh-tauri-panel-placeholder/src/client/icons.tsx
new file mode 100644
index 00000000..a3470cc5
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/icons.tsx
@@ -0,0 +1,14 @@
+import type { ReactElement } from 'react'
+import type { IconProps } from './types'
+
+/**
+ * icons.tsx — 自绘内联 SVG 图标(Gravity 风格描边,currentColor)。
+ * 不依赖 @deepseek-ai/dsh-client-ui-primitives 的类型/运行时(loader 模块表
+ * 虽提供该模块,但自绘零外部表面、跨部署更稳)。
+ */
+
+export function IconPlaceholder({ className }: IconProps): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" className={className} width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M13 12.6V9q0-.425-.288-.712T12 8t-.712.288T11 9v3.975q0 .2.075.388t.225.337l2.8 2.8q.275.275.7.275t.7-.275t.275-.7t-.275-.7zm-4.512 8.688q-1.638-.713-2.85-1.925t-1.925-2.85T3 13t.713-3.512t1.924-2.85t2.85-1.925T12 4t3.513.713t2.85 1.925t1.925 2.85T21 13t-.712 3.513t-1.925 2.85t-2.85 1.925T12 22t-3.512-.712M2.05 7.3q-.275-.275-.275-.7t.275-.7L4.9 3.05q.275-.275.7-.275t.7.275t.275.7t-.275.7L3.45 7.3q-.275.275-.7.275t-.7-.275m19.9 0q-.275.275-.7.275t-.7-.275L17.7 4.45q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l2.85 2.85q.275.275.275.7t-.275.7M12 20q2.925 0 4.963-2.037T19 13t-2.037-4.962T12 6T7.038 8.038T5 13t2.038 4.963T12 20" /></svg>
+ )
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/index.ts b/packages/dsh-tauri-panel-placeholder/src/client/index.ts
new file mode 100644
index 00000000..dcd9d1cd
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/index.ts
@@ -0,0 +1,39 @@
+import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
+/**
+ * dsh-tauri-panel-placeholder 客户端插件体(browser half):panel 协议样板。
+ *
+ * 作为 [dsh-tauri-panel 协议](./PROTOCOL.md)(槽 sidebar.panel.action)的
+ * 最小参考实现:
+ * - 面板区条目「定时任务」(复用 dsh-tauri-panel 全局注入的 dshp-menuItem
+ * 行样式,wide 显示图标+文字 / 折叠只显示图标钮);
+ * - 点击条目 → conversation 槽以 priority -1 **动态注册**(layout 声明的
+ * single/session-maybe 槽,官方 ui-conversation priority 0 是唯一注册者),
+ * 整个右侧会话区替换为居中「自定义内容区」;关闭(再点条目 toggle 或
+ * 点侧栏任意处)→ 注销条目,官方会话界面恢复。
+ *
+ * 无业务逻辑:样板只演示协议接入点与「会话区替换」的最小形态。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import { PLUGIN_ID } from './constants'
+import { installPanelLocale } from './locale'
+import { installPanel } from './panel'
+import { mountPlaceholderStyles } from './styles'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = PLUGIN_ID
+
+/** 需要的客户端服务:slots(注册点位)、locale(双语文案)。 */
+export const inject = ['slots', 'locale']
+
+/**
+ * 插件体:注册面板区条目与会话区替换。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ ctx.effect(
+ () => mountPlaceholderStyles(),
+ `${PLUGIN_ID}: styles`,
+ )
+ installPanelLocale(ctx)
+ installPanel(ctx)
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/locale.ts b/packages/dsh-tauri-panel-placeholder/src/client/locale.ts
new file mode 100644
index 00000000..5610ed1b
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/locale.ts
@@ -0,0 +1,17 @@
+import type { Context } from '@deepseek-ai/cordis'
+import { LOCALE_NAMESPACE, PANEL_LOCALE_KEY, PLUGIN_ID } from './constants'
+
+/**
+ * locale.ts — 样板插件的双语文案(placeholder NS)。
+ * ctx.locale.register 类型来自 slots.d.ts 对 cordis Context 的增广。
+ */
+/** 注册双语文案(分开注册:cordis locale 的 zh/en 分区;effect 内返回 dispose 组合)。 */
+export function installPanelLocale(ctx: Context): void {
+ ctx.effect(
+ () => [
+ ctx.locale.register(LOCALE_NAMESPACE, 'zh', { [PANEL_LOCALE_KEY]: '占位符' }),
+ ctx.locale.register(LOCALE_NAMESPACE, 'en', { [PANEL_LOCALE_KEY]: 'Placeholder' }),
+ ],
+ `${PLUGIN_ID}: placeholder locale`,
+ )
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/panel.tsx b/packages/dsh-tauri-panel-placeholder/src/client/panel.tsx
new file mode 100644
index 00000000..c947f229
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/panel.tsx
@@ -0,0 +1,61 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { PanelProtocol, PlaceholderPanelProps } from './types'
+import {
+ LOCALE_NAMESPACE,
+ PANEL_ID,
+ PANEL_LOCALE_KEY,
+ PANEL_ORDER,
+ PANEL_PRIORITY,
+ PANEL_PROTOCOL_NAME,
+ PANEL_SLOT_NAME,
+ PLUGIN_ID,
+} from './constants'
+import { Content } from './content'
+import { IconPlaceholder } from './icons'
+
+/**
+ * panel.tsx — 面板区(sidebar.panel.action 槽)样板条目:
+ * 「定时任务」。按 dsh-tauri-panel 面板协议接入(见 ../dsh-tauri-panel/PROTOCOL.md):
+ * 条目用宿主导出的 <ActionItem> 组装(样式/折叠/active 态宿主承担),点击调
+ * 宿主导出的 renderPanelContent 切换会话区替换——本插件零机制代码。
+ */
+
+function PlaceholderPanel(props: PlaceholderPanelProps): ReactElement {
+ const { t, protocol: { ActionItem, renderPanelContent } } = props
+
+ function onClick(): void {
+ renderPanelContent({ id: PANEL_ID, render: Content, locale: LOCALE_NAMESPACE })
+ }
+
+ return (
+ <ActionItem id={PANEL_ID} icon={<IconPlaceholder />} onClick={onClick}>
+ {t(PANEL_LOCALE_KEY)}
+ </ActionItem>
+ )
+}
+
+/** 注册面板区样板条目(等 sidebar.panel.action 声明出现——即 dsh-tauri-panel 生效后)。 */
+export function installPanel(ctx: Context): void {
+ ctx.slots.inject(PANEL_SLOT_NAME as never, () => {
+ // 宿主协议服务经反射注册(dsh-tauri-panel apply 先于本条目声明执行);
+ // 缺失时降级:不注册条目(旧核心/宿主未装)。
+ const protocol = ctx.reflect.get(PANEL_PROTOCOL_NAME) as PanelProtocol | undefined
+ if (!protocol) {
+ console.warn(`[${PLUGIN_ID}] ${PANEL_PROTOCOL_NAME} host service unavailable — panel item disabled.`)
+ // 类型要求返回 SlotInjectionEffect:空 disposer 表示不注册任何条目。
+ return () => {}
+ }
+ return ctx.slots.register(
+ {
+ name: PANEL_SLOT_NAME,
+ id: PLUGIN_ID,
+ order: PANEL_ORDER,
+ priority: PANEL_PRIORITY,
+ locale: LOCALE_NAMESPACE,
+ inject: () => ({ protocol }),
+ } as never,
+ PlaceholderPanel,
+ )
+ })
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/slots.d.ts b/packages/dsh-tauri-panel-placeholder/src/client/slots.d.ts
new file mode 100644
index 00000000..a159883a
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/slots.d.ts
@@ -0,0 +1,32 @@
+/**
+ * slots.d.ts — 本插件的类型增广(模块文件:含 import,故仅对**可解析**的
+ * 模块做增广)。
+ *
+ * 目标:零新增依赖仍获得类型检查。此处只增广 '@deepseek-ai/cordis'(该包在
+ * 插件 node_modules 根下可解析):locale 服务的非类型化表面来自
+ * dsh-client-locale 包(不在本插件类型图),按我们实际用到的子集声明。
+ *
+ * 注:'sidebar.panel.action' / 'conversation' 的 SlotMap 声明归属 ui-layout /
+ * ui-sidebar(不在本插件类型图、未提升到根 node_modules),无法在保留模块
+ * 同一性的前提下在此增广——注册处改用显式 cast(先例:dsh-tauri-ui 的
+ * trigger.tsx、dsh-tauri-panel 的 sidebar.tsx)。组件 props 仍由本地
+ * 接口提供类型。
+ *
+ * 本文件必须保持**模块身份**(末尾 `export {}` 维持;lint --fix 不会删除
+ * export):脚本文件里的 declare module 是环境模块声明,会遮蔽同名真实模块
+ * (连带吞掉 effect 等成员);模块文件里才是增广语义,与真实 cordis Context 合并。
+ */
+declare module '@deepseek-ai/cordis' {
+ /** locale 服务的非类型化表面(本插件用到的子集;typed 表面在 dsh-client-locale)。 */
+ interface DshLocaleRuntimeLike {
+ register: (ns: string, locale: string, dict: Record<string, string>) => () => void
+ getLocale: () => { active: string, revision: number }
+ getSnapshot: () => { active: string, revision: number }
+ subscribe: (fn: () => void) => () => void
+ }
+
+ interface Context {
+ locale: DshLocaleRuntimeLike
+ }
+}
+export {}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/styles.ts b/packages/dsh-tauri-panel-placeholder/src/client/styles.ts
new file mode 100644
index 00000000..99b26691
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/styles.ts
@@ -0,0 +1,32 @@
+/** Placeholder styles generated as structured css-render nodes. */
+import { CssRender } from 'dsh-tauri/client'
+import { PLACEHOLDER_CENTER_CLASS, PLACEHOLDER_TEXT_CLASS, STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+
+const placeholderStyle = c([
+ c(`.${PLACEHOLDER_CENTER_CLASS}`, {
+ boxSizing: 'border-box',
+ minHeight: '100%',
+ color: 'var(--dsw-alias-label-primary)',
+ alignItems: 'center',
+ justifyContent: 'center',
+ display: 'flex',
+ }),
+ c(`.${PLACEHOLDER_TEXT_CLASS}`, {
+ fontSize: '15px',
+ color: 'var(--dsw-alias-label-secondary)',
+ userSelect: 'none',
+ }),
+])
+
+/** Mount placeholder styles through css-render and return an unmount disposer. */
+export function mountPlaceholderStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(STYLE_ID) !== null)
+ return () => {}
+ placeholderStyle.mount({ id: STYLE_ID, head: true })
+ return () => placeholderStyle.unmount({ id: STYLE_ID })
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/client/types.ts b/packages/dsh-tauri-panel-placeholder/src/client/types.ts
new file mode 100644
index 00000000..4c6b9297
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/client/types.ts
@@ -0,0 +1,23 @@
+import type { ComponentType, ReactElement, ReactNode } from 'react'
+
+/** panel.protocol 宿主服务(经 ctx.reflect.get 取用;完整类型见 dsh-tauri-panel/PROTOCOL.md)。 */
+export interface PanelProtocol {
+ /** 面板区条目组件:id/icon/onClick/children 由子插件填,其余宿主处理。 */
+ ActionItem: (props: { id: string, icon?: ReactElement, onClick?: () => void, children?: ReactNode }) => ReactElement
+ /** 切换会话区替换:未替换则打开 render,已替换则关闭恢复官方会话界面。 */
+ renderPanelContent: (spec: { id: string, render: ComponentType<{ t?: (key: string) => string }>, locale?: string }) => void
+ /** 显式关闭当前面板内容并恢复官方会话界面。 */
+ closePanelContent: () => void
+}
+
+/** sidebar.panel.action 条目合成 props 子集(inject 提供 protocol)。 */
+export interface PlaceholderPanelProps {
+ /** 本条目 locale 翻译函数(placeholder NS)。 */
+ t: (key: string) => string
+ /** 宿主面板协议服务(inject:ctx.reflect.get('panel.protocol'))。 */
+ protocol: PanelProtocol
+}
+
+export interface IconProps {
+ className?: string
+}
diff --git a/packages/dsh-tauri-panel-placeholder/src/index.ts b/packages/dsh-tauri-panel-placeholder/src/index.ts
new file mode 100644
index 00000000..46dcaa1d
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/src/index.ts
@@ -0,0 +1,6 @@
+/**
+ * dsh-tauri-panel-placeholder 宿主侧(node half):纯浏览器插件,无宿主行为。
+ * loader 按行名导入包根时需要一个可挂载的插件入口;与官方浏览器插件
+ * (如 dsh-client-ui-layout)一致,这里提供空 apply。
+ */
+export function apply(): void {}
diff --git a/packages/dsh-tauri-panel-placeholder/tsdown.config.ts b/packages/dsh-tauri-panel-placeholder/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-panel-placeholder/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri-panel/README.md b/packages/dsh-tauri-panel/README.md
new file mode 100644
index 00000000..ab6d4db7
--- /dev/null
+++ b/packages/dsh-tauri-panel/README.md
@@ -0,0 +1,16 @@
+# dsh-tauri-panel
+
+`dsh-tauri-panel` 是 Tauri 桌面端面板能力的扩展入口。当前版本提供稳定的插件包结构和客户端注入点,后续面板组件将在此基础上演进。
+
+## 面板协议
+
+客户端注册 `sidebar.panel.action` 槽,并通过反射服务 `panel.protocol` 向面板扩展提供:
+
+- `ActionItem`:统一的侧栏面板条目。
+- `renderPanelContent(spec)`:切换面板内容与官方会话内容。
+- `closePanelContent()`:显式恢复官方会话内容,适合面板内跳转到会话的动作。
+
+## 相关包
+
+- [`dsh-tauri-ui`](../dsh-tauri-ui):通用桌面 UI。
+- [`dsh-tauri-panel-placeholder`](../dsh-tauri-panel-placeholder):占位实现。
diff --git a/packages/dsh-tauri-panel/cordis.patch.yml b/packages/dsh-tauri-panel/cordis.patch.yml
new file mode 100644
index 00000000..ed1ba2ae
--- /dev/null
+++ b/packages/dsh-tauri-panel/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-panel
+ name: dsh-tauri-panel
diff --git a/packages/dsh-tauri-panel/package.json b/packages/dsh-tauri-panel/package.json
new file mode 100644
index 00000000..ba663a3a
--- /dev/null
+++ b/packages/dsh-tauri-panel/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "dsh-tauri-panel",
+ "type": "module",
+ "version": "0.6.7",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-panel/src/client/constants.ts b/packages/dsh-tauri-panel/src/client/constants.ts
new file mode 100644
index 00000000..42e7947c
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/constants.ts
@@ -0,0 +1,53 @@
+/** Stable client-side identifiers shared by the panel implementation. */
+export const PANEL_PROTOCOL_SERVICE = 'panel.protocol'
+export const PANEL_VIEW_SLOT = 'conversation'
+export const PANEL_VIEW_COMPONENT_ID = 'dsh-tauri-panel-conversation-seat'
+export const PANEL_STYLE_ID = 'dsh-tauri-panel-styles'
+export const COLLAPSE_SETTLE_MS = 150
+export const SCROLLBAR_LINGER_MS = 2000
+export const SIDEBAR_INTERACTIVE_SELECTOR = 'button,a[href],input,select,textarea,summary,[role="button"],[role="link"],[role="menuitem"],[role="option"],[role="tab"],[role="treeitem"][aria-selected]'
+export const WORKSPACE_GROUP_SELECTOR = '[role="treeitem"][aria-expanded]'
+
+/**
+ * 只改变侧栏呈现、不应关闭面板的官方控件。dsh-client-ui-workspace 的工作区头部
+ * “分组方式”(viewOptions.label)与“添加工作区”(workspace.add)按钮的
+ * aria-label 随 locale 变化(仓库仅内置 zh/en 两组),这里同时匹配两种语言。
+ */
+export const SIDEBAR_KEEP_OPEN_SELECTOR = 'button[aria-label="视图选项"],button[aria-label="View options"],button[aria-label="添加工作区"],button[aria-label="Add workspace"]'
+
+export const PANEL_CLASSES = {
+ root: 'dshp-root',
+ collapsed: 'dshp-collapsed',
+ railIn: 'dshp-railIn',
+ fading: 'dshp-fading',
+ quietBars: 'dshp-quietBars',
+ wide: 'dshp-wide',
+ logoRow: 'dshp-logoRow',
+ brand: 'dshp-brand',
+ brandIdentity: 'dshp-brandIdentity',
+ brandMark: 'dshp-brandMark',
+ brandName: 'dshp-brandName',
+ fallbackBrandName: 'dshp-fallbackBrandName',
+ iconButton: 'dshp-iconButton',
+ toggle: 'dshp-toggle',
+ railMark: 'dshp-railMark',
+ panelArea: 'dshp-panelArea',
+ menuItem: 'dshp-menuItem',
+ menuItemSelected: 'dshp-menuItemSelected',
+ newSession: 'dshp-newSession',
+ menuItemIcon: 'dshp-menuItemIcon',
+ menuItemLabel: 'dshp-menuItemLabel',
+ regionArea: 'dshp-regionArea',
+ footArea: 'dshp-footArea',
+ footerActions: 'dshp-footerActions',
+ settingsArea: 'dshp-settingsArea',
+ panelView: 'dshp-panelView',
+ panelViewColumn: 'dshp-panelViewColumn',
+} as const
+
+export const PANEL_DATA_ATTRIBUTES = {
+ sidebar: 'data-dshp-panel-sidebar',
+ active: 'data-dshp-panel-active',
+ action: 'data-dshp-panel-action',
+ view: 'data-dshp-panel-view',
+} as const
diff --git a/packages/dsh-tauri-panel/src/client/icons.tsx b/packages/dsh-tauri-panel/src/client/icons.tsx
new file mode 100644
index 00000000..9927dacc
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/icons.tsx
@@ -0,0 +1,44 @@
+import type { ReactElement } from 'react'
+import type { IconProps } from './types'
+
+export type { IconProps } from './types'
+
+/**
+ * icons.tsx — 自绘内联 SVG 图标(Gravity 风格描边,currentColor)。
+ * 不依赖 @deepseek-ai/dsh-client-ui-primitives 的类型/运行时(loader 模块表
+ * 虽提供该模块,但自绘零外部表面、跨部署更稳)。
+ */
+
+/**
+ * 新会话:官方 ChatOutline16 同款(聊天气泡 + 加号,fill 风格)。
+ * primitives 包为 loader 运行时提供、不打进产物;此处自绘官方同一 path——
+ * 取自桌面前端 bundle(dsh-web-frontend/dist/assets/index-ClqxG24t.js,导出表
+ * ChatOutline16:V9),保证与官方「新会话」图标完全一致。
+ */
+export function ChatOutline({ size = 16, className }: IconProps): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true">
+ <path d="M8.00003 0.3237C3.76075 0.3237 0.32373 3.76072 0.32373 8C0.32373 9.17603 0.589121 10.2922 1.0632 11.2901L1.35291 11.8989L2.5705 11.3205L2.28079 10.7117C1.89079 9.89074 1.67301 8.97167 1.67301 8C1.67301 4.50546 4.50549 1.67298 8.00003 1.67298C11.4946 1.67298 14.3271 4.50546 14.3271 8C14.3271 11.4945 11.4946 14.327 8.00003 14.327C7.28473 14.327 6.76077 14.277 6.29621 14.1487C5.83857 14.0224 5.40441 13.8109 4.88514 13.4488C4.12569 12.919 3.03778 12.7316 2.141 13.2978L2.12682 13.307L2.11264 13.3171L1.34886 13.854L1.79659 15.188L2.86122 14.4384C3.19068 14.2305 3.68325 14.2542 4.11326 14.5539C4.72789 14.9826 5.30042 15.2724 5.93762 15.4484C6.56803 15.6224 7.22776 15.6763 8.00003 15.6763C12.2393 15.6763 15.6763 12.2393 15.6763 8C15.6763 3.76072 12.2393 0.3237 8.00003 0.3237ZM7.32033 4.82535V7.32536H4.82538V8.67464H7.32033V11.1747H8.6696V8.67464H11.1747V7.32536H8.6696V4.82535H7.32033Z" fill="currentColor" />
+ </svg>
+ )
+}
+
+/** 侧栏折叠开关:左侧面板轮廓(16 基准)。 */
+export function PanelLeftOutline({ size = 16, className }: IconProps): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true">
+ <rect x="2" y="3" width="12" height="10" rx="1.5" stroke="currentColor" strokeWidth="1.2" />
+ <path d="M6.5 3v10" stroke="currentColor" strokeWidth="1.2" />
+ </svg>
+ )
+}
+
+/** 品牌 fallback:简化鱼形(sidebar.brand.mark 槽无 live 条目时的兜底,24 基准)。 */
+export function FishMark({ size = 24, className }: IconProps): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" className={className} aria-hidden="true">
+ <path d="M4 12c3-4.5 9-6 16-6 0 7-13 9-16 6Zm0 0c3 2.5 16 4.5 16-6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
+ <circle cx="15.5" cy="9.5" r="1" fill="currentColor" />
+ </svg>
+ )
+}
diff --git a/packages/dsh-tauri-panel/src/client/index.ts b/packages/dsh-tauri-panel/src/client/index.ts
new file mode 100644
index 00000000..416667cc
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/index.ts
@@ -0,0 +1,65 @@
+import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
+/**
+ * dsh-tauri-panel 客户端插件体(browser half):工作区上方面板 UI。
+ *
+ * 能力(全部 slot-shadow,零结构补丁,零新增依赖):
+ * 整槽替换 sidebar(priority -1 shadow 官方 ui-sidebar):克隆
+ * SidebarRoot —— 紧凑 logoRow(32px、底距 4px)、面板区(新会话菜单项
+ * + 协议槽 sidebar.panel.action 的第三方功能项)、官方子槽(workspaces/
+ * settings/footer/brand)经 <SlotOutlet> 透传。
+ *
+ * 协议:第三方插件向面板区添加功能项 = 注册 `sidebar.panel.action`
+ * (list/root,本插件声明),详见 PROTOCOL.md。
+ *
+ * 依赖:renderer 补丁导出的 <SlotOutlet>(任意槽渲染入口)。核心未带补丁时
+ * (旧安装)SlotOutlet 为 undefined —— 此时整体不注册(官方侧栏原样工作),
+ * 绝不白屏。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+import { installPanelLocale } from './locale'
+import { installPanelService } from './service'
+import { installSidebarRoot } from './sidebar'
+import { mountPanelStyles } from './styles'
+
+export { PANEL_PROTOCOL_SERVICE } from './constants'
+export type { IconProps } from './icons'
+export type { PanelActionItemProps, PanelContentSpec, SidebarRootProps } from './types'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = 'dsh-tauri-panel'
+
+/**
+ * 需要的客户端服务:slots(注册点位)、layout(折叠/宽度)、locale(双语文案)。
+ *
+ * `workspaces` 不能列为强制注入:Alpha 将会话导航放在 `uiWorkspace`,而
+ * rc.2 才把 `startSession` 暴露在 `workspaces` 上。运行时差异由 compat(ctx)
+ * 在 apply 内探测,避免 Alpha 在执行 apply 前因缺少 workspaces 而被 Cordis 跳过。
+ */
+export const inject = ['slots', 'layout', 'locale']
+
+/**
+ * 插件体:注册面板侧栏(整槽替换)。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ ctx.effect(
+ () => mountPanelStyles(),
+ 'dsh-tauri-panel: styles',
+ )
+ installPanelLocale(ctx)
+ // 面板协议宿主服务(panel.protocol:ActionItem + renderPanelContent):
+ // 只走 slots runtime,不依赖 renderer 补丁——无补丁时内容区替换仍可用。
+ installPanelService(ctx)
+
+ // 侧栏面板依赖 renderer 补丁导出的 <SlotOutlet>;无补丁时不注册任何条目,
+ // 官方侧栏原样工作。
+ if (typeof SlotOutlet !== 'function') {
+ console.warn(
+ '[dsh-tauri-panel] <SlotOutlet> unavailable (renderer patch missing) — panel sidebar disabled, official UI stays.',
+ )
+ return
+ }
+
+ installSidebarRoot(ctx)
+}
diff --git a/packages/dsh-tauri-panel/src/client/locale.ts b/packages/dsh-tauri-panel/src/client/locale.ts
new file mode 100644
index 00000000..d273ad40
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/locale.ts
@@ -0,0 +1,37 @@
+import type { Context } from '@deepseek-ai/cordis'
+
+/**
+ * locale.ts — 本插件文案(zh/en 双语)。命名空间 `panel`:
+ * 克隆 SidebarRoot 的壳控制文案(新会话/折叠开关,与官方 sidebar NS 同值,
+ * 但独立命名空间,互不干扰)。
+ */
+export const NS = 'panel'
+
+const zh = {
+ 'session.new': '新会话',
+ 'session.new.label': '新建会话',
+ 'toggle.open': '打开侧边栏',
+ 'toggle.collapse': '收起侧边栏',
+}
+
+const en: Record<keyof typeof zh, string> = {
+ 'session.new': 'New Session',
+ 'session.new.label': 'New session',
+ 'toggle.open': 'Open sidebar',
+ 'toggle.collapse': 'Collapse sidebar',
+}
+
+/** 注册面板文案命名空间(effect 生命周期,随插件卸载注销)。 */
+export function installPanelLocale(ctx: Context): void {
+ ctx.effect(
+ () => {
+ const disposeZh = ctx.locale.register(NS, 'zh', zh)
+ const disposeEn = ctx.locale.register(NS, 'en', en)
+ return () => {
+ disposeZh()
+ disposeEn()
+ }
+ },
+ 'dsh-tauri-panel: dictionaries',
+ )
+}
diff --git a/packages/dsh-tauri-panel/src/client/service.tsx b/packages/dsh-tauri-panel/src/client/service.tsx
new file mode 100644
index 00000000..695d4508
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/service.tsx
@@ -0,0 +1,213 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { PanelActionItemProps, PanelContentSpec, PanelProtocol } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { PANEL_CLASSES, PANEL_DATA_ATTRIBUTES, PANEL_PROTOCOL_SERVICE, PANEL_VIEW_COMPONENT_ID, PANEL_VIEW_SLOT, SIDEBAR_INTERACTIVE_SELECTOR, SIDEBAR_KEEP_OPEN_SELECTOR, WORKSPACE_GROUP_SELECTOR } from './constants'
+import { NS } from './locale'
+
+export type { PanelActionItemProps, PanelContentSpec, PanelProtocol } from './types'
+
+/**
+ * service.tsx — 面板协议宿主服务(协议能力,见 PROTOCOL.md)。
+ *
+ * 宿主对外只暴露两个构件,子插件无需处理任何状态/机制:
+ * - `<ActionItem>`:面板区条目组件(样式、折叠态、active 态全由宿主承担);
+ * - `renderPanelContent(spec)`:切换会话区替换(conversation 槽条件 shadow),
+ * 子插件在 ActionItem 的 onClick 里调用。
+ *
+ * 机制(全部在宿主,单一权威):
+ * - 服务经 ctx.reflect.provide('panel.protocol', api) 暴露(cordis
+ * ReflectService,官方 runtime 同款用法 ctx.reflect.provide("sessions", this));
+ * - renderPanelContent:conversation 槽(single/session-maybe,layout 声明、
+ * 官方 ui-conversation priority 0 是唯一注册者)以 priority -1 **动态注册**
+ * → 整个右侧会话区被替换(CenterColumn 内、零定位层);官方条目被
+ * shadow 但仍 live(children/locale 有效)。再调(同 id)→ dispose 句柄
+ * → 官方恢复(toggle 语义)。
+ * - 替换状态存共享 snapshot store:ActionItem 经 useSyncExternalStore
+ * 感知「当前替换 id === 自己 id」→ 保持 active(hover)样式。
+ * - 退出时机:无关闭按钮——document capture 层监听 pointerdown,只在侧栏
+ * 内的有效导航/操作控件被点击时恢复官方会话界面;空白区、面板条目和只
+ * 改变工作区列表呈现的控件(工作区折叠行、分组、添加工作区)保持面板。
+ * 右侧区域(第三方悬浮按钮等)不影响替换,避免误关。
+ *
+ * 不能常驻注册 + SlotOutlet 透传:SlotOutlet 对 single 槽只渲染 live 条目,
+ * 自己 live 后渲染官方条目 = 自递归(无公开 API 渲染被 shadow 条目)。
+ */
+
+/** 当前 conversation 替换的 inject 句柄(undefined = 官方会话区 live)。 */
+let conversationSeat: (() => void) | undefined
+/** 当前替换视图规格。 */
+let currentSpec: PanelContentSpec | undefined
+/** 替换状态(ActionItem active 样式订阅源)。 */
+const panelViewStore = createExternalStore<{ id: string } | null>(null)
+/** 根上下文(renderPanelContent 内部注册用)。 */
+let rootCtx: Context | undefined
+
+/** 渲染 conversation 槽条目:包标记容器 + 宿主内容列(宽度约束由宿主决定,见 styles.ts)。 */
+function ConversationSeat({ t }: { t: (key: string) => string }): ReactElement | null {
+ const spec = currentSpec
+ if (!spec)
+ return null
+ const View = spec.render
+ return (
+ <div {...{ [PANEL_DATA_ATTRIBUTES.view]: '' }} className={PANEL_CLASSES.panelView}>
+ {/* 内容列:对齐官方内容列宽度(max-width var(--dsh-chat-content-width, 748px)),
+ 子插件零宽度关注,只负责内容自身布局(垂直方向自定)。 */}
+ <div style={{ padding: '16px 16px 16px 8px' }}>
+ <div className={PANEL_CLASSES.panelViewColumn}>
+ <View t={t} />
+ </div>
+ </div>
+ </div>
+ )
+}
+
+/**
+ * 判断侧栏 pointerdown 是否代表离开当前面板的导航动作:
+ * - 面板视图/条目与空白区不是动作,保持面板;
+ * - 只改变侧栏呈现的控件保持面板(工作区“分组方式”“添加工作区”按钮,
+ * 以及工作区折叠行本体——折叠行内的菜单/新建按钮仍是动作,会关闭);
+ * - 其余在侧栏内的可交互控件(会话行、搜索结果、设置等)视为导航,关闭。
+ */
+export function shouldClosePanelForSidebarTarget(target: Element | null): boolean {
+ if (!target)
+ return false
+ const sidebar = target.closest(`[${PANEL_DATA_ATTRIBUTES.sidebar}]`)
+ if (!sidebar)
+ return false
+ if (target.closest(`[${PANEL_DATA_ATTRIBUTES.view}],[${PANEL_DATA_ATTRIBUTES.action}]`))
+ return false
+ if (target.closest(SIDEBAR_KEEP_OPEN_SELECTOR))
+ return false
+
+ const interactive = target.closest(SIDEBAR_INTERACTIVE_SELECTOR)
+ if (!interactive || !sidebar.contains(interactive))
+ return false
+
+ // 工作区折叠行本身不在可交互集合内(自然保持面板);嵌套按钮(工作区菜单、
+ // 新建会话)是真实动作,按自身语义关闭。
+ const workspaceGroup = target.closest(WORKSPACE_GROUP_SELECTOR)
+ return workspaceGroup === null || interactive !== workspaceGroup
+}
+
+/** 捕获侧栏导航动作并在目标自身的 click 行为执行前恢复官方会话区。 */
+function onPointerDownCapture(event: PointerEvent): void {
+ if (!conversationSeat)
+ return
+ if (shouldClosePanelForSidebarTarget(event.target instanceof Element ? event.target : null))
+ closeConversation()
+}
+
+/** 将面板激活态投影到侧栏根,供官方工作区行的跨插件样式协议使用。 */
+function setSidebarPanelActive(active: boolean): void {
+ const sidebar = document.querySelector(`[${PANEL_DATA_ATTRIBUTES.sidebar}]`)
+ if (active)
+ sidebar?.setAttribute(PANEL_DATA_ATTRIBUTES.active, '')
+ else
+ sidebar?.removeAttribute(PANEL_DATA_ATTRIBUTES.active)
+}
+
+/** 打开会话区替换:动态注册 priority -1 的 conversation 条目。 */
+function openConversation(ctx: Context, spec: PanelContentSpec): void {
+ if (currentSpec && currentSpec.id === spec.id)
+ return
+ if (conversationSeat)
+ closeConversation()
+ currentSpec = spec
+ panelViewStore.set({ id: spec.id })
+ conversationSeat = ctx.slots.inject(PANEL_VIEW_SLOT as never, () =>
+ ctx.slots.register(
+ {
+ name: PANEL_VIEW_SLOT,
+ id: PANEL_VIEW_COMPONENT_ID,
+ priority: -1,
+ locale: spec.locale ?? NS,
+ } as never,
+ ConversationSeat,
+ ))
+ document.addEventListener('pointerdown', onPointerDownCapture, true)
+ setSidebarPanelActive(true)
+}
+
+/** 关闭会话区替换:dispose inject 句柄 → 注销条目 → 官方 ui-conversation 恢复。 */
+function closeConversation(): void {
+ conversationSeat?.()
+ conversationSeat = undefined
+ currentSpec = undefined
+ panelViewStore.set(null)
+ document.removeEventListener('pointerdown', onPointerDownCapture, true)
+ setSidebarPanelActive(false)
+}
+
+/** 订阅当前替换 id(null = 官方会话区)。 */
+function usePanelViewId(): { id: string } | null {
+ return useSyncExternalStore(
+ fn => panelViewStore.subscribe(fn),
+ () => panelViewStore.getSnapshot(),
+ )
+}
+
+/** ActionItem:面板区条目(样式/折叠/active 态全宿主,子插件只填内容与行为)。 */
+export function PanelActionItem({ id, icon, onClick, children }: PanelActionItemProps): ReactElement {
+ const active = usePanelViewId()?.id === id
+ return (
+ <button
+ type="button"
+ className={active ? `${PANEL_CLASSES.menuItem} ${PANEL_CLASSES.menuItemSelected}` : PANEL_CLASSES.menuItem}
+ {...{ [PANEL_DATA_ATTRIBUTES.action]: '' }}
+ onClick={onClick}
+ >
+ {icon !== undefined && <span className={PANEL_CLASSES.menuItemIcon}>{icon}</span>}
+ <span className={PANEL_CLASSES.menuItemLabel}>{children}</span>
+ </button>
+ )
+}
+
+/**
+ * 切换会话区替换:未替换则打开(conversation 槽动态注册 spec.render),
+ * 已替换则关闭恢复官方会话界面。子插件在 ActionItem 的 onClick 里调用。
+ * @param spec - 内容区规格。
+ */
+export function renderPanelContent(spec: PanelContentSpec): void {
+ if (!rootCtx)
+ return
+ if (conversationSeat)
+ closeConversation()
+ else
+ openConversation(rootCtx, spec)
+}
+
+/** 显式关闭当前面板内容;未打开面板时为空操作。 */
+export function closePanelContent(): void {
+ if (conversationSeat)
+ closeConversation()
+}
+
+/**
+ * 安装宿主服务:经 ctx.reflect.provide 暴露 panel.protocol(effect 生命周期,
+ * 插件卸载即注销)。不依赖 renderer 补丁(conversation 注册只走 slots
+ * runtime)——旧核心下内容区替换仍可用(仅面板区条目需 renderer)。
+ * @param ctx - 客户端根上下文。
+ */
+export function installPanelService(ctx: Context): void {
+ const api: PanelProtocol = {
+ ActionItem: PanelActionItem,
+ renderPanelContent,
+ closePanelContent,
+ }
+ // Publish synchronously during apply: alpha slot injections can run before
+ // sibling effects, so publishing from inside ctx.effect makes consumers see
+ // an absent protocol and permanently skip their action registration.
+ rootCtx = ctx
+ const disposeProtocol = ctx.reflect.provide(PANEL_PROTOCOL_SERVICE, api)
+ ctx.effect(() => {
+ return () => {
+ if (rootCtx === ctx) {
+ closePanelContent()
+ rootCtx = undefined
+ }
+ disposeProtocol()
+ }
+ }, 'dsh-tauri-panel: panel.protocol host service')
+}
diff --git a/packages/dsh-tauri-panel/src/client/sidebar.tsx b/packages/dsh-tauri-panel/src/client/sidebar.tsx
new file mode 100644
index 00000000..a72ee00a
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/sidebar.tsx
@@ -0,0 +1,225 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ClientContext, WorkspaceId } from 'dsh-tauri/client'
+import type { CSSProperties, ReactElement } from 'react'
+import type { SidebarRootProps } from './types'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+import { resolveStartSession } from 'dsh-tauri/client'
+import { useEffect, useRef, useState } from 'react'
+import { COLLAPSE_SETTLE_MS, PANEL_CLASSES, PANEL_DATA_ATTRIBUTES, SCROLLBAR_LINGER_MS } from './constants'
+import { ChatOutline, FishMark } from './icons'
+import { NS } from './locale'
+
+/**
+ * sidebar.tsx — sidebar 槽的整槽替换(priority -1 shadow 官方 ui-sidebar)。
+ *
+ * 结构为官方 SidebarRoot(dsh-client-ui-sidebar 0.1.1-rc.2)的克隆,改动点:
+ * - logoRow 高度 60px → 32px、底部间距 8px → 4px(需求①②);
+ * - 「新会话」按钮从 logoRow 下方移入**面板区**(需求③),样式改为
+ * workspace 菜单项行样式(需求④,镜像官方 Rows.module.css .sessionRow);
+ * - 面板区 = 新会话菜单项 + 第三方功能项(槽 `sidebar.panel.action`,
+ * list/root,本条目 children 声明,协议⑤,见 PROTOCOL.md)。
+ *
+ * 渲染官方子槽(brand.mark/brand.name/workspaces/footer.action/settings)一律
+ * 走 <SlotOutlet>(无 children 所有权检查):官方条目仍 live(被 shadow),
+ * 其 children 声明与 locale 注册继续生效;本条目**只**声明新增槽
+ * sidebar.panel.action(子槽 key 全局唯一,绝不重声明官方子槽)。
+ *
+ * 交互行为镜像官方:折叠 settled(COLLAPSE_SETTLE_MS=150)→ wide 判定、
+ * rail-in/fading 动画类、滚动条 linger(quietBars)。
+ */
+
+/** 简易 classnames 拼接。 */
+function cx(...parts: Array<string | false | undefined>): string {
+ return parts.filter(Boolean).join(' ')
+}
+
+/** 克隆的 SidebarRoot:紧凑 logoRow + 面板区 + 官方子槽透传。 */
+function SidebarRootClone({ collapsed, width, startSession, toggleSidebar, t }: SidebarRootProps): ReactElement {
+ const [settled, setSettled] = useState(false)
+ useEffect(() => {
+ setSettled(false)
+ const timer = window.setTimeout(() => {
+ setSettled(true)
+ }, COLLAPSE_SETTLE_MS)
+ return () => {
+ window.clearTimeout(timer)
+ }
+ }, [collapsed])
+
+ const wide = !collapsed || !settled
+ const lastWideWidth = useRef(width)
+ if (!collapsed)
+ lastWideWidth.current = width
+ const everWide = useRef(!collapsed)
+ if (!collapsed)
+ everWide.current = true
+
+ // 滚动条 linger:指针进入取消计时,离开后 2s 把滚动条 thumb 变透明。
+ const [pointerInside, setPointerInside] = useState(false)
+ const lingerTimer = useRef<number | undefined>(undefined)
+ const armLinger = (): void => {
+ if (lingerTimer.current !== undefined)
+ return
+ lingerTimer.current = window.setTimeout(() => {
+ lingerTimer.current = undefined
+ setPointerInside(false)
+ }, SCROLLBAR_LINGER_MS)
+ }
+ const cancelLinger = (): void => {
+ window.clearTimeout(lingerTimer.current)
+ lingerTimer.current = undefined
+ }
+
+ return (
+ <div
+ className={cx(
+ PANEL_CLASSES.root,
+ !wide && PANEL_CLASSES.collapsed,
+ !wide && everWide.current && PANEL_CLASSES.railIn,
+ collapsed && wide && PANEL_CLASSES.fading,
+ !pointerInside && PANEL_CLASSES.quietBars,
+ wide && PANEL_CLASSES.wide,
+ )}
+ {...{ [PANEL_DATA_ATTRIBUTES.sidebar]: '' }}
+ style={wide ? { '--dshp-width': `${collapsed ? lastWideWidth.current : width}px` } as CSSProperties : undefined}
+ onPointerEnter={() => {
+ cancelLinger()
+ setPointerInside(true)
+ }}
+ onPointerLeave={() => {
+ armLinger()
+ }}
+ >
+ <div className={PANEL_CLASSES.logoRow}>
+ {wide && (
+ <button
+ type="button"
+ className={PANEL_CLASSES.brand}
+ aria-label={t('session.new.label')}
+ onClick={() => {
+ console.warn('[dsh-tauri-panel] new session requested', { source: 'brand' })
+ try {
+ startSession()
+ }
+ catch (error) {
+ console.error('[dsh-tauri-panel] new session failed', error)
+ }
+ }}
+ >
+ <span className={PANEL_CLASSES.brandIdentity} aria-hidden="true">
+ <span className={PANEL_CLASSES.brandMark}>
+ <SlotOutlet
+ slotKey="sidebar.brand.mark"
+ ownerProps={{ size: 24 }}
+ opts={{ fallback: <FishMark size={24} /> }}
+ />
+ </span>
+ <span className={PANEL_CLASSES.brandName}>
+ <SlotOutlet
+ slotKey="sidebar.brand.name"
+ ownerProps={{}}
+ opts={{ fallback: <span className={PANEL_CLASSES.fallbackBrandName}>DSH Local Build</span> }}
+ />
+ </span>
+ </span>
+ </button>
+ )}
+ <button
+ type="button"
+ className={`${PANEL_CLASSES.iconButton} ${PANEL_CLASSES.toggle}`}
+ aria-label={collapsed ? t('toggle.open') : t('toggle.collapse')}
+ title={collapsed ? t('toggle.open') : t('toggle.collapse')}
+ onClick={() => toggleSidebar()}
+ >
+ {!wide && (
+ <span className={PANEL_CLASSES.railMark} aria-hidden="true">
+ <SlotOutlet
+ slotKey="sidebar.brand.mark"
+ ownerProps={{ size: 24 }}
+ opts={{ fallback: <FishMark size={24} /> }}
+ />
+ </span>
+ )}
+ </button>
+ </div>
+ {/* <div className="dshp-sectionHeader">
+ <span className="dshp-sectionHeaderTitle">工作面板</span>
+ </div> */}
+ <div className={PANEL_CLASSES.panelArea}>
+ <button
+ type="button"
+ className={`${PANEL_CLASSES.menuItem} ${PANEL_CLASSES.newSession}`}
+ title={t('session.new.label')}
+ onClick={() => {
+ console.warn('[dsh-tauri-panel] new session requested', { source: 'menu' })
+ try {
+ startSession()
+ }
+ catch (error) {
+ console.error('[dsh-tauri-panel] new session failed', error)
+ }
+ }}
+ >
+ <span className={PANEL_CLASSES.menuItemIcon}><ChatOutline size={wide ? 14 : 18} /></span>
+ <span className={PANEL_CLASSES.menuItemLabel}>{t('session.new')}</span>
+ </button>
+ <SlotOutlet slotKey="sidebar.panel.action" ownerProps={{ wide }} />
+ </div>
+
+ <div className={PANEL_CLASSES.regionArea}>
+ <SlotOutlet
+ slotKey="sidebar.workspaces"
+ ownerProps={{
+ wide,
+ expandSidebar: () => {
+ if (collapsed)
+ toggleSidebar()
+ },
+ }}
+ />
+ </div>
+
+ <div className={PANEL_CLASSES.footArea}>
+ <div className={PANEL_CLASSES.footerActions}>
+ <SlotOutlet slotKey="sidebar.footer.action" ownerProps={{ wide }} />
+ </div>
+ <div className={PANEL_CLASSES.settingsArea}>
+ <SlotOutlet slotKey="sidebar.settings" ownerProps={{ wide }} />
+ </div>
+ </div>
+ </div>
+ )
+}
+
+/**
+ * 注册:等待 sidebar 槽声明(layout 的 AppFrame renderSlot("sidebar"))后,
+ * 以 priority -1 shadow 官方 ui-sidebar 条目;children 仅声明新增的
+ * sidebar.panel.action 协议槽。
+ * @param ctx - 客户端根上下文。
+ */
+export function installSidebarRoot(ctx: Context): void {
+ ctx.slots.inject('sidebar' as never, () =>
+ ctx.slots.register(
+ {
+ name: 'sidebar',
+ id: 'dsh-tauri-panel',
+ priority: -1,
+ locale: NS,
+ children: {
+ 'sidebar.panel.action': { kind: 'list', scope: 'root' },
+ },
+ inject: () => ({
+ startSession: (workspaceId?: WorkspaceId) => {
+ const start = resolveStartSession(ctx as ClientContext)
+ if (start === undefined) {
+ console.error('[dsh-tauri-panel] new session unavailable: no workspace navigation service')
+ return
+ }
+ void start(workspaceId)
+ },
+ toggleSidebar: () => ctx.layout.toggleSidebar(),
+ }),
+ } as never,
+ SidebarRootClone,
+ ))
+}
diff --git a/packages/dsh-tauri-panel/src/client/styles.ts b/packages/dsh-tauri-panel/src/client/styles.ts
new file mode 100644
index 00000000..0e56de45
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/styles.ts
@@ -0,0 +1,134 @@
+/** CSS generated as css-render nodes so every declaration remains structured. */
+import { CssRender } from 'dsh-tauri/client'
+import { PANEL_DATA_ATTRIBUTES, PANEL_STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+
+const panelStyle = c([
+ c('.dshp-sectionHeader', {
+ boxSizing: 'border-box',
+ height: '36px',
+ color: 'var(--dsw-alias-label-tertiary)',
+ borderRadius: '12px',
+ flex: 'none',
+ alignItems: 'center',
+ gap: '4px',
+ marginBottom: '4px',
+ paddingLeft: '8px',
+ display: 'flex',
+ overflow: 'hidden',
+ }),
+ c('.dshp-sectionHeaderTitle', {
+ whiteSpace: 'nowrap',
+ opacity: 1,
+ visibility: 'visible',
+ minWidth: 0,
+ maxWidth: '45%',
+ transition: 'max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear',
+ flex: 'none',
+ lineHeight: '20px',
+ overflow: 'hidden',
+ }),
+ c('.dshp-collapsed .dshp-sectionHeaderTitle', { opacity: 0, visibility: 'hidden', maxWidth: 0 }),
+ c('.dshp-root', {
+ '--dshp-padding': '12px',
+ 'height': '100%',
+ 'padding': '6px var(--dshp-padding)',
+ 'boxSizing': 'border-box',
+ 'background': 'var(--dsw-specific-sidebar-fill)',
+ 'color': 'var(--dsw-alias-label-primary)',
+ '--dsh-scrollbar-thumb': 'var(--dsw-alias-scrollbar-bg-l2)',
+ '--dsh-scrollbar-thumb-hover': 'var(--dsw-alias-scrollbar-hover-l2)',
+ 'flexDirection': 'column',
+ 'fontSize': '14px',
+ 'display': 'flex',
+ '--dsh-sidebar-inline-padding': 'var(--dshp-padding)',
+ }),
+ c('.dshp-root.dshp-collapsed', { padding: '18px 10px 6px' }),
+ c('.dshp-root.dshp-wide', { width: 'var(--dshp-width)' }),
+ c('.dshp-root.dshp-quietBars', { '--dsh-scrollbar-thumb': 'transparent', '--dsh-scrollbar-thumb-hover': 'transparent' }),
+ c('.dshp-fading>*', { opacity: 0, transition: 'opacity .15s var(--ds-ease-in-out)' }),
+ c('.dshp-logoRow', { boxSizing: 'border-box', flex: 'none', justifyContent: 'flex-end', alignItems: 'center', gap: '8px', height: '60px', marginBottom: '4px', padding: '4px 0 4px 4px', display: 'flex', overflow: 'hidden' }),
+ c('.dshp-collapsed .dshp-logoRow', { justifyContent: 'flex-start', height: '40px', marginBottom: '4px', padding: 0 }),
+ c('.dshp-brand', { minWidth: 0, color: 'inherit', cursor: 'pointer', background: 'transparent', border: 'none', flex: 1, alignItems: 'center', padding: 0, display: 'inline-flex', overflow: 'hidden' }),
+ c('.dshp-brandIdentity', { alignItems: 'center', gap: '8px', minWidth: 0, height: '24px', display: 'inline-flex' }),
+ c('.dshp-brandMark', { flex: 'none', justifyContent: 'center', alignItems: 'center', display: 'inline-flex' }),
+ c('.dshp-brandName', { letterSpacing: '.04em', alignItems: 'center', gap: '6px', minWidth: 0, height: '24px', fontSize: '18px', fontWeight: 600, lineHeight: '24px', display: 'inline-flex' }),
+ c('.dshp-fallbackBrandName', { letterSpacing: 0, whiteSpace: 'nowrap', fontSize: '17px' }),
+ c('.dshp-iconButton', { cursor: 'pointer', width: '28px', height: '28px', color: 'var(--dsw-alias-label-secondary)', background: 'transparent', border: 'none', borderRadius: '50%', flex: 'none', justifyContent: 'center', alignItems: 'center', padding: 0, display: 'inline-flex' }, [c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' })]),
+ c('.dshp-collapsed .dshp-iconButton', { width: '36px', height: '36px', color: 'var(--dsw-alias-label-primary)' }),
+ c('.dshp-railMark', { justifyContent: 'center', alignItems: 'center', display: 'inline-flex' }),
+ c('.dshp-panelArea', { flex: 'none', flexDirection: 'column', alignItems: 'stretch', gap: '2px', margin: 0, display: 'flex', marginRight: 'var(--dsh-session-list-scrollbar-offset)', paddingLeft: '4px', paddingRight: 'calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset))' }),
+ c('.dshp-collapsed .dshp-panelArea', { alignItems: 'center', gap: '4px' }),
+ c('.dshp-menuItem', {
+ boxSizing: 'border-box',
+ appearance: 'none',
+ cursor: 'pointer',
+ userSelect: 'none',
+ width: '100%',
+ minWidth: 0,
+ height: '34px',
+ flex: 'none',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '6px',
+ padding: '0 8px',
+ border: 0,
+ borderRadius: '8px',
+ overflow: 'hidden',
+ background: 'transparent',
+ color: 'var(--dsw-alias-label-primary)',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ fontWeight: 400,
+ lineHeight: '22px',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+ transition: 'background-color .12s var(--ds-ease-in-out), color .12s var(--ds-ease-in-out)',
+ }, [c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }), c('&:focus-visible', { outline: '2px solid var(--dsw-alias-border-focus)', outlineOffset: '-2px' })]),
+ c('.dshp-menuItemSelected,.dshp-menuItemSelected:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ c('.dshp-newSession', { width: '100%', height: '38px', margin: '0 0 4px', padding: '8px 16px', border: '1px solid var(--dsw-alias-border-l2)', borderRadius: '12px', background: 'var(--dsw-alias-button-elevated-fill)', justifyContent: 'center', alignItems: 'center', gap: '6px', fontWeight: 500 }, [c('&:hover', { background: 'var(--dsw-alias-button-floating-hover)' })]),
+ c('.dshp-menuItemIcon', {
+ boxSizing: 'border-box',
+ flex: 'none',
+ justifyContent: 'center',
+ alignItems: 'center',
+ display: 'inline-flex',
+ fontSize: '16px',
+ }),
+ c('.dshp-menuItemLabel', { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', margin: '0 6px 0 0' }),
+ c('.dshp-collapsed .dshp-menuItem', { justifyContent: 'center', alignSelf: 'flex-start', width: '36px', minWidth: '36px', height: '36px', padding: 0, gap: 0, borderRadius: '12px' }),
+ c('.dshp-collapsed .dshp-menuItemLabel', { display: 'none' }),
+ c('.dshp-collapsed .dshp-panelArea', { marginBottom: '12px', paddingLeft: 0 }),
+ c('.dshp-collapsed .dshp-menuItemIcon', {
+ fontSize: '18px',
+ color: 'var(--dsw-alias-label-primary)',
+ }),
+ c('.dshp-collapsed .dshp-newSession', { borderColor: 'transparent', justifyContent: 'center', width: '36px', height: '36px', margin: 0, padding: 0, gap: 0 }),
+ c('.dshp-regionArea', { minHeight: 0, marginRight: 'calc(-1 * var(--dshp-padding))', flexDirection: 'column', flex: 1, padding: '0 4px', display: 'flex', overflow: 'hidden' }),
+ c('.dshp-collapsed .dshp-regionArea', { marginLeft: 0, marginRight: 0, padding: 0 }),
+ c('.dshp-footArea', { flexDirection: 'column', flex: 'none', display: 'flex' }),
+ c('.dshp-settingsArea,.dshp-footerActions', { flex: 'none', width: '100%', minWidth: 0 }),
+ c('.dshp-footerActions', { display: 'flex' }),
+ c('.dshp-collapsed .dshp-footArea', { alignItems: 'center' }),
+ c('.dshp-collapsed .dshp-settingsArea,.dshp-collapsed .dshp-footerActions', { justifyContent: 'center', width: 'auto', display: 'flex' }),
+ c('.dshp-panelView', { height: '100%', boxSizing: 'border-box', minWidth: 0, overflowY: 'auto', scrollbarGutter: 'stable' }),
+ c('.dshp-panelViewColumn', { maxWidth: 'var(--dsh-chat-content-width,780px)', minHeight: '100%', width: '100%', margin: '0 auto', flexDirection: 'column', gap: '16px', display: 'flex' }),
+ // 面板激活期间,侧栏工作区单项撤销 hover 底色(仅非选中行;选中行保留
+ // 自己的选中态,避免点按目标不可辨)。语义选择器按官方 aria 状态匹配,
+ // 不依赖 css-module hash。
+ c(`[${PANEL_DATA_ATTRIBUTES.active}] [role="treeitem"]:not([aria-selected="true"]):hover`, { background: 'transparent' }),
+ c('@keyframes dshp-rail-in', [c('from', { opacity: 0, transform: 'translate(49px)' })]),
+ c('@keyframes dshp-rail-fade-in', [c('from', { opacity: 0 })]),
+ c('@media (prefers-reduced-motion: reduce)', [c('.dshp-fading>*', { transition: 'none' }), c('.dshp-railIn .dshp-iconButton,.dshp-railIn .dshp-menuItem,.dshp-railIn .dshp-footArea,.dshp-railIn .dshp-regionArea', { animation: 'none' })]),
+])
+
+export function mountPanelStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(PANEL_STYLE_ID) !== null)
+ return () => {}
+ panelStyle.mount({ id: PANEL_STYLE_ID, head: true })
+ return () => panelStyle.unmount({ id: PANEL_STYLE_ID })
+}
diff --git a/packages/dsh-tauri-panel/src/client/types.ts b/packages/dsh-tauri-panel/src/client/types.ts
new file mode 100644
index 00000000..790fb454
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/types.ts
@@ -0,0 +1,53 @@
+import type { ComponentType, ReactElement, ReactNode } from 'react'
+
+/** 侧栏槽 owner 传入的合成 props 子集。 */
+export interface SidebarRootProps {
+ /** 侧栏折叠态(layout 的 sidebarCol 状态)。 */
+ collapsed: boolean
+ /** 侧栏宽度(wide 态生效)。 */
+ width: number
+ /** 开始新会话(inject:ctx.workspaces.startSession)。 */
+ startSession: (workspaceId?: string) => void
+ /** 折叠/展开切换(inject:ctx.layout.toggleSidebar)。 */
+ toggleSidebar: () => void
+ /** 本条目 locale 翻译函数(panel NS)。 */
+ t: (key: string) => string
+}
+
+/** 内容区替换规格(renderPanelContent 入参)。 */
+export interface PanelContentSpec {
+ /** 视图唯一标识(同一时刻只存在一个替换;active 态以它匹配 ActionItem)。 */
+ id: string
+ /** 视图组件:宿主渲染时按标准 kit 传入 t(可选,自包含组件可忽略)。 */
+ render: ComponentType<{ t?: (key: string) => string }>
+ /** 视图文案命名空间(可选,默认宿主 'panel';视图可声明自己的 NS)。 */
+ locale?: string
+}
+
+/** panel.protocol 的稳定服务面。 */
+export interface PanelProtocol {
+ /** 面板区条目组件:样式、折叠态与 active 态由宿主承担。 */
+ ActionItem: (props: PanelActionItemProps) => ReactElement
+ /** 切换会话区替换:当前关闭则打开,当前打开则恢复会话。 */
+ renderPanelContent: (spec: PanelContentSpec) => void
+ /** 显式恢复官方会话区;用于面板内需要跳转到会话的动作。 */
+ closePanelContent: () => void
+}
+
+/** ActionItem 合成 props:id + 图标 + 点击行为 + 文字(子插件只填这些)。 */
+export interface PanelActionItemProps {
+ /** 条目唯一标识(active 态:当前内容区替换 id 与之相等则保持选中样式)。 */
+ id: string
+ /** 条目图标(16px 语义,自绘 SVG 组件实例)。 */
+ icon?: ReactElement
+ /** 点击行为:自定义动作;打开内容区替换典型写法是调 renderPanelContent。 */
+ onClick?: () => void
+ /** 条目文字(wide 态显示;折叠态宿主 CSS 自动隐藏,只留图标钮)。 */
+ children?: ReactNode
+}
+
+/** 自绘 SVG 图标的通用 props。 */
+export interface IconProps {
+ size?: number
+ className?: string
+}
diff --git a/packages/dsh-tauri-panel/src/index.ts b/packages/dsh-tauri-panel/src/index.ts
new file mode 100644
index 00000000..dd2b5663
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/index.ts
@@ -0,0 +1,6 @@
+/**
+ * dsh-tauri-panel 宿主侧(node half):纯浏览器插件,无宿主行为。
+ * loader 按行名导入包根时需要一个可挂载的插件入口;与官方浏览器插件
+ * (如 dsh-client-ui-layout)一致,这里提供空 apply。
+ */
+export function apply(): void {}
diff --git a/packages/dsh-tauri-panel/tsdown.config.ts b/packages/dsh-tauri-panel/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-panel/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri-rightclick/README.md b/packages/dsh-tauri-rightclick/README.md
new file mode 100644
index 00000000..b84ead42
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/README.md
@@ -0,0 +1,77 @@
+# dsh-tauri-rightclick
+
+为 DeepSeek Harness 应用封装端提供更完整、接近原生客户端的鼠标右键体验,覆盖会话、工作区、未分组会话、设置页、对话正文、链接与输入框。菜单与提示文案支持中英文并自动跟随宿主 UI 语言。官方已有的会话操作转交官方组件。
+
+> [!WARNING]
+> 本插件面向承载 DeepSeek Harness Web UI 的应用封装端(Tauri、EAC、Electron、WebView2、CEF、Qt WebEngine 等),不面向直接在普通浏览器中打开的 `dsh web`。
+
+## 安装
+
+在承载 Web UI 的 Profile(例如 `web` 或 `tauri`)下安装本工作区的构建产物:
+
+```bash
+pnpm --filter dsh-tauri-rightclick build
+dsh plugin --profile web add ./packages/dsh-tauri-rightclick
+```
+
+重启 `dsh web` 或承载它的应用封装端后生效。
+
+### 更新 / 卸载
+
+```bash
+dsh plugin --profile web up dsh-tauri-rightclick
+dsh plugin --profile web remove dsh-tauri-rightclick
+```
+
+## 内置上下文
+
+- 会话:官方重命名、分叉、归档;打开目录、复制目录和会话 ID;临时“新会话”不处理。
+- 工作区及其“新会话”入口:新建会话、打开目录、重命名、复制路径、归档会话和安全移除工作区。
+- “未分组”:归档全部未分组正式会话、刷新。
+- 普通文本:复制所选文本;全选严格限定在当前对话内容 slot 或设置弹窗,不包含应用侧边栏。
+- 链接或选中的网址:使用系统默认浏览器打开、复制链接。
+- 输入框:撤销、重做、剪切、复制、粘贴、全选。
+- 所有插件菜单:刷新当前 Harness 页面。
+
+## 兼容策略
+
+- 不修改 `@deepseek-ai/*`、Tauri 壳或其他社区插件。
+- 通过会话行的无障碍语义定位目标,通过 `sessions` 和 `workspaces` 公开服务执行业务;无法确认目标时保留浏览器默认菜单。
+- 常规操作继续使用 Harness 公开服务;打开 URL 通过插件宿主路由交给系统默认浏览器。
+- 插件卸载后不留下补丁。
+- 与 dsh-better-sidebar 共存:better-sidebar 会包装宿主的 `workspaces.openPath` 把所有路径导向侧边栏编辑器。为避免目录被当文件打开(`xxx is a directory`),本插件“在资源管理器中打开”直接调用宿主 RPC `host.openPath`(`POST /api/host.openPath`),目录始终交给系统文件管理器;URL 不会传入文件路径接口,而由插件宿主路由交给系统默认浏览器。
+
+## 扩展协议
+
+其他 Web 插件可通过全局注册表登记扩展信息。`run` 会在点击菜单项时执行,`visible` 可按会话决定是否显示:
+
+```js
+const menu = globalThis[Symbol.for('dsh.rightclick-menu.extensions')]
+const dispose = menu.register({
+ id: 'example.session-details',
+ order: 100,
+ label: '会话详情',
+ visible: ({ session }) => Boolean(session),
+ run: ({ session }) => console.log(session),
+})
+```
+
+每次打开右键菜单还会派发 `dsh:rightclick-menu` 事件,`detail` 包含 `row`、官方菜单 `action`、`session`、`workspace`、原始 `target`、鼠标坐标 `x/y` 和当前 `extensions`。扩展插件应在卸载时调用注册返回的 disposer。
+
+## 宿主 API
+
+| 路由 | 方法 | 说明 |
+| --- | --- | --- |
+| `/api/dsh-rightclick-menu/open-url` | POST | 系统默认浏览器打开外链(同源 JSON;body: `{ url }`,仅 http/https) |
+
+## 为什么不在会话菜单提供“置顶会话”
+
+Codex 的“置顶聊天”由独立的 pin 状态驱动:被置顶的会话固定显示在置顶分区,未置顶的会话仍按最近更新时间排序。DeepSeek Harness 当前公开的会话与工作区状态中没有对应的 `pinned` 字段、置顶集合、置顶 RPC 或状态变更事件;侧栏只有“最近更新”和“手动排序”两种整体排序方式,都无法同时满足“固定置顶 + 其他会话继续按时间排序”。因此本插件不提供置顶,也不会用切换全局手动排序、直接修改 Harness 本地存储、重排 React DOM 或修改会话日志等方式模拟置顶。
+
+## 开发
+
+```bash
+pnpm --filter dsh-tauri-rightclick dev # tsdown --watch
+pnpm --filter dsh-tauri-rightclick test # vitest
+pnpm --filter dsh-tauri-rightclick typecheck
+```
diff --git a/packages/dsh-tauri-rightclick/cordis.patch.yml b/packages/dsh-tauri-rightclick/cordis.patch.yml
new file mode 100644
index 00000000..5c0fcd4c
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-rightclick
+ name: dsh-tauri-rightclick
diff --git a/packages/dsh-tauri-rightclick/package.json b/packages/dsh-tauri-rightclick/package.json
new file mode 100644
index 00000000..ba36209c
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "dsh-tauri-rightclick",
+ "type": "module",
+ "version": "0.6.7",
+ "description": "Native-style right-click context menus for DeepSeek Harness desktop wrappers (sessions, workspaces, conversation text, links, inputs).",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "context-menu",
+ "tauri",
+ "webview",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "@deepseek-ai/dsh-client-ui-primitives",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/actions.ts b/packages/dsh-tauri-rightclick/src/client/actions.ts
new file mode 100644
index 00000000..1fae87cf
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/actions.ts
@@ -0,0 +1,202 @@
+/**
+ * actions.ts — 菜单项对应的业务动作:官方操作转交官方组件;插件自有能力
+ * (资源管理器、默认浏览器打开外链、剪贴板)走宿主能力。
+ */
+import type {
+ SessionsRuntimeLike,
+ SessionSummaryLike,
+ WorkspacesRuntimeLike,
+ WorkspaceViewLike,
+} from './types'
+import { confirmDialog } from './confirm-dialog'
+import { HOST_OPEN_PATH_ENDPOINT, OPEN_URL_ROUTE } from './constants'
+import { toast } from './dialog'
+import { text } from './locale'
+import { externalUrl, officialAction } from './locate'
+
+/**
+ * 资源管理器打开目录:直接调用宿主 RPC host.openPath(HTTP 端点
+ * /api/host.openPath),绕过 better-sidebar 对 workspaces.openPath 的包装——
+ * 否则目录会被侧边栏编辑器当文件打开(`xxx is a directory`)。
+ */
+export async function openInExplorer(path: string): Promise<void> {
+ const response = await fetch(HOST_OPEN_PATH_ENDPOINT, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ type: 'client-request',
+ rpcId: crypto.randomUUID(),
+ method: 'host.openPath',
+ payload: { path },
+ }),
+ })
+ if (!response.ok)
+ throw new Error(text('openFailed', { reason: `HTTP ${response.status}` }))
+ const full = await response.json()
+ if (!full.result?.ok)
+ throw new Error(text('openFailed', { reason: full.result?.error?.message || text('unknownError') }))
+}
+
+/** 用系统默认浏览器打开外链(插件宿主路由,只收 http/https)。 */
+export async function openExternalUrl(value: string): Promise<void> {
+ const url = externalUrl(value)
+ if (!url)
+ throw new Error(text('openFailed', { reason: text('invalidLink') }))
+ const response = await fetch(OPEN_URL_ROUTE, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ url }),
+ })
+ let result: { ok?: boolean, error?: string } | null = null
+ try {
+ result = await response.json()
+ }
+ catch {}
+ if (!response.ok || !result?.ok)
+ throw new Error(text('openFailed', { reason: result?.error || `HTTP ${response.status}` }))
+}
+
+/** 官方菜单项选择:点击行内操作按钮后在 [role=menuitem] 中按文案点目标项。 */
+async function officialSelect(row: Element, labels: RegExp[], failureMessage: string): Promise<void> {
+ let action = officialAction(row)
+ if (!action) {
+ row.dispatchEvent(new MouseEvent('mouseover', {
+ bubbles: true,
+ clientX: row.getBoundingClientRect().left + 8,
+ clientY: row.getBoundingClientRect().top + 8,
+ }))
+ await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))
+ action = officialAction(row)
+ }
+ if (!action)
+ throw new Error(text('officialSessionActionUnavailable'))
+ action.click()
+ setTimeout(() => {
+ const item = [...document.querySelectorAll<HTMLElement>('[role="menuitem"]')].find(node =>
+ labels.some(label => label.test(node.textContent?.trim() || '')))
+ if (!item) {
+ toast(failureMessage)
+ return
+ }
+ item.click()
+ }, 0)
+}
+
+/** 重命名会话:行内有官方操作按钮时走官方重命名,否则回退插件 prompt + rename RPC。 */
+export async function renameSession(
+ sessions: SessionsRuntimeLike,
+ row: Element,
+ session: SessionSummaryLike | null,
+): Promise<void> {
+ if (officialAction(row)) {
+ await officialSelect(row, [/^重命名$/, /^rename$/i], text('officialRenameUnavailable'))
+ return
+ }
+ if (!session)
+ throw new Error(text('sessionUnknown'))
+ // 官方重命名不可用时回退原生 prompt(插件不引入额外弹窗组件)。
+ // eslint-disable-next-line no-alert
+ const title = globalThis.prompt(text('renameSession'), session.displayTitle || session.title || '')
+ if (title === null || title.trim() === (session.title || session.displayTitle))
+ return
+ if (!title.trim())
+ throw new Error(text('sessionNameEmpty'))
+ const binding = sessions.binding(session.id)
+ if (!binding)
+ throw new Error(text('sessionServiceUnavailable'))
+ const result = await binding.session.rename(title.trim())
+ if (!result.ok)
+ throw new Error(result.error?.message || text('renameFailed'))
+ toast(text('sessionRenamed'))
+}
+
+/** 归档会话:优先官方归档菜单,回退 workspaces.archiveSession。 */
+export async function archiveSession(
+ workspaces: WorkspacesRuntimeLike,
+ row: Element,
+ session: SessionSummaryLike | null,
+): Promise<void> {
+ if (officialAction(row)) {
+ await officialSelect(row, [/^归档会话$/, /^archive( session)?$/i], text('officialArchiveUnavailable'))
+ return
+ }
+ if (!session)
+ throw new Error(text('sessionUnknown'))
+ await workspaces.archiveSession(session.id)
+ toast(text('sessionArchived'))
+}
+
+/** 分叉会话:优先官方分叉菜单,回退 sessions.fork + open。 */
+export async function forkSession(
+ sessions: SessionsRuntimeLike,
+ row: Element,
+ session: SessionSummaryLike | null,
+): Promise<void> {
+ if (officialAction(row)) {
+ await officialSelect(row, [/^分叉会话$/, /^fork( session)?$/i], text('officialForkUnavailable'))
+ return
+ }
+ if (!session)
+ throw new Error(text('sessionUnknown'))
+ const childId = await sessions.fork({ sessionId: session.id, increaseTitle: true })
+ sessions.open(childId)
+}
+
+/** 归档整个工作区(跳过已归档的会话,客户端样式确认后逐个归档)。 */
+export async function archiveUngroupedSessions(workspaces: WorkspacesRuntimeLike, sessions: SessionsRuntimeLike): Promise<void> {
+ const snapshot = workspaces.list.getSnapshot()
+ const archived = new Set(snapshot.archivedSessionIds)
+ const assigned = new Set(snapshot.items.flatMap(workspace => workspace.sessionIds))
+ const sessionSnapshot = sessions.list.getSnapshot()
+ const sessionIds = sessionSnapshot.ids.filter((id) => {
+ const session = sessionSnapshot.byId[id]
+ return !assigned.has(id) && !archived.has(id) && session?.blank !== true
+ })
+ if (!sessionIds.length) {
+ toast(text('noUngroupedSessions'))
+ return
+ }
+ const ok = await confirmDialog({
+ title: text('archiveUngroupedTitle', { count: sessionIds.length }),
+ description: text('archiveUngroupedDescription', { count: sessionIds.length }),
+ confirmLabel: text('archiveWorkspaceConfirmAction'),
+ })
+ if (!ok)
+ return
+ for (const id of sessionIds)
+ await workspaces.archiveSession(id)
+ toast(text('workspaceSessionsArchived', { count: sessionIds.length }))
+}
+
+/** 归档整个工作区(跳过已归档的会话,客户端样式确认后逐个归档)。 */
+export async function archiveWorkspaceSessions(workspaces: WorkspacesRuntimeLike, workspace: WorkspaceViewLike): Promise<void> {
+ const archived = new Set(workspaces.list.getSnapshot().archivedSessionIds)
+ const sessionIds = workspace.sessionIds.filter(id => !archived.has(id))
+ if (!sessionIds.length) {
+ toast(text('noWorkspaceSessions'))
+ return
+ }
+ const ok = await confirmDialog({
+ title: text('archiveWorkspaceTitle', { count: sessionIds.length }),
+ description: text('archiveWorkspaceDescription', { workspace: workspace.title }),
+ confirmLabel: text('archiveWorkspaceConfirmAction'),
+ })
+ if (!ok)
+ return
+ for (const id of sessionIds)
+ await workspaces.archiveSession(id)
+ toast(text('workspaceSessionsArchived', { count: sessionIds.length }))
+}
+
+/** 删除工作区(官方非破坏性删除:仅移除注册,文件夹与会话记录保留,会话归入未分组)。 */
+export async function deleteWorkspaceAction(workspaces: WorkspacesRuntimeLike, workspace: WorkspaceViewLike): Promise<void> {
+ const ok = await confirmDialog({
+ title: text('deleteWorkspaceTitle'),
+ description: text('deleteWorkspaceDescription', { title: workspace.title }),
+ confirmLabel: text('deleteWorkspaceConfirm'),
+ })
+ if (!ok)
+ return
+ await workspaces.delete(workspace.workspaceId)
+ toast(text('workspaceDeleted'))
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/clipboard.ts b/packages/dsh-tauri-rightclick/src/client/clipboard.ts
new file mode 100644
index 00000000..cbf6c294
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/clipboard.ts
@@ -0,0 +1,48 @@
+/** clipboard.ts — 剪贴板读写(Clipboard API 优先,回退 execCommand 复制)。 */
+
+import type { LocaleKey } from './types'
+import { toast } from './dialog'
+import { text } from './locale'
+
+/** 回退复制:临时 textarea + document.execCommand(Clipboard API 不可写时兜底)。 */
+function legacyCopy(value: string): void {
+ const field = document.createElement('textarea')
+ field.value = value
+ field.setAttribute('readonly', '')
+ field.style.cssText = 'position:fixed;left:-9999px;top:0'
+ document.body.appendChild(field)
+ field.select()
+ const copied = document.execCommand('copy')
+ field.remove()
+ if (!copied)
+ throw new Error(text('clipboardUnavailable'))
+}
+
+/** 写剪贴板(Clipboard API 失败时回退 execCommand)。 */
+export async function writeClipboard(value: string): Promise<void> {
+ if (navigator.clipboard?.writeText) {
+ try {
+ await navigator.clipboard.writeText(value)
+ return
+ }
+ catch {}
+ }
+ legacyCopy(value)
+}
+
+/** 读剪贴板(只读失败时抛出;宿主禁止读取时提示用 Ctrl+V)。 */
+export async function readClipboard(): Promise<string> {
+ if (navigator.clipboard?.readText) {
+ try {
+ return await navigator.clipboard.readText()
+ }
+ catch {}
+ }
+ throw new Error(text('clipboardReadFailed'))
+}
+
+/** 复制并 toast 一条成功提示。 */
+export async function copyText(value: string, messageKey: LocaleKey): Promise<void> {
+ await writeClipboard(value)
+ toast(text(messageKey))
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/confirm-dialog.ts b/packages/dsh-tauri-rightclick/src/client/confirm-dialog.ts
new file mode 100644
index 00000000..5a382a69
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/confirm-dialog.ts
@@ -0,0 +1,51 @@
+/**
+ * confirm-dialog.ts — 客户端样式确认弹窗(primitives Modal),替代原生 confirm。
+ *
+ * 内嵌 WebView2 里的 `window.confirm` 会以「127.0.0.1:3080 嵌入页提示」横幅出现,
+ * 不随客户端 UI 主题(#235)。这里用与官方一致的 primitives Modal 渲染,
+ * Promise 化以便 await;仅依赖宿主提供的 react / primitives。
+ */
+import type { ReactElement } from 'react'
+import { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
+import { createElement } from 'react'
+import { createRoot } from 'react-dom/client'
+import { text } from './locale'
+
+/** 确认弹窗内容(标题 / 描述 / 确认按钮文案)。 */
+export interface ConfirmDialogOptions {
+ title: string
+ description: string
+ confirmLabel: string
+}
+
+/**
+ * 打开客户端样式确认框:确认 resolve(true),取消 / 关闭 resolve(false)。
+ * 弹窗挂到 document.body 的临时宿主,关闭后卸载并移除。
+ */
+export function confirmDialog(options: ConfirmDialogOptions): Promise<boolean> {
+ if (typeof document === 'undefined')
+ return Promise.resolve(false)
+ return new Promise((resolve) => {
+ const host = document.createElement('div')
+ document.body.append(host)
+ const root = createRoot(host)
+ const close = (result: boolean): void => {
+ root.unmount()
+ host.remove()
+ resolve(result)
+ }
+ const footer: ReactElement = createElement(
+ 'div',
+ {},
+ createElement(Button, { variant: 'ghost', onClick: () => close(false), style: { marginRight: 6 } }, text('cancel')),
+ createElement(Button, { variant: 'outline', onClick: () => close(true) }, options.confirmLabel),
+ )
+ root.render(createElement(Modal, {
+ open: true,
+ onClose: () => close(false),
+ title: options.title,
+ description: options.description,
+ footer,
+ }))
+ })
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/constants.ts b/packages/dsh-tauri-rightclick/src/client/constants.ts
new file mode 100644
index 00000000..e5cb0ad8
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/constants.ts
@@ -0,0 +1,43 @@
+/** Shared protocol and UI constants for the dsh-tauri-rightclick client plugin. */
+
+export const RIGHTCLICK_CLIENT_PLUGIN = 'dsh-tauri-rightclick'
+export const RIGHTCLICK_CLIENT_NS = RIGHTCLICK_CLIENT_PLUGIN
+export const RIGHTCLICK_API_PREFIX = '/api/dsh-rightclick-menu'
+
+/** 用系统默认浏览器打开外链(POST,同源 JSON)。 */
+export const OPEN_URL_ROUTE = `${RIGHTCLICK_API_PREFIX}/open-url`
+/** 宿主 openPath RPC(资源管理器打开目录;绕过 better-sidebar 对 workspaces.openPath 的包装)。 */
+export const HOST_OPEN_PATH_ENDPOINT = '/api/host.openPath'
+
+/** css-render style id。 */
+export const RIGHTCLICK_STYLE_ID = 'dsh-tauri-rightclick-styles'
+
+/** Effects / lifecycle ids(诊断元数据)。 */
+export const RIGHTCLICK_STYLES_EFFECT = `${RIGHTCLICK_CLIENT_PLUGIN}: styles`
+export const RIGHTCLICK_MENU_EFFECT = `${RIGHTCLICK_CLIENT_PLUGIN}: context menu`
+
+/** css-render class prefix(跨插件协议暴露给扩展事件 detail 的 DOM 结构保持稳定)。 */
+export const RIGHTCLICK_CLASSES = {
+ menu: 'dsh-tauri-rightclick',
+ item: 'dsh-tauri-rightclick-item',
+ itemDanger: 'dsh-tauri-rightclick-item--danger',
+ shortcut: 'dsh-tauri-rightclick-shortcut',
+ separator: 'dsh-tauri-rightclick-separator',
+ toast: 'dsh-tauri-rightclick-toast',
+} as const
+
+/** 扩展注册表协议(其他 Web 插件经 globalThis[Symbol.for(KEY)] 登记扩展项)。 */
+export const EXTENSIONS_REGISTRY_KEY = 'dsh.rightclick-menu.extensions'
+/** 注册表租约协议(插件实例持有/释放全局注册表)。 */
+export const EXTENSIONS_LEASE_KEY = 'dsh.rightclick-menu.lease'
+
+/** 每次打开右键菜单时派发的事件(detail 含 row/action/session/workspace/target/x/y/extensions)。 */
+export const CONTEXT_MENU_EVENT = 'dsh:rightclick-menu'
+
+/** Toast 展示时长(毫秒)。 */
+export const TOAST_DURATION_MS = 1800
+
+/** 菜单最小/最大宽度与视口边距。 */
+export const MENU_MIN_WIDTH = 148
+export const MENU_MAX_WIDTH = 260
+export const MENU_VIEWPORT_MARGIN = 6
diff --git a/packages/dsh-tauri-rightclick/src/client/dialog.ts b/packages/dsh-tauri-rightclick/src/client/dialog.ts
new file mode 100644
index 00000000..4f67eabe
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/dialog.ts
@@ -0,0 +1,12 @@
+/** dialog.ts — lightweight toast notifications for context-menu actions. */
+import { RIGHTCLICK_CLASSES as K, TOAST_DURATION_MS } from './constants'
+
+/** Toast 展示:同一时刻只保留一条,自动消失。 */
+export function toast(message: string): void {
+ document.querySelector(`.${K.toast}`)?.remove()
+ const node = document.createElement('div')
+ node.className = K.toast
+ node.textContent = message
+ document.body.appendChild(node)
+ setTimeout(() => node.remove(), TOAST_DURATION_MS)
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/index.ts b/packages/dsh-tauri-rightclick/src/client/index.ts
new file mode 100644
index 00000000..d92584ab
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/index.ts
@@ -0,0 +1,43 @@
+/**
+ * dsh-tauri-rightclick 客户端插件体(browser half):原生风格的完整右键菜单。
+ *
+ * 按目标组装菜单(全部为稳定的无障碍语义 + 零结构补丁,无 React 组件、无运行时
+ * 依赖):
+ * - 会话行:官方重命名/归档/分叉转交官方组件;插件补充资源管理器打开目录、复制目录/会话 ID;
+ * - 工作区行:新建会话、打开目录、官方重命名、复制路径、归档工作区;
+ * - 未分组行:归档全部未分组正式会话、刷新;临时新会话不处理;
+ * - 可编辑元素:撤销/重做/剪切/复制/粘贴/全选;
+ * - 对话正文/设置页:复制所选文本、默认浏览器打开链接、全选当前内容;
+ * - 所有菜单:刷新。
+ *
+ * 与 node half(src/index.ts)经 /api/dsh-rightclick-menu/* 通信(open-url)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import { compat } from 'dsh-tauri/client'
+import {
+ RIGHTCLICK_CLIENT_PLUGIN,
+ RIGHTCLICK_MENU_EFFECT,
+ RIGHTCLICK_STYLES_EFFECT,
+} from './constants'
+import { installLocale } from './locale'
+import { installContextMenu } from './menu'
+import { mountRightClickStyles } from './styles'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = RIGHTCLICK_CLIENT_PLUGIN
+
+/** 需要的客户端服务:locale(双语文案)、sessions(会话行匹配)、workspaces(工作区操作)。 */
+export const inject = ['locale', 'sessions', 'workspaces']
+
+/**
+ * 插件体:安装文案与样式,并挂载右键菜单监听。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ const cx = compat(ctx)
+ installLocale(cx)
+
+ ctx.effect(() => mountRightClickStyles(), RIGHTCLICK_STYLES_EFFECT)
+
+ ctx.effect(() => installContextMenu(cx), RIGHTCLICK_MENU_EFFECT)
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/locale.ts b/packages/dsh-tauri-rightclick/src/client/locale.ts
new file mode 100644
index 00000000..fe274a49
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/locale.ts
@@ -0,0 +1,168 @@
+/**
+ * locale.ts — 本插件自有文案(右键菜单 / Toast / 确认框 / 错误提示)。
+ * 走 locale 服务的非类型化注册面(register(ns, locale, dict)),zh/en 双语齐备,
+ * 语言自动跟随宿主 UI;`text()` 支持 `{name}` 插值(如归档确认框的标题/数量)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import type { LocaleKey } from './types'
+import { RIGHTCLICK_CLIENT_NS as NS } from './constants'
+
+export { RIGHTCLICK_CLIENT_NS as NS } from './constants'
+
+/** zh 字典(键集合的权威)。 */
+const DICT_ZH = {
+ renameSession: '重命名会话',
+ archiveSession: '归档会话',
+ openInExplorer: '在资源管理器中打开',
+ copyWorkingDirectory: '复制工作目录',
+ copySessionId: '复制会话 ID',
+ forkSession: '创建会话分支',
+ refresh: '刷新',
+ newSession: '新建会话',
+ renameWorkspace: '重命名工作区',
+ copyWorkspacePath: '复制工作区路径',
+ archiveWorkspaceSessions: '归档工作区',
+ archiveUngroupedSessions: '归档未分组会话',
+ undo: '撤销',
+ redo: '重做',
+ cut: '剪切',
+ copy: '复制',
+ paste: '粘贴',
+ selectAll: '全选',
+ copySelectedText: '复制所选文本',
+ openInDefaultBrowser: '使用默认浏览器打开',
+ copyLink: '复制链接',
+ selectCurrentContent: '全选当前内容',
+ copiedWorkingDirectory: '已复制工作目录',
+ copiedSessionId: '已复制会话 ID',
+ copiedWorkspacePath: '已复制工作区路径',
+ sessionRenamed: '会话已重命名',
+ sessionArchived: '会话已归档',
+ copied: '已复制',
+ cutDone: '已剪切',
+ linkCopied: '已复制链接',
+ noWorkspaceSessions: '该工作区没有可归档的会话',
+ noUngroupedSessions: '未分组中没有可归档的正式会话',
+ archiveWorkspaceTitle: '归档 {count} 个会话?',
+ archiveWorkspaceDescription: '这会将 {workspace} 中的会话归档。之后你可以在已归档的会话中找到它们',
+ archiveWorkspaceConfirmAction: '全部归档',
+ archiveUngroupedTitle: '归档未分组中的 {count} 个会话?',
+ archiveUngroupedDescription: '这会归档未分组中的全部正式会话',
+ deleteWorkspace: '删除工作区',
+ deleteWorkspaceTitle: '删除工作区?',
+ deleteWorkspaceDescription: '将把“{title}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。',
+ deleteWorkspaceConfirm: '删除',
+ workspaceDeleted: '工作区已删除',
+ cancel: '取消',
+ workspaceSessionsArchived: '已归档 {count} 个会话',
+ officialSessionActionUnavailable: '当前会话尚未提供该官方操作',
+ officialWorkspaceActionUnavailable: '找不到官方工作区操作',
+ openFailed: '打开失败: {reason}',
+ unknownError: '未知错误',
+ clipboardUnavailable: '剪贴板不可用',
+ clipboardReadFailed: '无法读取剪贴板,请使用 Ctrl+V',
+ useUndoShortcut: '请使用 Ctrl+Z 撤销',
+ useRedoShortcut: '请使用 Ctrl+Y 重做',
+ invalidLink: '链接地址无效',
+ officialRenameUnavailable: '无法打开官方重命名窗口',
+ officialWorkspaceRenameUnavailable: '无法打开官方工作区重命名窗口',
+ officialArchiveUnavailable: '无法调用官方归档会话',
+ officialForkUnavailable: '无法调用官方分叉会话',
+ sessionUnknown: '无法确定当前会话',
+ sessionNameEmpty: '会话名称不能为空',
+ sessionServiceUnavailable: '无法取得官方会话服务',
+ renameFailed: '重命名失败',
+ editPositionUnknown: '无法确定编辑位置',
+} as const satisfies Record<LocaleKey, string>
+
+/** en 字典,与 zh 键集完全一致(locale 运行时强制双语平衡)。 */
+const DICT_EN: Record<LocaleKey, string> = {
+ renameSession: 'Rename session',
+ archiveSession: 'Archive session',
+ openInExplorer: 'Open in File Explorer',
+ copyWorkingDirectory: 'Copy working directory',
+ copySessionId: 'Copy session ID',
+ forkSession: 'Fork session',
+ refresh: 'Refresh',
+ newSession: 'New session',
+ renameWorkspace: 'Rename workspace',
+ copyWorkspacePath: 'Copy workspace path',
+ archiveWorkspaceSessions: 'Archive workspace',
+ archiveUngroupedSessions: 'Archive ungrouped sessions',
+ undo: 'Undo',
+ redo: 'Redo',
+ cut: 'Cut',
+ copy: 'Copy',
+ paste: 'Paste',
+ selectAll: 'Select all',
+ copySelectedText: 'Copy selected text',
+ openInDefaultBrowser: 'Open in default browser',
+ copyLink: 'Copy link',
+ selectCurrentContent: 'Select current content',
+ copiedWorkingDirectory: 'Working directory copied',
+ copiedSessionId: 'Session ID copied',
+ copiedWorkspacePath: 'Workspace path copied',
+ sessionRenamed: 'Session renamed',
+ sessionArchived: 'Session archived',
+ copied: 'Copied',
+ cutDone: 'Cut',
+ linkCopied: 'Link copied',
+ noWorkspaceSessions: 'This workspace has no sessions to archive',
+ noUngroupedSessions: 'Ungrouped has no formal sessions to archive',
+ archiveWorkspaceTitle: 'Archive {count} sessions?',
+ archiveWorkspaceDescription: 'This will archive the sessions in {workspace}. You can find them in Archived sessions afterwards.',
+ archiveWorkspaceConfirmAction: 'Archive all',
+ archiveUngroupedTitle: 'Archive {count} sessions in Ungrouped?',
+ archiveUngroupedDescription: 'This will archive all formal sessions in Ungrouped.',
+ deleteWorkspace: 'Delete workspace',
+ deleteWorkspaceTitle: 'Delete workspace?',
+ deleteWorkspaceDescription: 'This removes “{title}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.',
+ deleteWorkspaceConfirm: 'Delete',
+ workspaceDeleted: 'Workspace deleted',
+ cancel: 'Cancel',
+ workspaceSessionsArchived: 'Archived {count} sessions',
+ officialSessionActionUnavailable: 'The official action is not available for this session',
+ officialWorkspaceActionUnavailable: 'Official workspace actions could not be found',
+ openFailed: 'Failed to open: {reason}',
+ unknownError: 'Unknown error',
+ clipboardUnavailable: 'Clipboard is unavailable',
+ clipboardReadFailed: 'Could not read the clipboard; use Ctrl+V',
+ useUndoShortcut: 'Use Ctrl+Z to undo',
+ useRedoShortcut: 'Use Ctrl+Y to redo',
+ invalidLink: 'Invalid link URL',
+ officialRenameUnavailable: 'Could not open the official rename dialog',
+ officialWorkspaceRenameUnavailable: 'Could not open the official workspace rename dialog',
+ officialArchiveUnavailable: 'Could not invoke the official archive action',
+ officialForkUnavailable: 'Could not invoke the official fork action',
+ sessionUnknown: 'Could not determine the current session',
+ sessionNameEmpty: 'Session name cannot be empty',
+ sessionServiceUnavailable: 'Official session service is unavailable',
+ renameFailed: 'Rename failed',
+ editPositionUnknown: 'Could not determine the editing position',
+}
+
+/** 活跃语言 id(module 级缓存,apply 时初始化并由订阅推进)。 */
+let activeLocale = 'en'
+
+/**
+ * 在 apply 里安装:注册双语字典,并桥接 locale 变更到 module 级缓存。
+ * @param ctx - 客户端根上下文(须已注入 locale 服务)。
+ */
+export function installLocale(ctx: ClientContext): void {
+ activeLocale = ctx.locale.getLocale().active
+ ctx.locale.register(NS, 'zh', DICT_ZH)
+ ctx.locale.register(NS, 'en', DICT_EN)
+ ctx.locale.subscribe(() => {
+ activeLocale = ctx.locale.getLocale().active
+ })
+}
+
+/**
+ * 按当前活跃语言取一条文案,并做 `{name}` 插值(缺失的值替换为空串)。
+ * @param key - 文案键。
+ * @param values - 插值表。
+ */
+export function text(key: LocaleKey, values: Record<string, string | number> = {}): string {
+ const dict = activeLocale === 'en' ? DICT_EN : DICT_ZH
+ return (dict[key] || DICT_EN[key] || key).replace(/\{(\w+)\}/g, (_, name: string) => String(values[name] ?? ''))
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/locate.ts b/packages/dsh-tauri-rightclick/src/client/locate.ts
new file mode 100644
index 00000000..f584bade
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/locate.ts
@@ -0,0 +1,188 @@
+/**
+ * locate.ts — 从右键目标定位「会话行 / 工作区行」及官方操作按钮的 DOM 解析。
+ *
+ * 全部基于稳定的无障碍语义([role=treeitem] / aria-label / aria-selected),
+ * 不依赖生成哈希的 CSS module 类名;无法唯一确认目标时返回 null,保留浏览器
+ * 默认菜单,避免操作错误的会话/工作区。
+ */
+import type {
+ SessionsRuntimeLike,
+ SessionSummaryLike,
+ WorkspacesRuntimeLike,
+ WorkspaceViewLike,
+} from './types'
+
+/** 会话行「操作」按钮判定(zh/en 双语文案)。 */
+export function isAction(button: Element): boolean {
+ const label = (button.getAttribute('aria-label') || '').toLocaleLowerCase()
+ return (label.includes('会话') && label.includes('操作')) || (label.includes('session') && label.includes('action'))
+}
+
+/** 工作区行「操作」按钮判定(zh/en 双语文案)。 */
+export function isWorkspaceAction(button: Element): boolean {
+ const label = (button.getAttribute('aria-label') || '').toLocaleLowerCase()
+ return (label.includes('工作区') && label.includes('操作')) || (label.includes('workspace') && label.includes('action'))
+}
+
+/** 从目标元素向上找会话行([role=treeitem],带 aria-selected 或含操作按钮)。 */
+export function rowFrom(target: unknown): Element | null {
+ const row = target instanceof Element ? target.closest('[role="treeitem"]') : null
+ if (!row)
+ return null
+ if (row.hasAttribute('aria-selected'))
+ return row
+ return [...row.querySelectorAll('button[aria-label]')].some(isAction) ? row : null
+}
+
+/** Locate the official Ungrouped group header, which intentionally has no menu button. */
+export function ungroupedRowFrom(target: unknown): Element | null {
+ const row = target instanceof Element ? target.closest('[role="treeitem"][aria-expanded]') : null
+ if (!row)
+ return null
+ const label = [
+ row.getAttribute('aria-label'),
+ row.getAttribute('title'),
+ ...[...row.querySelectorAll('span')]
+ .filter(node => node.children.length === 0)
+ .map(node => node.textContent?.trim() || ''),
+ ].find(value => typeof value === 'string' && /^(?:未分组|Ungrouped)$/i.test(value))
+ if (label === undefined || [...row.querySelectorAll('button[aria-label]')].some(isWorkspaceAction))
+ return null
+ return row
+}
+
+/** 行是否命中某个工作区(按 aria-label/title/纯文本三路匹配,要求唯一命中)。 */
+function treeItemWorkspace(row: Element, items: readonly WorkspaceViewLike[]): WorkspaceViewLike | null {
+ if (!row)
+ return null
+ const matches = items.filter((workspace) => {
+ if ([row.getAttribute('aria-label'), row.getAttribute('title')].some(value => value?.trim() === workspace.title))
+ return true
+ return [...row.querySelectorAll('span,button,div')].some(node =>
+ node.closest('[role="treeitem"]') === row
+ && node.children.length === 0
+ && node.textContent?.trim() === workspace.title)
+ })
+ return matches.length === 1 ? matches[0] : null
+}
+
+/** 从目标向上解析所属工作区(先沿祖先链,再回扫同级更上层行)。 */
+export function workspaceFrom(target: unknown, workspaces: WorkspacesRuntimeLike): {
+ workspace: WorkspaceViewLike
+ row: Element
+ targetRow: Element
+} | null {
+ const targetRow = target instanceof Element ? target.closest('[role="treeitem"]') : null
+ if (!targetRow)
+ return null
+ const items = workspaces.list.getSnapshot().items
+ for (let row: Element | null = targetRow; row; row = row.parentElement?.closest('[role="treeitem"]') ?? null) {
+ const workspace = treeItemWorkspace(row, items)
+ if (workspace)
+ return { workspace, row, targetRow }
+ }
+
+ const rows = [...document.querySelectorAll('[role="treeitem"]')]
+ const level = Number(targetRow.getAttribute('aria-level'))
+ for (let index = rows.indexOf(targetRow) - 1; index >= 0; index -= 1) {
+ const candidate = rows[index]
+ const candidateLevel = Number(candidate.getAttribute('aria-level'))
+ if (Number.isFinite(level) && Number.isFinite(candidateLevel) && candidateLevel >= level)
+ continue
+ if (rowFrom(candidate))
+ continue
+ const workspace = treeItemWorkspace(candidate, items)
+ if (workspace)
+ return { workspace, row: candidate, targetRow }
+ if (Number.isFinite(level) && Number.isFinite(candidateLevel) && candidateLevel < level)
+ break
+ }
+ return null
+}
+
+/** 行内的官方会话操作按钮(行内没有时按标题匹配全局操作按钮)。 */
+export function officialAction(row: Element): HTMLButtonElement | null {
+ const direct = [...row.querySelectorAll<HTMLButtonElement>('button[aria-label]')].find(isAction)
+ if (direct)
+ return direct
+ const title = [...row.querySelectorAll('span')]
+ .find(node => node.children.length === 0 && node.textContent?.trim())
+ ?.textContent
+ ?.trim()
+ return [...document.querySelectorAll<HTMLButtonElement>('button[aria-label]')].find((button) => {
+ if (!isAction(button))
+ return false
+ return !title || (button.getAttribute('aria-label') || '').includes(title)
+ }) ?? null
+}
+
+/** 会话行标题:优先从操作按钮 aria-label 提取引号内标题,回退首个文本子节点。 */
+export function titleFrom(row: Element): string {
+ const label = [...row.querySelectorAll('button[aria-label]')].find(isAction)?.getAttribute('aria-label') || ''
+ return label.match(/[“"](.+?)[”"]/)?.[1] || row.firstElementChild?.textContent?.trim() || ''
+}
+
+/** 解析行对应的会话对象(唯一匹配才返回;同名歧义时返回 null 保留默认菜单)。 */
+export function resolveSession(
+ sessions: SessionsRuntimeLike,
+ row: Element,
+ workspace: WorkspaceViewLike | null,
+): SessionSummaryLike | null {
+ const state = sessions.list.getSnapshot()
+ if (row.getAttribute('aria-selected') === 'true' && state.current)
+ return state.byId[state.current] || null
+ const title = titleFrom(row)
+ if (!title)
+ return null
+ const ids = workspace?.sessionIds || state.ids
+ const matches = ids.map(id => state.byId[id]).filter(item =>
+ item && (item.title === title
+ || item.displayTitle === title
+ || (item.blank && /^(?:新会话|new session)$/i.test(title))))
+ return matches.length === 1 ? matches[0] : null
+}
+
+/** 会话所属工作区(按 sessionIds 归属反查)。 */
+export function workspaceForSession(workspaces: WorkspacesRuntimeLike, session: SessionSummaryLike | null): WorkspaceViewLike | null {
+ if (!session)
+ return null
+ return workspaces.list.getSnapshot().items.find(workspace => workspace.sessionIds.includes(session.id)) || null
+}
+
+/** 从目标向上找可编辑元素(input/textarea/contenteditable)。 */
+export function editableFrom(target: unknown): HTMLElement | null {
+ return target instanceof Element
+ ? target.closest('input:not([type="button"]):not([type="submit"]),textarea,[contenteditable="true"]')
+ : null
+}
+
+/** 当前选中文本(可编辑元素内取选区值;外层取全局选区,且须在可编辑元素内)。 */
+export function selectedText(editable: HTMLElement | null): string {
+ if (editable instanceof HTMLInputElement || editable instanceof HTMLTextAreaElement)
+ return editable.value.slice(editable.selectionStart ?? 0, editable.selectionEnd ?? 0)
+ const selection = globalThis.getSelection()
+ if (!selection)
+ return ''
+ if (editable && (!editable.contains(selection.anchorNode) || !editable.contains(selection.focusNode)))
+ return ''
+ return selection.toString()
+}
+
+/** 只接受 http/https 的 URL 校验(用于外链打开 / 选中文本里的网址)。 */
+export function externalUrl(value: string): string | null {
+ try {
+ const url = new URL(value)
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null
+ }
+ catch {
+ return null
+ }
+}
+
+/** 选中文本是否为完整网址(http/https 且无空格)。 */
+export function selectedUrl(value: string): string | null {
+ const text = value.trim()
+ if (!/^https?:\/\/\S+$/i.test(text))
+ return null
+ return externalUrl(text)
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/menu.ts b/packages/dsh-tauri-rightclick/src/client/menu.ts
new file mode 100644
index 00000000..9cbd1967
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/menu.ts
@@ -0,0 +1,355 @@
+/**
+ * menu.ts — 右键菜单本体:按目标(会话行 / 工作区行 / 可编辑元素 / 选中文本 /
+ * 链接 / 对话内容区)组装菜单项,处理键盘导航与外部点击关闭。
+ *
+ * 会话与工作区的官方操作全部转交官方组件(officialSelect);插件只补充
+ * 宿主能力(资源管理器、剪贴板、默认浏览器、刷新)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import type {
+ SessionsRuntimeLike,
+ WorkspacesRuntimeLike,
+} from './types'
+import { compat } from 'dsh-tauri/client'
+import {
+ archiveSession,
+ archiveUngroupedSessions,
+ archiveWorkspaceSessions,
+ deleteWorkspaceAction,
+ forkSession,
+ openExternalUrl,
+ openInExplorer,
+ renameSession,
+} from './actions'
+import { copyText, readClipboard } from './clipboard'
+import {
+ CONTEXT_MENU_EVENT,
+ RIGHTCLICK_CLASSES as K,
+ MENU_VIEWPORT_MARGIN,
+} from './constants'
+import { toast } from './dialog'
+import { text } from './locale'
+import { editableFrom, externalUrl, isWorkspaceAction, officialAction, resolveSession, rowFrom, selectedText, selectedUrl, ungroupedRowFrom, workspaceForSession, workspaceFrom } from './locate'
+import { holdRegistryLease, registry } from './registry'
+
+/** 官方工作区菜单项选择(工作区操作按钮无 hover 兜底)。 */
+function officialWorkspaceSelect(row: Element, labels: RegExp[], failureMessage: string): void {
+ const action = [...row.querySelectorAll<HTMLButtonElement>('button[aria-label]')].find(isWorkspaceAction)
+ if (!action)
+ throw new Error(text('officialWorkspaceActionUnavailable'))
+ action.click()
+ setTimeout(() => {
+ const item = [...document.querySelectorAll<HTMLElement>('[role="menuitem"]')].find(node =>
+ labels.some(label => label.test(node.textContent?.trim() || '')))
+ if (!item) {
+ toast(failureMessage)
+ return
+ }
+ item.click()
+ }, 0)
+}
+
+/**
+ * 安装右键菜单。返回卸载函数(关闭菜单、移除监听、释放注册表租约)。
+ * @param ctx - 客户端根上下文(须已注入 sessions/workspaces)。
+ */
+export function installContextMenu(ctx: ClientContext): () => void {
+ const cx = compat(ctx)
+ const sessions = cx.sessions as unknown as SessionsRuntimeLike
+ const workspaces = cx.workspaces as unknown as WorkspacesRuntimeLike
+ const extensionsRegistry = registry()
+ const releaseLease = holdRegistryLease()
+
+ let menu: HTMLElement | null = null
+ const close = (): void => {
+ menu?.remove()
+ menu = null
+ }
+
+ const add = (root: HTMLElement, label: string, run: () => void | Promise<void>, shortcut = '', danger = false): void => {
+ const button = document.createElement('button')
+ button.type = 'button'
+ button.className = danger ? `${K.item} ${K.itemDanger}` : K.item
+ button.setAttribute('role', 'menuitem')
+ button.tabIndex = -1
+ const itemLabel = document.createElement('span')
+ itemLabel.textContent = label
+ button.appendChild(itemLabel)
+ if (shortcut) {
+ const hint = document.createElement('span')
+ hint.className = K.shortcut
+ hint.textContent = shortcut
+ button.appendChild(hint)
+ }
+ button.onclick = async () => {
+ close()
+ try {
+ await run()
+ }
+ catch (error) {
+ toast(error instanceof Error ? error.message : String(error))
+ }
+ }
+ root.appendChild(button)
+ }
+ const split = (root: HTMLElement): void => {
+ if (!root.childElementCount || root.lastElementChild?.classList.contains(K.separator))
+ return
+ const node = document.createElement('div')
+ node.className = K.separator
+ node.setAttribute('role', 'separator')
+ root.appendChild(node)
+ }
+
+ /** 替换可编辑元素中的当前选区(输入/文本域/可编辑区三态)。 */
+ const replaceSelection = (editable: HTMLElement, value: string): void => {
+ editable.focus()
+ if (editable instanceof HTMLInputElement || editable instanceof HTMLTextAreaElement) {
+ const start = editable.selectionStart ?? editable.value.length
+ const end = editable.selectionEnd ?? start
+ editable.setRangeText(value, start, end, 'end')
+ editable.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText', data: value }))
+ return
+ }
+ const selection = globalThis.getSelection()
+ if (!selection?.rangeCount || !editable.contains(selection.anchorNode))
+ throw new Error(text('editPositionUnknown'))
+ const range = selection.getRangeAt(0)
+ range.deleteContents()
+ const textNode = document.createTextNode(value)
+ range.insertNode(textNode)
+ range.setStartAfter(textNode)
+ range.collapse(true)
+ selection.removeAllRanges()
+ selection.addRange(range)
+ editable.dispatchEvent(new InputEvent('input', { bubbles: true, inputType: 'insertText', data: value }))
+ }
+
+ /** 全选某个内容面(Range.selectNodeContents)。 */
+ function selectSurface(surface: HTMLElement): void {
+ if (!surface)
+ return
+ const selection = globalThis.getSelection()
+ if (!selection)
+ return
+ const range = document.createRange()
+ range.selectNodeContents(surface)
+ selection.removeAllRanges()
+ selection.addRange(range)
+ }
+
+ /** 全选的可编辑目标。 */
+ const selectAll = (editable: HTMLElement): void => {
+ editable.focus()
+ if (editable instanceof HTMLInputElement || editable instanceof HTMLTextAreaElement)
+ editable.select()
+ else
+ selectSurface(editable)
+ }
+
+ /** 全选的会话内容区(对话正文 / 设置弹窗 / hero 首屏)。 */
+ const selectionSurface = (target: unknown): HTMLElement | null => {
+ if (target instanceof Element) {
+ const conversation = target.closest<HTMLElement>('[data-slot="conversation.session"]')
+ if (conversation)
+ return conversation
+ const dialog = target.closest<HTMLElement>('[role="dialog"]')
+ if (dialog)
+ return dialog
+ const hero = target.closest<HTMLElement>('[data-phase="hero"]')
+ if (hero?.querySelector(':scope > [data-conversation-scroll]'))
+ return hero
+ }
+ return null
+ }
+
+ /** 菜单定位:限制在视口内(最小边距 6px)。 */
+ const position = (root: HTMLElement, event: MouseEvent): void => {
+ const rect = root.getBoundingClientRect()
+ root.style.left = `${Math.max(MENU_VIEWPORT_MARGIN, Math.min(event.clientX, innerWidth - rect.width - MENU_VIEWPORT_MARGIN))}px`
+ root.style.top = `${Math.max(MENU_VIEWPORT_MARGIN, Math.min(event.clientY, innerHeight - rect.height - MENU_VIEWPORT_MARGIN))}px`
+ root.style.visibility = 'visible'
+ root.querySelector('button')?.focus()
+ }
+
+ const onContextMenu = (event: MouseEvent): void => {
+ if (event.defaultPrevented)
+ return
+ const row = rowFrom(event.target)
+ const ungroupedRow = !row ? ungroupedRowFrom(event.target) : null
+ const domSessionWorkspace = row ? workspaceFrom(event.target, workspaces) : null
+ const session = row ? resolveSession(sessions, row, domSessionWorkspace?.workspace ?? null) : null
+ // The visible blank “New Session” is only a provisional composer target.
+ if (session?.blank === true)
+ return
+ const resolvedWorkspace = domSessionWorkspace?.workspace || workspaceForSession(workspaces, session)
+ const sessionWorkspace = resolvedWorkspace ? { workspace: resolvedWorkspace } : null
+ const workspaceTarget = !row && !ungroupedRow ? workspaceFrom(event.target, workspaces) : null
+ const editable = editableFrom(event.target)
+ const selection = selectedText(editable).trim()
+ const link = event.target instanceof Element ? event.target.closest<HTMLAnchorElement>('a[href]') : null
+ const surface = selectionSurface(event.target)
+ if (!row && !ungroupedRow && !workspaceTarget && !editable && !selection && !link && !surface)
+ return
+ event.preventDefault()
+ event.stopPropagation()
+ close()
+ const root = document.createElement('div')
+ root.className = K.menu
+ root.setAttribute('role', 'menu')
+ root.style.visibility = 'hidden'
+ document.body.appendChild(root)
+ menu = root
+
+ const registeredExtensions = extensionsRegistry.list()
+ globalThis.dispatchEvent(new CustomEvent(CONTEXT_MENU_EVENT, {
+ detail: {
+ row: row || ungroupedRow || workspaceTarget?.targetRow || null,
+ action: row ? officialAction(row) : null,
+ session,
+ workspace: workspaceTarget?.workspace || null,
+ target: event.target,
+ x: event.clientX,
+ y: event.clientY,
+ extensions: registeredExtensions,
+ },
+ }))
+
+ if (row) {
+ add(root, text('renameSession'), () => renameSession(sessions, row, session))
+ add(root, text('archiveSession'), () => archiveSession(workspaces, row, session))
+ const cwd = session?.cwd || sessionWorkspace?.workspace.path
+ if (cwd) {
+ split(root)
+ add(root, text('openInExplorer'), () => openInExplorer(cwd))
+ add(root, text('copyWorkingDirectory'), () => copyText(cwd, 'copiedWorkingDirectory'))
+ }
+ if (session)
+ add(root, text('copySessionId'), () => copyText(session.id, 'copiedSessionId'))
+
+ split(root)
+ add(root, text('forkSession'), () => forkSession(sessions, row, session))
+
+ const extensions = session
+ ? registeredExtensions.filter(entry => entry.visible?.({ session, row }) !== false)
+ : []
+ if (extensions.length) {
+ split(root)
+ for (const entry of extensions)
+ add(root, entry.label || entry.id, () => entry.run({ session, row, sessions, workspaces, close }))
+ }
+ split(root)
+ add(root, text('refresh'), () => globalThis.location.reload(), 'Ctrl+R')
+ }
+ else if (ungroupedRow) {
+ add(root, text('archiveUngroupedSessions'), () => archiveUngroupedSessions(workspaces, sessions))
+ split(root)
+ add(root, text('refresh'), () => globalThis.location.reload(), 'Ctrl+R')
+ }
+ else if (workspaceTarget) {
+ const workspace = workspaceTarget.workspace
+ add(root, text('newSession'), () => workspaces.startSession(workspace.workspaceId))
+ add(root, text('openInExplorer'), () => openInExplorer(workspace.path))
+ split(root)
+ add(root, text('renameWorkspace'), () => officialWorkspaceSelect(
+ workspaceTarget.row,
+ [/^重命名$/, /^rename$/i],
+ text('officialWorkspaceRenameUnavailable'),
+ ))
+ add(root, text('copyWorkspacePath'), () => copyText(workspace.path, 'copiedWorkspacePath'))
+ split(root)
+ add(root, text('archiveWorkspaceSessions'), () => archiveWorkspaceSessions(workspaces, workspace))
+ add(root, text('deleteWorkspace'), () => deleteWorkspaceAction(workspaces, workspace), '', true)
+
+ split(root)
+ add(root, text('refresh'), () => globalThis.location.reload(), 'Ctrl+R')
+ }
+ else if (editable) {
+ add(root, text('undo'), () => {
+ editable.focus()
+ if (!document.execCommand('undo'))
+ throw new Error(text('useUndoShortcut'))
+ }, 'Ctrl+Z')
+ add(root, text('redo'), () => {
+ editable.focus()
+ if (!document.execCommand('redo'))
+ throw new Error(text('useRedoShortcut'))
+ }, 'Ctrl+Y')
+ split(root)
+ add(root, text('cut'), async () => {
+ if (selection)
+ await copyText(selection, 'cutDone')
+ replaceSelection(editable, '')
+ }, 'Ctrl+X')
+ add(root, text('copy'), () => copyText(selection, 'copied'), 'Ctrl+C')
+ add(root, text('paste'), async () => replaceSelection(editable, await readClipboard()), 'Ctrl+V')
+ split(root)
+ add(root, text('selectAll'), () => selectAll(editable), 'Ctrl+A')
+ split(root)
+ add(root, text('refresh'), () => globalThis.location.reload(), 'Ctrl+R')
+ }
+ else {
+ if (selection)
+ add(root, text('copySelectedText'), () => copyText(selection, 'copied'), 'Ctrl+C')
+ const url = externalUrl(link?.href || '') || selectedUrl(selection)
+ if (url) {
+ if (selection)
+ split(root)
+ add(root, text('openInDefaultBrowser'), () => openExternalUrl(url))
+ add(root, text('copyLink'), () => copyText(url, 'linkCopied'))
+ }
+ if (surface) {
+ if (selection || url)
+ split(root)
+ const surfaceNode = surface
+ add(root, text('selectCurrentContent'), () => selectSurface(surfaceNode), 'Ctrl+A')
+ }
+ split(root)
+ add(root, text('refresh'), () => globalThis.location.reload(), 'Ctrl+R')
+ }
+ position(root, event)
+ }
+
+ const outside = (event: PointerEvent): void => {
+ if (menu && !menu.contains(event.target as Node))
+ close()
+ }
+ const keyboard = (event: KeyboardEvent): void => {
+ if (!menu)
+ return
+ if (event.key === 'Escape') {
+ close()
+ return
+ }
+ const items = [...menu.querySelectorAll<HTMLElement>('[role="menuitem"]')]
+ const current = items.indexOf(document.activeElement as HTMLElement)
+ let next: Element | null = null
+ if (event.key === 'ArrowDown')
+ next = items[(current + 1 + items.length) % items.length]
+ else if (event.key === 'ArrowUp')
+ next = items[(current - 1 + items.length) % items.length]
+ else if (event.key === 'Home')
+ next = items[0]
+ else if (event.key === 'End')
+ next = items.at(-1) ?? null
+ if (next) {
+ event.preventDefault()
+ ;(next as HTMLElement).focus()
+ }
+ }
+ document.addEventListener('contextmenu', onContextMenu, true)
+ document.addEventListener('pointerdown', outside, true)
+ document.addEventListener('keydown', keyboard, true)
+
+ let disposed = false
+ return () => {
+ if (disposed)
+ return
+ disposed = true
+ close()
+ document.removeEventListener('contextmenu', onContextMenu, true)
+ document.removeEventListener('pointerdown', outside, true)
+ document.removeEventListener('keydown', keyboard, true)
+ releaseLease()
+ }
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/registry.ts b/packages/dsh-tauri-rightclick/src/client/registry.ts
new file mode 100644
index 00000000..4fab4e45
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/registry.ts
@@ -0,0 +1,66 @@
+/**
+ * registry.ts — 全局扩展注册表:其他 Web 插件经
+ * `globalThis[Symbol.for('dsh.rightclick-menu.extensions')]` 登记/查询扩展项。
+ *
+ * 注册表是插件间协议(不随 bundle 重载而失效),所以挂在 Symbol.for 全局键上,
+ * 并用租约计数(LEASE)保证「插件实例持有期间不清理全局注册表」:apply 时 +1,
+ * dispose 时 -1,全部释放且无条目时才删除全局键。
+ */
+import type { ContextMenuExtension } from './types'
+import { EXTENSIONS_LEASE_KEY, EXTENSIONS_REGISTRY_KEY } from './constants'
+
+const KEY = Symbol.for(EXTENSIONS_REGISTRY_KEY)
+const LEASE = Symbol.for(EXTENSIONS_LEASE_KEY)
+
+/** 全局注册表载体(Symbol 键索引,避免给 globalThis 补任意索引签名)。 */
+const globalStore = globalThis as typeof globalThis & Record<symbol, unknown>
+
+export interface ExtensionRegistryApi {
+ /** 登记一条扩展项;返回 disposer(卸载时调用,条目删除且无租约时回收全局注册表)。 */
+ register: (entry: ContextMenuExtension) => () => void
+ /** 按 order 升序的当前扩展项列表。 */
+ list: () => ContextMenuExtension[]
+ /** 租约计数(仅插件 apply/dispose 使用)。 */
+ [LEASE]: (delta: number) => void
+}
+
+/** 取得(或首次创建)全局扩展注册表。 */
+export function registry(): ExtensionRegistryApi {
+ const existing = globalStore[KEY] as ExtensionRegistryApi | undefined
+ if (existing)
+ return existing
+ const entries = new Map<string, ContextMenuExtension>()
+ let leases = 0
+ const api: ExtensionRegistryApi = {
+ register(entry) {
+ if (!entry?.id || entries.has(entry.id))
+ throw new Error('invalid or duplicate context-menu extension')
+ entries.set(entry.id, entry)
+ return () => {
+ entries.delete(entry.id)
+ if (!leases && !entries.size && globalStore[KEY] === api)
+ delete globalStore[KEY]
+ }
+ },
+ list() {
+ return [...entries.values()].sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
+ },
+ [LEASE](delta) {
+ leases += delta
+ if (!leases && !entries.size && globalStore[KEY] === api)
+ delete globalStore[KEY]
+ },
+ }
+ globalStore[KEY] = Object.freeze(api)
+ return api
+}
+
+/** 插件 apply 时持有租约、dispose 时释放。 */
+export function holdRegistryLease(): () => void {
+ const api = registry()
+ api[LEASE](1)
+ return () => {
+ if (globalStore[KEY] === api)
+ api[LEASE](-1)
+ }
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/styles.ts b/packages/dsh-tauri-rightclick/src/client/styles.ts
new file mode 100644
index 00000000..92a5aa8c
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/styles.ts
@@ -0,0 +1,80 @@
+/** Context menu and toast styles generated as css-render nodes. */
+import { CssRender } from 'dsh-tauri/client'
+import { RIGHTCLICK_CLASSES as K, RIGHTCLICK_STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+
+const rightClickStyle = c([
+ c(`.${K.menu}`, {
+ position: 'fixed',
+ zIndex: 2147483647,
+ width: 'max-content',
+ minWidth: '148px',
+ maxWidth: '260px',
+ padding: '4px',
+ background: 'var(--dsw-alias-bg-layer-2, #fff)',
+ color: 'var(--dsw-alias-label-primary, #161616)',
+ border: '1px solid var(--dsw-alias-border-l2, #ddd)',
+ borderRadius: '7px',
+ boxShadow: '0 5px 16px #00000029',
+ font: '13px/18px system-ui, sans-serif',
+ }),
+ c(`.${K.item}`, {
+ boxSizing: 'border-box',
+ width: '100%',
+ height: '30px',
+ padding: '0 8px',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+ color: 'inherit',
+ background: 'transparent',
+ border: '0',
+ borderRadius: '5px',
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '16px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ }, [
+ c('&:hover, &:focus-visible', {
+ background: 'var(--dsw-alias-interactive-bg-hover, #0000000f)',
+ outline: 'none',
+ }),
+ ]),
+ c(`.${K.itemDanger}`, {
+ color: 'var(--dsw-alias-state-error-primary, #d93025)',
+ }),
+ c(`.${K.shortcut}`, {
+ color: 'var(--dsw-alias-label-tertiary, #777)',
+ fontSize: '11px',
+ }),
+ c(`.${K.separator}`, {
+ height: '1px',
+ margin: '4px -4px',
+ background: 'var(--dsw-alias-border-l2, #ddd)',
+ }),
+ c(`.${K.toast}`, {
+ position: 'fixed',
+ zIndex: 2147483647,
+ left: '50%',
+ bottom: '28px',
+ transform: 'translateX(-50%)',
+ padding: '7px 12px',
+ borderRadius: '7px',
+ background: '#222',
+ color: '#fff',
+ font: '13px/18px system-ui, sans-serif',
+ boxShadow: '0 6px 20px #0003',
+ }),
+])
+
+/** 挂载右键菜单样式;若已由其他生命周期挂载则不取得所有权。 */
+export function mountRightClickStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(RIGHTCLICK_STYLE_ID) !== null)
+ return () => {}
+ rightClickStyle.mount({ id: RIGHTCLICK_STYLE_ID, head: true })
+ return () => rightClickStyle.unmount({ id: RIGHTCLICK_STYLE_ID })
+}
diff --git a/packages/dsh-tauri-rightclick/src/client/types.ts b/packages/dsh-tauri-rightclick/src/client/types.ts
new file mode 100644
index 00000000..97aac5bf
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/types.ts
@@ -0,0 +1,151 @@
+/** Client-side shared types for dsh-tauri-rightclick. */
+
+/** 会话列表摘要(最小 `ctx.sessions.list` 快照面)。 */
+export interface SessionSummaryLike {
+ id: string
+ title?: string
+ displayTitle?: string
+ cwd?: string
+ blank?: boolean
+}
+
+export interface SessionListSnapshotLike {
+ ids: string[]
+ byId: Record<string, SessionSummaryLike>
+ current?: string
+}
+
+/** 会话绑定(`ctx.sessions.binding` 返回面的最小子集)。 */
+export interface SessionBindingLike {
+ session: {
+ rename: (title: string) => Promise<{ ok: boolean, error?: { message?: string } }>
+ }
+}
+
+/** 最小 `ctx.sessions` 面(客户端用到的子集)。 */
+export interface SessionsRuntimeLike {
+ list: {
+ getSnapshot: () => SessionListSnapshotLike
+ }
+ binding: (sessionId: string) => SessionBindingLike | undefined
+ fork: (opts: { sessionId: string, increaseTitle?: boolean }) => Promise<string>
+ open: (sessionId: string) => void
+}
+
+/** 工作区视图(`ctx.workspaces.list` 快照项)。 */
+export interface WorkspaceViewLike {
+ workspaceId: string
+ title: string
+ path: string
+ sessionIds: string[]
+}
+
+export interface WorkspaceListSnapshotLike {
+ items: WorkspaceViewLike[]
+ archivedSessionIds: string[]
+}
+
+/** 最小 `ctx.workspaces` 面(客户端用到的子集)。 */
+export interface WorkspacesRuntimeLike {
+ list: {
+ getSnapshot: () => WorkspaceListSnapshotLike
+ }
+ archiveSession: (sessionId: string) => Promise<void>
+ startSession: (workspaceId: string) => void
+ delete: (workspaceId: string) => Promise<void>
+}
+
+/** 右键菜单扩展协议:其他 Web 插件登记到全局注册表的一条扩展项。 */
+export interface ContextMenuExtension {
+ id: string
+ order?: number
+ label?: string
+ /** 按会话决定是否显示(缺省显示)。 */
+ visible?: (context: { session?: SessionSummaryLike | null, row: Element | null }) => boolean
+ /** 点击菜单项时执行。 */
+ run: (context: {
+ session?: SessionSummaryLike | null
+ row: Element | null
+ sessions: SessionsRuntimeLike
+ workspaces: WorkspacesRuntimeLike
+ close: () => void
+ }) => void | Promise<void>
+}
+
+/** `dsh:rightclick-menu` 事件 detail(每次打开菜单时派发)。 */
+export interface ContextMenuEventDetail {
+ row: Element | null
+ /** 官方会话操作按钮(存在时)。 */
+ action: HTMLElement | null
+ session: SessionSummaryLike | null
+ workspace: WorkspaceViewLike | null
+ target: EventTarget | null
+ x: number
+ y: number
+ extensions: ContextMenuExtension[]
+}
+
+/** 本插件文案键(zh 字典键集合为权威)。 */
+export type LocaleKey
+ = | 'renameSession'
+ | 'archiveSession'
+ | 'openInExplorer'
+ | 'copyWorkingDirectory'
+ | 'copySessionId'
+ | 'forkSession'
+ | 'refresh'
+ | 'newSession'
+ | 'renameWorkspace'
+ | 'copyWorkspacePath'
+ | 'archiveWorkspaceSessions'
+ | 'archiveUngroupedSessions'
+ | 'undo'
+ | 'redo'
+ | 'cut'
+ | 'copy'
+ | 'paste'
+ | 'selectAll'
+ | 'copySelectedText'
+ | 'openInDefaultBrowser'
+ | 'copyLink'
+ | 'selectCurrentContent'
+ | 'copiedWorkingDirectory'
+ | 'copiedSessionId'
+ | 'copiedWorkspacePath'
+ | 'sessionRenamed'
+ | 'sessionArchived'
+ | 'copied'
+ | 'cutDone'
+ | 'linkCopied'
+ | 'noWorkspaceSessions'
+ | 'noUngroupedSessions'
+ | 'archiveWorkspaceTitle'
+ | 'archiveWorkspaceDescription'
+ | 'archiveWorkspaceConfirmAction'
+ | 'archiveUngroupedTitle'
+ | 'archiveUngroupedDescription'
+ | 'deleteWorkspace'
+ | 'deleteWorkspaceTitle'
+ | 'deleteWorkspaceDescription'
+ | 'deleteWorkspaceConfirm'
+ | 'workspaceDeleted'
+ | 'cancel'
+ | 'workspaceSessionsArchived'
+ | 'officialSessionActionUnavailable'
+ | 'officialWorkspaceActionUnavailable'
+ | 'openFailed'
+ | 'unknownError'
+ | 'clipboardUnavailable'
+ | 'clipboardReadFailed'
+ | 'useUndoShortcut'
+ | 'useRedoShortcut'
+ | 'invalidLink'
+ | 'officialRenameUnavailable'
+ | 'officialWorkspaceRenameUnavailable'
+ | 'officialArchiveUnavailable'
+ | 'officialForkUnavailable'
+ | 'sessionUnknown'
+ | 'sessionNameEmpty'
+ | 'sessionServiceUnavailable'
+ | 'renameFailed'
+ | 'editPositionUnknown'
diff --git a/packages/dsh-tauri-rightclick/src/constants.ts b/packages/dsh-tauri-rightclick/src/constants.ts
new file mode 100644
index 00000000..da1ab147
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/constants.ts
@@ -0,0 +1,9 @@
+/** Host-half protocol constants for dsh-tauri-rightclick. */
+
+export const RIGHTCLICK_PLUGIN_NAME = 'dsh-tauri-rightclick'
+export const RIGHTCLICK_API_PREFIX = '/api/dsh-rightclick-menu'
+/** 用系统默认浏览器打开外链(POST,同源 JSON)。 */
+export const OPEN_URL_ROUTE = `${RIGHTCLICK_API_PREFIX}/open-url`
+
+/** 请求体上限(开链只传一个小 JSON)。 */
+export const MAX_BODY_BYTES = 64 * 1024
diff --git a/packages/dsh-tauri-rightclick/src/index.ts b/packages/dsh-tauri-rightclick/src/index.ts
new file mode 100644
index 00000000..3519bc4f
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/index.ts
@@ -0,0 +1,94 @@
+/**
+ * dsh-tauri-rightclick 宿主侧(node half):系统浏览器开链。
+ *
+ * 客户端(src/client/)负责右键菜单的 DOM 交互;本 half 只提供宿主能力:
+ * - POST /api/dsh-rightclick-menu/open-url 用系统默认浏览器打开 http/https 外链
+ * (Harness 的 host.openPath 只接受文件系统路径,URL 必须走这里)。
+ *
+ * 路由只接受同源 JSON POST(isSameOriginJsonRequest 校验)。
+ */
+
+import type { HostContext, HostRoute } from './types.js'
+import { isSameOriginJsonRequest, openUrl, readJsonBody, respond, safeWebUrl, withConnectionAuth } from 'dsh-tauri'
+import {
+ OPEN_URL_ROUTE,
+ RIGHTCLICK_API_PREFIX,
+ RIGHTCLICK_PLUGIN_NAME,
+} from './constants.js'
+
+/** 插件名(诊断元数据,与导出的 name 一致)。 */
+export const name = RIGHTCLICK_PLUGIN_NAME
+
+/**
+ * 需要的宿主服务:webServer(HTTP 路由)、sessionPersistence(定位会话文件)、
+ * workspaceRegistry(归档过渡/记账)、agents(停止运行中会话)、
+ * sessions(live session 脱离)、storageDomain(投影/工作区账本)。
+ */
+export const inject = ['webServer', 'connection']
+
+/** API 路由前缀(客户端同源 fetch)。 */
+export const API_PREFIX = RIGHTCLICK_API_PREFIX
+
+/** 构建路由列表。 */
+export function buildRoutes(ctx: HostContext): HostRoute[] {
+ // 串行化变更操作:每个宿主变更依次排队执行。
+ let mutationTail: Promise<unknown> = Promise.resolve()
+ const withMutationLock = <T>(operation: () => Promise<T>): Promise<T> => {
+ const result = mutationTail.then(operation, operation)
+ mutationTail = result.then(() => undefined, () => undefined)
+ return result
+ }
+
+ const routes: HostRoute[] = [
+ {
+ kind: 'exact',
+ path: OPEN_URL_ROUTE,
+ handler: async (request, response) => {
+ if (request.method !== 'POST')
+ return respond(response, 405, { ok: false, error: 'method-not-allowed' })
+ const validation = isSameOriginJsonRequest(request)
+ if (!validation.ok)
+ return respond(response, validation.status, { ok: false, error: validation.error })
+ let body
+ try {
+ body = await readJsonBody(request)
+ }
+ catch {
+ return respond(response, 400, { ok: false, error: 'bad-request' })
+ }
+ const url = safeWebUrl(body?.url)
+ if (!url)
+ return respond(response, 400, { ok: false, error: 'invalid-url' })
+ return withMutationLock(async () => {
+ try {
+ await openUrl(url)
+ respond(response, 200, { ok: true })
+ }
+ catch (error) {
+ ctx.logger?.warn?.(`[${RIGHTCLICK_PLUGIN_NAME}] failed to open URL ${url}:`, error)
+ respond(response, 500, { ok: false, error: 'open-url-failed' })
+ }
+ })
+ },
+ },
+ ]
+ return routes.map(route => ({
+ ...route,
+ handler: withConnectionAuth(ctx.connection, route.handler, 'dsh-tauri-rightclick'),
+ }))
+}
+
+/**
+ * 插件体:注册 HTTP 路由。
+ * @param ctx - 宿主根上下文(注入 webServer/sessionPersistence/workspaceRegistry/
+ * agents/sessions/storageDomain)。
+ */
+export function apply(ctx: HostContext): void {
+ ctx.effect(() => {
+ const disposers = buildRoutes(ctx).map(route => ctx.webServer.register(route))
+ return () => {
+ for (const dispose of disposers)
+ dispose()
+ }
+ }, `${RIGHTCLICK_PLUGIN_NAME}: routes`)
+}
diff --git a/packages/dsh-tauri-rightclick/src/types.ts b/packages/dsh-tauri-rightclick/src/types.ts
new file mode 100644
index 00000000..d02a1803
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/types.ts
@@ -0,0 +1,17 @@
+/** Host-half shared types for dsh-tauri-rightclick. */
+
+/** 宿主上下文(沿用工作区先例:插件按需解构具体服务)。 */
+export type HostContext = any
+
+/** 路由处理器收到的 JSON 请求体。 */
+export type JsonBody = Record<string, unknown>
+
+export type RouteResult = [number, unknown]
+export type RouteFunction = (body: JsonBody, req: import('node:http').IncomingMessage) => Promise<RouteResult>
+
+/** 每个 host route 的注册描述(传给 ctx.webServer.register)。 */
+export interface HostRoute {
+ kind: 'exact'
+ path: string
+ handler: (req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => void | Promise<void>
+}
diff --git a/packages/dsh-tauri-rightclick/tsconfig.json b/packages/dsh-tauri-rightclick/tsconfig.json
new file mode 100644
index 00000000..520166d0
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/tsconfig.json
@@ -0,0 +1,4 @@
+{
+ "extends": "../../tsconfig.json",
+ "include": ["src/**/*.ts", "src/**/*.tsx", "../../types/**/*.d.ts"]
+}
diff --git a/packages/dsh-tauri-rightclick/tsdown.config.ts b/packages/dsh-tauri-rightclick/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri-session/README.md b/packages/dsh-tauri-session/README.md
new file mode 100644
index 00000000..6a603464
--- /dev/null
+++ b/packages/dsh-tauri-session/README.md
@@ -0,0 +1,94 @@
+# dsh-tauri-session
+
+DeepSeek Harness 桌面端插件:管理「已归档的聊天」的设置页(搜索 / 排序 / 分组 /
+项目选择 / 取消归档 / 全部删除),并在官方工作区浏览器的「删除工作区」菜单旁
+追加「归档工作区」入口。
+
+采用 host half / client half 架构:
+
+- `src/*.ts`:宿主侧(node half)实现。
+- `src/client/*.ts(x)`:浏览器侧(browser half)实现,渲染设置分区与 DOM 补丁。
+
+## 功能
+
+- **设置页「归档」**:在设置侧边栏新增「归档」导航项,内容为「已归档的聊天」列表。
+- **归档页控件**:搜索框(搜索已归档的聊天)、排序方式(更新时间 / 创建时间 /
+ 按字母排序)、项目选择框 —— 使用官方
+ `@deepseek-ai/dsh-client-ui-primitives` 组件(`Input` / `Menu` / `Button`);
+ 下拉触发器对齐官方「通用设置」Select 的 pill 样式(36px 全圆角、无边框、
+ `bg-module-platform` 底)。
+- **分组规则**:排序方式同时影响「组」与「组内聊天」(两级都排序);组按成员
+ 聚合值排序,组内按排序方式排序;无项目组统一命名为「未分组」。
+- **取消归档**:从宿主归档集合移除该会话后,回到其原来的工作区组(宿主归档
+ 从不修改工作区 sessionIds 记账,会话在组内保留的位置自动恢复显示);成功后
+ 弹「对话已取消归档 [查看]」toast,查看可跳转到恢复的会话。
+- **彻底删除**:每行垃圾桶与「全部删除」(危险色)为破坏性操作,均经官方
+ `Modal` 二次确认(单项:「删除已归档聊天?」;全部:「删除所有已归档本地
+ 聊天?」)—— 从宿主归档集合移除并物理删除会话数据(宿主无公开「删除会话」
+ API,按 `$DSH_HOME/sessions/<group>/session-<id>/` 有界扫描删除的是会话
+ 持久化目录,宿主重启后从持久化重建索引,会话从工作区与归档中彻底消失)。
+- **加载态**:变更(取消归档 / 删除)进行中时动作按钮禁用并弹 loading toast,
+ 完成后消失;失败在页面顶部显示错误。
+
+## 归档机制(v2:宿主归档集合)
+
+v2 起插件不再自持 `archive.json`,而是直接使用**宿主 `WorkspaceRegistry` 的归档
+集合**(`archivedSessionIds`,持久化、对官方所有分组界面隐藏、不动工作区记账)——
+与官方会话行菜单里的「归档」动作写入的是同一份数据,因此两种入口归档的会话都会
+出现在本插件的「已归档的聊天」页面。
+
+- 宿主公开 API 只有 `archiveSession`(没有 unarchive),因此「取消归档」/「全部
+ 删除」经由注册表内部状态机(`enqueueOperation` + `requireState` + `setState`)
+ 改写归档集合;若宿主升级改变内部结构,接口会明确报错而不是静默降级。
+- 插件初始化时会把 v1 自持的 `~/.dsh/dsh-tauri-session/archive.json` 记录一次性
+ 迁入宿主归档集合并删除旧文件(会话已不存在的僵尸记录随旧文件丢弃)。
+
+## 宿主路由(/api/dsh-session/*)
+
+| 方法 | 路径 | 说明 |
+| --- | --- | --- |
+| GET | `/archived` | 宿主归档集合 id + 每个会话的创建元数据(读 host session header) |
+| POST | `/archive` | 归档单个会话 |
+| POST | `/archive-workspace` | 归档一组会话(一次调用) |
+| POST | `/unarchive` | 取消归档(改写宿主归档集合) |
+| POST | `/delete` | 彻底删除单个归档会话(归档集合移除 + 物理删除会话数据) |
+| POST | `/clear` | 彻底删除全部已归档会话(同上,批量) |
+
+## 客户端补丁(workspace-patch.ts)
+
+官方 WorkspaceBrowser 的「删除工作区」是项目行「…」菜单(primitives `Menu`,
+portal 渲染到 `document.body`)里的 `button[role=menuitem]` 条目,不是侧边栏按钮。
+补丁因此:
+
+1. 监听每个项目行(`[role=treeitem][aria-expanded]`)「…」按钮的点击,按行标题与
+ 运行时快照唯一匹配记录其工作区 id;
+2. 扫描 portal 菜单:**保留**官方「删除工作区」条目(官方 Modal 确认、非破坏性:
+ 文件夹与会话记录保留,会话归入未分组),在其后**追加**「归档工作区」条目,
+ 点击 → 客户端样式确认框 → 归档该组全部会话(`/api/dsh-session/archive-workspace`)。
+
+归档目标与会话清单全部来自运行时快照(`workspace.sessionIds`),不依赖
+「组容器里装得下会话行」的 DOM 启发式——官方浏览器在组折叠时不渲染会话行,
+旧实现会因此「全部折叠时无动作、部分展开时错归档到相邻工作区」。
+
+## 目录约定
+
+- 旧版(v1)自有状态目录 `$DSH_HOME/dsh-tauri-session/`(默认
+ `~/.dsh/dsh-tauri-session/`)仅在迁移旧记录时读取;v2 不再写入。
+
+## 开发
+
+```bash
+pnpm install
+pnpm -F dsh-tauri-session typecheck
+pnpm -F dsh-tauri-session test -- --run
+pnpm -F dsh-tauri-session build
+```
+
+全局校验:
+
+```bash
+pnpm run lint --fix
+pnpm run typecheck
+pnpm run test -- --run
+pnpm run build
+```
diff --git a/packages/dsh-tauri-session/cordis.patch.yml b/packages/dsh-tauri-session/cordis.patch.yml
new file mode 100644
index 00000000..14f98ff4
--- /dev/null
+++ b/packages/dsh-tauri-session/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-session
+ name: dsh-tauri-session
diff --git a/packages/dsh-tauri-session/package.json b/packages/dsh-tauri-session/package.json
new file mode 100644
index 00000000..21ffd854
--- /dev/null
+++ b/packages/dsh-tauri-session/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "dsh-tauri-session",
+ "type": "module",
+ "version": "0.6.7",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "@deepseek-ai/dsh-client-ui-primitives",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-session/src/client/constants.ts b/packages/dsh-tauri-session/src/client/constants.ts
new file mode 100644
index 00000000..e2f6e8b7
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/constants.ts
@@ -0,0 +1,69 @@
+/** Shared protocol and UI constants for the dsh-tauri-session client plugin. */
+
+export const SESSION_CLIENT_PLUGIN = 'dsh-tauri-session'
+export const SESSION_CLIENT_NS = SESSION_CLIENT_PLUGIN
+export const SESSION_API_PREFIX = '/api/dsh-session'
+export const SESSION_REGISTRANT = SESSION_CLIENT_PLUGIN
+
+export const SETTINGS_SECTION_SLOT = 'settings.section'
+export const SESSION_SECTION_ID = 'dsh-tauri-session-archive'
+export const SESSION_SECTION_ORDER = 220
+
+export const SESSION_STYLE_ID = 'dsh-tauri-session-styles'
+
+/** Effects / lifecycle ids (诊断元数据). */
+export const SESSION_STYLES_EFFECT = `${SESSION_CLIENT_PLUGIN}: styles`
+export const SESSION_ARCHIVE_PATCH_EFFECT = `${SESSION_CLIENT_PLUGIN}: workspace archive patch`
+export const SESSION_ARCHIVE_SECTION_EFFECT = `${SESSION_CLIENT_PLUGIN}: archive section`
+
+/** css-render class prefix (value 仅用于样式命名,不作为协议). */
+export const SESSION_CLASSES = {
+ page: 'dsh-tauri-session-page',
+ header: 'dsh-tauri-session-header',
+ title: 'dsh-tauri-session-title',
+ deleteAll: 'dsh-tauri-session-delete-all',
+ toolbar: 'dsh-tauri-session-toolbar',
+ search: 'dsh-tauri-session-search',
+ menuSelect: 'dsh-tauri-session-menu-select',
+ menuSelectLabel: 'dsh-tauri-session-menu-select-label',
+ menuSelectChevron: 'dsh-tauri-session-menu-select-chevron',
+ groups: 'dsh-tauri-session-groups',
+ group: 'dsh-tauri-session-group',
+ groupHeader: 'dsh-tauri-session-group-header',
+ groupTitle: 'dsh-tauri-session-group-title',
+ groupCount: 'dsh-tauri-session-group-count',
+ groupMenu: 'dsh-tauri-session-group-menu',
+ groupMenuTrigger: 'dsh-tauri-session-group-menu-trigger',
+ list: 'dsh-tauri-session-list',
+ row: 'dsh-tauri-session-row',
+ rowMain: 'dsh-tauri-session-row-main',
+ rowTitle: 'dsh-tauri-session-row-title',
+ rowTime: 'dsh-tauri-session-row-time',
+ rowActions: 'dsh-tauri-session-row-actions',
+ rowDelete: 'dsh-tauri-session-row-delete',
+ unarchive: 'dsh-tauri-session-unarchive',
+ deleteBtn: 'dsh-tauri-session-delete-btn',
+ deleteBtnText: 'dsh-tauri-session-delete-btn-text',
+ empty: 'dsh-tauri-session-empty',
+ error: 'dsh-tauri-session-error',
+ toastView: 'dsh-tauri-session-toast-view',
+ archiveMenuItem: 'dsh-tauri-session-archive-menu-item',
+} as const
+
+/**
+ * Sync strings for matching the official workspace-row menu's delete item
+ * (zh/en). The item is a primitives `Menu` row rendered in a portal, so the
+ * patch scans `document.body`, not the sidebar.
+ */
+export const DELETE_WORKSPACE_LABELS: readonly string[] = ['删除工作区', 'Delete workspace']
+
+/** Official primitives menu row selector (portal). */
+export const MENU_ITEM_SELECTOR = 'button[role="menuitem"]'
+
+/** Sidebar shell seat holding the official WorkspaceBrowser. */
+export const SIDEBAR_SELECTOR = '[data-slot="sidebar"]'
+
+/** Attribute marking a project-row ellipsis whose click records the open menu's workspace. */
+export const WORKSPACE_MENU_ANCHOR_ATTRIBUTE = 'data-dsh-tauri-session-menu-anchor'
+/** Attribute marking a portal workspace menu already patched with the archive item. */
+export const WORKSPACE_MENU_PATCH_ATTRIBUTE = 'data-dsh-tauri-session-archive-menu-patched'
diff --git a/packages/dsh-tauri-session/src/client/icons.tsx b/packages/dsh-tauri-session/src/client/icons.tsx
new file mode 100644
index 00000000..10b74187
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/icons.tsx
@@ -0,0 +1,29 @@
+import type { ReactElement } from 'react'
+import type { IconProps } from './types'
+
+export function IconTrashBin({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M9 2H7a.5.5 0 0 0-.5.5V3h3v-.5A.5.5 0 0 0 9 2m2 1v-.5a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2V3H2.251a.75.75 0 0 0 0 1.5h.312l.317 7.625A3 3 0 0 0 5.878 15h4.245a3 3 0 0 0 2.997-2.875l.318-7.625h.312a.75.75 0 0 0 0-1.5zm.936 1.5H4.064l.315 7.562A1.5 1.5 0 0 0 5.878 13.5h4.245a1.5 1.5 0 0 0 1.498-1.438zm-6.186 2v5a.75.75 0 0 0 1.5 0v-5a.75.75 0 0 0-1.5 0m3.75-.75a.75.75 0 0 1 .75.75v5a.75.75 0 0 1-1.5 0v-5a.75.75 0 0 1 .75-.75" clipRule="evenodd" /></svg>
+}
+
+export function IconMagnifier({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0m-.82 4.74a6 6 0 1 1 1.06-1.06l2.79 2.79a.75.75 0 1 1-1.06 1.06z" clipRule="evenodd" /></svg>
+}
+
+export function IconFolderOpen({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="m6.379 4.5-.44-.44-.621-.62A1.5 1.5 0 0 0 4.258 3H3a1.5 1.5 0 0 0-1.5 1.5v5.25l1.376-2.293A3 3 0 0 1 5.45 6h7.05A1.5 1.5 0 0 0 11 4.5zM14 6.026V6a3 3 0 0 0-3-3H7l-.621-.621A3 3 0 0 0 4.257 1.5H3a3 3 0 0 0-3 3V11a3 3 0 0 0 3 3h8.301a3 3 0 0 0 2.573-1.457l1.791-2.985A2.35 2.35 0 0 0 14 6.026M10 12.5h1.301a1.5 1.5 0 0 0 1.287-.728l1.791-2.986 1.286.772-1.286-.772a.85.85 0 0 0-.728-1.286H5.449a1.5 1.5 0 0 0-1.287.728l-1.791 2.986a.85.85 0 0 0 .728 1.286z" clipRule="evenodd" /></svg>
+}
+
+export function IconChevronDown({ size = 16, className }: IconProps): ReactElement {
+ return <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 16 16" fill="none" className={className} aria-hidden="true"><path fill="currentColor" fillRule="evenodd" d="M2.97 5.47a.75.75 0 0 1 1.06 0L8 9.44l3.97-3.97a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" /></svg>
+}
+
+/** Official 16px horizontal ellipsis icon. */
+export function IconEllipsis({ size = 14, className }: IconProps): ReactElement {
+ return (
+ <svg width={size} height={size} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className} aria-hidden="true" style={{ marginTop: '1px' }}>
+ <path d="M4.55146 8.00001C4.55146 8.63513 4.03659 9.15001 3.40146 9.15001C2.76634 9.15001 2.25146 8.63513 2.25146 8.00001C2.25146 7.36488 2.76634 6.85001 3.40146 6.85001C4.03659 6.85001 4.55146 7.36488 4.55146 8.00001Z" fill="currentColor" />
+ <path d="M9.1476 8.00001C9.1476 8.63513 8.63273 9.15001 7.9976 9.15001C7.36248 9.15001 6.8476 8.63513 6.8476 8.00001C6.8476 7.36488 7.36248 6.85001 7.9976 6.85001C8.63273 6.85001 9.1476 7.36488 9.1476 8.00001Z" fill="currentColor" />
+ <path d="M13.7486 8.00001C13.7486 8.63513 13.2338 9.15001 12.5986 9.15001C11.9635 9.15001 11.4486 8.63513 11.4486 8.00001C11.4486 7.36488 11.9635 6.85001 12.5986 6.85001C13.2338 6.85001 13.7486 7.36488 13.7486 8.00001Z" fill="currentColor" />
+ </svg>
+ )
+}
diff --git a/packages/dsh-tauri-session/src/client/index.ts b/packages/dsh-tauri-session/src/client/index.ts
new file mode 100644
index 00000000..748b059b
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/index.ts
@@ -0,0 +1,71 @@
+/**
+ * dsh-tauri-session 客户端插件体(browser half):「已归档的聊天」设置分区 +
+ * 工作区浏览器的「删除工作区 → 归档工作区」替换。
+ *
+ * 两块功能:
+ * - archive-page.tsx 注册进 settings.section(导航项「归档」,经官方设置侧边栏
+ * 投影出导航行),渲染归档列表页(搜索 / 排序 / 分组 / 项目选择 / 取消归档);
+ * 数据源为宿主归档集合(官方「归档」与「归档工作区」共用同一份数据)。
+ * - workspace-patch.ts DOM 补丁:把官方项目行「…」菜单里的「删除工作区」改写为
+ * 「归档工作区」,点击改为归档该组全部会话(portal 菜单条目拦截)。
+ *
+ * 与 node half(src/index.ts)经 /api/dsh-session/* 通信(archived/archive/
+ * archive-workspace/unarchive/clear)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import { compat } from 'dsh-tauri/client'
+import {
+ SESSION_ARCHIVE_PATCH_EFFECT,
+ SESSION_ARCHIVE_SECTION_EFFECT,
+ SESSION_REGISTRANT,
+ SESSION_SECTION_ID,
+ SESSION_SECTION_ORDER,
+ SESSION_STYLES_EFFECT,
+ SETTINGS_SECTION_SLOT,
+} from './constants'
+import { installLocale, text } from './locale'
+import { ArchivePanel } from './panel'
+import { mountSessionStyles } from './styles'
+import { installWorkspaceArchivePatch } from './workspace-patch'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = 'dsh-tauri-session'
+
+/** 需要的客户端服务:slots / locale / sessions / workspaces。 */
+export const inject = ['slots', 'locale', 'sessions', 'workspaces']
+
+/**
+ * 插件体:安装文案与样式,注册「归档」设置分区,并安装工作区浏览器补丁。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ const cx = compat(ctx)
+ installLocale(cx)
+
+ ctx.effect(() => mountSessionStyles(), SESSION_STYLES_EFFECT)
+
+ // 1) 设置页「归档」分区(settings.section 单槽注册;导航行/内容由官方设置侧边栏投影)。
+ // 'settings.section' 不在本插件类型图的 SlotMap 键(声明权在 ui-sidebar / ui-layout),
+ // 此处对 options 显式 cast(先例:dsh-tauri-worktree 的 conversation.input.dock)。
+ // alpha 要求注册进入前槽已由父条目 children 表声明:settings.section 由
+ // ui-settings-general 的 sidebar.settings 条目声明,故用 inject 等其声明 live。
+ ctx.effect(
+ () =>
+ ctx.slots.inject(SETTINGS_SECTION_SLOT as never, () =>
+ ctx.slots.register(
+ {
+ name: SETTINGS_SECTION_SLOT,
+ id: SESSION_SECTION_ID,
+ order: SESSION_SECTION_ORDER,
+ registrant: SESSION_REGISTRANT,
+ label: () => text('section'),
+ inject: () => ({ sessionsRuntime: cx.sessions, workspacesRuntime: cx.workspaces }),
+ } as never,
+ ArchivePanel,
+ )),
+ SESSION_ARCHIVE_SECTION_EFFECT,
+ )
+
+ // 2) 工作区浏览器补丁:替换「删除工作区」+ 隐藏归档会话行。
+ ctx.effect(() => installWorkspaceArchivePatch(cx.workspaces as unknown as import('./types').WorkspacesRuntimeLike, cx.sessions as unknown as import('./types').SessionsRuntimeLike), SESSION_ARCHIVE_PATCH_EFFECT)
+}
diff --git a/packages/dsh-tauri-session/src/client/locale.ts b/packages/dsh-tauri-session/src/client/locale.ts
new file mode 100644
index 00000000..eff155e3
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/locale.ts
@@ -0,0 +1,129 @@
+/**
+ * locale.ts — 本插件自有文案(归档设置页 / 归档工作区按钮)。
+ * 走 locale 服务的非类型化注册面(register(ns, locale, dict)),zh/en 双语齐备。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import type { LocaleKey } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { SESSION_CLIENT_NS as NS } from './constants'
+
+export { SESSION_CLIENT_NS as NS } from './constants'
+
+/** zh 字典(键集合的权威)。 */
+const DICT_ZH = {
+ section: '归档',
+ archiveTitle: '已归档的聊天',
+ deleteAll: '全部删除',
+ searchPlaceholder: '搜索已归档的聊天',
+ sortLabel: '排序方式',
+ sortUpdatedAt: '更新时间',
+ sortCreatedAt: '创建时间',
+ sortTitle: '按字母排序',
+ allProjects: '所有项目',
+ ungrouped: '未分组',
+ unarchive: '取消归档',
+ empty: '没有已归档的聊天',
+ noResults: '没有匹配的聊天',
+ loadFailed: '加载失败',
+ chats: '个聊天',
+ groupMenuAria: '项目操作',
+ deleteProjectChats: '删除项目中的全部会话',
+ deleteProjectTitle: '删除该项目中的所有聊天?',
+ deleteProjectBody: '这将永久删除「{workspace}」中的 {count} 条本地已归档聊天',
+ archiveWorkspace: '归档会话',
+ archiveWorkspaceMenu: '归档工作区',
+ archiveWorkspaceTitle: '归档 {count} 个会话?',
+ archiveWorkspaceDescription: '这会将 {workspace} 中的会话归档。之后你可以在已归档的会话中找到它们',
+ archiveWorkspaceConfirm: '全部归档',
+ cancel: '取消',
+ deleteConfirm: '删除',
+ deleteRowAria: '删除此会话',
+ deleteSingleTitle: '删除已归档聊天?',
+ deleteSingleBody: '这将永久删除已归档聊天',
+ deleteAllTitle: '删除所有已归档本地聊天?',
+ deleteAllBody: '这将永久删除所有本地已归档聊天记录',
+ loading: '处理中…',
+ unarchivedToast: '对话已取消归档',
+ view: '查看',
+ untitled: '未命名会话',
+ requestFailed: '请求失败 ({status})',
+ requestTimeout: '请求超时,请检查会话插件是否已加载最新版本',
+} as const satisfies Record<LocaleKey, string>
+
+/** en 字典,与 zh 键集完全一致(locale 运行时强制双语平衡)。 */
+const DICT_EN: Record<LocaleKey, string> = {
+ section: 'Archive',
+ archiveTitle: 'Archived chats',
+ deleteAll: 'Delete all',
+ searchPlaceholder: 'Search archived chats',
+ sortLabel: 'Sort by',
+ sortUpdatedAt: 'Updated time',
+ sortCreatedAt: 'Created time',
+ sortTitle: 'Alphabetical',
+ allProjects: 'All projects',
+ ungrouped: 'Ungrouped',
+ unarchive: 'Unarchive',
+ empty: 'No archived chats',
+ noResults: 'No matching chats',
+ loadFailed: 'Failed to load',
+ chats: 'chats',
+ groupMenuAria: 'Project actions',
+ deleteProjectChats: 'Delete all chats in project',
+ deleteProjectTitle: 'Delete all chats in this project?',
+ deleteProjectBody: 'This will permanently delete {count} locally archived chats in “{workspace}”.',
+ archiveWorkspace: 'Archive sessions',
+ archiveWorkspaceMenu: 'Archive workspace',
+ archiveWorkspaceTitle: 'Archive {count} sessions?',
+ archiveWorkspaceDescription: 'This will archive the sessions in {workspace}. You can find them in Archived sessions afterwards.',
+ archiveWorkspaceConfirm: 'Archive all',
+ cancel: 'Cancel',
+ deleteConfirm: 'Delete',
+ deleteRowAria: 'Delete this session',
+ deleteSingleTitle: 'Delete archived chat?',
+ deleteSingleBody: 'This will permanently delete the archived chat.',
+ deleteAllTitle: 'Delete all archived chats?',
+ deleteAllBody: 'This will permanently delete all locally archived chat records.',
+ loading: 'Working…',
+ unarchivedToast: 'Chat unarchived',
+ view: 'View',
+ untitled: 'Untitled session',
+ requestFailed: 'Request failed ({status})',
+ requestTimeout: 'Request timed out. Check that the session plugin is up to date.',
+}
+
+/** 活跃语言 id(module 级缓存,apply 时初始化并由订阅推进)。 */
+let activeLocale = 'en'
+
+/** 当前是否使用英文界面(格式化函数读取,避免导出可变绑定)。 */
+export function isEnglishLocale(): boolean {
+ return activeLocale === 'en'
+}
+
+/** locale 变更推进器:revision 前进 -> uSES 订阅方重渲染。 */
+export const localeRev = createExternalStore({ rev: 0 })
+
+/**
+ * 在 apply 里安装:注册双语字典,并桥接 locale 变更到 rev。
+ * @param ctx - 客户端根上下文(须已注入 locale 服务)。
+ */
+export function installLocale(ctx: ClientContext): void {
+ activeLocale = ctx.locale.getLocale().active
+ ctx.locale.register(NS, 'zh', DICT_ZH)
+ ctx.locale.register(NS, 'en', DICT_EN)
+ ctx.locale.subscribe(() => {
+ activeLocale = ctx.locale.getLocale().active
+ localeRev.set(state => ({ ...state, rev: state.rev + 1 }))
+ })
+}
+
+/** 按当前活跃语言取一条文案。 */
+export function text(key: LocaleKey, values: Record<string, string | number> = {}): string {
+ const template = activeLocale === 'en' ? DICT_EN[key] : DICT_ZH[key]
+ return template.replace(/\{(\w+)\}/g, (_, name: string) => String(values[name] ?? `{${name}}`))
+}
+
+/** 组件内订阅 locale 变更(revision 前进即重渲染)。 */
+export function useLocale(): void {
+ useSyncExternalStore(localeRev.subscribe, () => localeRev.getSnapshot().rev)
+}
diff --git a/packages/dsh-tauri-session/src/client/panel.tsx b/packages/dsh-tauri-session/src/client/panel.tsx
new file mode 100644
index 00000000..96be6fef
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/panel.tsx
@@ -0,0 +1,382 @@
+import type { MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
+/**
+ * archive-page.tsx — 设置页「归档」分区内容(已归档的聊天)。
+ *
+ * 布局(参照需求截图):
+ * 标题「已归档的聊天」 + 右上「全部删除」(危险色);
+ * 工具条:搜索框 / 排序方式下拉(官方 primitives Input + Menu 组件);
+ * 分组列表:每行左侧竖排「标题 + 时间」(标题加粗),右侧「垃圾桶(彻底删除)
+ * + 取消归档」按钮。删除均为破坏性操作,经官方 Modal 二次确认(单项 / 全部)。
+ *
+ * 数据源:宿主归档集合。列表 id 取「GET /archived 载荷 ∪ 客户端 workspace 快照的
+ * archivedSessionIds」——后者随宿主帧实时镜像官方「归档」动作,保证用户刚用官方
+ * 菜单归档的会话立刻出现在本页。
+ *
+ * 变更期间(unarchive/delete/clear)页面进入 pending:动作按钮禁用并弹 loading
+ * toast;取消归档成功后弹「对话已取消归档 [查看]」,查看可跳转到恢复的会话。
+ */
+import type { ReactElement } from 'react'
+import type { ArchivePanelProps, ArchiveRow, ArchiveSort, WorkspaceViewLike } from './types'
+import { Button, Input, Menu, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
+import { useCallback, useEffect, useState, useSyncExternalStore } from 'react'
+import { SESSION_CLASSES as K } from './constants'
+import { IconEllipsis, IconFolderOpen, IconMagnifier, IconTrashBin } from './icons'
+import { isEnglishLocale, text, useLocale } from './locale'
+import { MenuSelect } from './select'
+import { groupArchive } from './sort'
+import {
+ archiveStore,
+ clearArchive,
+ deleteSession,
+ deleteWorkspaceSessions,
+ refreshArchived,
+ setQuery,
+ setSort,
+ setWorkspaceFilter,
+ unarchiveSession,
+ useArchiveUi,
+} from './store'
+
+/** 打开的删除确认弹窗:null 关闭;'single' 删除单个会话;'all' 删除全部。 */
+type DeleteConfirm = null | { kind: 'single', sessionId: string } | { kind: 'all' } | { kind: 'workspace', workspaceTitle: string, sessionIds: string[] }
+
+function workspaceTitleOf(path: string): string {
+ const parts = path.replace(/[\\/]+$/, '').split(/[\\/]/)
+ return parts[parts.length - 1] ?? ''
+}
+
+/** 按出现顺序合并多个 id 列表(去重;GET 载荷优先,快照补漏)。 */
+function unionIds(...lists: readonly (readonly string[])[]): string[] {
+ const seen = new Set<string>()
+ const out: string[] = []
+ for (const list of lists) {
+ for (const id of list) {
+ if (seen.has(id))
+ continue
+ seen.add(id)
+ out.push(id)
+ }
+ }
+ return out
+}
+
+/** 合并归档载荷与 session/workspace 运行时快照,生成带展示字段的归档行。 */
+function buildRows(
+ archivedSessionIds: string[],
+ meta: Record<string, { createdAt?: number, cwd?: string, title?: string }>,
+ sessions: ReturnType<ArchivePanelProps['sessionsRuntime']['list']['getSnapshot']>,
+ workspaces: ReturnType<ArchivePanelProps['workspacesRuntime']['list']['getSnapshot']>,
+ titleById: Record<string, string>,
+): ArchiveRow[] {
+ const byPath = new Map<string, WorkspaceViewLike>()
+ for (const ws of workspaces.items) {
+ byPath.set(ws.path, ws)
+ }
+
+ const rows: ArchiveRow[] = []
+ for (const sessionId of archivedSessionIds) {
+ const summary = sessions.byId[sessionId]
+ const entry = meta[sessionId]
+ // The host archive set can briefly contain stale ids after a refresh; do not
+ // render those ghosts, and never expose temporary blank sessions as archives.
+ if (!summary && !entry)
+ continue
+ if (summary?.blank === true)
+ continue
+ let workspace = workspaces.items.find(ws => ws.sessionIds.includes(sessionId))
+ const cwd = summary?.cwd ?? entry?.cwd
+ if (!workspace && cwd)
+ workspace = byPath.get(cwd)
+ rows.push({
+ sessionId,
+ title: summary?.displayTitle ?? summary?.title ?? entry?.title ?? titleById[sessionId] ?? (cwd ? workspaceTitleOf(cwd) : undefined) ?? text('untitled'),
+ cwd,
+ createdAt: entry?.createdAt,
+ updatedAt: summary?.updatedAt,
+ workspaceId: workspace?.workspaceId,
+ workspaceTitle: workspace?.title ?? (workspace ? workspaceTitleOf(workspace.path) : undefined),
+ })
+ }
+ return rows
+}
+
+/** 设置页「归档」分区。 */
+export function ArchivePanel(props: ArchivePanelProps): ReactElement | null {
+ const ui = useArchiveUi()
+ useLocale()
+ const [confirm, setConfirm] = useState<DeleteConfirm>(null)
+ const [openGroupMenu, setOpenGroupMenu] = useState<string | null>(null)
+
+ const sessions = useSyncExternalStore(props.sessionsRuntime.list.subscribe, props.sessionsRuntime.list.getSnapshot)
+ const workspaces = useSyncExternalStore(props.workspacesRuntime.list.subscribe, props.workspacesRuntime.list.getSnapshot)
+
+ // 变更走宿主注册表内部状态机,不产生官方 changed frame;成功后手动重拉镜像。
+ const resyncWorkspaces = useCallback(() => {
+ return props.workspacesRuntime.manager?.refresh?.() ?? Promise.resolve()
+ }, [props.workspacesRuntime])
+ const refreshSessions = useCallback(() => {
+ return props.sessionsRuntime.refresh?.() ?? Promise.resolve()
+ }, [props.sessionsRuntime])
+
+ // 进入分区或宿主归档集合规模变化时刷新归档载荷(meta:createdAt/cwd)。
+ const archivedCount = (workspaces.archivedSessionIds ?? []).length
+ useEffect(() => {
+ void refreshArchived()
+ }, [archivedCount])
+
+ const archivedIds = unionIds(ui.archived.archivedSessionIds, workspaces.archivedSessionIds ?? [])
+ .filter(id => !ui.suppressedSessionIds.includes(id))
+ const rows = buildRows(archivedIds, ui.archived.meta, sessions, workspaces, ui.titleById)
+ useEffect(() => {
+ const titles: Record<string, string> = {}
+ for (const row of rows)
+ titles[row.sessionId] = row.title
+ const current = archiveStore.getSnapshot().titleById
+ if (Object.entries(titles).some(([id, title]) => current[id] !== title)) {
+ archiveStore.set(state => ({
+ ...state,
+ titleById: { ...state.titleById, ...titles },
+ }))
+ }
+ }, [rows])
+
+ const query = ui.query.trim().toLowerCase()
+ const filtered = query
+ ? rows.filter(row =>
+ row.title.toLowerCase().includes(query)
+ || (row.cwd ?? '').toLowerCase().includes(query)
+ || (row.workspaceTitle ?? '').toLowerCase().includes(query))
+ : rows
+
+ const visible = ui.workspaceId === 'all'
+ ? filtered
+ : filtered.filter(row => ui.workspaceId === 'ungrouped' ? !row.workspaceId : row.workspaceId === ui.workspaceId)
+
+ const groups = groupArchive(visible, ui.sort, text('ungrouped'))
+
+ const busy = ui.pending || ui.loading
+
+ /** 取消归档:成功后弹「对话已取消归档 [查看]」。 */
+ function handleUnarchive(sessionId: string): void {
+ void unarchiveSession(sessionId, resyncWorkspaces)
+ }
+
+ /** 确认弹窗的删除动作(单项 / 全部)。 */
+ function handleConfirmDelete(): void {
+ const active = confirm
+ setConfirm(null)
+ if (active?.kind === 'single') {
+ void deleteSession(active.sessionId, async () => {
+ await refreshSessions()
+ await resyncWorkspaces()
+ })
+ }
+ else if (active?.kind === 'all') {
+ void clearArchive(async () => {
+ await refreshSessions()
+ await resyncWorkspaces()
+ })
+ }
+ else if (active?.kind === 'workspace') {
+ void deleteWorkspaceSessions(active.sessionIds, async () => {
+ await refreshSessions()
+ await resyncWorkspaces()
+ })
+ }
+ }
+
+ const footer = (
+ <>
+ <Button variant="ghost" onClick={() => setConfirm(null)}>{text('cancel')}</Button>
+ <Button
+ variant="outline"
+ className={K.deleteBtn}
+ disabled={ui.pending}
+ onClick={handleConfirmDelete}
+ >
+ {text('deleteConfirm')}
+ </Button>
+ </>
+ )
+
+ return (
+ <div className={K.page}>
+ <div className={K.header}>
+ <h1 className={K.title}>{text('archiveTitle')}</h1>
+ <Button
+ type="button"
+ variant="ghost"
+ icon={<IconTrashBin />}
+ className={K.deleteAll}
+ style={{ color: 'var(--dsw-alias-state-error-primary)' }}
+ disabled={busy}
+ onClick={() => setConfirm({ kind: 'all' })}
+ >
+ <span className={K.deleteBtnText}>{text('deleteAll')}</span>
+ </Button>
+ </div>
+
+ <div className={K.toolbar}>
+ <Input
+ className={K.search}
+ value={ui.query}
+ placeholder={text('searchPlaceholder')}
+ aria-label={text('searchPlaceholder')}
+ icon={<IconMagnifier />}
+ onChange={event => setQuery(event.target.value)}
+ />
+ <MenuSelect
+ label={text('sortLabel')}
+ value={ui.sort}
+ onSelect={id => setSort(id as ArchiveSort)}
+ options={[
+ { id: 'updatedAt', label: text('sortUpdatedAt') },
+ { id: 'createdAt', label: text('sortCreatedAt') },
+ { id: 'title', label: text('sortTitle') },
+ ]}
+ />
+ <MenuSelect
+ label={text('allProjects')}
+ value={ui.workspaceId}
+ onSelect={setWorkspaceFilter}
+ options={[
+ { id: 'all', label: text('allProjects') },
+ ...[...projectOptions(rows).entries()].map(([id, title]) => ({ id, label: title })),
+ ...(rows.some(row => !row.workspaceId) ? [{ id: 'ungrouped', label: text('ungrouped') }] : []),
+ ]}
+ />
+ </div>
+
+ {ui.error && <div className={K.error}>{ui.error}</div>}
+
+ {!ui.loading && visible.length === 0 && (
+ <div className={K.empty}>{query ? text('noResults') : text('empty')}</div>
+ )}
+
+ <div className={K.groups}>
+ {groups.map(group => (
+ <section key={group.id} className={K.group}>
+ <div className={K.groupHeader}>
+ <IconFolderOpen />
+ <span className={K.groupTitle}>{group.title || text('ungrouped')}</span>
+ <span className={K.groupCount}>
+ {group.rows.length}
+ {' '}
+ {text('chats')}
+ </span>
+ <Menu
+ open={openGroupMenu === group.id}
+ onClose={() => setOpenGroupMenu(null)}
+ onSelect={(id) => {
+ setOpenGroupMenu(null)
+ if (id === 'delete') {
+ setConfirm({
+ kind: 'workspace',
+ workspaceTitle: group.title || text('ungrouped'),
+ sessionIds: rows.filter(row => group.id === 'ungrouped' ? !row.workspaceId : row.workspaceId === group.id).map(row => row.sessionId),
+ })
+ }
+ }}
+ items={[{
+ id: 'delete',
+ label: text('deleteProjectChats'),
+ icon: <IconTrashBin />,
+ danger: true,
+ } satisfies MenuEntry]}
+ portal
+ align="end"
+ anchor={(
+ <button
+ type="button"
+ className={K.groupMenuTrigger}
+ aria-label={text('groupMenuAria')}
+ aria-haspopup="menu"
+ aria-expanded={openGroupMenu === group.id}
+ onClick={() => setOpenGroupMenu(openGroupMenu === group.id ? null : group.id)}
+ >
+ <IconEllipsis />
+ </button>
+ )}
+ />
+ </div>
+ <ul className={K.list}>
+ {group.rows.map(row => (
+ <li key={row.sessionId} className={K.row}>
+ <div className={K.rowMain}>
+ <span className={K.rowTitle}>{row.title}</span>
+ <span className={K.rowTime}>{formatTime(row)}</span>
+ </div>
+ <div className={K.rowActions}>
+ <button
+ type="button"
+ className={K.rowDelete}
+ aria-label={text('deleteRowAria')}
+ disabled={busy}
+ onClick={() => setConfirm({ kind: 'single', sessionId: row.sessionId })}
+ >
+ <IconTrashBin />
+ </button>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className={K.unarchive}
+ disabled={busy}
+ onClick={() => handleUnarchive(row.sessionId)}
+ >
+ {text('unarchive')}
+ </Button>
+ </div>
+ </li>
+ ))}
+ </ul>
+ </section>
+ ))}
+ </div>
+
+ <Modal
+ open={confirm?.kind === 'single'}
+ onClose={() => setConfirm(null)}
+ title={text('deleteSingleTitle')}
+ description={text('deleteSingleBody')}
+ footer={footer}
+ />
+ <Modal
+ open={confirm?.kind === 'all'}
+ onClose={() => setConfirm(null)}
+ title={text('deleteAllTitle')}
+ description={text('deleteAllBody')}
+ footer={footer}
+ />
+ <Modal
+ open={confirm?.kind === 'workspace'}
+ onClose={() => setConfirm(null)}
+ title={text('deleteProjectTitle')}
+ description={confirm?.kind === 'workspace' ? text('deleteProjectBody', { count: confirm.sessionIds.length, workspace: confirm.workspaceTitle }) : ''}
+ footer={footer}
+ />
+ </div>
+ )
+}
+
+/** 项目下拉选项:从归档行收集「工作区 id → 标题」映射(保持出现顺序)。 */
+function projectOptions(rows: ArchiveRow[]): Map<string, string> {
+ const options = new Map<string, string>()
+ for (const row of rows) {
+ if (row.workspaceId)
+ options.set(row.workspaceId, row.workspaceTitle ?? row.workspaceId)
+ }
+ return options
+}
+
+function formatTime(row: ArchiveRow): string {
+ const value = row.updatedAt ?? row.createdAt
+ if (!value)
+ return ''
+ const d = new Date(value)
+ const pad = (n: number): string => String(n).padStart(2, '0')
+ if (isEnglishLocale()) {
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
+ }
+ return `${d.getFullYear()}年${pad(d.getMonth() + 1)}月${pad(d.getDate())}日 ${pad(d.getHours())}:${pad(d.getMinutes())}`
+}
diff --git a/packages/dsh-tauri-session/src/client/select.tsx b/packages/dsh-tauri-session/src/client/select.tsx
new file mode 100644
index 00000000..d92277a8
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/select.tsx
@@ -0,0 +1,60 @@
+import type { MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
+/**
+ * menu-select.tsx — 官方风格的「下拉选择」:primitives `Menu` 锚定在触发按钮上。
+ *
+ * 官方 UI 没有独立 `Select` 组件;设置页/选择器的标准做法是「触发按钮 + Menu」
+ * (参见官方 ModelSelect)。本组件封装该模式:触发按钮显示当前选项与旋转箭头,
+ * Menu 以 portal 形式打开(align=end,避免被祖先裁剪)。
+ */
+import type { ReactElement } from 'react'
+import type { MenuSelectProps } from './types'
+import { Menu } from '@deepseek-ai/dsh-client-ui-primitives'
+import { useState } from 'react'
+import { SESSION_CLASSES as K } from './constants'
+import { IconChevronDown } from './icons'
+import { useLocale } from './locale'
+
+/**
+ * 官方风格下拉选择器。
+ * @param props - 下拉选择器 props。
+ * @param props.value - 当前选中项 id。
+ * @param props.options - 有序选项列表。
+ * @param props.onSelect - 选中回调(携带选项 id)。
+ * @param props.label - 触发按钮的无障碍名称(aria-label)。
+ */
+export function MenuSelect({ value, options, onSelect, label }: MenuSelectProps): ReactElement {
+ const [open, setOpen] = useState(false)
+ useLocale()
+
+ const current = options.find(option => option.id === value)
+ const items: MenuEntry[] = options.map(option => ({ id: option.id, label: option.label }))
+
+ return (
+ <Menu
+ open={open}
+ onClose={() => setOpen(false)}
+ onSelect={(id) => {
+ setOpen(false)
+ onSelect(id)
+ }}
+ items={items}
+ selectedId={value}
+ portal
+ closeOnPointerLeave
+ align="end"
+ anchor={(
+ <button
+ type="button"
+ className={K.menuSelect}
+ aria-label={label}
+ aria-haspopup="menu"
+ aria-expanded={open}
+ onClick={() => setOpen(openState => !openState)}
+ >
+ <span className={K.menuSelectLabel}>{current?.label ?? value}</span>
+ <IconChevronDown size={14} className={K.menuSelectChevron} />
+ </button>
+ )}
+ />
+ )
+}
diff --git a/packages/dsh-tauri-session/src/client/sort.ts b/packages/dsh-tauri-session/src/client/sort.ts
new file mode 100644
index 00000000..4b5d383d
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/sort.ts
@@ -0,0 +1,93 @@
+/**
+ * archive-sort.ts — 归档列表的分组与排序纯函数。
+ *
+ * 需求规则:
+ * - 排序方式(更新时间 / 创建时间 / 按字母排序)同时影响「组」与「组内聊天」
+ * (组与聊天两级都排序);
+ * - 组的排序键取自其成员按当前排序方式聚合出的值(更新时间取组内最新、
+ * 创建时间取组内最早、字母取组内标题首位)。
+ */
+import type { ArchiveRow, ArchiveSort } from './types'
+
+/** 组内聊天排序后的行。 */
+export interface ArchiveGroupRow {
+ /** workspaceId,或未分组桶的 'ungrouped'。 */
+ id: string
+ /** 工作区标题;未分组桶传 ''(由组件填当前语言的「未分组」文案)。 */
+ title: string
+ rows: ArchiveRow[]
+}
+
+/** 单个聊天的排序键(按排序方式)。 */
+export function rowSortValue(row: ArchiveRow, sort: ArchiveSort): number | string {
+ if (sort === 'title')
+ return row.title.toLowerCase()
+ if (sort === 'createdAt')
+ return row.createdAt ?? 0
+ return row.updatedAt ?? 0
+}
+
+/** 按当前排序方式比较两个聊天(时间降序、字母升序)。 */
+function compareRows(a: ArchiveRow, b: ArchiveRow, sort: ArchiveSort): number {
+ const av = rowSortValue(a, sort)
+ const bv = rowSortValue(b, sort)
+ if (sort === 'title') {
+ const as = typeof av === 'string' ? av : ''
+ const bs = typeof bv === 'string' ? bv : ''
+ return as.localeCompare(bs)
+ }
+ return (bv as number) - (av as number)
+}
+
+/** 组的聚合排序键(按当前排序方式从成员聚合出)。 */
+function groupSortValue(rows: ArchiveRow[], sort: ArchiveSort): number | string {
+ if (sort === 'title')
+ return rows.reduce<string>((min, row) => (row.title.toLowerCase() < min ? row.title.toLowerCase() : min), rows[0]?.title.toLowerCase() ?? '')
+ if (sort === 'createdAt')
+ return rows.reduce<number>((min, row) => Math.min(min, row.createdAt ?? 0), Number.MAX_SAFE_INTEGER)
+ return rows.reduce<number>((max, row) => Math.max(max, row.updatedAt ?? 0), 0)
+}
+
+/**
+ * 把归档行按工作区分组并按排序方式排好(组与组内聊天两级都按排序方式排)。
+ * @param rows - 合并后的归档行(未过滤)。
+ * @param sort - 排序方式(影响组内与组排名)。
+ * @param ungroupedLabel - 「未分组」桶的标题。
+ * @returns 有序的组列表(组内已按排序方式排好)。
+ */
+export function groupArchive(rows: ArchiveRow[], sort: ArchiveSort, ungroupedLabel: string): ArchiveGroupRow[] {
+ const buckets = new Map<string, ArchiveRow[]>()
+ for (const row of rows) {
+ const key = row.workspaceId ?? 'ungrouped'
+ const bucket = buckets.get(key)
+ if (bucket)
+ bucket.push(row)
+ else
+ buckets.set(key, [row])
+ }
+
+ const groups: ArchiveGroupRow[] = []
+ for (const [id, memberRows] of buckets) {
+ const sortedRows = [...memberRows].sort((a, b) => compareRows(a, b, sort))
+ const workspace = id === 'ungrouped' ? undefined : rows.find(r => r.workspaceId === id)
+ groups.push({
+ id,
+ title: workspace?.workspaceTitle ?? (id === 'ungrouped' ? ungroupedLabel : ''),
+ rows: sortedRows,
+ })
+ }
+
+ // 组按成员聚合值排(时间降序、字母升序),与组内聊天同一排序口径。
+ groups.sort((a, b) => {
+ const av = groupSortValue(a.rows, sort)
+ const bv = groupSortValue(b.rows, sort)
+ if (sort === 'title') {
+ const as = typeof av === 'string' ? av : ''
+ const bs = typeof bv === 'string' ? bv : ''
+ return as.localeCompare(bs)
+ }
+ return (bv as number) - (av as number)
+ })
+
+ return groups
+}
diff --git a/packages/dsh-tauri-session/src/client/store.ts b/packages/dsh-tauri-session/src/client/store.ts
new file mode 100644
index 00000000..0b2f163c
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/store.ts
@@ -0,0 +1,225 @@
+/**
+ * store.ts — 归档页面的共享客户端状态与 RPC(/api/dsh-session/*)。
+ *
+ * store 保存「原始归档载荷」(archivedSessionIds + meta)与页面筛选状态;
+ * 每个归档会话的业务字段(标题、更新时间、工作区组)由组件合并
+ * ctx.sessions / ctx.workspaces 的运行时快照得到,这里不复制那份数据。
+ *
+ * unarchive/delete/clear 走宿主注册表内部状态机(官方没有对应 unary 动作),
+ * 不会产生官方 changed frame —— 因此这些变更成功后调用方必须传入 resync
+ * (ctx.workspaces.manager.refresh)重新拉取归档镜像,否则列表原地不动。
+ */
+import type { ArchivedListPayload, ArchiveSort, ArchiveUiState } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { SESSION_API_PREFIX } from './constants'
+import { text } from './locale'
+
+export type { ArchivedListPayload, ArchiveUiState } from './types'
+
+/** 从 unknown 错误里取可展示文本(Error 取 message,其余字符串化)。 */
+function errMessage(error: unknown): string {
+ return error instanceof Error ? error.message : String(error)
+}
+
+const MUTATION_TIMEOUT_MS = 15_000
+
+async function request<T>(path: string, init?: RequestInit): Promise<T> {
+ const controller = new AbortController()
+ const timeout = setTimeout(() => controller.abort(), MUTATION_TIMEOUT_MS)
+ try {
+ const res = await fetch(`${SESSION_API_PREFIX}${path}`, {
+ headers: { 'content-type': 'application/json' },
+ signal: controller.signal,
+ ...init,
+ })
+ const body = await res.json().catch(() => ({} as { error?: string })) as T & { error?: string }
+ if (!res.ok)
+ throw new Error(body.error ?? text('requestFailed', { status: res.status }))
+ return body as T
+ }
+ catch (error) {
+ if (error instanceof DOMException && error.name === 'AbortError')
+ throw new Error(text('requestTimeout'))
+ throw error
+ }
+ finally {
+ clearTimeout(timeout)
+ }
+}
+
+/** 查询归档会话列表。 */
+export function fetchArchived(): Promise<ArchivedListPayload> {
+ return request<ArchivedListPayload>('/archived')
+}
+
+/** 归档单个会话。 */
+export function postArchive(sessionId: string, workspaceId?: string, beforeSessionId?: string): Promise<ArchivedListPayload> {
+ return request<ArchivedListPayload>('/archive', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId, ...(workspaceId ? { workspaceId } : {}), ...(beforeSessionId ? { beforeSessionId } : {}) }),
+ })
+}
+
+/** 取消归档(会话回到其工作区组保留的位置)。 */
+export function postUnarchive(sessionId: string): Promise<{ ok: boolean }> {
+ return request<{ ok: boolean }>('/unarchive', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId }),
+ })
+}
+
+/** 彻底删除一个归档会话(宿主移除 + 物理删除会话数据,不可恢复)。 */
+export function postDelete(sessionId: string): Promise<{ ok: boolean }> {
+ return request<{ ok: boolean }>('/delete', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId }),
+ })
+}
+
+/** 归档整个工作区组(一次写入多条记录)。 */
+export function postArchiveWorkspace(workspaceId: string, sessionIds: string[]): Promise<ArchivedListPayload> {
+ return request<ArchivedListPayload>('/archive-workspace', {
+ method: 'POST',
+ body: JSON.stringify({ workspaceId, sessionIds }),
+ })
+}
+
+/** 清空归档(全部会话彻底删除,不可恢复)。 */
+export function postClear(): Promise<{ ok: boolean }> {
+ return request<{ ok: boolean }>('/clear', { method: 'POST', body: JSON.stringify({}) })
+}
+
+/** 删除项目内的全部归档会话。 */
+export function postDeleteWorkspace(sessionIds: readonly string[]): Promise<{ ok: boolean }> {
+ return request<{ ok: boolean }>('/delete-workspace', {
+ method: 'POST',
+ body: JSON.stringify({ sessionIds }),
+ })
+}
+
+/** 全局唯一共享状态源(模块级单例)。 */
+export const archiveStore = createExternalStore<ArchiveUiState>({
+ archived: { archivedSessionIds: [], meta: {} },
+ sort: 'updatedAt',
+ query: '',
+ workspaceId: 'all',
+ loading: false,
+ pending: false,
+ error: '',
+ suppressedSessionIds: [],
+ titleById: {},
+})
+
+/** 组件内订阅归档 UI 状态(uSES)。 */
+export function useArchiveUi(): ArchiveUiState {
+ return useSyncExternalStore(archiveStore.subscribe, archiveStore.getSnapshot)
+}
+
+/** 归档页排序方式(更新时间 / 创建时间 / 标题)。 */
+export function setSort(sort: ArchiveSort): void {
+ archiveStore.set(state => ({ ...state, sort }))
+}
+
+/** 归档页搜索关键字。 */
+export function setQuery(query: string): void {
+ archiveStore.set(state => ({ ...state, query }))
+}
+
+/** 归档页项目筛选('all' 显示全部组)。 */
+export function setWorkspaceFilter(workspaceId: string): void {
+ archiveStore.set(state => ({ ...state, workspaceId }))
+}
+
+/** 归档刷新代数:只允许最新一次刷新的响应写回 store(过期响应整体丢弃)。 */
+let refreshGeneration = 0
+
+/**
+ * 拉取归档载荷并写入 store。
+ *
+ * 刷新成功后清空抑制标记:抑制只服务于「变更 → 刷新」窗口内的幽灵行
+ * (宿主归档集合在变更后短暂含过期 id)。刷新成功即载荷权威,若保留抑制,
+ * 取消归档后再归档的会话会被旧标记永久过滤出归档页(#235)。
+ *
+ * 并发保护:每次调用推进代数,只有仍是最新代数的响应才写回 —— 否则慢的旧
+ * 响应会覆盖新数据,或把刚写入的抑制标记清掉(幽灵行提前闪现)。
+ */
+export async function refreshArchived(): Promise<void> {
+ const generation = ++refreshGeneration
+ archiveStore.set(state => ({ ...state, loading: true, error: '' }))
+ try {
+ const archived = await fetchArchived()
+ if (generation !== refreshGeneration)
+ return
+ archiveStore.set(state => ({ ...state, archived, loading: false, suppressedSessionIds: [] }))
+ }
+ catch (error) {
+ if (generation !== refreshGeneration)
+ return
+ archiveStore.set(state => ({ ...state, loading: false, error: errMessage(error) }))
+ }
+}
+
+/**
+ * 包裹一个破坏性/恢复变更:置 pending(驱动禁用 + loading toast),成功后并行
+ * 刷新归档载荷与工作区归档镜像,失败写入 error。返回是否成功。
+ */
+async function runMutation(mutate: () => Promise<unknown>, resync?: () => Promise<void>, sessionIds: readonly string[] = []): Promise<boolean> {
+ archiveStore.set(state => ({ ...state, pending: true, error: '' }))
+ try {
+ await mutate()
+ if (sessionIds.length > 0) {
+ archiveStore.set(state => ({
+ ...state,
+ suppressedSessionIds: [...state.suppressedSessionIds, ...sessionIds.filter(sessionId => !state.suppressedSessionIds.includes(sessionId))],
+ }))
+ }
+ await Promise.all([
+ refreshArchived(),
+ resync ? Promise.race([resync(), new Promise<void>(resolve => setTimeout(resolve, 2_000))]) : Promise.resolve(),
+ ])
+ return true
+ }
+ catch (error) {
+ archiveStore.set(state => ({ ...state, error: errMessage(error) }))
+ return false
+ }
+ finally {
+ archiveStore.set(state => ({ ...state, pending: false }))
+ }
+}
+
+/** 归档一个会话并刷新。 */
+export async function archiveSession(sessionId: string, workspaceId?: string, beforeSessionId?: string): Promise<void> {
+ archiveStore.set(state => ({
+ ...state,
+ suppressedSessionIds: state.suppressedSessionIds.filter(id => id !== sessionId),
+ }))
+ await runMutation(() => postArchive(sessionId, workspaceId, beforeSessionId))
+}
+
+/** 归档整个工作区并刷新。 */
+export async function archiveWorkspace(workspaceId: string, sessionIds: string[]): Promise<void> {
+ await runMutation(() => postArchiveWorkspace(workspaceId, sessionIds))
+}
+
+/** 取消归档并刷新(resync 重新拉取官方归档镜像)。返回是否成功。 */
+export function unarchiveSession(sessionId: string, resync?: () => Promise<void>): Promise<boolean> {
+ return runMutation(() => postUnarchive(sessionId), resync, [sessionId])
+}
+
+/** 彻底删除单个归档会话并刷新。返回是否成功。 */
+export function deleteSession(sessionId: string, resync?: () => Promise<void>): Promise<boolean> {
+ return runMutation(() => postDelete(sessionId), resync, [sessionId])
+}
+
+/** 彻底删除全部归档会话并刷新。返回是否成功。 */
+export function clearArchive(resync?: () => Promise<void>): Promise<boolean> {
+ const sessionIds = [...archiveStore.getSnapshot().archived.archivedSessionIds]
+ return runMutation(() => postClear(), resync, sessionIds)
+}
+
+/** 彻底删除项目内归档会话并刷新。返回是否成功。 */
+export function deleteWorkspaceSessions(sessionIds: readonly string[], resync?: () => Promise<void>): Promise<boolean> {
+ return runMutation(() => postDeleteWorkspace(sessionIds), resync, sessionIds)
+}
diff --git a/packages/dsh-tauri-session/src/client/styles.ts b/packages/dsh-tauri-session/src/client/styles.ts
new file mode 100644
index 00000000..9d780120
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/styles.ts
@@ -0,0 +1,258 @@
+/** Archive page styles generated as css-render nodes. */
+import { CssRender } from 'dsh-tauri/client'
+import { SESSION_CLASSES as K, SESSION_STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+
+const archiveStyle = c([
+ c(`.${K.page}`, {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '16px',
+ minHeight: '100%',
+ color: 'var(--dsw-alias-label-primary)',
+ }),
+ c(`.${K.header}`, {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ gap: '12px',
+ }),
+ c(`.${K.title}`, {
+ margin: 0,
+ fontSize: '24px',
+ lineHeight: '32px',
+ fontWeight: 600,
+ }),
+ // 「全部删除」:红字 + hover 透明红底。官方 ghost hover 是单类 + :hover:not()
+ // 的同特异性选择器,靠样式表顺序不保险,这里叠加双类抬高特异性保证覆盖。
+ c(`.${K.deleteAll}`, {
+ color: 'var(--dsw-alias-state-error-primary, var(--dsw-alias-danger-text, inherit))',
+ }),
+ c(`.${K.deleteAll}.${K.deleteAll}:hover:not(:disabled)`, {
+ background: 'var(--dsw-alias-interactive-bg-hover-danger)',
+ }),
+ c(`.${K.archiveMenuItem}`, {
+ color: 'var(--dsw-alias-label-primary) !important',
+ background: 'transparent !important',
+ }, [
+ c('&:hover', {
+ color: 'var(--dsw-alias-label-primary) !important',
+ background: 'var(--dsw-alias-interactive-bg-hover) !important',
+ }),
+ c('&:focus', {
+ color: 'var(--dsw-alias-label-primary) !important',
+ }),
+ ]),
+
+ c(`.${K.toolbar}`, {
+ position: 'sticky',
+ top: 0,
+ zIndex: 2,
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ flexWrap: 'wrap',
+ padding: '8px 0',
+ background: 'var(--dsw-alias-bg-base, var(--dsw-alias-bg-module-platform))',
+ }),
+ // 官方 Input 自带外观(32px 圆角框、focus 描边),这里只控制弹性宽度。
+ c(`.${K.search}`, {
+ flex: '1 1 220px',
+ minWidth: 0,
+ }),
+ // 官方风格下拉触发器(MenuSelect):对齐官方「通用设置」Select 的 pill 规格
+ // (36px 高、全圆角、无边框、bg-module-platform 底、hover 换 interactive 底)。
+ c(`.${K.menuSelect}`, {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: '12px',
+ boxSizing: 'border-box',
+ height: '36px',
+ maxWidth: '220px',
+ padding: '0 14px',
+ border: 'none',
+ borderRadius: '18px',
+ background: 'var(--dsw-alias-bg-module-platform)',
+ color: 'var(--dsw-alias-label-primary)',
+ cursor: 'pointer',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ lineHeight: '22px',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ c(`.${K.menuSelectLabel}`, {
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ minWidth: 0,
+ }),
+ c(`.${K.menuSelectChevron}`, {
+ flex: 'none',
+ }),
+ c(`.${K.groups}`, {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '20px',
+ }),
+ c(`.${K.group}`, {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '8px',
+ }),
+ c(`.${K.groupHeader}`, {
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ padding: '0 2px',
+ color: 'var(--dsw-alias-label-secondary)',
+ }),
+ c(`.${K.groupTitle}`, {
+ fontSize: '14px',
+ lineHeight: '22px',
+ fontWeight: 500,
+ color: 'var(--dsw-alias-label-primary)',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }),
+ c(`.${K.groupCount}`, {
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))',
+ marginLeft: 'auto',
+ }),
+ c(`.${K.groupMenuTrigger}`, {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '20px',
+ height: '20px',
+ padding: 0,
+ border: 'none',
+ borderRadius: '6px',
+ background: 'transparent',
+ color: 'var(--dsw-alias-label-secondary)',
+ cursor: 'pointer',
+ fontSize: '18px',
+ lineHeight: '1',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ // 重置 ul 默认 margin/padding/标记,行内边距由 .row 自行控制,去掉左侧缩进空白。
+ c(`.${K.list}`, {
+ display: 'flex',
+ flexDirection: 'column',
+ margin: 0,
+ padding: 0,
+ listStyle: 'none',
+ border: '1px solid var(--dsw-alias-border-weak, rgba(127,127,127,0.2))',
+ borderRadius: '12px',
+ overflow: 'hidden',
+ }),
+ c(`.${K.row}`, {
+ display: 'flex',
+ alignItems: 'center',
+ gap: '12px',
+ boxSizing: 'border-box',
+ padding: '14px 16px',
+ background: 'var(--dsw-alias-bg-base)',
+ minHeight: '64px',
+ }, [
+ c('& + &', { borderTop: '1px solid var(--dsw-alias-border-weak, rgba(127,127,127,0.2))' }),
+ ]),
+ c(`.${K.rowMain}`, {
+ flex: '1 1 auto',
+ minWidth: 0,
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '4px',
+ }),
+ c(`.${K.rowTitle}`, {
+ fontSize: '13px',
+ lineHeight: '22px',
+ fontWeight: 600,
+ color: 'var(--dsw-alias-label-primary)',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }),
+ c(`.${K.rowTime}`, {
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }),
+ c(`.${K.rowActions}`, {
+ flex: 'none',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ }),
+ // 行内垃圾桶:官方 iconButton 规格(28px 圆角方形、hover 底色)。
+ c(`.${K.rowDelete}`, {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '28px',
+ height: '28px',
+ flex: 'none',
+ padding: 0,
+ border: 'none',
+ borderRadius: '6px',
+ background: 'none',
+ color: 'var(--dsw-alias-label-secondary)',
+ cursor: 'pointer',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ c(`.${K.unarchive}`, {
+ color: 'var(--dsw-alias-label-primary)',
+ }),
+ // 删除确认弹窗的「删除」按钮:危险色(浅红底 + 红字)。
+ c(`.${K.deleteBtn}`, {
+ background: 'var(--dsw-alias-interactive-bg-hover-danger, var(--dsw-alias-interactive-bg-hover))',
+ borderColor: 'var(--dsw-alias-state-error-primary, var(--dsw-alias-border-l2))',
+ }, [
+ ]),
+ c(`.${K.empty}`, {
+ padding: '32px 0',
+ textAlign: 'center',
+ fontSize: '14px',
+ lineHeight: '22px',
+ color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))',
+ }),
+ c(`.${K.error}`, {
+ padding: '12px 16px',
+ borderRadius: '10px',
+ background: 'var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.08))',
+ color: 'var(--dsw-alias-state-error-primary, var(--dsw-alias-danger-text, var(--dsw-alias-label-primary)))',
+ fontSize: '13px',
+ lineHeight: '20px',
+ }),
+ // 取消归档 toast 里的「查看」:内联链接式动作按钮(官方 Toast 文案槽不支持动作,
+ // 这里以插件类名渲染内联按钮)。
+ c(`.${K.toastView}`, {
+ padding: 0,
+ border: 'none',
+ background: 'none',
+ color: 'var(--dsw-alias-brand-primary)',
+ font: 'inherit',
+ cursor: 'pointer',
+ }, [
+ c('&:hover', { textDecoration: 'underline' }),
+ ]),
+])
+
+export function mountSessionStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(SESSION_STYLE_ID) !== null)
+ return () => {}
+ archiveStyle.mount({ id: SESSION_STYLE_ID, head: true })
+ return () => archiveStyle.unmount({ id: SESSION_STYLE_ID })
+}
diff --git a/packages/dsh-tauri-session/src/client/types.ts b/packages/dsh-tauri-session/src/client/types.ts
new file mode 100644
index 00000000..e7683fb8
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/types.ts
@@ -0,0 +1,168 @@
+/** Client-side shared types for dsh-tauri-session. */
+
+/** Raw archive listing from the host (`GET /api/dsh-session/archived`). */
+export interface ArchivedListPayload {
+ archivedSessionIds: string[]
+ /** Per archived session, creation metadata read from the host session header. */
+ meta: Record<string, { createdAt?: number, cwd?: string, title?: string }>
+}
+
+/** One archived session row after merging host metadata + session/workspace runtime facts. */
+export interface ArchiveRow {
+ sessionId: string
+ title: string
+ cwd?: string
+ createdAt?: number
+ updatedAt?: number
+ archivedAt?: number
+ /** Workspace group this session is displayed under; undefined means the 未分组 bucket. */
+ workspaceId?: string
+ workspaceTitle?: string
+}
+
+/** Sort method for the archive page filter (applies to both rows and groups). */
+export type ArchiveSort = 'updatedAt' | 'createdAt' | 'title'
+
+/** Persistent archive-page UI state (shared via a module SnapshotStore). */
+export interface ArchiveUiState {
+ archived: ArchivedListPayload
+ sort: ArchiveSort
+ query: string
+ /** Selected project/workspace filter; 'all' shows every group. */
+ workspaceId: string
+ loading: boolean
+ /** A destructive/restore mutation is in flight (drives disabled + loading toast). */
+ pending: boolean
+ error: string
+ /** IDs hidden optimistically after a successful restore/delete until host mirror catches up. */
+ suppressedSessionIds: string[]
+ /** Titles observed before a session disappears from the filtered session list. */
+ titleById: Record<string, string>
+}
+
+/** Props injected into the settings.section slot component. */
+export interface ArchivePanelProps {
+ close?: () => void
+ sessionsRuntime: SessionsRuntimeLike
+ workspacesRuntime: WorkspacesRuntimeLike
+}
+
+/** Shared props for the local gravity-ui icon components. */
+export interface IconProps {
+ size?: number
+ className?: string
+}
+
+/** One option of the official-style dropdown (primitives Menu select). */
+export interface MenuSelectOption {
+ id: string
+ label: string
+}
+
+/** Props for the official-style `Menu`-based select trigger. */
+export interface MenuSelectProps {
+ /** Selected option id. */
+ value: string
+ /** Ordered options. */
+ options: MenuSelectOption[]
+ /** Called with the picked option id. */
+ onSelect: (id: string) => void
+ /** Accessible trigger name (aria-label). */
+ label: string
+}
+
+/** Minimal `ctx.sessions` face the archive page subscribes to. */
+export interface SessionsRuntimeLike {
+ list: {
+ subscribe: (listener: () => void) => () => void
+ getSnapshot: () => SessionListSnapshot
+ }
+ /** Open (navigate to) a session; used by the unarchive toast's 查看 action. */
+ /** Rebuild the in-memory session list after deleting persisted sessions. */
+ refresh?: () => Promise<void>
+}
+
+export interface SessionSummaryLike {
+ id: string
+ title?: string
+ displayTitle?: string
+ cwd?: string
+ updatedAt?: number
+ blank?: boolean
+ /** Session provenance; official sidebar hides subagent sessions. */
+ origin?: string
+}
+
+export interface SessionListSnapshot {
+ ids: string[]
+ byId: Record<string, SessionSummaryLike>
+ current?: string
+ phase?: 'pending' | 'ready'
+}
+
+/** Minimal `ctx.workspaces` face the archive page subscribes to. */
+export interface WorkspacesRuntimeLike {
+ list: {
+ subscribe: (listener: () => void) => () => void
+ getSnapshot: () => WorkspaceListSnapshot
+ }
+ /**
+ * Wire-truth owner behind the `list` projection. The plugin's unarchive/
+ * delete/clear mutations bypass the official unary actions (no changed
+ * frames are emitted), so callers re-sync the archive mirror via `refresh`.
+ */
+ manager?: {
+ refresh?: () => Promise<void>
+ }
+}
+
+export interface WorkspaceViewLike {
+ workspaceId: string
+ path: string
+ title?: string
+ sessionIds: string[]
+}
+
+export interface WorkspaceListSnapshot {
+ items: readonly WorkspaceViewLike[]
+ archivedSessionIds?: readonly string[]
+}
+
+export type LocaleKey
+ = | 'section'
+ | 'archiveTitle'
+ | 'deleteAll'
+ | 'searchPlaceholder'
+ | 'sortLabel'
+ | 'sortUpdatedAt'
+ | 'sortCreatedAt'
+ | 'sortTitle'
+ | 'allProjects'
+ | 'ungrouped'
+ | 'unarchive'
+ | 'empty'
+ | 'noResults'
+ | 'loadFailed'
+ | 'chats'
+ | 'groupMenuAria'
+ | 'deleteProjectChats'
+ | 'deleteProjectTitle'
+ | 'deleteProjectBody'
+ | 'archiveWorkspace'
+ | 'archiveWorkspaceMenu'
+ | 'archiveWorkspaceTitle'
+ | 'archiveWorkspaceDescription'
+ | 'archiveWorkspaceConfirm'
+ | 'cancel'
+ | 'deleteConfirm'
+ | 'deleteRowAria'
+ | 'deleteSingleTitle'
+ | 'deleteSingleBody'
+ | 'deleteAllTitle'
+ | 'deleteAllBody'
+ | 'loading'
+ | 'unarchivedToast'
+ | 'view'
+ | 'untitled'
+ | 'requestFailed'
+ | 'requestTimeout'
diff --git a/packages/dsh-tauri-session/src/client/workspace-patch.ts b/packages/dsh-tauri-session/src/client/workspace-patch.ts
new file mode 100644
index 00000000..cc9010cb
--- /dev/null
+++ b/packages/dsh-tauri-session/src/client/workspace-patch.ts
@@ -0,0 +1,348 @@
+import type { Root } from 'react-dom/client'
+/**
+ * workspace-patch.ts — 在官方工作区浏览器里为「删除工作区」补一个「归档工作区」。
+ *
+ * 官方 WorkspaceBrowser 的「删除工作区」不是侧边栏里的独立按钮,而是项目行
+ * 「…」菜单(primitives `Menu`,portal 渲染到 document.body)里的一个条目
+ * `button[role=menuitem]`。本补丁做两件事:
+ * 1. 监听每个项目行(`[role=treeitem][aria-expanded]`)的「…」按钮点击,
+ * 按行标题与运行时快照唯一匹配记录该行的工作区 id;
+ * 2. 扫描 document.body 的 portal 菜单:保留官方「删除工作区」条目原样
+ * (官方 Modal 确认,非破坏性:文件夹与会话记录保留,会话归入未分组),
+ * 在其前插入「归档工作区」条目(删除条目保持最底),点击 → 客户端样式确认框 → 归档该组全部会话。
+ *
+ * 归档目标与会话清单全部来自运行时快照(workspace.sessionIds),不依赖
+ * 「组容器里装得下会话行」的 DOM 启发式——官方浏览器在组折叠时不渲染会话行,
+ * 旧实现会因此「全部折叠时无动作、部分展开时错归档到相邻工作区」(#235)。
+ *
+ * 归档后会话由宿主归档集合隐藏(官方浏览器按 archivedSessionIds 过滤),
+ * 无需本插件再做行隐藏。
+ */
+import type { SessionsRuntimeLike, WorkspacesRuntimeLike, WorkspaceViewLike } from './types'
+import { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
+import { createElement } from 'react'
+import { createRoot } from 'react-dom/client'
+import {
+ DELETE_WORKSPACE_LABELS,
+ SESSION_CLASSES as K,
+ MENU_ITEM_SELECTOR,
+ SIDEBAR_SELECTOR,
+ WORKSPACE_MENU_ANCHOR_ATTRIBUTE,
+ WORKSPACE_MENU_PATCH_ATTRIBUTE,
+} from './constants'
+import { text } from './locale'
+import { archiveSession, archiveWorkspace } from './store'
+
+/** 归档条目图标(gravity-ui archive 的 path,与归档设置页一致)。 */
+const ARCHIVE_ICON_SVG = '<svg width="16" height="16" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.8659 2.05975C17.2603 2.05995 18.3913 3.19096 18.3914 4.58527V5.4874C18.3914 6.02747 18.2192 6.52672 17.9303 6.93735C17.9336 6.96524 17.9388 6.99318 17.9388 7.02195V12.8884C17.9388 13.6345 17.9395 14.2379 17.8996 14.7254C17.8642 15.1593 17.7936 15.5499 17.6373 15.9141L17.5654 16.0685C17.278 16.6328 16.8405 17.1046 16.3038 17.434L16.0679 17.5661C15.66 17.7739 15.2196 17.8598 14.7237 17.9003C14.2362 17.9401 13.6327 17.9405 12.8867 17.9405H7.11122C6.36511 17.9405 5.76171 17.9401 5.27418 17.9003C4.84051 17.8649 4.44949 17.7952 4.08545 17.6391L3.93104 17.5661C3.36673 17.2785 2.89392 16.8414 2.56465 16.3044L2.43245 16.0685C2.22473 15.6608 2.13878 15.2211 2.09825 14.7254C2.05841 14.2379 2.05912 13.6345 2.05912 12.8884V7.02195C2.05912 6.99284 2.06422 6.96449 2.06758 6.93629C1.77931 6.52592 1.60858 6.02687 1.60858 5.4874V4.58527C1.60876 3.19084 2.73962 2.05975 4.1341 2.05975H15.8659ZM16.4984 7.92936C16.296 7.98169 16.0847 8.01288 15.8659 8.01291H4.1341C3.91478 8.01291 3.70246 7.98194 3.49955 7.92936V12.8884C3.49955 13.6582 3.50053 14.1927 3.53445 14.608C3.56769 15.0146 3.62923 15.244 3.71635 15.415L3.7925 15.5514C3.98339 15.8627 4.25749 16.1165 4.58464 16.2833L4.72529 16.3435C4.88095 16.3993 5.08638 16.4402 5.39158 16.4651C5.80685 16.4991 6.34138 16.5001 7.11122 16.5001H12.8867C13.6564 16.5001 14.1911 16.499 14.6063 16.4651C15.0128 16.432 15.2429 16.3703 15.4133 16.2833L15.5508 16.2061C15.8618 16.0152 16.116 15.7419 16.2827 15.415L16.3429 15.2732C16.3985 15.1177 16.4396 14.9128 16.4645 14.608C16.4985 14.1927 16.4984 13.6583 16.4984 12.8884V7.92936ZM4.1341 3.50019C3.53511 3.50019 3.0492 3.98631 3.04902 4.58527V5.4874C3.04902 6.08649 3.535 6.57248 4.1341 6.57248H15.8659C16.4648 6.57228 16.951 6.08638 16.951 5.4874V4.58527C16.9509 3.98644 16.4647 3.50038 15.8659 3.50019H4.1341Z" fill="currentColor"/></svg>'
+
+/**
+ * 从 React Fiber key 里读 session id(只读,不移动 React 管理的节点)。
+ * 参照 dsh-tauri-worktree/src/client/session.ts 的 HARDCODE 技法。
+ */
+function reactKey(element: Element, prefix: 'session-' | ''): string | undefined {
+ const fiberName = Object.keys(element).find(key => key.startsWith('__reactFiber$'))
+ let fiber = fiberName ? (element as unknown as Record<string, any>)[fiberName] : undefined
+ for (let depth = 0; fiber && depth < 10; depth++, fiber = fiber.return) {
+ if (typeof fiber.key === 'string' && fiber.key.startsWith(prefix))
+ return fiber.key
+ }
+}
+
+/** 收集一个工作区组容器里的全部会话 id(仅作标题匹配失败的兜底)。 */
+function collectSessionIds(group: Element, sessionsRuntime: SessionsRuntimeLike): string[] {
+ const ids = new Set<string>()
+ const sessionSnapshot = sessionsRuntime.list.getSnapshot()
+ for (const row of group.querySelectorAll<Element>('[role="treeitem"][aria-selected]')) {
+ const id = reactKey(row, 'session-')
+ if (id && sessionSnapshot?.byId[id]?.blank !== true)
+ ids.add(id)
+ }
+ return [...ids]
+}
+
+/** 解析节点所隶属的工作区组容器(向上找最近的、同时装得下会话行的祖先)。 */
+function workspaceGroupOf(node: Element): Element | undefined {
+ let current = node.parentElement
+ for (let depth = 0; current && depth < 12; depth++, current = current.parentElement) {
+ if (current.querySelector('[role="treeitem"][aria-selected]'))
+ return current
+ }
+ return undefined
+}
+
+/**
+ * 从项目行解析工作区(按 aria-label/title/纯文本与运行时快照唯一匹配)。
+ * 官方行标题即工作区标题(重名被官方重命名拦截),唯一命中才返回。
+ * 空白/缺失标题的工作区不参与匹配,避免与行内空文本节点误命中。
+ */
+export function workspaceFromRow(row: Element, workspacesRuntime: WorkspacesRuntimeLike): WorkspaceViewLike | null {
+ const items = [...workspacesRuntime.list.getSnapshot().items]
+ const matches = items.filter((workspace) => {
+ const title = workspace.title?.trim()
+ if (!title)
+ return false
+ if ([row.getAttribute('aria-label'), row.getAttribute('title')].some(value => value?.trim() === title))
+ return true
+ return [...row.querySelectorAll('span,button,div')].some(node =>
+ node.closest('[role="treeitem"]') === row
+ && node.children.length === 0
+ && node.textContent?.trim() === title)
+ })
+ return matches.length === 1 ? matches[0] : null
+}
+
+/**
+ * 解析工作区归档清单:只统计官方浏览器会展示的真实会话。
+ * subagent 会话、空白占位会话和运行时缺失摘要的 id 不显示在工作区组中,
+ * 因而不应计入「归档 N 个会话」的 N(#235)。
+ */
+export function collectWorkspaceSessionIds(
+ workspace: WorkspaceViewLike,
+ workspacesRuntime: WorkspacesRuntimeLike,
+ sessionsRuntime: SessionsRuntimeLike,
+): string[] {
+ const archived = new Set(workspacesRuntime.list.getSnapshot().archivedSessionIds ?? [])
+ const byId = sessionsRuntime.list.getSnapshot().byId
+ return workspace.sessionIds.filter((id) => {
+ if (archived.has(id))
+ return false
+ const session = byId[id]
+ return session !== undefined && session.blank !== true && session.origin !== 'subagent'
+ })
+}
+
+/**
+ * 安装工作区浏览器补丁。返回卸载函数。
+ * @param workspacesRuntime - 客户端 ctx.workspaces(归档目标与会话清单来源)。
+ * @param sessionsRuntime - 客户端 ctx.sessions(仅兜底 DOM 收集用)。
+ */
+export function installWorkspaceArchivePatch(workspacesRuntime: WorkspacesRuntimeLike, sessionsRuntime: SessionsRuntimeLike): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+
+ /** 最近一次打开的工作区「…」菜单所隶属的工作区(运行时解析)。 */
+ let pendingWorkspace: WorkspaceViewLike | undefined
+ /** 兜底:标题匹配失败时退回的组容器(历史 DOM 启发式)。 */
+ let pendingGroup: Element | undefined
+ let dialogRoot: Root | undefined
+ let dialogHost: HTMLDivElement | undefined
+ /** 菜单条目清理器:与条目元素关联,元素脱离文档后即被丢弃。 */
+ const itemCleanups: Array<{ element: HTMLElement, cleanup: () => void }> = []
+ /** 行「…」按钮清理器:与按钮元素关联,行被官方替换后即被丢弃。 */
+ const rowCleanups: Array<{ element: HTMLElement, cleanup: () => void }> = []
+
+ /** 关闭归档确认对话框并清理宿主节点(幂等)。 */
+ function closeDialog(): void {
+ dialogRoot?.unmount()
+ dialogRoot = undefined
+ dialogHost?.remove()
+ dialogHost = undefined
+ }
+
+ function openArchiveDialog(workspace: WorkspaceViewLike | undefined, sessionIds: string[]): void {
+ // 先关闭可能残留的旧对话框,避免宿主节点与 React root 泄漏。
+ closeDialog()
+ const workspaceTitle = workspace?.title ?? workspace?.path.split(/[\\/]/).pop() ?? text('ungrouped')
+ dialogHost = document.createElement('div')
+ document.body.append(dialogHost)
+ dialogRoot = createRoot(dialogHost)
+ const confirm = (): void => {
+ closeDialog()
+ void archiveGroup(workspace, sessionIds)
+ }
+ dialogRoot.render(createElement(Modal, {
+ open: true,
+ onClose: closeDialog,
+ title: text('archiveWorkspaceTitle', { count: sessionIds.length }),
+ description: text('archiveWorkspaceDescription', { workspace: workspaceTitle }),
+ footer: createElement('div', {}, createElement(Button, { variant: 'ghost', onClick: closeDialog, style: { marginRight: 6 } }, text('cancel')), createElement(Button, { variant: 'outline', onClick: confirm }, text('archiveWorkspaceConfirm'))),
+ }))
+ }
+
+ /** 归档一个工作区组(点击「归档工作区」后触发)。 */
+ async function archiveGroup(workspace: WorkspaceViewLike | undefined, sessionIds: string[]): Promise<void> {
+ if (workspace)
+ await archiveWorkspace(workspace.workspaceId, sessionIds)
+ else
+ await Promise.all(sessionIds.map(id => archiveSession(id)))
+ }
+
+ /** 项目行「…」按钮点击时记录其工作区(会话行菜单不记录)。 */
+ function recordAnchor(button: Element): void {
+ pendingWorkspace = undefined
+ pendingGroup = undefined
+ const row = button.closest('[role="treeitem"]')
+ // 项目行带 aria-expanded;会话行带 aria-selected —— 只记录前者。
+ if (!row || row.hasAttribute('aria-selected'))
+ return
+ const workspace = workspaceFromRow(row, workspacesRuntime)
+ if (workspace) {
+ pendingWorkspace = workspace
+ return
+ }
+ // 标题匹配失败(如重名工作区)时退回 DOM 组容器启发式(历史行为)。
+ const group = workspaceGroupOf(row)
+ if (group)
+ pendingGroup = group
+ }
+
+ /** 为项目行「…」按钮挂一次性记录监听(capture 阶段先于 React 打开菜单)。 */
+ function watchRow(row: HTMLElement): void {
+ const ellipsis = row.querySelector<HTMLElement>('button')
+ if (!ellipsis || ellipsis.hasAttribute(WORKSPACE_MENU_ANCHOR_ATTRIBUTE))
+ return
+ ellipsis.setAttribute(WORKSPACE_MENU_ANCHOR_ATTRIBUTE, '1')
+ const onAnchorClick = (): void => recordAnchor(ellipsis)
+ ellipsis.addEventListener('click', onAnchorClick, { capture: true })
+ rowCleanups.push({
+ element: ellipsis,
+ cleanup: () => {
+ ellipsis.removeEventListener('click', onAnchorClick, { capture: true })
+ ellipsis.removeAttribute(WORKSPACE_MENU_ANCHOR_ATTRIBUTE)
+ },
+ })
+ }
+
+ /**
+ * 替换菜单条目文案。返回是否找到官方 label 节点 —— 找不到(非官方 primitives
+ * 结构,如其他插件的自绘菜单按钮)时返回 false,调用方中止 patch,绝不追加
+ * 文本节点造成「删除工作区归档工作区」式粘连。
+ */
+ function setItemLabel(item: HTMLElement, label: string): boolean {
+ const labelNode = item.querySelector<HTMLElement>('[class*="itemLabel"], [class*="label"]')
+ if (labelNode) {
+ labelNode.textContent = label
+ return true
+ }
+ return false
+ }
+
+ /**
+ * 给一个 portal 菜单追加「归档工作区」条目;官方「删除工作区」条目保持原样。
+ * 克隆官方条目以继承 primitives 菜单样式,只替换文案/图标与点击行为。
+ * 同一菜单只处理一次(菜单关闭即从 DOM 消失,下次打开是全新节点)。
+ */
+ function patchWorkspaceMenu(item: HTMLButtonElement): void {
+ const menu = item.closest<HTMLElement>('[role="menu"]')
+ if (!menu || menu.hasAttribute(WORKSPACE_MENU_PATCH_ATTRIBUTE))
+ return
+ menu.setAttribute(WORKSPACE_MENU_PATCH_ATTRIBUTE, '1')
+
+ const archiveItem = item.cloneNode(true) as HTMLButtonElement
+ // 克隆的文案替换失败(条目不是官方 primitives 结构)时不插入,避免文本粘连。
+ if (!setItemLabel(archiveItem, text('archiveWorkspaceMenu')))
+ return
+ const icon = archiveItem.querySelector<HTMLElement>('[class*="itemIcon"]')
+ if (icon)
+ icon.innerHTML = ARCHIVE_ICON_SVG
+ // 删除条目带 danger 样式,归档条目需要还原成普通条目外观。
+ archiveItem.classList.add(K.archiveMenuItem)
+ archiveItem.style.setProperty('color', 'var(--dsw-alias-label-primary)', 'important')
+ archiveItem.style.setProperty('background', 'transparent', 'important')
+ icon?.style.setProperty('color', 'var(--dsw-alias-label-tertiary)', 'important')
+ const onEnter = (): void => archiveItem.style.setProperty('background', 'var(--dsw-alias-interactive-bg-hover)', 'important')
+ const onLeave = (): void => archiveItem.style.setProperty('background', 'transparent', 'important')
+ archiveItem.addEventListener('mouseenter', onEnter)
+ archiveItem.addEventListener('mouseleave', onLeave)
+ const onClick = (event: MouseEvent): void => {
+ event.preventDefault()
+ event.stopImmediatePropagation()
+ const workspace = pendingWorkspace
+ let sessionIds: string[] | undefined
+ if (workspace) {
+ // 运行时快照与会话归属即权威:折叠/空工作区也能正确定位;计数与
+ // 官方行可见性一致,排除 subagent、空白占位和缺失摘要的会话。
+ sessionIds = collectWorkspaceSessionIds(workspace, workspacesRuntime, sessionsRuntime)
+ }
+ else if (pendingGroup) {
+ sessionIds = collectSessionIds(pendingGroup, sessionsRuntime)
+ }
+ if (!sessionIds || sessionIds.length === 0)
+ return
+ openArchiveDialog(workspace, sessionIds)
+ // 克隆条目不会触发官方的 onSelect(菜单不会自行关闭),派发一次外部
+ // pointerdown 触发 primitives Menu 的 onClose。
+ const PointerCtor = typeof PointerEvent === 'function' ? PointerEvent : MouseEvent
+ document.dispatchEvent(new PointerCtor('pointerdown', { bubbles: true, cancelable: true }))
+ }
+ archiveItem.addEventListener('click', onClick, { capture: true })
+ // 归档条目插在删除条目之前,官方「删除工作区」保持菜单最底(#235 菜单顺序回归)。
+ item.before(archiveItem)
+ itemCleanups.push({
+ element: archiveItem,
+ cleanup: () => {
+ archiveItem.removeEventListener('mouseenter', onEnter)
+ archiveItem.removeEventListener('mouseleave', onLeave)
+ archiveItem.removeEventListener('click', onClick, { capture: true })
+ },
+ })
+ }
+
+ /**
+ * 全量扫描:项目行记录监听 + portal 菜单追加归档条目。
+ * MutationObserver 每次 DOM 变化都会触发;guard 属性保证每项只处理一次。
+ */
+ function scan(): void {
+ // 丢弃已脱离文档的菜单条目/行清理器,避免数组随菜单反复开关、行被官方
+ // 替换而无限增长(脱离文档的监听器随元素 GC,无需逐个执行 cleanup)。
+ for (let index = itemCleanups.length - 1; index >= 0; index--) {
+ if (!itemCleanups[index].element.isConnected)
+ itemCleanups.splice(index, 1)
+ }
+ for (let index = rowCleanups.length - 1; index >= 0; index--) {
+ if (!rowCleanups[index].element.isConnected)
+ rowCleanups.splice(index, 1)
+ }
+ const sidebar = document.querySelector<HTMLElement>(SIDEBAR_SELECTOR)
+ if (sidebar) {
+ for (const row of sidebar.querySelectorAll<HTMLElement>('[role="treeitem"][aria-expanded]'))
+ watchRow(row)
+ }
+ for (const item of document.querySelectorAll<HTMLButtonElement>(MENU_ITEM_SELECTOR)) {
+ const label = item.textContent?.trim() ?? ''
+ if (!label)
+ continue
+ // 只处理官方 primitives 菜单条目:官方条目由 `itemWrap` 包裹,其他插件
+ // (如右键菜单)自绘的 `button[role=menuitem]` 没有该结构 —— 误 patch
+ // 会把克隆项插进别人的菜单并在文案替换失败时造成文本粘连(#235)。
+ if (!item.closest('[class*="itemWrap"]'))
+ continue
+ if (DELETE_WORKSPACE_LABELS.includes(label) || DELETE_WORKSPACE_LABELS.some(needle => label.includes(needle)))
+ patchWorkspaceMenu(item)
+ }
+ }
+
+ const ro = new MutationObserver(scan)
+ let timer: ReturnType<typeof setInterval> | undefined
+ let tries = 0
+ /** 首次挂载:侧边栏就绪后开始观察并执行首轮扫描;未就绪时由调用方轮询重试。 */
+ function attach(): boolean {
+ const sidebar = document.querySelector<HTMLElement>(SIDEBAR_SELECTOR)
+ if (!sidebar)
+ return false
+ ro.observe(document.body, { childList: true, subtree: true })
+ scan()
+ return true
+ }
+
+ if (!attach()) {
+ timer = setInterval(() => {
+ if (attach() || ++tries > 30)
+ clearInterval(timer)
+ }, 500)
+ }
+
+ return () => {
+ ro.disconnect()
+ closeDialog()
+ for (const { cleanup } of itemCleanups)
+ cleanup()
+ itemCleanups.length = 0
+ for (const { cleanup } of rowCleanups)
+ cleanup()
+ rowCleanups.length = 0
+ if (timer !== undefined)
+ clearInterval(timer)
+ }
+}
diff --git a/packages/dsh-tauri-session/src/constants.ts b/packages/dsh-tauri-session/src/constants.ts
new file mode 100644
index 00000000..a08e97b4
--- /dev/null
+++ b/packages/dsh-tauri-session/src/constants.ts
@@ -0,0 +1,7 @@
+/** Host-half protocol constants for dsh-tauri-session (plugin-owned archive). */
+
+export const SESSION_PLUGIN_NAME = 'dsh-tauri-session'
+export const SESSION_API_PREFIX = '/api/dsh-session'
+export const SESSION_SECTION_ORDER = 220
+export const SESSION_STATE_DIRECTORY = 'dsh-tauri-session'
+export const SESSION_ARCHIVE_FILE = 'archive.json'
diff --git a/packages/dsh-tauri-session/src/index.ts b/packages/dsh-tauri-session/src/index.ts
new file mode 100644
index 00000000..d15fbf8b
--- /dev/null
+++ b/packages/dsh-tauri-session/src/index.ts
@@ -0,0 +1,475 @@
+/**
+ * dsh-tauri-session 宿主侧(node half):「已归档聊天」的管理接口。
+ *
+ * 归档语义(v2,与官方机制对齐):
+ * 官方工作区浏览器会话行菜单自带「归档」动作,写入宿主 WorkspaceRegistry 的
+ * 归档集合(`archivedSessionIds`,持久化、隐藏于所有分组界面、不动工作区记账,
+ * 取消归档自动恢复原组原位)。因此本插件不再维护自有的 `archive.json`,
+ * 而是直接读写宿主归档集合:
+ * - `GET /archived` 读宿主归档集合 + 会话头元数据;
+ * - `POST /archive` 归档单个会话(宿主 `archiveSession`);
+ * - `POST /archive-workspace` 归档一组会话(插件 UI「归档工作区」);
+ * - `POST /unarchive` 从宿主归档集合移除(宿主无公开 unarchive,
+ * 走注册表内部状态机,见 `updateRegistryArchiveSet`);
+ * - `POST /delete` 彻底删除单个归档会话(归档集合移除 + 物理删除会话数据);
+ * - `POST /clear` 彻底删除全部已归档会话(同上,批量)。
+ * 插件初始化时把旧版自持 `archive.json` 的记录一次性迁入宿主集合后删除旧文件。
+ */
+
+import type {
+ ArchivedListPayload,
+ ArchiveDocument,
+ HostContext,
+ PluginConfig,
+ SessionLike,
+} from './types.js'
+import { readdirSync, rmSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join, resolve, sep } from 'node:path'
+import process from 'node:process'
+import { routeHandler, withConnectionAuth } from 'dsh-tauri'
+import { SESSION_API_PREFIX, SESSION_ARCHIVE_FILE, SESSION_PLUGIN_NAME } from './constants.js'
+import { loadArchive, saveArchive, sessionStateDir } from './storage.js'
+
+/** 插件名(诊断元数据,与导出的 name 一致)。 */
+export const name = SESSION_PLUGIN_NAME
+
+/** 需要的宿主服务:webServer(HTTP 路由)、sessions(会话枚举/header)、workspaceRegistry(归档集合)。 */
+export const inject = ['webServer', 'sessions', 'workspaceRegistry', 'connection']
+
+/** API 路由前缀(客户端同源 fetch)。 */
+export const API_PREFIX = SESSION_API_PREFIX
+
+function resolveDshHome(config: PluginConfig): string {
+ return typeof config.dshHome === 'string' && config.dshHome ? config.dshHome : process.env.DSH_HOME ?? join(homedir(), '.dsh')
+}
+
+/** 查找会话对象(host ctx.sessions)。 */
+function findSession(ctx: HostContext, sessionId: string): SessionLike | undefined {
+ if (!sessionId)
+ return undefined
+ return (ctx.sessions?.get?.(sessionId) as SessionLike | undefined)
+ ?? (ctx.sessions?.list?.() as SessionLike[] | undefined)?.find((session: SessionLike) => session.id === sessionId)
+}
+
+/** 会话工作目录(header.cwd)。 */
+function sessionCwd(session: SessionLike | undefined): string | undefined {
+ const cwd = session?.header?.cwd
+ return typeof cwd === 'string' && cwd ? cwd : undefined
+}
+
+/** 组装 GET /archived 的载荷:宿主归档集合 id + 每个会话的创建元数据(读 host session header)。 */
+function buildArchivedPayload(ctx: HostContext): ArchivedListPayload {
+ const registry = ctx.workspaceRegistry as { archivedSessionIds?: readonly string[] } | undefined
+ const archivedSessionIds: string[] = []
+ const meta: ArchivedListPayload['meta'] = {}
+ for (const sessionId of registry?.archivedSessionIds ?? []) {
+ const session = findSession(ctx, sessionId)
+ if (!session)
+ continue
+ archivedSessionIds.push(sessionId)
+ const cwd = sessionCwd(session)
+ meta[sessionId] = {
+ createdAt: session?.header?.createdAt,
+ cwd,
+ ...(session?.displayTitle ? { title: session.displayTitle } : session?.title ? { title: session.title } : {}),
+ }
+ }
+ return { archivedSessionIds, meta }
+}
+
+/** 归档一个会话(宿主归档集合,幂等:已归档则无操作)。 */
+async function archiveSession(ctx: HostContext, body: Record<string, unknown>): Promise<ArchivedListPayload> {
+ const sessionId = String(body.sessionId ?? '')
+ if (!sessionId)
+ throw new Error('缺少 sessionId')
+ await requireArchiveSession(ctx)(sessionId)
+ return buildArchivedPayload(ctx)
+}
+
+/** 归档一组会话(「归档工作区」:一次调用归档该组全部会话)。 */
+async function archiveWorkspace(ctx: HostContext, body: Record<string, unknown>): Promise<ArchivedListPayload> {
+ const sessionIds = Array.isArray(body.sessionIds) ? body.sessionIds.map(String) : []
+ if (sessionIds.length === 0)
+ throw new Error('缺少 sessionIds')
+ const archiveSession = requireArchiveSession(ctx)
+ for (const sessionId of sessionIds)
+ await archiveSession(sessionId)
+ return buildArchivedPayload(ctx)
+}
+
+/**
+ * 宿主归档集合的私有状态机面。宿主公开 API 只有 `archiveSession`(没有 unarchive),
+ * 而取消归档是插件的核心功能,因此这里显式依赖注册表内部方法:
+ * `enqueueOperation`(串行化读改写)、`requireState`(当前持久化状态)、
+ * `setState`(写回并发布)。三者任一缺失(宿主升级改内部结构)即报错,绝不静默降级。
+ */
+interface SessionStoreSurface {
+ get?: (id: string) => SessionLike | undefined
+ remove?: (id: string) => boolean
+}
+
+interface RegistryArchiveSurface {
+ enqueueOperation?: (fn: () => Promise<void>) => Promise<void>
+ requireState?: () => { archivedSessionIds?: readonly string[] }
+ requireTable?: () => {
+ entries: () => Iterable<[string, { sessionIds?: readonly string[] }]>
+ update: (id: string, update: (record: { sessionIds?: readonly string[] }) => { sessionIds: string[] }) => Promise<void>
+ }
+ setState?: (state: unknown) => Promise<void>
+}
+
+function registryArchiveSurface(ctx: HostContext): RegistryArchiveSurface {
+ const registry = ctx.workspaceRegistry as unknown as RegistryArchiveSurface | undefined
+ if (!registry || typeof registry.enqueueOperation !== 'function' || typeof registry.requireState !== 'function' || typeof registry.setState !== 'function')
+ throw new Error('宿主 workspaceRegistry 未暴露归档集合的变更接口(宿主版本不兼容)')
+ return registry
+}
+
+/** 归档所需方法缺失时报错,绝不静默跳过(否则迁移会误删旧记录)。 */
+function requireArchiveSession(ctx: HostContext): (sessionId: string) => Promise<void> {
+ const archiveSession = ctx.workspaceRegistry?.archiveSession
+ if (typeof archiveSession !== 'function')
+ throw new Error('宿主 workspaceRegistry 未提供 archiveSession(宿主版本不兼容)')
+ return archiveSession.bind(ctx.workspaceRegistry) as (sessionId: string) => Promise<void>
+}
+
+/** Remove a session from every workspace accounting slot before physical deletion. */
+async function removeSessionFromWorkspaceAccounting(ctx: HostContext, sessionIds: readonly string[]): Promise<void> {
+ const registry = registryArchiveSurface(ctx)
+ const table = registry.requireTable?.()
+ if (!table)
+ throw new Error('宿主 workspaceRegistry 未暴露工作区会话记账接口(宿主版本不兼容)')
+ const ids = new Set(sessionIds)
+ for (const [workspaceId, record] of table.entries()) {
+ const next = (record.sessionIds ?? []).filter(id => !ids.has(id))
+ if (next.length !== (record.sessionIds ?? []).length)
+ await table.update(workspaceId, current => ({ ...current, sessionIds: next }))
+ }
+}
+
+/** 串行化地改写宿主归档集合(unarchive / clear 共用)。 */
+export async function updateRegistryArchiveSet(ctx: HostContext, update: (ids: string[]) => string[]): Promise<void> {
+ const registry = registryArchiveSurface(ctx)
+ await registry.enqueueOperation!(async () => {
+ const state = registry.requireState!()
+ const archived = [...(state.archivedSessionIds ?? [])]
+ const next = update(archived)
+ if (next.length === archived.length && next.every((id, index) => id === archived[index]))
+ return
+ await registry.setState!({ ...state, archivedSessionIds: next })
+ })
+}
+
+/**
+ * Restore the accounting slot when an older delete-all attempt removed it.
+ * Normal archives already have the slot and this is a no-op; damaged historical
+ * data is repaired from the session header cwd and the matching workspace path.
+ */
+async function restoreSessionWorkspaceAccounting(ctx: HostContext, sessionId: string): Promise<void> {
+ const registry = registryArchiveSurface(ctx)
+ const table = registry.requireTable?.()
+ const session = findSession(ctx, sessionId)
+ const cwd = sessionCwd(session)
+ if (!table || !cwd || typeof ctx.workspaceRegistry?.list !== 'function')
+ return
+ const workspace = (ctx.workspaceRegistry.list() as Array<{ id: string, path?: string, sessionIds?: readonly string[] }>).find(item => item.path === cwd)
+ if (!workspace || workspace.sessionIds?.includes(sessionId))
+ return
+ await table.update(workspace.id, current => ({ ...current, sessionIds: [...(current.sessionIds ?? []), sessionId] }))
+}
+
+/** 取消归档:移除归档标记,并修复历史数据缺失的工作区归属槽位。 */
+async function unarchiveSession(ctx: HostContext, body: Record<string, unknown>): Promise<{ ok: true }> {
+ const sessionId = String(body.sessionId ?? '')
+ if (!sessionId)
+ throw new Error('缺少 sessionId')
+ const registry = registryArchiveSurface(ctx)
+ await registry.enqueueOperation!(async () => {
+ await restoreSessionWorkspaceAccounting(ctx, sessionId)
+ const state = registry.requireState!()
+ const archived = [...(state.archivedSessionIds ?? [])]
+ const next = archived.filter(id => id !== sessionId)
+ if (next.length !== archived.length)
+ await registry.setState!({ ...state, archivedSessionIds: next })
+ })
+ return { ok: true as const }
+}
+
+/** 判断一个路径是否是存在的目录。 */
+function isDir(path: string): boolean {
+ try {
+ return readdirSync(path).length >= 0
+ }
+ catch {
+ return false
+ }
+}
+
+/** 规范化路径是否严格位于 sessionsRoot 之内(防 `..`/绝对路径逃逸)。 */
+export function isWithinSessionsRoot(sessionsRoot: string, candidate: string): boolean {
+ const root = resolve(sessionsRoot)
+ const target = resolve(candidate)
+ return target === root || target.startsWith(`${root}${sep}`)
+}
+
+/** 会话 id 是否为归档集合成员(删除的授权边界)。 */
+function requireArchivedMember(ctx: HostContext, sessionId: string): void {
+ const registry = ctx.workspaceRegistry as { archivedSessionIds?: readonly string[] } | undefined
+ if (!registry?.archivedSessionIds?.includes(sessionId))
+ throw new Error(`会话 '${sessionId}' 不在归档集合中,拒绝删除`)
+}
+
+/** Encode the session id exactly as the JSONL persistence backend does. */
+export function encodeSessionId(id: string): string {
+ if (id === '.')
+ return '~002E'
+ if (id === '..')
+ return '~002E~002E'
+ let encoded = ''
+ for (let index = 0; index < id.length; index++) {
+ const code = id.charCodeAt(index)
+ const char = String.fromCharCode(code)
+ encoded += char !== '~' && /^[\w.-]$/.test(char)
+ ? char
+ : `~${code.toString(16).toUpperCase().padStart(4, '0')}`
+ }
+ return encoded
+}
+
+/**
+ * 物理删除一个会话的持久化目录(best-effort,找不到就跳过)。
+ * dsh 宿主没有公开的「删除会话」API,会话数据存放在 `$DSH_HOME/sessions/<group>/session-<id>/`;
+ * 这里做有界扫描(深度 2)命中 `session-<id>` 目录后删除。删除后宿主重启时
+ * 会从持久化重建会话索引,该会话从工作区/归档中彻底消失。
+ * @returns 是否实际删除了目录。
+ */
+function removeSessionDataDir(dshHome: string, sessionId: string): boolean {
+ const sessionsRoot = join(dshHome, 'sessions')
+ // DSH versions use either the raw id or the legacy `session-<id>` directory name.
+ const encodedId = encodeSessionId(sessionId)
+ const markers = [encodedId, `session-${sessionId}`, sessionId]
+ // 一级:sessions/<id> or sessions/session-<id>
+ for (const marker of markers) {
+ const direct = join(sessionsRoot, marker)
+ if (isWithinSessionsRoot(sessionsRoot, direct) && isDir(direct)) {
+ rmSync(direct, { recursive: true, force: true })
+ return true
+ }
+ }
+ // 二级:sessions/<group>/session-<id>
+ let groups: string[] = []
+ try {
+ groups = readdirSync(sessionsRoot, { withFileTypes: true })
+ .filter(entry => entry.isDirectory())
+ .map(entry => entry.name)
+ }
+ catch {
+ return false
+ }
+ for (const group of groups) {
+ for (const marker of markers) {
+ const nested = join(sessionsRoot, group, marker)
+ if (isWithinSessionsRoot(sessionsRoot, nested) && isDir(nested)) {
+ rmSync(nested, { recursive: true, force: true })
+ return true
+ }
+ }
+ }
+ return false
+}
+
+/** 验证删除所需宿主面齐全;缺失时在变更前报错,保证可重试。 */
+function requireDeletionSurfaces(ctx: HostContext, sessionIds: readonly string[]): { sessions: SessionStoreSurface | undefined } {
+ registryArchiveSurface(ctx)
+ const registry = ctx.workspaceRegistry as unknown as RegistryArchiveSurface | undefined
+ if (!registry?.requireTable)
+ throw new Error('宿主 workspaceRegistry 未暴露工作区会话记账接口(宿主版本不兼容)')
+ const sessions = ctx.sessions as SessionStoreSurface | undefined
+ for (const sessionId of sessionIds) {
+ if (sessions?.get?.(sessionId) && !sessions.remove)
+ throw new Error('宿主未提供 SessionStore.remove,请先更新桌面壳')
+ }
+ return { sessions }
+}
+
+/** 从内存会话 store 移除(best-effort:live 会话必须成功)。 */
+function removeLiveSessions(sessions: SessionStoreSurface | undefined, sessionIds: readonly string[]): void {
+ for (const sessionId of sessionIds) {
+ if (sessions?.get?.(sessionId) && !sessions.remove?.(sessionId))
+ throw new Error(`无法从内存会话中移除 '${sessionId}'`)
+ }
+}
+
+/** 彻底删除一个归档会话(成员校验 + 物理删除 + 记账更新)。 */
+async function permanentlyDeleteSession(ctx: HostContext, dshHome: string, body: Record<string, unknown>): Promise<{ ok: true }> {
+ const sessionId = String(body.sessionId ?? '')
+ if (!sessionId)
+ throw new Error('缺少 sessionId')
+ requireArchivedMember(ctx, sessionId)
+ const { sessions } = requireDeletionSurfaces(ctx, [sessionId])
+ // 先物理删除,再更新记账:物理删除失败时归档集合未动,会话仍可寻址重试。
+ const removed = removeSessionDataDir(dshHome, sessionId)
+ removeLiveSessions(sessions, [sessionId])
+ await removeSessionFromWorkspaceAccounting(ctx, [sessionId])
+ await updateRegistryArchiveSet(ctx, ids => ids.filter(id => id !== sessionId))
+ ctx.logger?.info?.(`[${SESSION_PLUGIN_NAME}] permanently deleted archived session (data removed: ${removed})`)
+ return { ok: true as const }
+}
+
+/** 彻底删除指定归档会话(先物理删除全部,再批量更新记账)。 */
+async function permanentlyDeleteSelected(ctx: HostContext, dshHome: string, body: Record<string, unknown>): Promise<{ ok: true }> {
+ const rawIds = body.sessionIds
+ if (!Array.isArray(rawIds) || rawIds.length === 0)
+ throw new Error('缺少 sessionIds')
+ const ids = [...new Set(rawIds.map(String).filter(Boolean))]
+ for (const sessionId of ids)
+ requireArchivedMember(ctx, sessionId)
+ const { sessions } = requireDeletionSurfaces(ctx, ids)
+ let removed = 0
+ for (const sessionId of ids) {
+ if (removeSessionDataDir(dshHome, sessionId))
+ removed += 1
+ }
+ removeLiveSessions(sessions, ids)
+ await removeSessionFromWorkspaceAccounting(ctx, ids)
+ await updateRegistryArchiveSet(ctx, current => current.filter(id => !ids.includes(id)))
+ ctx.logger?.info?.(`[${SESSION_PLUGIN_NAME}] permanently deleted ${ids.length} selected archived session(s) (data removed: ${removed})`)
+ return { ok: true as const }
+}
+
+/** 彻底删除全部已归档会话(先物理删除全部,再批量更新记账)。 */
+async function permanentlyDeleteAll(ctx: HostContext, dshHome: string): Promise<{ ok: true }> {
+ const registry = ctx.workspaceRegistry as { archivedSessionIds?: readonly string[] } | undefined
+ const ids = [...(registry?.archivedSessionIds ?? [])]
+ const { sessions } = requireDeletionSurfaces(ctx, ids)
+ let removed = 0
+ // 全部先物理删除:任一会话目录删除失败即中止,归档集合保持不变可重试。
+ for (const sessionId of ids) {
+ if (removeSessionDataDir(dshHome, sessionId))
+ removed += 1
+ }
+ removeLiveSessions(sessions, ids)
+ await removeSessionFromWorkspaceAccounting(ctx, ids)
+ await updateRegistryArchiveSet(ctx, () => [])
+ ctx.logger?.info?.(`[${SESSION_PLUGIN_NAME}] permanently deleted ${ids.length} archived session(s) (data removed: ${removed})`)
+ return { ok: true as const }
+}
+
+/**
+ * 一次性迁移旧版插件自持归档(`$DSH_HOME/dsh-tauri-session/archive.json`)到宿主
+ * 归档集合。迁移成功的记录从旧文件中移除;仍失败的(如会话已不存在)保留在旧
+ * 文件中,下次启动幂等重试 —— 绝不因单次失败丢弃用户数据。
+ */
+async function migrateLegacyArchive(ctx: HostContext, dshHome: string): Promise<void> {
+ const legacy = loadArchive(dshHome)
+ const sessionIds = Object.keys(legacy)
+ if (sessionIds.length === 0)
+ return
+ let migrated = 0
+ const failed: string[] = []
+ let archiveSession: ((sessionId: string) => Promise<void>) | undefined
+ try {
+ archiveSession = requireArchiveSession(ctx)
+ }
+ catch {
+ // 宿主不提供 archiveSession 时保留全部旧记录,下次启动重试,绝不误删。
+ failed.push(...sessionIds)
+ }
+ if (archiveSession) {
+ for (const sessionId of sessionIds) {
+ try {
+ await archiveSession(sessionId)
+ migrated += 1
+ }
+ catch {
+ failed.push(sessionId)
+ }
+ }
+ }
+ try {
+ if (failed.length === 0) {
+ rmSync(join(sessionStateDir(dshHome), SESSION_ARCHIVE_FILE), { force: true })
+ }
+ else {
+ // 只保留未迁移成功的记录,避免下次启动重复迁移已成功的会话。
+ const remaining: ArchiveDocument = {}
+ for (const sessionId of failed)
+ remaining[sessionId] = legacy[sessionId]
+ saveArchive(remaining, dshHome)
+ }
+ }
+ catch {
+ // 旧文件整理失败不影响新机制(下次启动会再尝试迁移)。
+ }
+ ctx.logger?.info?.(`[${SESSION_PLUGIN_NAME}] migrated ${migrated}/${sessionIds.length} legacy archived session(s) into the host registry`)
+}
+
+/** 构建路由列表。 */
+export function buildRoutes(ctx: HostContext, dshHome: string): any[] {
+ const routes = [
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/archived`,
+ handler: routeHandler(async () => [200, buildArchivedPayload(ctx)]),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/archive`,
+ handler: routeHandler(async body => [200, await archiveSession(ctx, body)], { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/archive-workspace`,
+ handler: routeHandler(async body => [200, await archiveWorkspace(ctx, body)], { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/unarchive`,
+ handler: routeHandler(async body => [200, await unarchiveSession(ctx, body)], { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/delete`,
+ handler: routeHandler(async body => [200, await permanentlyDeleteSession(ctx, dshHome, body)], { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/delete-workspace`,
+ handler: routeHandler(async body => [200, await permanentlyDeleteSelected(ctx, dshHome, body)], { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/clear`,
+ handler: routeHandler(async () => [200, await permanentlyDeleteAll(ctx, dshHome)], { mutate: true }),
+ },
+ ]
+ return routes.map(route => ({
+ ...route,
+ handler: withConnectionAuth(ctx.connection, route.handler, 'dsh-tauri-session'),
+ }))
+}
+
+/**
+ * 插件体:迁移旧版归档 + 注册 HTTP 路由。
+ * @param ctx - 宿主根上下文(注入 webServer/sessions/workspaceRegistry)。
+ * @param config - 插件行配置(dshHome 等,仅用于旧版归档迁移路径)。
+ */
+export function apply(ctx: HostContext, config: PluginConfig = {}): void {
+ const cfg = config ?? {}
+ const dshHome = resolveDshHome(cfg)
+
+ // 旧版自持归档一次性迁入宿主集合(幂等:文件不存在或为空则直接跳过)。
+ ctx.effect(() => {
+ void migrateLegacyArchive(ctx, dshHome)
+ }, `${SESSION_PLUGIN_NAME}: migrate legacy archive`)
+
+ // HTTP 路由注册(客户端经此调用 archived/archive/unarchive/delete/clear)。
+ ctx.effect(() => {
+ const disposers = buildRoutes(ctx, dshHome).map(route => ctx.webServer.register(route))
+ return () => {
+ for (const dispose of disposers)
+ dispose()
+ }
+ }, `${SESSION_PLUGIN_NAME}: routes`)
+}
diff --git a/packages/dsh-tauri-session/src/storage.ts b/packages/dsh-tauri-session/src/storage.ts
new file mode 100644
index 00000000..5ca7330a
--- /dev/null
+++ b/packages/dsh-tauri-session/src/storage.ts
@@ -0,0 +1,67 @@
+/**
+ * Plugin-owned archive persistence under `$DSH_HOME/dsh-tauri-session/`.
+ * The archive is deliberately plugin-owned (not the host workspace archive set):
+ * the host `WorkspaceRegistry` exposes `archiveSession` but no way to remove a
+ * session from its archive set, so un-archiving cannot go through it. Keeping
+ * our own set + never touching workspace accounting lets us un-archive back to
+ * the original group without depending on host APIs that do not exist.
+ */
+
+import type { ArchiveDocument } from './types.js'
+import { randomBytes } from 'node:crypto'
+import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import process from 'node:process'
+import { SESSION_ARCHIVE_FILE, SESSION_STATE_DIRECTORY } from './constants.js'
+
+/** The plugin's own state directory under DSH_HOME (default `~/.dsh`). */
+export function sessionStateDir(dshHome?: string): string {
+ return join(dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'), SESSION_STATE_DIRECTORY)
+}
+
+function archivePath(dshHome?: string): string {
+ return join(sessionStateDir(dshHome), SESSION_ARCHIVE_FILE)
+}
+
+/** Fresh empty archive document. */
+export function emptyArchive(): ArchiveDocument {
+ return {}
+}
+
+/** Load the archive; missing/corrupt files yield an empty archive. */
+export function loadArchive(dshHome?: string): ArchiveDocument {
+ const path = archivePath(dshHome)
+ if (!existsSync(path))
+ return emptyArchive()
+ try {
+ const parsed = JSON.parse(readFileSync(path, 'utf8')) as unknown
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
+ return emptyArchive()
+ const out: ArchiveDocument = {}
+ for (const [key, value] of Object.entries(parsed as Record<string, unknown>)) {
+ const record = value as Partial<{ sessionId: string, archivedAt: number }>
+ if (typeof key === 'string' && typeof record?.sessionId === 'string' && key === record.sessionId)
+ out[key] = record as ArchiveDocument[string]
+ }
+ return out
+ }
+ catch {
+ return emptyArchive()
+ }
+}
+
+/** Persist by atomic rename so readers never observe partial JSON. */
+export function saveArchive(archive: ArchiveDocument, dshHome?: string): void {
+ const dir = sessionStateDir(dshHome)
+ const target = archivePath(dshHome)
+ const temporary = join(dir, `.archive-${process.pid}-${randomBytes(6).toString('hex')}.tmp`)
+ mkdirSync(dir, { recursive: true })
+ try {
+ writeFileSync(temporary, `${JSON.stringify(archive, null, 2)}\n`, 'utf8')
+ renameSync(temporary, target)
+ }
+ finally {
+ rmSync(temporary, { force: true })
+ }
+}
diff --git a/packages/dsh-tauri-session/src/types.ts b/packages/dsh-tauri-session/src/types.ts
new file mode 100644
index 00000000..471e9b8b
--- /dev/null
+++ b/packages/dsh-tauri-session/src/types.ts
@@ -0,0 +1,50 @@
+export type HostContext = any
+
+export type JsonBody = Record<string, unknown>
+
+export type RouteResult = [number, unknown]
+export type RouteFunction = (body: JsonBody, req: import('node:http').IncomingMessage) => Promise<RouteResult>
+
+export interface PluginConfig {
+ /** 旧版自持归档的根目录(v1 迁移用;默认 `~/.dsh`)。 */
+ dshHome?: string
+}
+
+/**
+ * 旧版(v1)插件自持归档记录 —— 仅用于启动时一次性迁入宿主归档集合。
+ * v2 起归档集合由宿主 WorkspaceRegistry 持有:归档不动工作区记账,会话保留
+ * 其 `sessionIds` 槽位,取消归档自动恢复原组原位。
+ */
+export interface ArchivedSessionRecord {
+ sessionId: string
+ /** The workspace group the session belonged to when archived (for grouping). */
+ workspaceId?: string
+ /** The session that preceded it in the workspace order at archive time. */
+ beforeSessionId?: string
+ /** Epoch ms when it was archived. */
+ archivedAt: number
+}
+
+/** Whole archive document keyed by session id. */
+export type ArchiveDocument = Record<string, ArchivedSessionRecord>
+
+/** Minimal host session header surface (createdAt/cwd live on the host Session.header). */
+export interface SessionHeaderLike {
+ createdAt?: number
+ cwd?: string
+}
+
+/** Minimal host session surface used by this plugin. */
+export interface SessionLike {
+ id: string
+ header?: SessionHeaderLike
+ title?: string
+ displayTitle?: string
+}
+
+/** Wire payload for `GET /api/dsh-session/archived`. */
+export interface ArchivedListPayload {
+ archivedSessionIds: string[]
+ /** Per archived session, creation metadata read from the host session header. */
+ meta: Record<string, { createdAt?: number, cwd?: string, title?: string }>
+}
diff --git a/packages/dsh-tauri-session/tsconfig.json b/packages/dsh-tauri-session/tsconfig.json
new file mode 100644
index 00000000..520166d0
--- /dev/null
+++ b/packages/dsh-tauri-session/tsconfig.json
@@ -0,0 +1,4 @@
+{
+ "extends": "../../tsconfig.json",
+ "include": ["src/**/*.ts", "src/**/*.tsx", "../../types/**/*.d.ts"]
+}
diff --git a/packages/dsh-tauri-session/tsdown.config.ts b/packages/dsh-tauri-session/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-session/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri-tsdown/README.md b/packages/dsh-tauri-tsdown/README.md
new file mode 100644
index 00000000..f2cd17f8
--- /dev/null
+++ b/packages/dsh-tauri-tsdown/README.md
@@ -0,0 +1,17 @@
+# dsh-tauri-tsdown
+
+`dsh-tauri-tsdown` 是本 monorepo 内部使用的 tsdown 配置与类型辅助包,用于统一各插件的 ESM 构建、声明文件生成和导出配置。
+
+## 使用范围
+
+该包标记为 private,不应被应用直接安装或作为运行时插件启用。开发者通常只需要在工作区根目录运行:
+
+```bash
+pnpm build
+```
+
+各工作区插件会复用此包提供的构建约定。
+
+## 许可证
+
+[MIT](../../LICENSE.md) © [Hairyf](https://github.com/hairyf)
diff --git a/packages/dsh-tauri-tsdown/package.json b/packages/dsh-tauri-tsdown/package.json
new file mode 100644
index 00000000..5d261c12
--- /dev/null
+++ b/packages/dsh-tauri-tsdown/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "dsh-tauri-tsdown",
+ "type": "module",
+ "version": "0.6.7",
+ "private": true,
+ "exports": {
+ ".": {
+ "types": "./src/index.d.ts",
+ "default": "./src/index.mjs"
+ }
+ },
+ "files": [
+ "src"
+ ],
+ "scripts": {
+ "typecheck": "tsc --noEmit"
+ },
+ "devDependencies": {
+ "tsdown": "catalog:cli",
+ "typescript": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-tsdown/src/index.d.ts b/packages/dsh-tauri-tsdown/src/index.d.ts
new file mode 100644
index 00000000..3bfb05ce
--- /dev/null
+++ b/packages/dsh-tauri-tsdown/src/index.d.ts
@@ -0,0 +1,15 @@
+import type { UserConfig } from 'tsdown'
+
+export interface DshConfig {
+ /**
+ * Package-level publint toggle (defaults to `true`). Turn it off for packages
+ * whose client bundle inlines CJS deps (e.g. css-render) that publint's static
+ * scan mistakes for `exports.__esModule + exports.default` — the assignment
+ * lives in a sealed module wrapper and never reaches the real module exports.
+ */
+ publint?: UserConfig['publint']
+ server?: UserConfig
+ client?: UserConfig
+}
+
+export function defineDshConfig(options?: DshConfig): UserConfig[]
diff --git a/packages/dsh-tauri-tsdown/src/index.mjs b/packages/dsh-tauri-tsdown/src/index.mjs
new file mode 100644
index 00000000..75177cbe
--- /dev/null
+++ b/packages/dsh-tauri-tsdown/src/index.mjs
@@ -0,0 +1,75 @@
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import process from 'node:process'
+
+function clientBundleRegistration() {
+ const packageName = process.env.npm_package_name
+ const pkg = packageName
+ ? { name: packageName }
+ : JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'))
+ const id = JSON.stringify(pkg.name)
+ // Only the JS bundle is a runtime script wrapped in the ModuleLoader factory.
+ // Declaration files must stay real ES modules (top-level import/export) —
+ // wrapping them breaks types ("file is not a module") — so apply the wrapper
+ // exclusively to JS outputs via the `{ js }` addon form.
+ return {
+ banner: {
+ js: `window.__ModuleLoader__.load({id:${id},factory:(require)=>{const loaderRequire=require;const resolve=(specifier)=>specifier.endsWith('/client')?specifier.slice(0,-7):specifier;require=(specifier)=>loaderRequire(resolve(specifier));var module={exports:{}};var exports=module.exports;`,
+ },
+ footer: {
+ js: 'return module.exports;}});',
+ },
+ }
+}
+
+export const dshExternal = [
+ 'react',
+ 'react/jsx-runtime',
+ 'react-dom',
+ 'react-dom/client',
+ 'dsh-tauri/client',
+ /^@deepseek-ai\//,
+]
+
+export function defineDshConfig(options = {}) {
+ const common = {
+ outDir: 'dist',
+ format: 'esm',
+ outExtensions: () => ({ js: '.js' }),
+ publint: options.publint ?? true,
+ external: dshExternal,
+ }
+
+ return [
+ {
+ ...common,
+ ...options.server,
+ entry: { index: 'src/index.ts' },
+ dts: true,
+ sourcemap: false,
+ clean: true,
+ },
+ {
+ ...common,
+ entry: { client: 'src/client/index.ts' },
+ // Client bundles are classic scripts consumed by dsh-client-modules.
+ // CJS output is required so its exports remain inside the loader factory.
+ format: 'cjs',
+ // CJS must not use `.js` in a `"type": "module"` package — publint would
+ // flag the ESM/CJS mismatch. Emit `.cjs` (declarations pair as `.d.cts`).
+ outExtensions: () => ({ js: '.cjs' }),
+ define: { 'process.env.NODE_ENV': JSON.stringify('production') },
+ ...clientBundleRegistration(),
+ // The client entry is deliberately a classic CJS script wrapped by ModuleLoader;
+ // publint's ESM/CJS default-export heuristic is inapplicable.
+ publint: false,
+ dts: false,
+ sourcemap: true,
+ minify: true,
+ clean: false,
+ ...options.client,
+ },
+ ]
+}
+
+export { defineConfig } from 'tsdown'
diff --git a/packages/dsh-tauri-ui/README.md b/packages/dsh-tauri-ui/README.md
new file mode 100644
index 00000000..d4adfc63
--- /dev/null
+++ b/packages/dsh-tauri-ui/README.md
@@ -0,0 +1,16 @@
+# dsh-tauri-ui
+
+`dsh-tauri-ui` 为 DSH 提供 Tauri 风格的客户端界面扩展。目前包含将设置对话框改造成左侧停靠设置栏的功能。
+
+## 功能
+
+- 在 `sidebar.settings` 注册设置触发器。
+- 在 `shell.overlay` 渲染桌面化设置侧边栏。
+- 通过 `settings.section` 展示官方设置分区。
+- 设置打开期间持续隐藏并禁用宿主内容列及异步挂载的 Better Sidebar,关闭时精确恢复原状态。
+- 提供中英文的返回应用、搜索设置等文案。
+- renderer 缺少 `SlotOutlet` 时自动保留官方设置对话框。
+
+## 兼容性
+
+设置侧边栏需要 renderer 提供通用 `SlotOutlet`。在旧版核心或缺少 renderer patch 的环境中,插件会安全降级,不会阻塞官方设置功能。
diff --git a/packages/dsh-tauri-ui/cordis.patch.yml b/packages/dsh-tauri-ui/cordis.patch.yml
new file mode 100644
index 00000000..edde676a
--- /dev/null
+++ b/packages/dsh-tauri-ui/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-ui
+ name: dsh-tauri-ui
diff --git a/packages/dsh-tauri-ui/package.json b/packages/dsh-tauri-ui/package.json
new file mode 100644
index 00000000..da8e825f
--- /dev/null
+++ b/packages/dsh-tauri-ui/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "dsh-tauri-ui",
+ "type": "module",
+ "version": "0.6.7",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "@deepseek-ai/dsh-client-ui-primitives",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-ui/src/client/constants.ts b/packages/dsh-tauri-ui/src/client/constants.ts
new file mode 100644
index 00000000..6e69b9ec
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/constants.ts
@@ -0,0 +1,37 @@
+/** Shared protocol and UI constants for the dsh-tauri-ui client plugin. */
+
+export const SETTINGS_UI_PLUGIN = 'dsh-tauri-ui'
+export const SETTINGS_UI_NS = SETTINGS_UI_PLUGIN
+
+export const SETTINGS_SHELL_OVERLAY_SLOT = 'shell.overlay'
+export const SETTINGS_SIDEBAR_SLOT = 'sidebar.settings'
+export const SETTINGS_SECTION_SLOT = 'settings.section'
+export const SETTINGS_TRIGGER_SLOT = 'settings.trigger'
+export const SETTINGS_ONBOARDING_SLOT = 'settings.onboarding'
+
+export const SETTINGS_SHELL_SEAT_ID = SETTINGS_UI_PLUGIN
+export const SETTINGS_SIDEBAR_ID = 'dsh-tauri-ui-settings'
+export const SETTINGS_STYLE_ID = 'dsh-tauri-ui-settings-styles'
+export const SETTINGS_REGISTRANT = SETTINGS_UI_PLUGIN
+export const SETTINGS_TRIGGER_PRIORITY = -1
+
+export const SETTINGS_UNDERLAY_SLOT_KEYS = ['sidebar', 'conversation', 'details'] as const
+export const SETTINGS_EXTERNAL_OVERLAY_SELECTORS = ['[data-dsh-better-sidebar]'] as const
+
+export const RAIL_WIDTH_MIN = 264
+export const RAIL_WIDTH_MAX = 420
+export const RAIL_WIDTH_DEFAULT = 280
+
+export const DICT_ZH = {
+ back: '返回应用',
+ search: '搜索设置…',
+ settings: '设置',
+ noResults: '没有匹配的设置项',
+} as const
+
+export const DICT_EN: Record<keyof typeof DICT_ZH, string> = {
+ back: 'Back to app',
+ search: 'Search settings…',
+ settings: 'Settings',
+ noResults: 'No matching settings',
+}
diff --git a/packages/dsh-tauri-ui/src/client/icons.tsx b/packages/dsh-tauri-ui/src/client/icons.tsx
new file mode 100644
index 00000000..4e55bab9
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/icons.tsx
@@ -0,0 +1,7 @@
+import type { ReactElement } from 'react'
+
+export function ArrowRight(): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M14.75 8a.75.75 0 0 1-.75.75H3.81l2.72 2.72a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 1.06L3.81 7.25H14a.75.75 0 0 1 .75.75" clip-rule="evenodd" /></svg>
+ )
+}
diff --git a/packages/dsh-tauri-ui/src/client/index.ts b/packages/dsh-tauri-ui/src/client/index.ts
new file mode 100644
index 00000000..e02b4601
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/index.ts
@@ -0,0 +1,89 @@
+/**
+ * dsh-tauri-ui 客户端插件体(browser half):定制化 Tauri UI 的未来载体。
+ *
+ * 第一项功能:把 dsh 的设置弹窗(dialog)改为左侧停靠的侧边栏
+ * (左栏 = 返回应用 + 搜索 + 设置项导航;右侧 = 官方各设置分区内容)。
+ *
+ * 关系:`dsh-tauri` 是纯消息桥(无 UI、无运行时依赖),只负责把宿主导航栏
+ * 命令转发给 iframe 内的 dsh 应用并回报状态;本插件是它的 **UI 半区**——
+ * 桌面风格的自定义 chrome 作为插件加载进 `shell.overlay` 帧级浮动层。
+ *
+ * 本功能的结构(全部 slot-shadow,零结构补丁,零新增依赖):
+ * - trigger.tsx 注册进 sidebar.settings(priority -1)shadow
+ * 官方 SettingsRoot:齿轮按钮 + onboarding 宿主;官方 dialog 被抑制。
+ * - sidebar.tsx 注册进 shell.overlay(id dsh-tauri-ui-settings):
+ * 整窗 docked 左栏 + 内容区,经 <SlotOutlet slotKey="settings.section"/>
+ * 渲染官方各分区(SlotOutlet 由 renderer 的一行导出补丁提供)。
+ * - store.ts 触发器与侧边栏共享 {open, activeId, query}。
+ * - sections.ts 'settings.section' / 'settings.onboarding'
+ * 注册条目的导航行投影(订阅槽位与 locale 变更)。
+ * - locale.ts 本插件文案(返回应用/搜索设置…)双语注册。
+ *
+ * 保留了骨架期的 `shell.overlay` 条目(id dsh-tauri-ui)作为未来 chrome
+ * 的落点,与设置侧边栏(id dsh-tauri-ui-settings)并行不冲突。
+ */
+import type { Context as ClientContext } from '@deepseek-ai/cordis'
+import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+import {
+ SETTINGS_REGISTRANT,
+ SETTINGS_SHELL_OVERLAY_SLOT,
+ SETTINGS_SHELL_SEAT_ID,
+ SETTINGS_UI_PLUGIN,
+} from './constants'
+import { installSettingsLocale } from './locale'
+import { TauriUiSeat } from './seat'
+import { installSettingsSections } from './sections'
+import { registerSettingsSidebar } from './sidebar'
+import { mountSettingsStyles } from './styles'
+import { registerSettingsTrigger } from './trigger'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = SETTINGS_UI_PLUGIN
+
+/** 需要的客户端服务:slots(注册点位)、layout(未来 chrome 的面板动作)、locale(双语文案)。 */
+export const inject = ['slots', 'layout', 'locale']
+
+/**
+ * 插件体:注册未来 chrome 的落点座位 + 设置侧边栏功能。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ // 骨架期落点:未来桌面 chrome(顶部导航/窗口控件等)在此渲染。
+ // alpha 的 slot 必须先由父条目的 children 表声明才能注册进入;shell.overlay
+ // 由 ui-layout 的 AppFrame 声明,故通过 inject 等其声明(live)后再注册,
+ // 避免 `slot "shell.overlay" is not declared` 运行时报错。
+ ctx.effect(
+ () =>
+ ctx.slots.inject(SETTINGS_SHELL_OVERLAY_SLOT, () =>
+ ctx.slots.register(
+ {
+ name: SETTINGS_SHELL_OVERLAY_SLOT,
+ id: SETTINGS_SHELL_SEAT_ID,
+ registrant: SETTINGS_REGISTRANT,
+ },
+ TauriUiSeat,
+ )),
+ 'dsh-tauri-ui: shell.overlay seat',
+ )
+
+ // 第一项功能:设置弹窗 → 侧边栏。
+ // 侧边栏依赖 renderer 补丁导出的 <SlotOutlet>(任意槽渲染的入口)。核心未带
+ // 补丁时(旧安装),SlotOutlet 为 undefined —— 此时降级:不注册侧边栏与
+ // 触发条目,官方设置 dialog 原样工作,绝不白屏(功能整体不生效即可)。
+ ctx.effect(
+ () => mountSettingsStyles(),
+ 'dsh-tauri-ui: settings styles',
+ )
+ installSettingsLocale(ctx)
+ installSettingsSections(ctx.slots)
+ if (typeof SlotOutlet === 'function') {
+ registerSettingsSidebar(ctx)
+ registerSettingsTrigger(ctx)
+ }
+ else {
+ console.warn(
+ '[dsh-tauri-ui] <SlotOutlet> unavailable (renderer patch missing) — settings sidebar disabled, official dialog stays.',
+ )
+ }
+}
diff --git a/packages/dsh-tauri-ui/src/client/locale.ts b/packages/dsh-tauri-ui/src/client/locale.ts
new file mode 100644
index 00000000..ce26d5bc
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/locale.ts
@@ -0,0 +1,48 @@
+/**
+ * locale.ts — 本插件自有的界面文案(返回应用 / 搜索设置… / 设置)。
+ *
+ * 用 locale 服务的**非类型化**注册面(register(ns, locale, dict))挂进
+ * dsh 的 locale 表:zh/en 双语齐全即满足运行时“bilingual balance”约束,
+ * 且无需增广 LocaleNamespaceMap(避免外部类型依赖)。
+ *
+ * 组件侧不引入框架的 `t` 座(那需要 register option locale + 增广),
+ * 改用一个极薄的 uSES 桥:apply 时订阅 locale 变更并推进 rev ->
+ * 组件订阅 rev 重渲染,文案按当前 active locale 从本地字典读取。
+ */
+import type { Context } from '@deepseek-ai/cordis'
+import type { SettingsUiKey } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { DICT_EN, DICT_ZH, SETTINGS_UI_NS } from './constants'
+
+export type { SettingsUiKey } from './types'
+
+/** 活跃语言 id(module 级缓存,apply 时初始化并由订阅推进)。 */
+let activeLocale = 'en'
+
+/** locale 变更推进器:revision 前进 -> uSES 订阅方重渲染。 */
+export const settingsLocaleRev = createExternalStore({ rev: 0 })
+
+/**
+ * 在 apply 里安装:注册本插件的双语字典,并桥接 locale 变更到 rev。
+ * @param ctx - 客户端根上下文(须已注入 locale 服务)。
+ */
+export function installSettingsLocale(ctx: Context): void {
+ activeLocale = ctx.locale.getLocale().active
+ ctx.locale.register(SETTINGS_UI_NS, 'zh', DICT_ZH)
+ ctx.locale.register(SETTINGS_UI_NS, 'en', DICT_EN)
+ ctx.locale.subscribe(() => {
+ activeLocale = ctx.locale.getLocale().active
+ settingsLocaleRev.set(s => ({ ...s, rev: s.rev + 1 }))
+ })
+}
+
+/** 按当前活跃语言取一条文案。 */
+export function settingsText(key: SettingsUiKey): string {
+ return activeLocale === 'zh' ? DICT_ZH[key] : DICT_EN[key]
+}
+
+/** 组件内订阅 locale 变更(revision 前进即重渲染)。 */
+export function useSettingsLocale(): void {
+ useSyncExternalStore(settingsLocaleRev.subscribe, () => settingsLocaleRev.getSnapshot().rev)
+}
diff --git a/packages/dsh-tauri-ui/src/client/nav-icon.tsx b/packages/dsh-tauri-ui/src/client/nav-icon.tsx
new file mode 100644
index 00000000..af984b14
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/nav-icon.tsx
@@ -0,0 +1,30 @@
+import type { ReactElement } from 'react'
+import {
+ IconAgentPresetOutline16,
+ IconDataOutline16,
+ IconPersonalizationOutline16,
+ IconSettingsOutline16,
+} from '@deepseek-ai/dsh-client-ui-primitives'
+
+/**
+ * nav-icon.tsx — 设置导航行的分区图标。
+ *
+ * `settings.section` 契约只携带 {id, order, label};官方 SettingsRoot 在壳内
+ * 按 id 从闭集选图标(models / agent-presets / plugins,未知 id 回落设置齿轮)。
+ * 本侧边栏镜像同一映射、复用同一图标组件(@deepseek-ai/dsh-client-ui-primitives
+ * 经 ModuleLoader 解析,与官方视觉同源、自动跟随上游),保证停靠设置栏与官方
+ * 设置弹窗的导航观感一致。
+ */
+
+/** 官方 navIcon 同款闭集映射:已知分区 id → 图标组件。 */
+const NAV_ICONS: Record<string, typeof IconSettingsOutline16> = {
+ 'models': IconDataOutline16,
+ 'agent-presets': IconAgentPresetOutline16,
+ 'plugins': IconPersonalizationOutline16,
+}
+
+/** 渲染分区导航图标(官方兜底语义:未知 id 显示设置齿轮)。 */
+export function SettingsNavIcon({ id }: { id: string }): ReactElement {
+ const Icon = NAV_ICONS[id] ?? IconSettingsOutline16
+ return <Icon size={16} className="dsh-tu-settingsNavIcon" />
+}
diff --git a/packages/dsh-tauri-ui/src/client/seat.ts b/packages/dsh-tauri-ui/src/client/seat.ts
new file mode 100644
index 00000000..572ff824
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/seat.ts
@@ -0,0 +1,15 @@
+/**
+ * `shell.overlay` 条目组件(骨架占位):定制化 Tauri UI 的渲染落点。
+ *
+ * shell.overlay 是帧级浮动层(list/root):位于所有列之上、滚动容器之外,
+ * 层本身 click-through,条目自行 opt-in pointer-events。将来桌面风格的自定义
+ * chrome(顶部导航/窗口控件/状态胶囊等)在这里渲染;当前骨架不渲染任何
+ * 可见内容,仅保证注册链路的类型合约完整可编译。
+ *
+ * 类型说明:register 的组件须满足 SlotComponent 合约(参数为四份合成 props,
+ * 返回 ReactNode)。此处零参数、返回 null 亦合法(参数逆变 + 返回值是
+ * ReactNode 子集);接入真实 UI 后改为消费 props 的常规函数组件即可。
+ */
+export function TauriUiSeat(): null {
+ return null
+}
diff --git a/packages/dsh-tauri-ui/src/client/sections.ts b/packages/dsh-tauri-ui/src/client/sections.ts
new file mode 100644
index 00000000..47d5c8f1
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/sections.ts
@@ -0,0 +1,82 @@
+import type { SlotRegistry } from 'dsh-tauri/client'
+import type { SettingsRow } from './types'
+import { useMemo, useSyncExternalStore } from 'react'
+import { SETTINGS_ONBOARDING_SLOT, SETTINGS_SECTION_SLOT } from './constants'
+import { useSettingsLocale } from './locale'
+
+export type { SettingsRow } from './types'
+/**
+ * sections.ts — 设置分区/引导步骤的注册表投影。
+ *
+ * 官方 SettingsRoot 用 inject hooks(sections / onboardingSteps)把
+ * 'settings.section' / 'settings.onboarding' 两个 list 槽的注册条目投影为
+ * 导航行。这里做同样的事,但更贴近 renderer 自身的 uSES 习惯:订阅槽位
+ * 版本 + locale 变更,重算 `entries(key) -> {id, order, label}` 排序行。
+ *
+ * label 与官方一致经 resolveSlotLabel 语义解析(函数型 label 即按当前
+ * locale 求值,所以 locale 变更也要触发重算)。
+ */
+/** apply 时存入的槽注册中心(组件在 render 期经它订阅/投影)。 */
+let slotsRef: SlotRegistry | undefined
+
+/**
+ * 在 apply 里安装:把 ctx.slots 引用留给投影 hooks。
+ * @param slots - 客户端 slota 注册中心(ctx.slots)。
+ */
+export function installSettingsSections(slots: SlotRegistry): void {
+ slotsRef = slots
+}
+
+/** 解析条目 label(镜像官方 resolveSlotLabel 语义;不依赖 ui-slots 运行时导出)。 */
+function resolveLabel(label: unknown): string | undefined {
+ if (typeof label === 'function')
+ return String((label as () => unknown)())
+ return typeof label === 'string' ? label : undefined
+}
+
+/** 带 key/order/label 的条目行(按 order 升序)。 */
+function projectRows(slotKey: string): SettingsRow[] {
+ const slots = slotsRef
+ if (!slots)
+ return []
+ return slots
+ .entries(slotKey as never)
+ .map(e => ({
+ id: e.options.id ?? '',
+ order: e.options.order ?? 0,
+ label: resolveLabel(e.options.label) ?? '',
+ }))
+ .filter(r => r.id !== '')
+ .sort((a, b) => a.order - b.order)
+}
+
+/**
+ * 订阅一个 list 槽的注册/声明变更(uSES:getVersion 做快照,变更在
+ * microtask 批量通知后重渲染)。
+ * @param slotKey - 槽 key。
+ * @returns 当前版本号。
+ */
+function useSlotVersion(slotKey: string): number {
+ const slots = slotsRef
+ return useSyncExternalStore(
+ (onChange) => {
+ if (!slots)
+ return () => {}
+ return slots.subscribe(slotKey as never, onChange)
+ },
+ () => (slots ? slots.getVersion(slotKey as never) : 0),
+ )
+}
+
+/** 设置分区导航行('settings.section' 投影;订阅槽位与 locale 变更)。 */
+export function useSettingsSectionRows(): SettingsRow[] {
+ const sectionVersion = useSlotVersion(SETTINGS_SECTION_SLOT)
+ useSettingsLocale()
+ return useMemo(() => projectRows(SETTINGS_SECTION_SLOT), [sectionVersion])
+}
+
+/** 引导步骤行('settings.onboarding' 投影,仅 id+order)。 */
+export function useSettingsOnboardingSteps(): SettingsRow[] {
+ const onboardingVersion = useSlotVersion(SETTINGS_ONBOARDING_SLOT)
+ return useMemo(() => projectRows(SETTINGS_ONBOARDING_SLOT), [onboardingVersion])
+}
diff --git a/packages/dsh-tauri-ui/src/client/settings-obstructions.ts b/packages/dsh-tauri-ui/src/client/settings-obstructions.ts
new file mode 100644
index 00000000..6139552b
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/settings-obstructions.ts
@@ -0,0 +1,107 @@
+import {
+ SETTINGS_EXTERNAL_OVERLAY_SELECTORS,
+ SETTINGS_UNDERLAY_SLOT_KEYS,
+} from './constants'
+
+interface SettingsObstructionState {
+ element: HTMLElement
+ inert: boolean
+ hadInlineOpacity: boolean
+ opacityPriority: string
+ opacityValue: string
+}
+
+/**
+ * Finds host surfaces that could remain above or show through the settings overlay.
+ * A set is required because an independently mounted overlay may also own a slot anchor.
+ */
+export function getSettingsObstructionTargets(root: ParentNode): HTMLElement[] {
+ const targets = new Set<HTMLElement>()
+
+ for (const slotKey of SETTINGS_UNDERLAY_SLOT_KEYS) {
+ const anchor = root.querySelector<HTMLElement>(`[data-slot="${slotKey}"]`)
+ if (anchor)
+ targets.add(anchor.parentElement ?? anchor)
+ }
+
+ for (const selector of SETTINGS_EXTERNAL_OVERLAY_SELECTORS) {
+ for (const element of root.querySelectorAll<HTMLElement>(selector))
+ targets.add(element)
+ }
+
+ return [...targets]
+}
+
+/**
+ * Temporarily conceals and disables every surface below the docked settings page.
+ * Newly mounted plugin surfaces are reconciled while settings remains open. The
+ * disposer stops observation and restores every surface's exact inline state.
+ */
+export function concealSettingsObstructions(root: ParentNode = document): () => void {
+ const previous = new Map<HTMLElement, SettingsObstructionState>()
+ let restored = false
+
+ const reconcile = (): void => {
+ if (restored)
+ return
+
+ for (const element of getSettingsObstructionTargets(root)) {
+ if (!previous.has(element)) {
+ const opacityValue = element.style.getPropertyValue('opacity')
+ previous.set(element, {
+ element,
+ inert: element.inert,
+ hadInlineOpacity: opacityValue !== '',
+ opacityPriority: element.style.getPropertyPriority('opacity'),
+ opacityValue,
+ })
+ }
+
+ // Inline !important keeps independently mounted overlays concealed even
+ // when they supplied their own important opacity declaration.
+ element.style.setProperty('opacity', '0', 'important')
+ element.inert = true
+ }
+ }
+
+ const ownerDocument = root instanceof Document
+ ? root
+ : (root as Node).ownerDocument
+ const observerRoot = root instanceof Document
+ ? root.documentElement
+ : (root as Node)
+ const Observer = ownerDocument?.defaultView?.MutationObserver ?? MutationObserver
+ const observer = new Observer(reconcile)
+
+ observer.observe(observerRoot, {
+ attributeFilter: ['data-dsh-better-sidebar', 'data-slot'],
+ attributes: true,
+ childList: true,
+ subtree: true,
+ })
+ reconcile()
+
+ return () => {
+ if (restored)
+ return
+
+ restored = true
+ observer.disconnect()
+
+ for (const {
+ element,
+ hadInlineOpacity,
+ inert,
+ opacityPriority,
+ opacityValue,
+ } of previous.values()) {
+ if (hadInlineOpacity)
+ element.style.setProperty('opacity', opacityValue, opacityPriority)
+ else
+ element.style.removeProperty('opacity')
+ element.inert = inert
+ }
+
+ previous.clear()
+ }
+}
diff --git a/packages/dsh-tauri-ui/src/client/sidebar.tsx b/packages/dsh-tauri-ui/src/client/sidebar.tsx
new file mode 100644
index 00000000..e51d2d24
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/sidebar.tsx
@@ -0,0 +1,208 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { SettingsSidebarProps } from './types'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+/**
+ * sidebar.tsx — shell.overlay 里的设置侧边栏(id 'dsh-tauri-ui-settings')。
+ *
+ * 布局即需求方 ASCII:整窗左侧停靠 —— 左栏(← 返回应用 / 🔍 搜索设置…
+ * / 设置项导航,只过滤左栏列表)+ 右侧内容区。内容区渲染当前激活分区:
+ *
+ * <SlotOutlet slotKey={SETTINGS_SECTION_SLOT} ownerProps={{ close }} opts={{ only: activeId }} />
+ *
+ * 与官方 SettingsPanel 的渲染调用逐参数一致(owner={close},only=active)。
+ * shell.overlay 是 list/root 且层本身 click-through,本条目 opt-in pointer
+ * events。Esc 与“返回应用”都走 closeSettings();打开时聚焦搜索框。
+ *
+ * 视觉对齐官方(用户反馈 m00308/m00310):
+ * 1. 左栏背景 = 官方 sidebar(.hHd-Xa_root)的 --dsw-specific-sidebar-fill;
+ * 2. 内容区背景 = 主界面(.wSkVaW_root / .wSkVaW_scrollBody)的 --dsw-alias-bg-base;
+ * 3. 左栏宽度可拖拽调整(镜像官方 DragHandle:pointer capture + rAF 节流),
+ * 开通与官方一致的合约区间 clamp [264, 420](官方默认 280、关闭即忘);
+ * 打开时按官方 sidebar 槽([data-slot="sidebar"])的实际渲染宽度做一次同步。
+ * 4. 内容区宽度与主界面 hero 行一致:
+ * min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%)
+ * (这些 --dsh-composer-* 变量定义域在官方 .wSkVaW_root 容器,overlay 在其外,
+ * 由本组件在根节点自带相同定义),左右留空与主界面对齐。
+ * 无“最小化/折叠 rail”模式:返回应用/Esc 即整体隐藏(与 codex 同思路)。
+ */
+import { useEffect, useRef, useState } from 'react'
+import {
+ SETTINGS_REGISTRANT,
+ SETTINGS_SECTION_SLOT,
+ SETTINGS_SHELL_OVERLAY_SLOT,
+ SETTINGS_SIDEBAR_ID,
+} from './constants'
+import { ArrowRight } from './icons'
+import { settingsText, useSettingsLocale } from './locale'
+import { SettingsNavIcon } from './nav-icon'
+import { useSettingsSectionRows } from './sections'
+import { concealSettingsObstructions } from './settings-obstructions'
+import {
+ clampRailWidth,
+ closeSettings,
+ RAIL_WIDTH_DEFAULT,
+ selectSection,
+ setRailWidth,
+ settingsStore,
+ useSettingsUi,
+} from './store'
+
+/**
+ * 侧边栏组件:整窗 docked 左栏 + 右侧官方设置分区内容。
+ * @param _props - 标准钩子(当前未消费 useSessions,保留以符合合成 props)。
+ * @returns 侧边栏,或 null(未打开时 shell.overlay 条目不占位、不挡点击)。
+ */
+export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | null {
+ const ui = useSettingsUi()
+ const rows = useSettingsSectionRows()
+ useSettingsLocale()
+ const searchRef = useRef<HTMLInputElement>(null)
+ const [dragging, setDragging] = useState(false)
+
+ // Esc 关闭(仅打开期间挂载监听,与官方 SettingsPanel 同生命周期)。
+ useEffect(() => {
+ if (!ui.open)
+ return
+ const onKeyDown = (event: KeyboardEvent): void => {
+ if (event.key === 'Escape')
+ closeSettings()
+ }
+ document.addEventListener('keydown', onKeyDown)
+ return () => document.removeEventListener('keydown', onKeyDown)
+ }, [ui.open])
+
+ // 打开时聚焦搜索框;并按官方 sidebar 槽的实际渲染宽度同步左栏宽度(item 3)。
+ useEffect(() => {
+ if (!ui.open)
+ return
+ const el = document.querySelector('[data-slot="sidebar"]')
+ const width = el?.getBoundingClientRect().width
+ if (typeof width === 'number' && width >= 264)
+ setRailWidth(clampRailWidth(width))
+ searchRef.current?.focus()
+ }, [ui.open])
+
+ // 自定义主题可能让设置页背景半透明,独立挂载到 body 的第三方 overlay 也可能
+ // 建立自己的层叠上下文。设置打开期间隐藏并禁用这些下层/外部表面,关闭时由
+ // disposer 精确恢复插件或主题原先拥有的内联状态。
+ useEffect(() => {
+ if (!ui.open)
+ return
+ return concealSettingsObstructions()
+ }, [ui.open])
+
+ if (!ui.open)
+ return null
+
+ const railWidth = ui.railWidth ?? RAIL_WIDTH_DEFAULT
+ const query = ui.query.trim().toLowerCase()
+ const visible = query
+ ? rows.filter(
+ row =>
+ row.label.toLowerCase().includes(query) || row.id.toLowerCase().includes(query),
+ )
+ : rows
+ const activeId = visible.some(row => row.id === ui.activeId)
+ ? ui.activeId
+ : visible[0]?.id
+
+ return (
+ <div className="dsh-tu-settingsRoot" data-slot-sidebar="dsh-tauri-ui">
+ <div
+ className="dsh-tu-settingsRail"
+ style={{ '--dsh-settings-rail-width': `${railWidth}px` } as React.CSSProperties}
+ >
+ <button
+ type="button"
+ className="dsh-tu-settingsBack"
+ onClick={() => closeSettings()}
+ >
+ <ArrowRight />
+ {settingsText('back')}
+ </button>
+ <input
+ ref={searchRef}
+ className="dsh-tu-settingsSearch"
+ value={ui.query}
+ placeholder={settingsText('search')}
+ aria-label={settingsText('search')}
+ onChange={event =>
+ settingsStore.set(state => ({ ...state, query: event.target.value }))}
+ />
+ <nav className="dsh-tu-settingsNav" aria-label={settingsText('settings')}>
+ {visible.map(row => (
+ <button
+ key={row.id}
+ type="button"
+ className={`dsh-tu-settingsNavItem${row.id === activeId ? ' dsh-tu-settingsNavItemActive' : ''}`}
+ aria-current={row.id === activeId ? 'true' : undefined}
+ onClick={() => selectSection(row.id)}
+ >
+ <SettingsNavIcon id={row.id} />
+ <span className="dsh-tu-settingsNavLabel">{row.label}</span>
+ </button>
+ ))}
+ {visible.length === 0 && <div className="dsh-tu-settingsEmpty">{settingsText('noResults')}</div>}
+ </nav>
+ </div>
+ <div
+ role="separator"
+ aria-orientation="vertical"
+ aria-label={settingsText('settings')}
+ className={`dsh-tu-settingsHandle${dragging ? ' dsh-tu-settingsHandleDragging' : ''}`}
+ onPointerDown={(event) => {
+ event.preventDefault()
+ event.currentTarget.setPointerCapture(event.pointerId)
+ const startX = event.clientX
+ const startWidth = ui.railWidth ?? RAIL_WIDTH_DEFAULT
+ setDragging(true)
+ let raf = 0
+ const onMove = (moveEvent: PointerEvent): void => {
+ if (raf)
+ cancelAnimationFrame(raf)
+ raf = requestAnimationFrame(() => {
+ setRailWidth(clampRailWidth(startWidth + (moveEvent.clientX - startX)))
+ })
+ }
+ const onUp = (): void => {
+ window.removeEventListener('pointermove', onMove)
+ window.removeEventListener('pointerup', onUp)
+ setDragging(false)
+ }
+ window.addEventListener('pointermove', onMove)
+ window.addEventListener('pointerup', onUp)
+ }}
+ />
+ <div className="dsh-tu-settingsContentOuter">
+ <div className="dsh-tu-settingsContentInner">
+ {activeId !== undefined && (
+ <SlotOutlet
+ slotKey={SETTINGS_SECTION_SLOT}
+ ownerProps={{ close: () => closeSettings() }}
+ opts={{ only: activeId }}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ )
+}
+
+/**
+ * 注册:shell.overlay(list)新增一个独立条目,渲染设置侧边栏。
+ * @param ctx - 客户端根上下文。
+ */
+export function registerSettingsSidebar(ctx: Context): void {
+ // shell.overlay 由 ui-layout 的 AppFrame 声明;alpha 要求注册进入前该槽已
+ // 由父条目 children 表声明,故用 inject 等其声明 live 后再注册。
+ ctx.effect(
+ () =>
+ ctx.slots.inject(SETTINGS_SHELL_OVERLAY_SLOT, () =>
+ ctx.slots.register(
+ { name: SETTINGS_SHELL_OVERLAY_SLOT, id: SETTINGS_SIDEBAR_ID, registrant: SETTINGS_REGISTRANT },
+ SettingsSidebar,
+ )),
+ 'dsh-tauri-ui: settings sidebar',
+ )
+}
diff --git a/packages/dsh-tauri-ui/src/client/store.ts b/packages/dsh-tauri-ui/src/client/store.ts
new file mode 100644
index 00000000..1d4db2b9
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/store.ts
@@ -0,0 +1,71 @@
+import type { SettingsUiState } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { RAIL_WIDTH_MAX, RAIL_WIDTH_MIN } from './constants'
+
+export { RAIL_WIDTH_DEFAULT } from './constants'
+export type { SettingsUiState } from './types'
+
+/**
+ * store.ts — dsh-tauri-ui 设置侧边栏的共享 UI 状态。
+ *
+ * 触发器(sidebar.settings 槽内)与侧边栏(shell.overlay 槽内)是同一插件
+ * 的两个独立注册条目,凭一个模块级 SnapshotStore 共享开关/当前分区/搜索词:
+ * - 触发器把 open 置 true(并可选跳到某分区);
+ * - 侧边栏订阅 open/activeId/query 渲染,Esc 或“返回应用”置 false。
+ *
+ * createExternalStore 是框架无关的 uSES 安全状态源
+ * (getSnapshot 在变更间返回同一引用;set 返回不可变新状态)。
+ */
+/**
+ * 左栏宽度合约,与官方 sidebar 面板一致:
+ * defineStore init sidebar:280,setSidebar clamp clampWidth(px, 264, 420),关闭即忘
+ * (官方“closing a panel forgets its drag width”——不持久化,重开回默认)。
+ */
+/** 钳制到左栏合约区间(镜像官方 clampWidth 语义)。 */
+export function clampRailWidth(px: number): number {
+ return Math.min(RAIL_WIDTH_MAX, Math.max(RAIL_WIDTH_MIN, px))
+}
+
+/** 全局唯一共享状态源(模块级单例;插件重载时随 bundle 重建,可接受)。 */
+export const settingsStore = createExternalStore<SettingsUiState>({
+ open: false,
+ activeId: undefined,
+ query: '',
+ railWidth: undefined,
+})
+
+/** 打开侧边栏;可选直接跳到一个设置分区(onboarding 的 openSection 用)。 */
+export function openSettings(sectionId?: string): void {
+ settingsStore.set(s => ({
+ ...s,
+ open: true,
+ ...(sectionId !== undefined ? { activeId: sectionId } : {}),
+ }))
+}
+
+/** 关闭侧边栏并复位视图状态(与官方 close 的复位语义一致;宽度也即忘)。 */
+export function closeSettings(): void {
+ settingsStore.set(s => ({
+ ...s,
+ open: false,
+ activeId: undefined,
+ query: '',
+ railWidth: undefined,
+ }))
+}
+
+/** 切换左栏当前分区。 */
+export function selectSection(id: string): void {
+ settingsStore.set(s => ({ ...s, activeId: id }))
+}
+
+/** 拖拽中实时写入左栏宽度(调用方已按合约钳制)。 */
+export function setRailWidth(px: number): void {
+ settingsStore.set(s => ({ ...s, railWidth: px }))
+}
+
+/** 组件内读取 UI 状态(uSES;state 引用在 update 之间稳定)。 */
+export function useSettingsUi(): SettingsUiState {
+ return useSyncExternalStore(settingsStore.subscribe, settingsStore.getSnapshot)
+}
diff --git a/packages/dsh-tauri-ui/src/client/styles.ts b/packages/dsh-tauri-ui/src/client/styles.ts
new file mode 100644
index 00000000..31895f39
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/styles.ts
@@ -0,0 +1,177 @@
+/** Settings UI styles generated as css-render nodes. */
+import { CssRender } from 'dsh-tauri/client'
+import { SETTINGS_STYLE_ID } from './constants'
+
+const cssr = CssRender()
+const { c } = cssr
+
+const settingsStyle = c([
+ c('.dsh-tu-settingsTrigger', {
+ boxSizing: 'border-box',
+ cursor: 'pointer',
+ width: 'calc(100% + 4px)',
+ height: '42px',
+ color: 'var(--dsw-alias-label-primary)',
+ background: 'none',
+ border: 'none',
+ borderRadius: '12px',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ margin: '4px -2px',
+ padding: '0 10px 0 8px',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ lineHeight: '22px',
+ overflow: 'hidden',
+ flex: 'none',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ c('.dsh-tu-settingsTriggerRail', {
+ borderRadius: '50%',
+ justifyContent: 'center',
+ gap: 0,
+ width: '36px',
+ height: '36px',
+ margin: '8px 0 10px',
+ padding: 0,
+ }),
+ c('.dsh-tu-settingsRoot', {
+ '--dsh-chat-content-width': '748px',
+ '--dsh-composer-card-max-width': 'calc(var(--dsh-chat-content-width) + 32px)',
+ '--dsh-composer-side-clearance': '16px',
+ 'position': 'fixed',
+ 'inset': 0,
+ 'zIndex': 1000,
+ 'display': 'flex',
+ 'background': 'var(--dsw-alias-bg-base)',
+ 'color': 'var(--dsw-alias-label-primary)',
+ }),
+ c('.dsh-tu-settingsRail', {
+ flex: 'none',
+ boxSizing: 'border-box',
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '14px',
+ width: 'var(--dsh-settings-rail-width)',
+ padding: '6px 12px',
+ background: 'var(--dsw-specific-sidebar-fill)',
+ borderRight: '1px solid var(--dsw-alias-border-weak, rgba(127,127,127,0.2))',
+ overflow: 'hidden',
+ }),
+ c('.dsh-tu-settingsBack', {
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ alignSelf: 'flex-start',
+ padding: '6px 10px',
+ border: 'none',
+ background: 'none',
+ borderRadius: '10px',
+ cursor: 'pointer',
+ fontFamily: 'inherit',
+ width: '100%',
+ fontSize: '14px',
+ lineHeight: '22px',
+ color: 'var(--dsw-alias-label-primary)',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ c('.dsh-tu-settingsSearch', {
+ width: '100%',
+ height: '36px',
+ boxSizing: 'border-box',
+ padding: '0 10px',
+ borderRadius: '10px',
+ border: '1px solid var(--dsw-alias-border-weak, rgba(127,127,127,0.25))',
+ background: 'var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.08))',
+ color: 'var(--dsw-alias-label-primary)',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ outline: 'none',
+ }),
+ c('.dsh-tu-settingsNav', {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '4px',
+ flex: 1,
+ overflowY: 'auto',
+ minHeight: 0,
+ }),
+ c('.dsh-tu-settingsNavItem', {
+ boxSizing: 'border-box',
+ height: '40px',
+ padding: '9px 12px',
+ border: 'none',
+ background: 'none',
+ borderRadius: '12px',
+ textAlign: 'left',
+ cursor: 'pointer',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ lineHeight: '22px',
+ fontWeight: 400,
+ color: 'var(--dsw-alias-label-primary)',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ }),
+ c('.dsh-tu-settingsNavIcon', {
+ flex: 'none',
+ }),
+ c('.dsh-tu-settingsNavLabel', {
+ flex: 1,
+ minWidth: 0,
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ }),
+ c('.dsh-tu-settingsNavItemActive', {
+ background: 'var(--dsw-specific-sidebar-nav-item-active)',
+ fontWeight: 500,
+ }),
+ c('.dsh-tu-settingsEmpty', {
+ padding: '12px 10px',
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))',
+ }),
+ c('.dsh-tu-settingsHandle', {
+ flex: 'none',
+ alignSelf: 'stretch',
+ width: '8px',
+ marginLeft: '-4px',
+ zIndex: 2,
+ cursor: 'col-resize',
+ touchAction: 'none',
+ background: 'transparent',
+ borderRadius: '4px',
+ }),
+ c('.dsh-tu-settingsHandleDragging', {
+ background: 'var(--dsw-alias-border-l2)',
+ }),
+ c('.dsh-tu-settingsContentOuter', {
+ flex: 1,
+ minWidth: 0,
+ height: '100%',
+ boxSizing: 'border-box',
+ overflowY: 'auto',
+ display: 'flex',
+ }),
+ c('.dsh-tu-settingsContentInner', {
+ width: 'min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%)',
+ margin: '0 auto',
+ boxSizing: 'border-box',
+ padding: '28px 36px',
+ }),
+])
+
+export function mountSettingsStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ if (cssr.find(SETTINGS_STYLE_ID) !== null)
+ return () => {}
+ settingsStyle.mount({ id: SETTINGS_STYLE_ID, head: true })
+ return () => settingsStyle.unmount({ id: SETTINGS_STYLE_ID })
+}
diff --git a/packages/dsh-tauri-ui/src/client/trigger.tsx b/packages/dsh-tauri-ui/src/client/trigger.tsx
new file mode 100644
index 00000000..b53b3d22
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/trigger.tsx
@@ -0,0 +1,106 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { SettingsTriggerProps } from './types'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+/**
+ * trigger.tsx — sidebar.settings 座位的新“赢家”(priority -1)。
+ *
+ * 官方 SettingsRoot 以默认 priority 0 注册进 sidebar.settings 单槽;同 cell
+ * 内最低 priority 渲染,因此本条目将其 shadow——官方“齿轮按钮 + 居中 modal”
+ * 整体不再渲染。本组件取而代之:
+ * - 同款触发按钮(内容借 <SlotOutlet slotKey="settings.trigger"/> 复用官方的
+ * TriggerContent = 齿轮图标 + label,样式由本组件实现);
+ * - 宿主 onboarding(谓词与官方一致:phase==='ready' 且无会话或当前会话
+ * blank),步骤经 <SlotOutlet slotKey="settings.onboarding"/> 渲染。
+ *
+ * 关键点:本条目**不声明任何 children**(声明的六列子槽归属于官方条目,
+ * 再声明会 throw),所有“渲染他人声明的槽”都走 SlotOutlet —— 这也是
+ * renderer 补丁(导出一行 SlotOutlet)存在的全部理由。
+ */
+import { useCallback, useEffect, useState } from 'react'
+import {
+ SETTINGS_REGISTRANT,
+ SETTINGS_SIDEBAR_SLOT,
+ SETTINGS_TRIGGER_PRIORITY,
+ SETTINGS_TRIGGER_SLOT,
+} from './constants'
+
+import { useSettingsOnboardingSteps } from './sections'
+import { openSettings, useSettingsUi } from './store'
+
+/**
+ * 触发组件:侧栏脚部的齿轮按钮 + 空会话引导宿主。
+ * @param props - 合成槽位 props。
+ * @param props.wide - 侧栏展开态(折叠时渲染 rail 圆钮)。
+ * @param props.useSessions - 框架标准钩子:会话列表快照(引导激活谓词)。
+ * @returns 触发按钮(open 状态写入共享 store)与可能的引导步骤。
+ */
+export function SettingsTrigger({ wide, useSessions }: SettingsTriggerProps): ReactElement {
+ const ui = useSettingsUi()
+ const steps = useSettingsOnboardingSteps()
+ const [completed, setCompleted] = useState<Set<string>>(() => new Set())
+
+ // 官方同款引导谓词:就绪且(无当前会话 或 当前会话空日志)→ 引导激活。
+ const onboardingActive = useSessions(
+ state =>
+ state.phase === 'ready'
+ && (state.current === undefined || state.byId[state.current]?.blank === true),
+ )
+
+ // 引导退出时复位完成集(与官方一致)。
+ useEffect(() => {
+ if (!onboardingActive)
+ setCompleted(new Set())
+ }, [onboardingActive])
+
+ const step = onboardingActive ? steps.find(s => !completed.has(s.id)) : undefined
+
+ const completeStep = useCallback((id: string) => {
+ setCompleted(previous => (previous.has(id) ? previous : new Set([...previous, id])))
+ }, [])
+
+ const openSection = useCallback((id: string) => {
+ openSettings(id)
+ }, [])
+
+ return (
+ <>
+ <button
+ type="button"
+ aria-haspopup="dialog"
+ aria-expanded={ui.open}
+ onClick={() => openSettings()}
+ className={`dsh-tu-settingsTrigger${wide ? '' : ' dsh-tu-settingsTriggerRail'}`}
+ >
+ <SlotOutlet slotKey={SETTINGS_TRIGGER_SLOT} ownerProps={{ wide }} />
+ </button>
+ {step !== undefined && (
+ <SlotOutlet
+ slotKey="settings.onboarding"
+ ownerProps={{
+ stepId: step.id,
+ complete: () => completeStep(step.id),
+ openSection,
+ }}
+ opts={{ only: step.id }}
+ />
+ )}
+ </>
+ )
+}
+
+/**
+ * 注册:等待 sidebar.settings 声明后,以 priority -1 shadow 官方 SettingsRoot。
+ *
+ * 'sidebar.settings' 不属于本插件类型图的 SlotMap 键(声明权在 ui-sidebar,
+ * 类型未提升到根 node_modules),此处对 options 显式 cast 以通过 K 收窄;
+ * 组件 props 仍由本地 SettingsTriggerProps 提供类型保证。
+ * @param ctx - 客户端根上下文。
+ */
+export function registerSettingsTrigger(ctx: Context): void {
+ ctx.slots.inject(SETTINGS_SIDEBAR_SLOT as never, () =>
+ ctx.slots.register(
+ { name: SETTINGS_SIDEBAR_SLOT, priority: SETTINGS_TRIGGER_PRIORITY, registrant: SETTINGS_REGISTRANT } as never,
+ SettingsTrigger,
+ ))
+}
diff --git a/packages/dsh-tauri-ui/src/client/types.ts b/packages/dsh-tauri-ui/src/client/types.ts
new file mode 100644
index 00000000..13709425
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/types.ts
@@ -0,0 +1,44 @@
+import type { SessionListState } from 'dsh-tauri/client'
+
+/** Selector hook shape shared by standard slot props. */
+export type SelectorHook<T> = <S>(sel: (state: T) => S) => S
+
+/** Props supplied to the settings trigger slot. */
+export interface SettingsTriggerProps {
+ /** sidebar.settings owner: expanded sidebar state. */
+ wide: boolean
+ /** Framework standard hook: session list snapshot. */
+ useSessions: SelectorHook<SessionListState>
+ useWorkspaces?: unknown
+}
+
+/** Props supplied to the shell.overlay settings sidebar slot. */
+export interface SettingsSidebarProps {
+ useSessions: SelectorHook<SessionListState>
+ useWorkspaces?: unknown
+}
+
+/** Settings sidebar UI state. */
+export interface SettingsUiState {
+ /** Whether the sidebar is open. */
+ open: boolean
+ /** Active settings section id. */
+ activeId: string | undefined
+ /** Search query used to filter the settings list. */
+ query: string
+ /** Current sidebar width in pixels, or undefined when unset. */
+ railWidth: number | undefined
+}
+
+/** A settings section or onboarding step projected into a navigation row. */
+export interface SettingsRow {
+ /** List slot entry id. */
+ id: string
+ /** Display order, defaulting to 0. */
+ order: number
+ /** Resolved display label. */
+ label: string
+}
+
+/** Keys in the settings UI translation dictionary. */
+export type SettingsUiKey = 'back' | 'search' | 'settings' | 'noResults'
diff --git a/packages/dsh-tauri-ui/src/index.ts b/packages/dsh-tauri-ui/src/index.ts
new file mode 100644
index 00000000..02314b64
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/index.ts
@@ -0,0 +1,6 @@
+/**
+ * dsh-tauri-ui 宿主侧(node half):纯浏览器插件,无宿主行为。
+ * loader 按行名导入包根时需要一个可挂载的插件入口;与官方浏览器插件
+ * (如 dsh-client-ui-layout)一致,这里提供空 apply。
+ */
+export function apply(): void {}
diff --git a/packages/dsh-tauri-ui/tsdown.config.ts b/packages/dsh-tauri-ui/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-ui/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri-worktree/README.md b/packages/dsh-tauri-worktree/README.md
new file mode 100644
index 00000000..679e4d96
--- /dev/null
+++ b/packages/dsh-tauri-worktree/README.md
@@ -0,0 +1,58 @@
+# dsh-tauri-worktree
+
+`dsh-tauri-worktree` 为 DSH 会话提供 Git worktree 隔离。每个工作树会话拥有独立目录,Agent 可以安全地修改代码,而不会影响本地主工作区。
+
+![dsh-tauri-worktree 工作流](public/worktree.png)
+
+## 功能
+
+- 按项目路径和会话 ID 创建稳定、可复用的隔离工作树。
+- 注册 `create_worktree`、`checkout_worktree` 工具。
+- `create_worktree` / `checkout_worktree` 支持可选 `carry_staged` 参数(默认 `false`):把已暂存(index)改动携带进新工作树、或携带回本地检出,避免暂存内容在隔离/移除工作树时丢失。
+- 提供创建、状态、检出和放弃 API:`/api/dsh-worktree/*`。
+- 将工作树状态注入系统提示:`is_worktree: true`。
+- 检出时创建或切换本地分支,并带回完整会话历史。
+- 放弃工作树时清理临时分支和 ledger 记录。
+
+## 携带暂存(carry_staged)
+
+git worktree 的 index 与暂存状态是每个工作树私有的:`git worktree add` 从 HEAD 干净检出,
+未提交改动不会跟随;移除工作树时未提交改动也随之删除。为避免「有暂存时创建/检出工作树
+导致内容丢失」,两个工具都提供开关:
+
+```ts
+// 创建时把源仓库已暂存改动带入新工作树(不携带未暂存/未跟踪改动)
+create_worktree({ branch_name: 'dsh/feature-xyz', carry_staged: true })
+
+// 检出时把工作树已暂存改动带回本地分支,再移除工作树
+checkout_worktree({ worktree_hash_dirname: '[hash]/[dirname]', branch_name: 'dsh/feature-xyz', carry_staged: true })
+```
+
+语义说明:
+
+- `carry_staged` 只移动「已暂存(index)」状态:修改、新增、删除的暂存条目会在目标目录
+ 重建为同样的暂存状态(文件内容同步到 index,`git status` 分布一致)。
+- 未暂存与未跟踪改动按 git worktree 的设计不携带:创建时留在源仓库,检出时随工作树移除。
+- 实现基于 `git diff --cached --binary` + `git apply --cached`,只触碰补丁涉及的路径,
+ 不使用仓库级共享的 `git stash`,避免跨 worktree 污染 stash 列表或覆盖目标目录无关改动。
+- 创建时携带失败会回滚刚创建的工作树;检出时携带失败会回滚到检出前分支并保留工作树。
+
+## 用户流程
+
+1. 用户明确要求使用 worktree 后,Agent 调用 `create_worktree`。
+2. 插件创建 `~/.dsh/worktrees/[hash]/[dirname]`,并把会话交接到新工作树。
+3. 在工作树会话中修改、测试和提交代码。
+4. 用户明确请求或批准后,才能调用 `checkout_worktree`;该操作会把改动带回本地分支并移除工作树。
+5. 如果不需要保留改动,可从面板执行放弃操作。
+
+> `checkout_worktree` 是用户授权操作。任务完成、PR 合并或 Agent 的便利性都不能代替用户授权。
+
+## 要求
+
+- 项目目录必须是 Git 仓库。
+- 宿主环境需要可执行的 `git`。
+- 插件需要 DSH 的 tools、systemPrompt、webServer、sessions、workspaceRegistry 和 agents 服务。
+
+## 许可证
+
+[MIT](../../LICENSE.md) © [Hairyf](https://github.com/hairyf)
diff --git a/packages/dsh-tauri-worktree/cordis.patch.yml b/packages/dsh-tauri-worktree/cordis.patch.yml
new file mode 100644
index 00000000..1135c1c7
--- /dev/null
+++ b/packages/dsh-tauri-worktree/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri-worktree
+ name: dsh-tauri-worktree
diff --git a/packages/dsh-tauri-worktree/package.json b/packages/dsh-tauri-worktree/package.json
new file mode 100644
index 00000000..f87e028b
--- /dev/null
+++ b/packages/dsh-tauri-worktree/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "dsh-tauri-worktree",
+ "type": "module",
+ "version": "0.6.7",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": "./dist/client.cjs",
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout",
+ "dsh-tauri"
+ ],
+ "external": [
+ "dsh-tauri/client"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "dependencies": {
+ "dsh-tauri": "workspace:*"
+ },
+ "devDependencies": {
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri-worktree/public/worktree.png b/packages/dsh-tauri-worktree/public/worktree.png
new file mode 100644
index 00000000..038c0701
Binary files /dev/null and b/packages/dsh-tauri-worktree/public/worktree.png differ
diff --git a/packages/dsh-tauri-worktree/src/client/constants.ts b/packages/dsh-tauri-worktree/src/client/constants.ts
new file mode 100644
index 00000000..194ef6f5
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/constants.ts
@@ -0,0 +1,87 @@
+export const WORKTREE_PLUGIN_NAME = 'dsh-tauri-worktree'
+export const WORKTREE_LOCALE_NAMESPACE = WORKTREE_PLUGIN_NAME
+export const WORKTREE_API_PREFIX = '/api/dsh-worktree'
+export const PREFERRED_MODE_STORAGE_KEY = `${WORKTREE_PLUGIN_NAME}:preferred-mode`
+
+export const INPUT_DOCK_SLOT = 'conversation.input.dock'
+export const SHELL_OVERLAY_SLOT = 'shell.overlay'
+export const MODE_SELECT_ID = `${WORKTREE_PLUGIN_NAME}-mode`
+export const MODE_SELECT_ORDER = -20
+export const SURFACE_ID = `${WORKTREE_PLUGIN_NAME}-surface`
+export const SURFACE_ORDER = -10
+export const DIALOG_ID = `${WORKTREE_PLUGIN_NAME}-dialog`
+
+export const STYLES_EFFECT = `${WORKTREE_PLUGIN_NAME}: styles`
+export const DIALOG_EFFECT = `${WORKTREE_PLUGIN_NAME}: dialog`
+export const HYDRATION_EFFECT = `${WORKTREE_PLUGIN_NAME}: hydrate session bindings`
+export const SESSION_ICONS_EFFECT = `${WORKTREE_PLUGIN_NAME}: session branch icons`
+
+export const SESSION_SWITCH_RETRY_DELAY_MS = 100
+export const SESSION_SWITCH_MAX_ATTEMPTS = 30
+
+/** hydration 失败/未知状态的重试间隔与上限(1.5s × 30 ≈ 45s,成功后立即停止)。 */
+export const HYDRATION_RETRY_DELAY_MS = 1500
+export const HYDRATION_MAX_RETRIES = 30
+
+/**
+ * create_worktree 自动交接的时效窗口:只有「本次运行期间新出现」且出现不超过该时长的
+ * 工作树会话才允许自动打开。启动时已存在的历史工作树、以及用户事后回到源会话的场景
+ * 一律不抢焦点(否则点击新建会话会被误跳转到工作树会话)。
+ * 60s 覆盖 hydration 的完整重试链(45s),避免慢速首查把真实交接误判为过期。
+ */
+export const HANDOFF_WINDOW_MS = 60_000
+
+export const MODE_SELECT_STYLE_ID = '@deepseek-ai/dsh-tauri-worktree/ModeSelect.module.css'
+export const WORKTREE_STYLE_ID = '@deepseek-ai/dsh-tauri-worktree/SurfaceDialog.module.css'
+export const SESSION_ICON_STYLE_ID = '@deepseek-ai/dsh-tauri-worktree/SessionBranchIcon.module.css'
+
+export const MODE_SELECT_CLASSES = {
+ anchor: 'dsh-tauri-worktree-mode-anchor',
+ chevron: 'dsh-tauri-worktree-mode-chevron',
+ host: 'dsh-tauri-worktree-mode-host',
+ icon: 'dsh-tauri-worktree-mode-icon',
+ trigger: 'dsh-tauri-worktree-mode-trigger',
+ triggerOpen: 'dsh-tauri-worktree-mode-trigger-open',
+} as const
+
+export const worktreeStyles = {
+ surface: 'dsh-tauri-worktree-surface',
+ surfaceBar: 'dsh-tauri-worktree-surface-bar',
+ surfaceContent: 'dsh-tauri-worktree-surface-content',
+ surfaceLabel: 'dsh-tauri-worktree-surface-label',
+ action: 'dsh-tauri-worktree-action',
+ actionLog: 'dsh-tauri-worktree-action-log',
+ actionDanger: 'dsh-tauri-worktree-action-danger',
+ spacer: 'dsh-tauri-worktree-spacer',
+ logs: 'dsh-tauri-worktree-logs',
+ logsOpen: 'dsh-tauri-worktree-logs-open',
+ logsInner: 'dsh-tauri-worktree-logs-inner',
+ logsPanel: 'dsh-tauri-worktree-logs-panel',
+ logLine: 'dsh-tauri-worktree-log-line',
+ modal: 'dsh-tauri-worktree-modal',
+ card: 'dsh-tauri-worktree-dialog-card',
+ title: 'dsh-tauri-worktree-dialog-title',
+ body: 'dsh-tauri-worktree-dialog-body',
+ field: 'dsh-tauri-worktree-dialog-field',
+ fieldLabel: 'dsh-tauri-worktree-dialog-field-label',
+ inputWrap: 'dsh-tauri-worktree-dialog-input-wrap',
+ input: 'dsh-tauri-worktree-dialog-input',
+ pathRow: 'dsh-tauri-worktree-dialog-path-row',
+ pathKey: 'dsh-tauri-worktree-dialog-path-key',
+ pathValue: 'dsh-tauri-worktree-dialog-path-value',
+ error: 'dsh-tauri-worktree-dialog-error',
+ footer: 'dsh-tauri-worktree-dialog-footer',
+ button: 'dsh-tauri-worktree-dialog-button',
+ buttonGhost: 'dsh-tauri-worktree-dialog-button-ghost',
+ buttonPrimary: 'dsh-tauri-worktree-dialog-button-primary',
+ buttonDanger: 'dsh-tauri-worktree-dialog-button-danger',
+ buttonDisabled: 'dsh-tauri-worktree-dialog-button-disabled',
+} as const
+
+export const SESSION_ICON_ATTRIBUTE = 'data-dsh-worktree-icon'
+export const SIDEBAR_SELECTOR = '[data-slot="sidebar"]'
+export const COMPOSER_SEAT_SELECTOR = '[data-composer-seat]'
+export const HERO_PRESET_SLOT_SELECTOR = '[data-slot="conversation.hero.agentPreset"]'
+/** rc.2/alpha 共用的稳定模式按钮定位(alpha 已移除 hero preset slot)。 */
+export const COMPOSER_MODE_BUTTON_SELECTOR = '[data-composer-card="true"] button[aria-label*="访问模式"], [data-composer-card="true"] button[aria-label*="Access mode"]'
+export const MODE_ANCHOR_ATTRIBUTE = 'data-dsh-tauri-worktree-mode-anchor'
diff --git a/packages/dsh-tauri-worktree/src/client/dialog.tsx b/packages/dsh-tauri-worktree/src/client/dialog.tsx
new file mode 100644
index 00000000..d883f8f7
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/dialog.tsx
@@ -0,0 +1,273 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { WorkspacesRuntime, WorktreeDialogProps } from './types'
+import { compat } from 'dsh-tauri/client'
+/**
+ * dialog.tsx — 检出本地 / 放弃更改 两个模态框(shell.overlay 条目)。
+ *
+ * 需求:
+ * - 检出本地:标题「将更改带回本地检出并继续」;分支名输入框预填 `dsh/`;
+ * 显示「当前关联路径 [hash]/[dirname]」与「目标项目路径 [项目路径]」;
+ * 按钮「确认检出并合并 / 取消」。
+ * - 放弃更改:标题「放弃工作树更改」;确认文本「确认放弃吗?这将删除当前会话及
+ * 对应的临时工作树。」;按钮「确认放弃(危险)/ 取消」。
+ *
+ * 两个弹窗由 store 的 checkoutOpen / abandonOpen 驱动;均渲染为 shell.overlay
+ * 下的居中模态(层本身 click-through,条目 opt-in pointer events)。
+ */
+import { useEffect } from 'react'
+import { DIALOG_EFFECT, DIALOG_ID, SHELL_OVERLAY_SLOT, WORKTREE_PLUGIN_NAME } from './constants'
+import { text, useLocale } from './locale'
+import { resolveWorkspaceTopInsertion } from './session'
+import { applyCheckout, applyDiscard, patchSession, useWorktreeSession } from './store'
+import { worktreeStyles } from './styles'
+
+/**
+ * 检出本地 / 放弃 弹窗组件(读 store 的 checkoutOpen / abandonOpen 决定渲染哪个)。
+ * @param props - 复合槽位 props。
+ * @param props.useSessions - 标准钩子:会话列表快照(取当前会话 id)。
+ * @param props.workspacesRuntime - 宿主工作区运行时(归档会话)。
+ * @param props.sessionsRuntime - 宿主会话运行时(打开继承会话)。
+ * @returns 居中模态(无打开项时返回 null)。
+ */
+export function WorktreeDialog({ useSessions, workspacesRuntime, sessionsRuntime }: WorktreeDialogProps): ReactElement | null {
+ useLocale()
+ const sessionId = useSessions(state => state.current)
+ const state = useWorktreeSession(sessionId)
+ const checkout = state.checkoutOpen
+ const abandon = state.abandonOpen
+ const closeAll = (): void => patchSession(sessionId, { checkoutOpen: false, abandonOpen: false })
+
+ // Hook 必须在所有 render 中保持相同顺序;仅打开弹窗时安装 Esc 监听。
+ useEffect(() => {
+ if (!sessionId || (!checkout && !abandon))
+ return
+ const onKeyDown = (event: KeyboardEvent): void => {
+ if (event.key === 'Escape')
+ closeAll()
+ }
+ document.addEventListener('keydown', onKeyDown)
+ return () => document.removeEventListener('keydown', onKeyDown)
+ }, [sessionId, checkout, abandon])
+
+ if (!sessionId || (!checkout && !abandon))
+ return null
+
+ return (
+ <div className={worktreeStyles.modal} data-dsh-worktree-dialog="1" onClick={closeAll}>
+ {checkout && (
+ <CheckoutDialog
+ sessionId={sessionId}
+ worktreeKey={state.worktreeKey}
+ projectPath={state.projectPath}
+ branchName={state.branchName}
+ error={state.error}
+ workspacesRuntime={workspacesRuntime}
+ sessionsRuntime={sessionsRuntime}
+ onCancel={closeAll}
+ />
+ )}
+ {abandon && (
+ <AbandonDialog
+ sessionId={sessionId}
+ worktreeKey={state.worktreeKey}
+ error={state.error}
+ workspacesRuntime={workspacesRuntime}
+ onCancel={closeAll}
+ />
+ )}
+ </div>
+ )
+}
+
+function CheckoutDialog(props: {
+ sessionId: string
+ worktreeKey: string
+ projectPath: string
+ branchName: string
+ error: string
+ workspacesRuntime: WorkspacesRuntime
+ sessionsRuntime: {
+ open: (sessionId: string) => void
+ refresh: () => Promise<void>
+ list: { getSnapshot: () => { current?: string, ids: string[] } }
+ }
+ onCancel: () => void
+}): ReactElement {
+ const { sessionId, worktreeKey, projectPath, workspacesRuntime, sessionsRuntime, onCancel } = props
+ const branchName = props.branchName || 'dsh/'
+ const disabled = branchName.trim() === '' || branchName.trim().endsWith('/')
+
+ const updateBranch = (value: string): void => patchSession(sessionId, { branchName: value })
+ const waitUntilListed = async (targetSessionId: string): Promise<boolean> => {
+ for (let attempt = 0; attempt < 30; attempt++) {
+ try {
+ await sessionsRuntime.refresh()
+ if (sessionsRuntime.list.getSnapshot().ids.includes(targetSessionId))
+ return true
+ }
+ catch {}
+ await new Promise(resolve => setTimeout(resolve, 250))
+ }
+ return false
+ }
+ const openAndConfirm = async (targetSessionId: string): Promise<boolean> => {
+ for (let attempt = 0; attempt < 10; attempt++) {
+ try {
+ sessionsRuntime.open(targetSessionId)
+ if (sessionsRuntime.list.getSnapshot().current === targetSessionId)
+ return true
+ }
+ catch {
+ await sessionsRuntime.refresh().catch(() => {})
+ }
+ await new Promise(resolve => setTimeout(resolve, 100))
+ }
+ return false
+ }
+ const promoteToWorkspaceTop = async (targetSessionId: string): Promise<void> => {
+ const insertion = resolveWorkspaceTopInsertion(
+ workspacesRuntime.list.getSnapshot().items,
+ projectPath,
+ targetSessionId,
+ )
+ if (!insertion)
+ return
+ await workspacesRuntime.insertSessionBefore(
+ insertion.workspaceId,
+ targetSessionId,
+ insertion.beforeSessionId,
+ )
+ }
+ const checkout = async (): Promise<void> => {
+ const result = await applyCheckout(sessionId, worktreeKey, branchName.trim())
+ if (!result.ok)
+ return
+ if (!result.targetSessionId) {
+ patchSession(sessionId, { checkoutOpen: false })
+ return
+ }
+ const listed = await waitUntilListed(result.targetSessionId)
+ if (!listed) {
+ patchSession(sessionId, { error: `Local session ${result.targetSessionId} was created but did not appear in the session list.` })
+ return
+ }
+ await promoteToWorkspaceTop(result.targetSessionId).catch(() => {})
+ await workspacesRuntime.archiveSession(sessionId)
+ const opened = await openAndConfirm(result.targetSessionId)
+ if (!opened)
+ patchSession(sessionId, { error: `Local session ${result.targetSessionId} could not be selected.` })
+ }
+
+ return (
+ <div
+ className={worktreeStyles.card}
+ role="dialog"
+ aria-modal="true"
+ aria-label={text('checkoutTitle')}
+ onClick={event => event.stopPropagation()}
+ >
+ <h2 className={worktreeStyles.title}>{text('checkoutTitle')}</h2>
+ <div className={worktreeStyles.field}>
+ <label className={worktreeStyles.fieldLabel} htmlFor="wt-checkout-branch">{text('checkoutBranchLabel')}</label>
+ <div className={worktreeStyles.inputWrap}>
+ <input
+ id="wt-checkout-branch"
+ className={worktreeStyles.input}
+ value={branchName}
+ placeholder="dsh/feature-xyz"
+ onChange={event => updateBranch(event.target.value)}
+ />
+ </div>
+ </div>
+ <div className={worktreeStyles.pathRow}>
+ <span className={worktreeStyles.pathKey}>{text('checkoutCurrentPath')}</span>
+ <span className={worktreeStyles.pathValue}>{worktreeKey || '—'}</span>
+ </div>
+ <div className={worktreeStyles.pathRow}>
+ <span className={worktreeStyles.pathKey}>{text('checkoutTargetPath')}</span>
+ <span className={worktreeStyles.pathValue}>{projectPath.replaceAll('\\', '/') || '—'}</span>
+ </div>
+ {props.error && <div className={worktreeStyles.error}>{props.error}</div>}
+ <div className={worktreeStyles.footer}>
+ <button type="button" className={`${worktreeStyles.button} ${worktreeStyles.buttonGhost}`} onClick={onCancel}>{text('checkoutCancel')}</button>
+ <button
+ type="button"
+ className={`${worktreeStyles.button} ${worktreeStyles.buttonPrimary} ${disabled ? worktreeStyles.buttonDisabled : ''}`}
+ disabled={disabled}
+ onClick={() => void checkout()}
+ >
+ {text('checkoutConfirm')}
+ </button>
+ </div>
+ </div>
+ )
+}
+
+function AbandonDialog(props: {
+ sessionId: string
+ worktreeKey: string
+ error: string
+ workspacesRuntime: Pick<WorkspacesRuntime, 'archiveSession'>
+ onCancel: () => void
+}): ReactElement {
+ const { sessionId, worktreeKey, workspacesRuntime, onCancel } = props
+ const abandon = async (): Promise<void> => {
+ const result = await applyDiscard(sessionId, worktreeKey)
+ if (!result.ok)
+ return
+ // 不显式打开源会话:官方 archiveSession 投影会清空当前选择,回到
+ // 「选择一个工作区开始」默认界面;显式 open 会触发工作区新建/复用 blank 会话。
+ await workspacesRuntime.archiveSession(sessionId)
+ }
+ return (
+ <div
+ className={worktreeStyles.card}
+ role="dialog"
+ aria-modal="true"
+ aria-label={text('abandonTitle')}
+ onClick={event => event.stopPropagation()}
+ >
+ <h2 className={worktreeStyles.title}>{text('abandonTitle')}</h2>
+ <p className={worktreeStyles.body}>{text('abandonBody')}</p>
+ {props.error && <div className={worktreeStyles.error}>{props.error}</div>}
+ <div className={worktreeStyles.footer}>
+ <button type="button" className={`${worktreeStyles.button} ${worktreeStyles.buttonGhost}`} onClick={onCancel}>{text('abandonCancel')}</button>
+ <button
+ type="button"
+ className={`${worktreeStyles.button} ${worktreeStyles.buttonDanger}`}
+ onClick={() => void abandon()}
+ >
+ {text('abandonConfirm')}
+ </button>
+ </div>
+ </div>
+ )
+}
+
+/**
+ * 注册:shell.overlay(list)新增一个条目,渲染检出/放弃弹窗。
+ * @param ctx - 客户端根上下文。
+ */
+export function registerDialog(ctx: Context): void {
+ const cx = compat(ctx as import('dsh-tauri/client').ClientContext)
+ // shell.overlay 由 ui-layout 的 AppFrame 声明;alpha 要求注册进入前该槽已由
+ // 父条目 children 表声明,故用 inject 等其声明 live 后再注册。
+ ctx.effect(
+ () =>
+ ctx.slots.inject(SHELL_OVERLAY_SLOT, () =>
+ ctx.slots.register(
+ {
+ name: SHELL_OVERLAY_SLOT,
+ id: DIALOG_ID,
+ registrant: WORKTREE_PLUGIN_NAME,
+ inject: () => ({
+ workspacesRuntime: cx.workspaces,
+ sessionsRuntime: cx.sessions,
+ }),
+ },
+ WorktreeDialog,
+ )),
+ DIALOG_EFFECT,
+ )
+}
diff --git a/packages/dsh-tauri-worktree/src/client/handoff.ts b/packages/dsh-tauri-worktree/src/client/handoff.ts
new file mode 100644
index 00000000..18d256d9
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/handoff.ts
@@ -0,0 +1,60 @@
+import type { WorktreeHydrationSessionsRuntime } from './types'
+import { SESSION_SWITCH_MAX_ATTEMPTS, SESSION_SWITCH_RETRY_DELAY_MS } from './constants'
+
+interface OpenWorktreeSessionOptions {
+ isActive?: () => boolean
+ maxAttempts?: number
+ retryDelayMs?: number
+}
+
+/**
+ * 等待新工作树会话在客户端列表中稳定后再打开,并确认 selection 已实际切换。
+ * Host 发布新会话、列表增量和 Session scope 可寻址并非同一时刻;只调用一次 open()
+ * 会把瞬时失败永久记为已切换,最终停在空白会话页,刷新后才由持久化状态恢复。
+ */
+export async function openWorktreeSession(
+ sessions: WorktreeHydrationSessionsRuntime,
+ sourceSessionId: string,
+ targetSessionId: string,
+ options: OpenWorktreeSessionOptions = {},
+): Promise<boolean> {
+ const isActive = options.isActive ?? (() => true)
+ const maxAttempts = options.maxAttempts ?? SESSION_SWITCH_MAX_ATTEMPTS
+ const retryDelayMs = options.retryDelayMs ?? SESSION_SWITCH_RETRY_DELAY_MS
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
+ if (!isActive())
+ return false
+ let snapshot = sessions.list.getSnapshot()
+ if (snapshot.current === targetSessionId)
+ return true
+
+ // 用户已主动切到其他会话时不能再抢回;pending 阶段 current 暂时为空则继续等待。
+ if (snapshot.current !== sourceSessionId && !(snapshot.current === undefined && snapshot.phase === 'pending'))
+ return false
+
+ if (!snapshot.ids.includes(targetSessionId)) {
+ await sessions.refresh().catch(() => {})
+ if (!isActive())
+ return false
+ snapshot = sessions.list.getSnapshot()
+ if (snapshot.current === targetSessionId)
+ return true
+ if (snapshot.current !== sourceSessionId && !(snapshot.current === undefined && snapshot.phase === 'pending'))
+ return false
+ }
+ if (snapshot.ids.includes(targetSessionId)) {
+ try {
+ sessions.open(targetSessionId)
+ }
+ catch {
+ await sessions.refresh().catch(() => {})
+ }
+ if (sessions.list.getSnapshot().current === targetSessionId)
+ return true
+ }
+
+ if (attempt + 1 < maxAttempts)
+ await new Promise(resolve => setTimeout(resolve, retryDelayMs))
+ }
+ return false
+}
diff --git a/packages/dsh-tauri-worktree/src/client/hydrate.ts b/packages/dsh-tauri-worktree/src/client/hydrate.ts
new file mode 100644
index 00000000..288675e5
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/hydrate.ts
@@ -0,0 +1,276 @@
+/**
+ * hydrate.ts — 从 Host ledger 恢复所有已知会话的工作树状态。
+ *
+ * Mode selector 只在 hero composer 出现,不能承担全局状态恢复;侧边栏图标、归组、
+ * 状态条和弹窗均依赖本 observer 在普通历史会话打开前完成 hydration。
+ *
+ * 启动/新建会话存在竞态(客户端列表先于宿主会话就绪):/status 失败或返回未知
+ * (isGit: null)时按固定间隔重试,直到拿到确定答案,保证「刷新才有」的工作树 UI 自愈。
+ *
+ * create_worktree 自动交接只允许发生在「本次运行期间新出现」的工作树会话首次复核时,
+ * 且每个来源只交接一次、有时效窗口——历史遗留工作树、用户事后回到源会话、点击新建
+ * 会话等场景绝不抢焦点(否则「新建会话」会被误跳到工作树会话)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import type { SessionListSnapshot, WorkspaceListSnapshot, WorktreeHydrationSessionsRuntime } from './types'
+import { HANDOFF_WINDOW_MS, HYDRATION_MAX_RETRIES, HYDRATION_RETRY_DELAY_MS } from './constants'
+import { openWorktreeSession } from './handoff'
+import { attachWorktreeSession, discardWorktree, fetchStatus, patchSession, selectSessionState, worktreeStore } from './store'
+
+export function installWorktreeHydration(ctx: ClientContext): () => void {
+ // HARDCODE: SessionRuntime.binding() is an internal DSH 0.1.1-rc.2 API.
+ // The public session-list source does not emit every tool-event mutation, so
+ // live checkout/discard reconciliation subscribes to the bound Session source.
+ const sessionsRuntime = ctx.sessions as unknown as WorktreeHydrationSessionsRuntime
+ const seen = new Set<string>()
+ const switching = new Map<string, string>()
+ const cleanedArchives = new Set<string>()
+ const inFlight = new Set<string>()
+ const queued = new Set<string>()
+ const retryAttempts = new Map<string, number>()
+ const retryTimers = new Set<ReturnType<typeof setTimeout>>()
+ // 插件安装时的会话基线:基线内的工作树会话是历史遗留,绝不自动交接。
+ let baselineCaptured = false
+ const baselineIds = new Set<string>()
+ // 会话首次出现在列表的时间(用于限定交接时效窗口)。
+ const appearedAt = new Map<string, number>()
+ // 已建立过 worktree 状态的会话:自动交接只允许发生在「第一次」复核成功时,
+ // 事件流/重试触发的后续复核只负责 checkout/discard 状态对齐,不再抢焦点。
+ const worktreeReconciled = new Set<string>()
+ // 已完成自动交接的来源会话:一次交接后永久不再抢(区别于 switching 的在途标记)。
+ const handedOff = new Set<string>()
+ let disposed = false
+
+ /**
+ * 捕获插件安装基线:等第一个非空列表快照(应用启动时列表 RPC 可能尚未返回,
+ * 空快照不能当基线,否则启动期已存在的工作树会话会被误判为「新出现」)。
+ */
+ const noteListBaseline = (): void => {
+ if (baselineCaptured)
+ return
+ const snapshot = ctx.sessions.list.getSnapshot() as SessionListSnapshot
+ if (snapshot.ids.length === 0)
+ return
+ baselineCaptured = true
+ for (const sessionId of snapshot.ids)
+ baselineIds.add(sessionId)
+ }
+
+ /** 记录会话首次出现在列表的时间(交接时效窗口的起点)。 */
+ const noteAppearances = (): void => {
+ const snapshot = ctx.sessions.list.getSnapshot() as SessionListSnapshot
+ const now = Date.now()
+ for (const sessionId of snapshot.ids) {
+ if (!appearedAt.has(sessionId))
+ appearedAt.set(sessionId, now)
+ }
+ }
+
+ /**
+ * 请求失败或宿主返回「未知」(isGit: null,会话尚未就绪)时按固定间隔重试。
+ * 启动/新建会话存在竞态:客户端列表已出现会话而宿主尚无 header.cwd,一次失败后
+ * 若只等列表事件,可能永远不再触发(列表已稳定),工作树 UI 就停留在「刷新才有」。
+ * 达到上限后停止定时重试,但失败/未知都会从 seen 移除,后续列表事件仍可再次拉起。
+ */
+ function scheduleRetry(sessionId: string): void {
+ if (disposed)
+ return
+ const attempts = retryAttempts.get(sessionId) ?? 0
+ if (attempts >= HYDRATION_MAX_RETRIES) {
+ retryAttempts.delete(sessionId)
+ return
+ }
+ retryAttempts.set(sessionId, attempts + 1)
+ const timer = setTimeout(() => {
+ retryTimers.delete(timer)
+ if (disposed)
+ return
+ reconcileSession(sessionId, true)
+ }, HYDRATION_RETRY_DELAY_MS)
+ retryTimers.add(timer)
+ }
+
+ function reconcileSession(sessionId: string, force = false): void {
+ if (inFlight.has(sessionId)) {
+ if (force)
+ queued.add(sessionId)
+ return
+ }
+ const previous = selectSessionState(worktreeStore.getSnapshot(), sessionId)
+ // 普通 hydration 每个会话只做一次;已绑定会话则在其事件流变化时强制复核,
+ // 以便 Agent 调用 checkout_worktree / discard_worktree 后无刷新切回本地状态。
+ if (!force && seen.has(sessionId))
+ return
+ seen.add(sessionId)
+ inFlight.add(sessionId)
+ void fetchStatus(sessionId)
+ .then((status) => {
+ if (disposed)
+ return
+ if (status.mode === 'worktree') {
+ patchSession(sessionId, {
+ mode: 'worktree',
+ phase: 'created',
+ isGit: status.isGit !== false,
+ worktreeKey: status.worktreeKey ?? '',
+ worktreePath: status.worktreePath ?? '',
+ projectPath: status.projectPath ?? '',
+ sourceSessionId: status.sourceSessionId ?? '',
+ log: status.log ?? [],
+ })
+ retryAttempts.delete(sessionId)
+ // 自愈旧 ledger 会话:Desktop workspace 补丁允许显式归属到源 Workspace。
+ if (status.sourceSessionId)
+ void attachWorktreeSession(sessionId).catch(() => {})
+ // create_worktree 工具在 Host 先发布继承上下文的新根会话;它进入列表后,
+ // 客户端把当前源会话视觉交接到该工作树会话(不启动额外模型 turn)。
+ // 触发必须同时满足:首次复核成功、会话是本次运行期间新出现(基线外且未过
+ // 时效窗口)、当前仍在源会话、且该来源尚未交接过——否则会在「查看源会话」或
+ // 「新建会话」流程中误抢焦点(跳到工作树会话,导致无法新建会话)。
+ if (!worktreeReconciled.has(sessionId)) {
+ worktreeReconciled.add(sessionId)
+ const currentId = sessionsRuntime.list.getSnapshot().current
+ const sourceSessionId = status.sourceSessionId
+ const appeared = appearedAt.get(sessionId)
+ const fresh = !baselineIds.has(sessionId)
+ && appeared !== undefined
+ && Date.now() - appeared <= HANDOFF_WINDOW_MS
+ if (sourceSessionId && fresh && currentId === sourceSessionId
+ && !handedOff.has(sourceSessionId) && !switching.has(sourceSessionId)) {
+ handedOff.add(sourceSessionId)
+ switching.set(sourceSessionId, sessionId)
+ void openWorktreeSession(sessionsRuntime, sourceSessionId, sessionId, {
+ isActive: () => !disposed,
+ })
+ .finally(() => {
+ if (switching.get(sourceSessionId) === sessionId)
+ switching.delete(sourceSessionId)
+ })
+ }
+ }
+ return
+ }
+ // 未知状态(宿主尚无该会话的 cwd,新建/启动竞态):不写入任何状态——保持
+ // 默认 git 假设与用户已选模式(选择器可见),固定间隔重试直到拿到确定答案。
+ if (status.isGit === null) {
+ seen.delete(sessionId)
+ scheduleRetry(sessionId)
+ return
+ }
+ retryAttempts.delete(sessionId)
+ const isGit = status.isGit !== false
+ // 非 git 目录:永远只能是本地模式,且隐藏工作树模式选择器(select 据此渲染)。
+ if (!isGit) {
+ patchSession(sessionId, {
+ mode: 'local',
+ phase: 'idle',
+ isGit: false,
+ loadingLabel: '',
+ log: [],
+ worktreeKey: '',
+ worktreePath: '',
+ projectPath: status.projectPath ?? previous.projectPath,
+ sourceSessionId: '',
+ checkoutOpen: false,
+ abandonOpen: false,
+ error: '',
+ })
+ return
+ }
+ if (previous.mode === 'worktree') {
+ patchSession(sessionId, {
+ mode: 'local',
+ phase: 'idle',
+ isGit: true,
+ loadingLabel: '',
+ log: [],
+ worktreeKey: '',
+ worktreePath: '',
+ projectPath: status.projectPath ?? previous.projectPath,
+ sourceSessionId: '',
+ checkoutOpen: false,
+ abandonOpen: false,
+ error: '',
+ })
+ }
+ else {
+ patchSession(sessionId, { isGit: true })
+ }
+ })
+ .catch(() => {
+ // 状态接口失败(宿主路由尚未就绪、会话瞬时不可寻址等)不应影响普通会话;
+ // 从 seen 移除并退避重试,使启动/新建竞态在无刷新下自愈。
+ seen.delete(sessionId)
+ scheduleRetry(sessionId)
+ })
+ .finally(() => {
+ inFlight.delete(sessionId)
+ if (queued.delete(sessionId) && !disposed)
+ reconcileSession(sessionId, true)
+ })
+ }
+
+ const hydrate = (): void => {
+ const snapshot = ctx.sessions.list.getSnapshot() as SessionListSnapshot
+ for (const sessionId of snapshot.ids) reconcileSession(sessionId)
+ }
+
+ // 原生侧栏「归档」只隐藏会话。若该会话绑定工作树,归档集合变化后补做
+ // worktree/owned branch/ledger 清理;会话日志仍由 DSH 归档持久化保留。
+ const cleanupArchivedWorktrees = (): void => {
+ const snapshot = ctx.workspaces.list.getSnapshot() as WorkspaceListSnapshot
+ for (const sessionId of snapshot.archivedSessionIds) {
+ if (cleanedArchives.has(sessionId))
+ continue
+ cleanedArchives.add(sessionId)
+ void fetchStatus(sessionId)
+ .then((status) => {
+ if (disposed || status.mode !== 'worktree')
+ return
+ return discardWorktree(sessionId, status.worktreeKey ?? '')
+ })
+ .catch(() => {
+ // 网络/Host 暂不可用时允许下次快照重试。
+ cleanedArchives.delete(sessionId)
+ })
+ }
+ }
+
+ const sessionSubscriptions = new Map<string, () => void>()
+ const bindSessionEvents = (): void => {
+ const snapshot = ctx.sessions.list.getSnapshot() as SessionListSnapshot
+ for (const sessionId of snapshot.ids) {
+ if (sessionSubscriptions.has(sessionId))
+ continue
+ const session = sessionsRuntime.binding(sessionId)?.session
+ if (!session?.subscribe)
+ continue
+ sessionSubscriptions.set(sessionId, session.subscribe(() => {
+ const state = selectSessionState(worktreeStore.getSnapshot(), sessionId)
+ if (state.mode === 'worktree')
+ reconcileSession(sessionId, true)
+ }))
+ }
+ }
+ const unsubscribeSessions = ctx.sessions.list.subscribe(() => {
+ noteListBaseline()
+ noteAppearances()
+ hydrate()
+ bindSessionEvents()
+ })
+ const unsubscribeWorkspaces = ctx.workspaces.list.subscribe(cleanupArchivedWorktrees)
+ noteListBaseline()
+ noteAppearances()
+ hydrate()
+ bindSessionEvents()
+ cleanupArchivedWorktrees()
+ return () => {
+ disposed = true
+ unsubscribeSessions()
+ unsubscribeWorkspaces()
+ for (const unsubscribe of sessionSubscriptions.values()) unsubscribe()
+ for (const timer of retryTimers) clearTimeout(timer)
+ retryTimers.clear()
+ retryAttempts.clear()
+ }
+}
diff --git a/packages/dsh-tauri-worktree/src/client/icons.tsx b/packages/dsh-tauri-worktree/src/client/icons.tsx
new file mode 100644
index 00000000..138b564c
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/icons.tsx
@@ -0,0 +1,21 @@
+/**
+ * Gravity UI Icons `circle-tree.svg`.
+ * Source: https://github.com/gravity-ui/icons/blob/main/svgs/circle-tree.svg
+ * License: MIT, © 2022 YANDEX LLC (see NOTICE).
+ */
+import type { ReactElement } from 'react'
+
+const CIRCLE_TREE_PATH = 'M2.327.504A.75.75 0 0 1 3 1.25V2a1.5 1.5 0 0 0 1.5 1.5h2.588A3.25 3.25 0 0 1 10.25 1l.167.004A3.25 3.25 0 0 1 13.5 4.25l-.004.167A3.25 3.25 0 0 1 10.25 7.5l-.167-.004A3.25 3.25 0 0 1 7.088 5H4.5c-.547 0-1.058-.15-1.5-.405V10a1.5 1.5 0 0 0 1.5 1.5h2.588a3.25 3.25 0 1 1 0 1.5H4.5a3 3 0 0 1-3-3V1.25A.75.75 0 0 1 2.25.5zM10.25 10.5a1.75 1.75 0 1 0 0 3.5 1.75 1.75 0 0 0 0-3.5m0-8a1.75 1.75 0 1 0 0 3.5 1.75 1.75 0 0 0 0-3.5'
+
+export function CircleTreeIcon({ size = 16 }: { size?: number }): ReactElement {
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} fill="none" viewBox="0 0 16 16" aria-hidden="true">
+ <path fill="currentColor" fillRule="evenodd" d={CIRCLE_TREE_PATH} clipRule="evenodd" />
+ </svg>
+ )
+}
+
+/** Returns the same icon for DOM insertion outside the React render tree. */
+export function circleTreeSvg(size: number): string {
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="none" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="${CIRCLE_TREE_PATH}" clip-rule="evenodd"/></svg>`
+}
diff --git a/packages/dsh-tauri-worktree/src/client/index.ts b/packages/dsh-tauri-worktree/src/client/index.ts
new file mode 100644
index 00000000..5cc56a09
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/index.ts
@@ -0,0 +1,59 @@
+/**
+ * dsh-tauri-worktree 客户端插件体(browser half):会话级 Git Worktree 隔离的 UI。
+ *
+ * 四项 UI(全部 slot-shadow / DOM 补丁,零结构补丁,零新增运行时依赖):
+ * - select.tsx 注册进 conversation.input.right:模式选择下拉框(本地/工作树)
+ * 及内联的会话处理状态与创建日志(三阶段)。
+ * - surface.tsx 注册进 shell.overlay:工作树模式的常驻顶部提示条
+ * [ 该会话正在工作树进行 ] --- [ 检出本地 ] [ 放弃 ]。
+ * - dialog.tsx 注册进 shell.overlay:检出本地/放弃更改两个模态框。
+ * - session.ts DOM 补丁:侧边栏会话行时间标识左侧的 Git 分支图标。
+ *
+ * 与 node half(src/index.ts)经 /api/dsh-worktree/* 通信(create/status/checkout/discard)。
+ */
+import type { ClientContext } from 'dsh-tauri/client'
+import { compat } from 'dsh-tauri/client'
+import {
+ HYDRATION_EFFECT,
+ SESSION_ICONS_EFFECT,
+ STYLES_EFFECT,
+ WORKTREE_PLUGIN_NAME,
+} from './constants'
+import { registerDialog } from './dialog'
+import { installWorktreeHydration } from './hydrate'
+import { installLocale } from './locale'
+import { mountModeSelectStyles, registerModeSelect } from './select'
+import { installSessionIcons } from './session'
+import { mountWorktreeStyles } from './styles'
+import { registerSurface } from './surface'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = WORKTREE_PLUGIN_NAME
+
+/** 需要的客户端服务:slots(注册点位)、layout(面板)、locale(双语)、sessions(会话行匹配)。 */
+export const inject = ['slots', 'layout', 'locale', 'sessions', 'workspaces']
+
+/**
+ * 插件体:安装文案并注册四项 UI。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ const cx = compat(ctx)
+ installLocale(cx)
+ ctx.effect(
+ () => {
+ const unmountModeSelectStyles = mountModeSelectStyles()
+ const unmountWorktreeStyles = mountWorktreeStyles()
+ return () => {
+ unmountModeSelectStyles()
+ unmountWorktreeStyles()
+ }
+ },
+ STYLES_EFFECT,
+ )
+ registerModeSelect(cx)
+ registerSurface(cx)
+ registerDialog(cx)
+ ctx.effect(() => installWorktreeHydration(cx), HYDRATION_EFFECT)
+ ctx.effect(() => installSessionIcons(), SESSION_ICONS_EFFECT)
+}
diff --git a/packages/dsh-tauri-worktree/src/client/locale.ts b/packages/dsh-tauri-worktree/src/client/locale.ts
new file mode 100644
index 00000000..a92f244a
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/locale.ts
@@ -0,0 +1,110 @@
+/**
+ * locale.ts — 本插件自有的界面文案(模式选择 / Surface 提示 / 检出 / 放弃 / 处理状态)。
+ *
+ * 用 locale 服务的**非类型化**注册面(register(ns, locale, dict))挂进 dsh 的 locale
+ * 表:zh/en 双语齐全即满足运行时“bilingual balance”约束,无需增广 LocaleNamespaceMap。
+ * 组件侧不引入框架 `t` 座,改用一个极薄的 uSES 桥:apply 时订阅 locale 变更推进 rev,
+ * 组件订阅 rev 重渲染,文案按当前 active locale 从本地字典读取。
+ */
+import type { Context } from '@deepseek-ai/cordis'
+import type { LocaleKey } from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+import { useSyncExternalStore } from 'react'
+import { WORKTREE_LOCALE_NAMESPACE as NS } from './constants'
+
+export { WORKTREE_LOCALE_NAMESPACE as NS } from './constants'
+export type { LocaleKey } from './types'
+
+/** zh 字典(键集合的权威)。 */
+const DICT_ZH = {
+ modeLabel: '工作模式',
+ modeLocal: '本地',
+ modeWorktree: '工作树',
+ modeNewWorktree: '新建工作树',
+ modeWorktreeDesc: '发送下一条消息时新建隔离 Git 工作树',
+ modeLocalDesc: '在当前本地工作区处理',
+ surfaceWorktree: '该会话正在工作树进行',
+ surfaceCheckout: '检出本地',
+ surfaceAbandon: '放弃',
+ checkoutTitle: '将更改带回本地检出并继续',
+ checkoutBranchLabel: '本地检出分支名',
+ checkoutCurrentPath: '关联路径',
+ checkoutTargetPath: '项目路径',
+ checkoutConfirm: '确认检出',
+ checkoutCancel: '取消',
+ abandonTitle: '放弃工作树更改',
+ abandonBody: '确认放弃吗?这将归档当前会话及删除对应的临时工作树。',
+ abandonConfirm: '确认放弃',
+ abandonCancel: '取消',
+ progressCreating: '正在准备工作树',
+ progressCheckingOut: '正在检出文件',
+ progressCreated: '已创建工作树',
+ progressViewLogs: '日志',
+ progressThinking: '正在思考…',
+ progressError: '工作树处理失败',
+ branchPlaceholder: 'dsh/feature-xyz',
+ logEmpty: '暂无创建日志',
+ sessionWorkingTreeBadge: '工作树',
+} as const satisfies Record<LocaleKey, string>
+
+/** en 字典,与 zh 键集完全一致(locale 运行时强制双语平衡)。 */
+const DICT_EN: Record<LocaleKey, string> = {
+ modeLabel: 'Mode',
+ modeLocal: 'Local',
+ modeWorktree: 'Worktree',
+ modeNewWorktree: 'New worktree',
+ modeWorktreeDesc: 'Create an isolated Git worktree when the next message is sent',
+ modeLocalDesc: 'Process in the current local workspace',
+ surfaceWorktree: 'This session is running in a worktree',
+ surfaceCheckout: 'Checkout local',
+ surfaceAbandon: 'Abandon',
+ checkoutTitle: 'Bring changes back to local and continue',
+ checkoutBranchLabel: 'Local checkout branch name',
+ checkoutCurrentPath: 'Current path',
+ checkoutTargetPath: 'Target project path',
+ checkoutConfirm: 'Confirm checkout & merge',
+ checkoutCancel: 'Cancel',
+ abandonTitle: 'Abandon worktree changes',
+ abandonBody: 'Are you sure? This will archive this session and delete its temporary worktree.',
+ abandonConfirm: 'Confirm abandon',
+ abandonCancel: 'Cancel',
+ progressCreating: 'Preparing workspace',
+ progressCheckingOut: 'Checking out files',
+ progressCreated: 'Workspace created',
+ progressViewLogs: 'Logs',
+ progressThinking: 'Thinking…',
+ progressError: 'Worktree processing failed',
+ branchPlaceholder: 'dsh/feature-xyz',
+ logEmpty: 'No creation log yet',
+ sessionWorkingTreeBadge: 'Worktree',
+}
+
+/** 活跃语言 id(module 级缓存,apply 时初始化并由订阅推进)。 */
+let activeLocale = 'en'
+
+/** locale 变更推进器:revision 前进 -> uSES 订阅方重渲染。 */
+export const localeRev = createExternalStore({ rev: 0 })
+
+/**
+ * 在 apply 里安装:注册本插件的双语字典,并桥接 locale 变更到 rev。
+ * @param ctx - 客户端根上下文(须已注入 locale 服务)。
+ */
+export function installLocale(ctx: Context): void {
+ activeLocale = ctx.locale.getLocale().active
+ ctx.locale.register(NS, 'zh', DICT_ZH)
+ ctx.locale.register(NS, 'en', DICT_EN)
+ ctx.locale.subscribe(() => {
+ activeLocale = ctx.locale.getLocale().active
+ localeRev.set(state => ({ ...state, rev: state.rev + 1 }))
+ })
+}
+
+/** 按当前活跃语言取一条文案。 */
+export function text(key: LocaleKey): string {
+ return activeLocale === 'en' ? DICT_EN[key] : DICT_ZH[key]
+}
+
+/** 组件内订阅 locale 变更(revision 前进即重渲染)。 */
+export function useLocale(): void {
+ useSyncExternalStore(localeRev.subscribe, () => localeRev.getSnapshot().rev)
+}
diff --git a/packages/dsh-tauri-worktree/src/client/select.tsx b/packages/dsh-tauri-worktree/src/client/select.tsx
new file mode 100644
index 00000000..57a82a7e
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/select.tsx
@@ -0,0 +1,302 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { InputActions, ModeSelectProps, SessionsRuntime } from './types'
+import { IconChevronDownOutline14, Menu } from '@deepseek-ai/dsh-client-ui-primitives'
+import { compat, CssRender } from 'dsh-tauri/client'
+
+/**
+ * select.tsx — 「标准模式」右侧的会话工作模式选择器。
+ *
+ * 选择「新建工作树」只为下一条消息设为待创建;提交时先创建 worktree 和绑定该 cwd
+ * 的新会话,再迁移草稿并调用官方 inputActions.submit()。
+ */
+import { useEffect, useRef, useState } from 'react'
+import { createPortal } from 'react-dom'
+import {
+ COMPOSER_MODE_BUTTON_SELECTOR,
+ COMPOSER_SEAT_SELECTOR,
+ HERO_PRESET_SLOT_SELECTOR,
+ INPUT_DOCK_SLOT,
+ MODE_ANCHOR_ATTRIBUTE,
+ MODE_SELECT_CLASSES,
+ MODE_SELECT_ID,
+ MODE_SELECT_ORDER,
+ MODE_SELECT_STYLE_ID,
+} from './constants'
+import { CircleTreeIcon } from './icons'
+import { NS, text, useLocale } from './locale'
+import {
+ attachWorktreeSession,
+ createWorktree,
+ patchSession,
+ rememberNewSessionMode,
+ useWorktreeSession,
+} from './store'
+
+export function mountModeSelectStyles(): () => void {
+ const cssr = CssRender()
+ if (cssr.find(MODE_SELECT_STYLE_ID) !== null)
+ return () => {}
+ const { c } = cssr
+ const style = c([
+ c(`.${MODE_SELECT_CLASSES.trigger}`, {
+ boxSizing: 'border-box',
+ maxWidth: '240px',
+ minHeight: '28px',
+ padding: '0 8px',
+ border: 'none',
+ borderRadius: '16px',
+ background: 'transparent',
+ color: 'var(--dsw-alias-label-primary)',
+ fontFamily: 'var(--dsw-font-family, inherit)',
+ fontSize: '13px',
+ fontWeight: 500,
+ lineHeight: '20px',
+ cursor: 'pointer',
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: '4px',
+ whiteSpace: 'nowrap',
+ }, [c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' })]),
+ c(`.${MODE_SELECT_CLASSES.triggerOpen}`, { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ c(`.${MODE_SELECT_CLASSES.icon}`, { color: 'var(--dsw-alias-label-primary)', display: 'inline-flex', flex: 'none' }),
+ c(`.${MODE_SELECT_CLASSES.chevron}`, { color: 'var(--dsw-alias-label-caption)', flex: 'none' }),
+ c(`.${MODE_SELECT_CLASSES.host}`, { display: 'inline-flex', alignItems: 'center' }),
+ c(`.${MODE_SELECT_CLASSES.anchor}`, { display: 'none' }),
+ ])
+ style.mount({ id: MODE_SELECT_STYLE_ID, head: true })
+ return () => style.unmount({ id: MODE_SELECT_STYLE_ID })
+}
+
+export function WorktreeModeSelect(props: ModeSelectProps): ReactElement {
+ const { sessionId } = props
+ const anchorRef = useRef<HTMLSpanElement>(null)
+ const [portalHost, setPortalHost] = useState<HTMLSpanElement | null>(null)
+
+ useEffect(() => {
+ const anchor = anchorRef.current
+ // HARDCODE: DSH 0.1.1-rc.2 has no slot beside AgentPresetSeat, so this relies
+ // on the shell's private composer marker and hero preset slot DOM placement.
+ const composerSeat = anchor?.closest<HTMLElement>(COMPOSER_SEAT_SELECTOR)
+ if (!composerSeat)
+ return
+
+ let host: HTMLSpanElement | null = null
+ const place = (): void => {
+ // rc.2 exposes the hero preset slot; alpha removed it but keeps the
+ // stable composer mode button. Prefer the old anchor and fall back to
+ // the button without depending on generated CSS module hashes.
+ const presetSlot = composerSeat.querySelector<HTMLElement>(HERO_PRESET_SLOT_SELECTOR)
+ const modeButton = composerSeat.querySelector<HTMLElement>(COMPOSER_MODE_BUTTON_SELECTOR)
+ const target = presetSlot ?? modeButton
+ if (!target) {
+ setPortalHost(null)
+ host?.remove()
+ host = null
+ return
+ }
+ if (!host) {
+ host = document.createElement('span')
+ host.dataset.dshTauriWorktreeMode = sessionId
+ host.className = MODE_SELECT_CLASSES.host
+ }
+ if (target.nextElementSibling !== host)
+ target.after(host)
+ setPortalHost(host)
+ }
+
+ place()
+ const observer = new MutationObserver(place)
+ observer.observe(composerSeat, { childList: true, subtree: true })
+ return () => {
+ observer.disconnect()
+ host?.remove()
+ }
+ }, [sessionId])
+
+ return (
+ <>
+ <span ref={anchorRef} className={MODE_SELECT_CLASSES.anchor} {...{ [MODE_ANCHOR_ATTRIBUTE]: sessionId }} />
+ {portalHost && createPortal(<WorktreeModeControl {...props} />, portalHost)}
+ </>
+ )
+}
+
+async function waitForInputActions(sessionsRuntime: SessionsRuntime, sessionId: string): Promise<InputActions> {
+ for (let attempt = 0; attempt < 30; attempt++) {
+ const actions = sessionsRuntime.provideInfo(sessionId)?.props?.inputActions
+ if (actions)
+ return actions
+ await new Promise<void>(resolve => window.setTimeout(resolve, 100))
+ }
+ throw new Error('新工作树会话的输入服务尚未就绪')
+}
+
+function WorktreeModeControl({ sessionId, useInput, inputActions, sessionsRuntime }: ModeSelectProps): ReactElement | null {
+ const state = useWorktreeSession(sessionId)
+ const draft = useInput(input => input.draft)
+ const imageIds = useInput(input => input.imageIds)
+ useLocale()
+ const [open, setOpen] = useState(false)
+ const submittingRef = useRef(false)
+
+ useEffect(() => {
+ if (state.mode !== 'pending')
+ return
+ // HARDCODE: capture submission from the private composer DOM because the
+ // current client API exposes inputActions.submit(), but no pre-submit hook.
+ const root = document.querySelector<HTMLElement>(`[${MODE_ANCHOR_ATTRIBUTE}="${CSS.escape(sessionId)}"]`)
+ const composerSeat = root?.closest<HTMLElement>(COMPOSER_SEAT_SELECTOR)
+ if (!composerSeat)
+ return
+
+ const start = async (): Promise<void> => {
+ if (submittingRef.current || draft.trim() === '')
+ return
+ submittingRef.current = true
+ const targetSessionId = `session-${crypto.randomUUID()}`
+ patchSession(sessionId, { mode: 'pending', phase: 'creating', loadingLabel: text('progressCreating'), error: '' })
+ try {
+ const created = await createWorktree(targetSessionId, sessionId)
+ patchSession(targetSessionId, {
+ mode: 'worktree',
+ phase: 'created',
+ loadingLabel: text('progressCreated'),
+ log: created.log,
+ worktreeKey: created.worktreeKey,
+ worktreePath: created.worktreePath,
+ projectPath: created.projectPath,
+ sourceSessionId: created.sourceSessionId,
+ })
+ await sessionsRuntime.create({ cwd: created.worktreePath, sessionId: targetSessionId })
+ await attachWorktreeSession(targetSessionId)
+ const nextActions = await waitForInputActions(sessionsRuntime, targetSessionId)
+ nextActions.setDraft(draft)
+ if (imageIds.length > 0 && !nextActions.addImages(imageIds))
+ throw new Error('无法迁移消息附件到工作树会话')
+ inputActions.setDraft('')
+ for (const imageId of imageIds) inputActions.removeImage(imageId)
+ patchSession(sessionId, { mode: 'local', phase: 'idle', loadingLabel: '' })
+ sessionsRuntime.open(targetSessionId)
+ // 迁移草稿后提交到新工作树会话;submit() 会在进入时同步捕获草稿/附件快照再发送。
+ // 无论提交结果如何,创建了工作树就必须清空输入框内容(含附件),避免内容仍残留进后续新会话。
+ queueMicrotask(() => {
+ try {
+ nextActions.submit()
+ }
+ finally {
+ nextActions.setDraft('')
+ for (const imageId of imageIds) nextActions.removeImage(imageId)
+ }
+ })
+ }
+ catch (error) {
+ patchSession(sessionId, {
+ mode: 'pending',
+ phase: 'error',
+ loadingLabel: '',
+ error: error instanceof Error ? error.message : String(error),
+ })
+ }
+ finally {
+ submittingRef.current = false
+ }
+ }
+
+ const intercept = (event: Event): void => {
+ const target = event.target
+ if (!(target instanceof Node) || !composerSeat.contains(target))
+ return
+ if (event instanceof MouseEvent) {
+ const button = target instanceof Element ? target.closest('button[aria-label]') : null
+ if (button?.getAttribute('aria-label')?.includes('发送') !== true && button?.getAttribute('aria-label')?.toLowerCase().includes('send') !== true)
+ return
+ }
+ if (event instanceof KeyboardEvent && (event.key !== 'Enter' || event.shiftKey || event.isComposing))
+ return
+ event.preventDefault()
+ event.stopImmediatePropagation()
+ void start()
+ }
+
+ composerSeat.addEventListener('click', intercept, true)
+ composerSeat.addEventListener('keydown', intercept, true)
+ return () => {
+ composerSeat.removeEventListener('click', intercept, true)
+ composerSeat.removeEventListener('keydown', intercept, true)
+ }
+ }, [draft, imageIds, inputActions, sessionId, sessionsRuntime, state.mode])
+
+ // 非 git 目录不提供工作树:隐藏整个模式选择器,会话永远只能停留在本地模式。
+ if (state.isGit === false)
+ return null
+
+ const pending = state.mode === 'pending'
+ const bound = state.mode === 'worktree'
+ const activeLabel = bound ? text('modeWorktree') : pending ? text('modeNewWorktree') : text('modeLocal')
+ const trigger = (
+ <button
+ type="button"
+ aria-label={text('modeLabel')}
+ aria-haspopup="menu"
+ aria-expanded={open}
+ onClick={() => setOpen(value => !value)}
+ className={open ? `${MODE_SELECT_CLASSES.trigger} ${MODE_SELECT_CLASSES.triggerOpen}` : MODE_SELECT_CLASSES.trigger}
+ >
+ <span className={MODE_SELECT_CLASSES.icon}>
+ <CircleTreeIcon size={13} />
+ </span>
+ <span>{activeLabel}</span>
+ <IconChevronDownOutline14 className={MODE_SELECT_CLASSES.chevron} />
+ </button>
+ )
+
+ return (
+ <Menu
+ open={open}
+ onClose={() => setOpen(false)}
+ items={bound
+ ? [{ id: 'worktree', label: text('modeWorktree') }]
+ : [
+ { id: 'local', label: text('modeLocal') },
+ { id: 'pending', label: text('modeWorktree') },
+ ]}
+ selectedId={bound ? 'worktree' : pending ? 'pending' : 'local'}
+ onSelect={(id) => {
+ setOpen(false)
+ if (bound)
+ return
+ const mode = id === 'pending' ? 'pending' : 'local'
+ rememberNewSessionMode(mode)
+ patchSession(sessionId, {
+ mode,
+ phase: 'idle',
+ loadingLabel: '',
+ error: '',
+ })
+ }}
+ side="bottom"
+ align="start"
+ portal
+ anchor={trigger}
+ />
+ )
+}
+
+/** 使用 input.dock 的 session 生命周期,并把控件 portal 到标准模式右侧。 */
+export function registerModeSelect(ctx: Context): void {
+ const cx = compat(ctx as import('dsh-tauri/client').ClientContext)
+ ctx.slots.inject(INPUT_DOCK_SLOT as never, () =>
+ ctx.slots.register(
+ {
+ name: INPUT_DOCK_SLOT,
+ id: MODE_SELECT_ID,
+ order: MODE_SELECT_ORDER,
+ locale: NS,
+ inject: (sessionId: string | undefined) => sessionId === undefined
+ ? undefined
+ : { sessionId, sessionsRuntime: cx.sessions as unknown as SessionsRuntime },
+ } as never,
+ WorktreeModeSelect,
+ ))
+}
diff --git a/packages/dsh-tauri-worktree/src/client/session.ts b/packages/dsh-tauri-worktree/src/client/session.ts
new file mode 100644
index 00000000..2e506c52
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/session.ts
@@ -0,0 +1,157 @@
+/**
+ * session.ts — 会话列表里给绑定工作树的会话行加 Git 分支图标(DOM 补丁)。
+ *
+ * 背景:会话行由官方 WorkspaceBrowser(sidebar.workspaces 单槽)内部渲染,
+ * **没有** per-row 注入槽。因此采用「零结构补丁」:注入一条 CSS + MutationObserver,
+ * 按语义结构([role=treeitem])而非生成的哈希类名(.YDXeBa_*)定位行,在行内
+ * 「时间标识」左侧插入一个 Git 分支图标的 span。已完成「检出本地」的会话因
+ * store 里 mode 回到 local,图标被移除。
+ *
+ * 注意:行没有 data-session-id 属性,使用 React `SessionNodeItem` Fiber key 读取精确
+ * session id(只读,不移动 React 管理的节点),再读 store 判断是否处于工作树模式。
+ */
+import type { WorkspaceSessionOrder } from './types'
+import { CssRender } from 'dsh-tauri/client'
+import {
+ SESSION_ICON_ATTRIBUTE,
+ SESSION_ICON_STYLE_ID,
+ SIDEBAR_SELECTOR,
+} from './constants'
+import { circleTreeSvg } from './icons'
+import { worktreeStore } from './store'
+
+export type { WorkspaceSessionOrder } from './types'
+
+/**
+ * 安装会话行分支图标(CSS + DOM 观察器)。返回卸载函数。
+ * @returns 卸载函数。
+ */
+export function installSessionIcons(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ const cssr = CssRender()
+ if (cssr.find(SESSION_ICON_STYLE_ID) !== null)
+ return () => {}
+ const { c } = cssr
+ const iconStyle = c([
+ c(`[${SESSION_ICON_ATTRIBUTE}]`, {
+ width: '16px',
+ height: '20px',
+ flex: 'none',
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ marginLeft: '2px',
+ color: 'var(--dsw-alias-label-secondary)',
+ }),
+ c('[role="treeitem"]', { position: 'relative' }),
+ ])
+ iconStyle.mount({ id: SESSION_ICON_STYLE_ID, head: true })
+
+ /**
+ * HARDCODE: DSH 0.1.1-rc.2 does not expose a per-session-row slot or data id,
+ * so read the private React Fiber key to avoid locale/title-based matching.
+ */
+ function reactKey(element: Element, prefix: 'session-' | ''): string | undefined {
+ const fiberName = Object.keys(element).find(key => key.startsWith('__reactFiber$'))
+ let fiber = fiberName ? (element as unknown as Record<string, any>)[fiberName] : undefined
+ for (let depth = 0; fiber && depth < 10; depth++, fiber = fiber.return) {
+ if (typeof fiber.key === 'string' && fiber.key.startsWith(prefix))
+ return fiber.key
+ }
+ }
+
+ function sessionRows(): Map<string, Element> {
+ const rows = new Map<string, Element>()
+ for (const row of document.querySelectorAll<Element>('[role="treeitem"][aria-selected]')) {
+ const id = reactKey(row, 'session-')
+ if (id)
+ rows.set(id, row)
+ }
+ return rows
+ }
+
+ // HARDCODE: DSH 0.1.1-rc.2 SessionNodeItem children are status, title,
+ // time, rowActions. Anchor on rowActions instead of locale-dependent text;
+ // blank rows have no time, so never fall back to inserting before the title.
+ function applyIcon(row: Element): void {
+ if (row.querySelector(`[${SESSION_ICON_ATTRIBUTE}]`))
+ return
+ const actions = row.lastElementChild
+ const time = actions?.previousElementSibling
+ if (!actions?.querySelector('button') || !time || time.querySelector('button'))
+ return
+
+ const icon = document.createElement('span')
+ icon.setAttribute(SESSION_ICON_ATTRIBUTE, '1')
+ icon.style.marginRight = '5px'
+ icon.innerHTML = circleTreeSvg(12)
+ row.insertBefore(icon, time)
+ }
+
+ // 全量扫描:只绘制/清除图标,不移动 React 管理的 DOM。
+ function scan(): void {
+ const rows = sessionRows()
+ const states = worktreeStore.getSnapshot().bySession
+ for (const [sessionId, row] of rows) {
+ const icon = row.querySelector<HTMLElement>(`[${SESSION_ICON_ATTRIBUTE}]`)
+ if (states[sessionId]?.mode === 'worktree') {
+ if (!icon)
+ applyIcon(row)
+ }
+ else {
+ icon?.remove()
+ }
+ }
+ }
+
+ const ro = new MutationObserver(scan)
+ function attach(): boolean {
+ const target = document.querySelector<HTMLElement>(SIDEBAR_SELECTOR) ?? document.body
+ ro.observe(target, { childList: true, subtree: true })
+ scan()
+ return true
+ }
+
+ // store 变更时重扫(不在 DOM 事件里也能感知模式切换)。
+ const unsubscribeStore = worktreeStore.subscribe(scan)
+
+ let tries = 0
+ let timer: ReturnType<typeof setInterval> | undefined
+ if (!attach()) {
+ timer = setInterval(() => {
+ if (attach() || ++tries > 30)
+ clearInterval(timer)
+ }, 500)
+ }
+ // 应用晚挂载时侧边栏可能尚未出现,短暂轮询补扫。
+ if (!timer) {
+ timer = setInterval(() => {
+ if (document.querySelector(SIDEBAR_SELECTOR))
+ clearInterval(timer)
+ }, 400)
+ }
+
+ return () => {
+ iconStyle.unmount({ id: SESSION_ICON_STYLE_ID })
+ ro.disconnect()
+ unsubscribeStore()
+ if (timer !== undefined)
+ clearInterval(timer)
+ }
+}
+
+/** 返回目标工作区与当前首个其他会话,供检出会话插到工作区最上方。 */
+export function resolveWorkspaceTopInsertion(
+ workspaces: readonly WorkspaceSessionOrder[],
+ projectPath: string,
+ targetSessionId: string,
+): { workspaceId: string, beforeSessionId?: string } | undefined {
+ const workspace = workspaces.find(item => item.path === projectPath)
+ if (!workspace)
+ return undefined
+ return {
+ workspaceId: workspace.workspaceId,
+ beforeSessionId: workspace.sessionIds.find(id => id !== targetSessionId),
+ }
+}
diff --git a/packages/dsh-tauri-worktree/src/client/store.ts b/packages/dsh-tauri-worktree/src/client/store.ts
new file mode 100644
index 00000000..856267af
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/store.ts
@@ -0,0 +1,209 @@
+import type {
+ WorktreeCheckout,
+ WorktreeCreate,
+ WorktreeSessionState,
+ WorktreeStatus,
+ WorktreeUiState,
+} from './types'
+import { createExternalStore } from 'dsh-tauri/client'
+/**
+ * store.ts — dsh-tauri-worktree 的共享客户端状态(per-session 工作树状态 + RPC)。
+ *
+ * 桌面壳四个注册条目(select / surface / dialog / session)是同一
+ * 插件的多个独立槽位,凭一个模块级 SnapshotStore 共享按会话缓存的工作树状态。
+ * 任何条目把某会话的 state 写入 store,其余条目订阅渲染;所有后端调用集中在
+ * 本文件的 worktreeApi 里(/api/dsh-worktree/*),与宿主侧的 HTTP 路由一一对应。
+ */
+import { useSyncExternalStore } from 'react'
+import { PREFERRED_MODE_STORAGE_KEY, WORKTREE_API_PREFIX } from './constants'
+
+/** 新会话沿用用户最近选择;存储不可用时保持官方默认「本地」。 */
+export function preferredNewSessionMode(): 'local' | 'pending' {
+ try {
+ return localStorage.getItem(PREFERRED_MODE_STORAGE_KEY) === 'pending' ? 'pending' : 'local'
+ }
+ catch {
+ return 'local'
+ }
+}
+
+export function rememberNewSessionMode(mode: 'local' | 'pending'): void {
+ try {
+ localStorage.setItem(PREFERRED_MODE_STORAGE_KEY, mode)
+ }
+ catch {
+ // 隐私模式或受限存储不影响会话功能。
+ }
+}
+
+/** 从 unknown 错误里取可展示文本。 */
+function errMessage(error: unknown): string {
+ return error instanceof Error ? error.message : String(error)
+}
+
+export type { WorktreePhase, WorktreeSessionState } from './types'
+
+/** 无绑定会话的初始状态。 */
+export function blankState(): WorktreeSessionState {
+ return {
+ mode: preferredNewSessionMode(),
+ // 未知 git 状态时默认按 git 仓库处理(工作树插件的目标用户),待 status 返回后校准。
+ isGit: true,
+ phase: 'idle',
+ loadingLabel: '',
+ log: [],
+ worktreeKey: '',
+ worktreePath: '',
+ projectPath: '',
+ sourceSessionId: '',
+ branchName: 'dsh/',
+ checkoutOpen: false,
+ abandonOpen: false,
+ error: '',
+ }
+}
+
+/** useSyncExternalStore 的空 snapshot 必须保持引用稳定,否则会触发无限重渲染。 */
+const EMPTY_STATE = blankState()
+
+export type { WorktreeCheckout, WorktreeCreate, WorktreeStatus, WorktreeUiState } from './types'
+
+export const worktreeStore = createExternalStore<WorktreeUiState>({
+ bySession: {},
+})
+
+/** 取某会话的 state(无则回退空白态)。 */
+export function selectSessionState(state: WorktreeUiState, sessionId: string | undefined): WorktreeSessionState {
+ if (!sessionId)
+ return EMPTY_STATE
+ return state.bySession[sessionId] ?? EMPTY_STATE
+}
+
+/** 更新某会话的 state(merge 语义)。 */
+export function patchSession(sessionId: string | undefined, patch: Partial<WorktreeSessionState>): void {
+ if (!sessionId)
+ return
+ worktreeStore.set(state => ({
+ ...state,
+ bySession: {
+ ...state.bySession,
+ [sessionId]: { ...(state.bySession[sessionId] ?? blankState()), ...patch },
+ },
+ }))
+}
+
+/** 组件内订阅某会话的工作树状态(uSES)。 */
+export function useWorktreeSession(sessionId: string | undefined): WorktreeSessionState {
+ return useSyncExternalStore(
+ worktreeStore.subscribe,
+ () => selectSessionState(worktreeStore.getSnapshot(), sessionId),
+ )
+}
+
+// ---------------------------------------------------------------------------
+// RPC(/api/dsh-worktree/*,同源 fetch)
+// ---------------------------------------------------------------------------
+
+async function request<T>(path: string, init?: RequestInit): Promise<T> {
+ const res = await fetch(`${WORKTREE_API_PREFIX}${path}`, {
+ headers: { 'content-type': 'application/json' },
+ ...init,
+ })
+ if (!res.ok) {
+ const text = await res.text().catch(() => '')
+ throw new Error(`请求失败 (${res.status}): ${text}`)
+ }
+ return res.json() as Promise<T>
+}
+
+/** 查询某会话的工作树状态(GET,sessionId 走查询串)。 */
+export function fetchStatus(sessionId: string): Promise<WorktreeStatus> {
+ return request<WorktreeStatus>(`/status?sessionId=${encodeURIComponent(sessionId)}`)
+}
+
+/** 为预分配的新会话创建工作树;项目路径从当前源会话解析。 */
+export function createWorktree(sessionId: string, sourceSessionId = sessionId): Promise<WorktreeCreate> {
+ return request<WorktreeCreate>('/create', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId, sourceSessionId }),
+ })
+}
+
+/** 将已创建的 worktree 会话正式归属到源项目 Workspace。 */
+export function attachWorktreeSession(sessionId: string): Promise<{ ok: boolean, workspaceId: string }> {
+ return request('/attach', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId }),
+ })
+}
+
+export function checkoutWorktree(
+ sessionId: string,
+ worktreeHashDirname: string,
+ branchName: string,
+): Promise<WorktreeCheckout> {
+ return request('/checkout', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId, worktreeHashDirname, branchName }),
+ })
+}
+
+/** 放弃更改:删除工作树并解除绑定,会话保留。 */
+export function discardWorktree(
+ sessionId: string,
+ worktreeHashDirname: string,
+): Promise<{ ok: boolean }> {
+ return request('/discard', {
+ method: 'POST',
+ body: JSON.stringify({ sessionId, worktreeHashDirname }),
+ })
+}
+
+/** 检出本地(弹窗确认后调用)。 */
+export async function applyCheckout(
+ sessionId: string,
+ worktreeHashDirname: string,
+ branchName: string,
+): Promise<{ ok: boolean, error?: string, targetSessionId?: string }> {
+ try {
+ const result = await checkoutWorktree(sessionId, worktreeHashDirname, branchName)
+ patchSession(sessionId, {
+ mode: 'local',
+ phase: 'idle',
+ loadingLabel: '',
+ log: [],
+ worktreeKey: '',
+ checkoutOpen: false,
+ error: '',
+ })
+ return { ok: true, targetSessionId: result.targetSessionId }
+ }
+ catch (error) {
+ patchSession(sessionId, { error: errMessage(error) })
+ return { ok: false, error: errMessage(error) }
+ }
+}
+
+/** 放弃更改(弹窗确认后调用)。 */
+export async function applyDiscard(
+ sessionId: string,
+ worktreeHashDirname: string,
+): Promise<{ ok: boolean, error?: string }> {
+ try {
+ await discardWorktree(sessionId, worktreeHashDirname)
+ patchSession(sessionId, {
+ mode: 'local',
+ phase: 'idle',
+ loadingLabel: '',
+ log: [],
+ worktreeKey: '',
+ abandonOpen: false,
+ error: '',
+ })
+ return { ok: true }
+ }
+ catch (error) {
+ patchSession(sessionId, { error: errMessage(error) })
+ return { ok: false, error: errMessage(error) }
+ }
+}
diff --git a/packages/dsh-tauri-worktree/src/client/styles.ts b/packages/dsh-tauri-worktree/src/client/styles.ts
new file mode 100644
index 00000000..c1255c85
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/styles.ts
@@ -0,0 +1,49 @@
+import { CssRender } from 'dsh-tauri/client'
+import { WORKTREE_STYLE_ID, worktreeStyles } from './constants'
+
+export { worktreeStyles } from './constants'
+
+export function mountWorktreeStyles(): () => void {
+ if (typeof document === 'undefined')
+ return () => {}
+ const cssr = CssRender()
+ if (cssr.find(WORKTREE_STYLE_ID) !== null)
+ return () => {}
+ const { c } = cssr
+ const s = worktreeStyles
+ const style = c([
+ c(`.${s.surface}`, { boxSizing: 'border-box', width: 'calc(100% - 2 * var(--dsh-composer-side-clearance) - 4 * var(--dsh-composer-dock-inset))', maxWidth: 'calc(var(--dsh-composer-card-max-width) - 4 * var(--dsh-composer-dock-inset))', margin: '0 auto', alignSelf: 'center' }),
+ c(`.${s.surfaceBar}`, { boxSizing: 'border-box', width: '100%', position: 'relative', height: '36px', display: 'flex', alignItems: 'center', gap: '10px', padding: '4px 5px 4px 12px', margin: '0 auto', border: '1px solid var(--dsw-alias-border-l1)', borderRadius: '12px', background: 'var(--dsw-specific-tip)', color: 'var(--dsw-alias-label-primary)', pointerEvents: 'auto' }),
+ c(`.${s.surfaceContent}`, { display: 'flex', alignItems: 'center', gap: '5px' }),
+ c(`.${s.surfaceLabel}`, { fontSize: '13px', lineHeight: '20px', fontWeight: 500 }),
+ c(`.${s.action}`, { height: '26px', padding: '0 10px', border: 'none', borderRadius: '7px', fontFamily: 'inherit', fontSize: '12px', cursor: 'pointer', color: 'var(--dsw-alias-label-primary)', background: 'var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.08))', whiteSpace: 'nowrap' }),
+ c(`.${s.actionLog}`, { padding: 0, fontSize: '13px', background: 'transparent', textDecoration: 'underline' }),
+ c(`.${s.actionDanger}`, { color: 'var(--dsw-alias-danger-foreground, #c0392b)', background: 'transparent' }),
+ c(`.${s.spacer}`, { flex: 1 }),
+ c(`.${s.logs}`, { display: 'grid', gridTemplateRows: '0fr', opacity: 0, transition: 'grid-template-rows 180ms cubic-bezier(.16, 1, .3, 1), opacity 140ms ease' }),
+ c(`.${s.logsOpen}`, { gridTemplateRows: '1fr', opacity: 1 }),
+ c(`.${s.logsInner}`, { minHeight: 0, overflow: 'hidden' }),
+ c(`.${s.logsPanel}`, { maxHeight: '180px', overflowY: 'auto', padding: '10px', borderRadius: '10px', border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-base)', zIndex: 30 }),
+ c(`.${s.logLine}`, { fontSize: '12px', fontFamily: 'cursive', lineHeight: '16px' }),
+ c(`.${s.modal}`, { position: 'absolute', inset: 0, zIndex: 1000, display: 'grid', placeItems: 'center', background: 'rgba(0,0,0,0.4)' }),
+ c(`.${s.card}`, { boxSizing: 'border-box', width: 'min(460px, calc(100vw - 48px))', padding: '20px 22px', borderRadius: '16px', background: 'var(--dsw-alias-bg-base)', color: 'var(--dsw-alias-label-primary)', boxShadow: '0 24px 64px rgba(0,0,0,0.28)', display: 'flex', flexDirection: 'column', gap: '14px' }),
+ c(`.${s.title}`, { fontSize: '16px', fontWeight: 600, lineHeight: '24px', margin: 0 }),
+ c(`.${s.body}`, { fontSize: '13px', lineHeight: '20px', color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))', margin: 0 }),
+ c(`.${s.field}`, { display: 'flex', flexDirection: 'column', gap: '6px' }),
+ c(`.${s.fieldLabel}`, { fontSize: '12px', lineHeight: '18px', color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))' }),
+ c(`.${s.inputWrap}`, { display: 'flex', alignItems: 'center', gap: 0, border: '1px solid var(--dsw-alias-border-weak, rgba(127,127,127,0.25))', borderRadius: '10px', overflow: 'hidden', background: 'var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.06))' }),
+ c(`.${s.input}`, { flex: 1, minWidth: 0, height: '36px', padding: '0 10px', border: 'none', background: 'none', color: 'var(--dsw-alias-label-primary)', fontFamily: 'inherit', fontSize: '13px', outline: 'none' }),
+ c(`.${s.pathRow}`, { display: 'flex', justifyContent: 'space-between', gap: '12px', fontSize: '12px', lineHeight: '18px' }),
+ c(`.${s.pathKey}`, { flex: 'none', color: 'var(--dsw-alias-label-secondary, var(--dsw-alias-label-primary))' }),
+ c(`.${s.pathValue}`, { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', fontFamily: 'monospace' }),
+ c(`.${s.error}`, { fontSize: '12px', lineHeight: '18px', color: '#c0392b' }),
+ c(`.${s.footer}`, { display: 'flex', justifyContent: 'flex-end', gap: '10px', marginTop: '4px' }),
+ c(`.${s.button}`, { boxSizing: 'border-box', height: '36px', padding: '0 16px', border: 'none', borderRadius: '10px', fontFamily: 'inherit', fontSize: '13px', cursor: 'pointer', whiteSpace: 'nowrap' }),
+ c(`.${s.buttonGhost}`, { color: 'var(--dsw-alias-label-primary)', background: 'var(--dsw-alias-interactive-bg-hover, rgba(127,127,127,0.08))' }),
+ c(`.${s.buttonPrimary}`, { color: '#fff', background: 'var(--dsw-alias-bg-accent, #2f6feb)' }),
+ c(`.${s.buttonDanger}`, { color: '#fff', background: '#c0392b' }),
+ c(`.${s.buttonDisabled}`, { opacity: 0.5, cursor: 'not-allowed' }),
+ ])
+ style.mount({ id: WORKTREE_STYLE_ID, head: true })
+ return () => style.unmount({ id: WORKTREE_STYLE_ID })
+}
diff --git a/packages/dsh-tauri-worktree/src/client/surface.tsx b/packages/dsh-tauri-worktree/src/client/surface.tsx
new file mode 100644
index 00000000..019146ee
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/surface.tsx
@@ -0,0 +1,90 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ReactElement } from 'react'
+import type { SurfaceBarProps } from './types'
+/**
+ * surface.tsx — 聊天框正上方、仅会话内容区内的工作树状态条。
+ */
+import { useState } from 'react'
+import { INPUT_DOCK_SLOT, SURFACE_ID, SURFACE_ORDER } from './constants'
+import { CircleTreeIcon } from './icons'
+import { text, useLocale } from './locale'
+import { patchSession, useWorktreeSession } from './store'
+import { worktreeStyles } from './styles'
+
+export function WorktreeSurface({ sessionId }: SurfaceBarProps): ReactElement | null {
+ useLocale()
+ const state = useWorktreeSession(sessionId)
+ const [logOpen, setLogOpen] = useState(false)
+
+ if (state.phase === 'idle' || state.mode === 'local')
+ return null
+
+ const creating = state.phase === 'creating'
+ const failed = state.phase === 'error'
+ const bound = state.mode === 'worktree'
+ const label = creating
+ ? state.loadingLabel || text('progressCreating')
+ : failed
+ ? `${text('progressError')}${state.error ? `: ${state.error}` : ''}`
+ : text('surfaceWorktree')
+
+ return (
+ <div className={worktreeStyles.surface}>
+ <div className={worktreeStyles.surfaceBar} data-dsh-worktree-surface={sessionId}>
+ <CircleTreeIcon size={14} />
+ <div className={worktreeStyles.surfaceContent}>
+ <span className={worktreeStyles.surfaceLabel}>
+ {label}
+ {creating && `...`}
+ </span>
+ {bound && state.log.length > 0 && (
+ <button type="button" className={`${worktreeStyles.action} ${worktreeStyles.actionLog}`} onClick={() => setLogOpen(value => !value)}>
+ {text('progressViewLogs')}
+ </button>
+ )}
+ </div>
+ <span className={worktreeStyles.spacer} />
+ {bound && (
+ <>
+ <button type="button" className={worktreeStyles.action} onClick={() => patchSession(sessionId, { checkoutOpen: true })}>
+ {text('surfaceCheckout')}
+ </button>
+ <button type="button" className={`${worktreeStyles.action} ${worktreeStyles.actionDanger}`} onClick={() => patchSession(sessionId, { abandonOpen: true })}>
+ {text('surfaceAbandon')}
+ </button>
+ </>
+ )}
+ </div>
+ <Logs log={state.log} open={logOpen} />
+ </div>
+ )
+}
+
+export function Logs({ log, open }: { log: string[], open: boolean }): ReactElement {
+ return (
+ <div
+ aria-hidden={!open}
+ className={`${worktreeStyles.logs} ${open ? worktreeStyles.logsOpen : ''}`}
+ >
+ <div className={worktreeStyles.logsInner}>
+ <div className={worktreeStyles.logsPanel}>
+ {log.map((line, index) => <div key={`${index}:${line}`} className={worktreeStyles.logLine}>{line}</div>)}
+ </div>
+ </div>
+ </div>
+ )
+}
+
+/** input.dock 正位于 inputBar 上方,宽度天然受右侧会话内容区约束。 */
+export function registerSurface(ctx: Context): void {
+ ctx.slots.inject(INPUT_DOCK_SLOT as never, () =>
+ ctx.slots.register(
+ {
+ name: INPUT_DOCK_SLOT,
+ id: SURFACE_ID,
+ order: SURFACE_ORDER,
+ inject: (sessionId: string | undefined) => sessionId === undefined ? undefined : { sessionId },
+ } as never,
+ WorktreeSurface,
+ ))
+}
diff --git a/packages/dsh-tauri-worktree/src/client/types.ts b/packages/dsh-tauri-worktree/src/client/types.ts
new file mode 100644
index 00000000..ee4475a4
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/client/types.ts
@@ -0,0 +1,187 @@
+export interface InputState {
+ draft: string
+ imageIds: string[]
+}
+
+export interface InputActions {
+ setDraft: (text: string) => void
+ addImages: (ids: string[]) => boolean
+ removeImage: (id: string) => void
+ submit: () => void
+}
+
+export interface SessionsRuntime {
+ create: (opts: { cwd: string, sessionId: string }) => Promise<string>
+ open: (sessionId: string) => void
+ provideInfo: (sessionId: string) => { props?: { inputActions?: InputActions } } | undefined
+}
+
+export interface ModeSelectProps {
+ sessionId: string
+ useInput: <S>(selector: (state: InputState) => S) => S
+ inputActions: InputActions
+ sessionsRuntime: SessionsRuntime
+}
+
+export interface SurfaceBarProps {
+ sessionId: string
+}
+
+export interface WorkspaceSessionOrder {
+ workspaceId: string
+ path: string
+ sessionIds: readonly string[]
+}
+
+export interface WorkspacesRuntime {
+ archiveSession: (sessionId: string) => Promise<void>
+ list: { getSnapshot: () => { items: WorkspaceSessionOrder[] } }
+ insertSessionBefore: (workspaceId: string, sessionId: string, beforeSessionId?: string) => Promise<unknown>
+}
+
+export interface WorktreeDialogProps {
+ useSessions: <S>(sel: (state: DialogListState) => S) => S
+ sessionsRuntime: {
+ open: (sessionId: string) => void
+ refresh: () => Promise<void>
+ list: { getSnapshot: () => { current?: string, ids: string[] } }
+ }
+ workspacesRuntime: WorkspacesRuntime
+}
+
+export interface DialogListState {
+ phase: string
+ current?: string
+ byId: Record<string, unknown>
+}
+
+export interface SessionListSnapshot {
+ ids: string[]
+ current?: string
+ phase?: 'pending' | 'ready'
+}
+
+export interface WorktreeHydrationSessionsRuntime {
+ binding: (sessionId: string) => { session?: { subscribe?: (listener: () => void) => () => void } } | undefined
+ list: {
+ getSnapshot: () => SessionListSnapshot
+ subscribe: (listener: () => void) => () => void
+ }
+ open: (sessionId: string) => void
+ refresh: () => Promise<void>
+}
+
+export interface WorkspaceListSnapshot {
+ archivedSessionIds: readonly string[]
+}
+
+/** 工作树处理阶段(会话处理状态与日志展示的三阶段)。 */
+export type WorktreePhase = 'idle' | 'creating' | 'created' | 'thinking' | 'error'
+
+/** 某会话绑定的工作树状态。 */
+export interface WorktreeSessionState {
+ /** 模式:local(本地)| pending(下一条消息新建)| worktree(隔离工作树)。 */
+ mode: 'local' | 'pending' | 'worktree'
+ /** 会话工作目录是否位于 git 仓库内(非 git 目录强制 local 且隐藏模式选择器)。 */
+ isGit: boolean
+ /** 处理阶段(本地会话恒为 idle)。 */
+ phase: WorktreePhase
+ /** 阶段 1 的加载提示(正在准备工作区 → 正在检出文件),随创建推进。 */
+ loadingLabel: string
+ /** 阶段 2 的创建日志(点击查看)。 */
+ log: string[]
+ /** 工作树标识 [hash]/[dirname](弹窗的「当前关联路径」)。 */
+ worktreeKey: string
+ /** 工作树绝对路径。 */
+ worktreePath: string
+ /** 项目(目标仓库)绝对路径。 */
+ projectPath: string
+ /** 创建工作树前所在的源会话(用于侧边栏归组与完成后返回)。 */
+ sourceSessionId: string
+ /** 检出弹窗分支名输入框当前值。 */
+ branchName: string
+ /** 检出弹窗是否打开。 */
+ checkoutOpen: boolean
+ /** 放弃弹窗是否打开。 */
+ abandonOpen: boolean
+ /** 最近一次 API 错误(展示用)。 */
+ error: string
+}
+
+/** 全局共享状态源(模块级单例;插件重载时随 bundle 重建,可接受)。 */
+export interface WorktreeUiState {
+ /** 按会话 id 缓存的工作树状态。 */
+ bySession: Record<string, WorktreeSessionState>
+}
+
+export interface WorktreeStatus {
+ mode: 'local' | 'worktree'
+ worktreeKey?: string
+ worktreePath?: string
+ projectPath?: string
+ hash?: string
+ dirname?: string
+ sourceSessionId?: string
+ log?: string[]
+ /**
+ * 会话工作目录是否位于 git 仓库内(非 git 目录时客户端应强制本地并隐藏模式选择器)。
+ * null 表示宿主尚未解析出该会话(新建/启动竞态):客户端保持默认 git 假设、不落库,
+ * 稍后重试,绝不据此隐藏工作树 UI。
+ */
+ isGit?: boolean | null
+}
+
+export interface WorktreeCreate {
+ ok: boolean
+ hash: string
+ dirname: string
+ worktreeKey: string
+ worktreePath: string
+ projectPath: string
+ sourceSessionId: string
+ log: string[]
+ existed: boolean
+}
+
+/** 检出本地:把工作树改动带回本地分支,解除绑定,恢复本地会话。 */
+export interface WorktreeCheckout {
+ ok: boolean
+ branch: string
+ projectPath?: string
+ /**
+ * 检出后带回本地的新会话 id(继承工作树会话完整对话历史,cwd 指向本地项目)。
+ * 缺失表示继承会话创建失败(宿主返回 warning)。
+ */
+ targetSessionId?: string
+ warning?: string
+}
+
+export type LocaleKey
+ = | 'modeLabel'
+ | 'modeLocal'
+ | 'modeWorktree'
+ | 'modeNewWorktree'
+ | 'modeWorktreeDesc'
+ | 'modeLocalDesc'
+ | 'surfaceWorktree'
+ | 'surfaceCheckout'
+ | 'surfaceAbandon'
+ | 'checkoutTitle'
+ | 'checkoutBranchLabel'
+ | 'checkoutCurrentPath'
+ | 'checkoutTargetPath'
+ | 'checkoutConfirm'
+ | 'checkoutCancel'
+ | 'abandonTitle'
+ | 'abandonBody'
+ | 'abandonConfirm'
+ | 'abandonCancel'
+ | 'progressCreating'
+ | 'progressCheckingOut'
+ | 'progressCreated'
+ | 'progressViewLogs'
+ | 'progressThinking'
+ | 'progressError'
+ | 'branchPlaceholder'
+ | 'logEmpty'
+ | 'sessionWorkingTreeBadge'
diff --git a/packages/dsh-tauri-worktree/src/constants.ts b/packages/dsh-tauri-worktree/src/constants.ts
new file mode 100644
index 00000000..056dfc8a
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/constants.ts
@@ -0,0 +1,3 @@
+export const WORKTREE_API_PREFIX = '/api/dsh-worktree'
+export const WORKTREE_SECTION_ORDER = 210
+export const WORKTREE_BRANCH_NAME_PATTERN = /^[\w./-]+$/
diff --git a/packages/dsh-tauri-worktree/src/git.ts b/packages/dsh-tauri-worktree/src/git.ts
new file mode 100644
index 00000000..fe456ee1
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/git.ts
@@ -0,0 +1,164 @@
+import type { GitOptions, OperationResult } from './types.js'
+import { execFile } from 'node:child_process'
+import { mkdtemp, rm, writeFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { basename, join, resolve } from 'node:path'
+import { promisify } from 'node:util'
+
+const execFileAsync = promisify(execFile)
+
+function errorMessage(error: unknown): string {
+ if (error && typeof error === 'object') {
+ const value = error as { stderr?: unknown, message?: unknown }
+ return String(value.stderr ?? value.message ?? error).trim()
+ }
+ return String(error).trim()
+}
+
+export async function git(args: string[], cwd: string, options: GitOptions = {}): Promise<OperationResult<{ out: string }>> {
+ try {
+ const { stdout } = await execFileAsync('git', args, {
+ cwd,
+ timeout: options.timeout ?? 30_000,
+ maxBuffer: 8 * 1024 * 1024,
+ signal: options.signal,
+ })
+ return { ok: true, out: String(stdout).trim() }
+ }
+ catch (error) {
+ return { ok: false, error: errorMessage(error) }
+ }
+}
+
+/**
+ * 把补丁以临时文件形式喂给 `git apply`。async execFile 不支持 stdin 的 `input` 选项,
+ * 而 binary patch(`--binary`)是 ASCII(base85) 编码,UTF-8 写盘无损;临时文件放在系统
+ * 临时目录,避免污染目标仓库的工作区状态。
+ * @param {string} cwd
+ * @param {string} patch
+ * @param {GitOptions} [options]
+ * @returns {Promise<OperationResult<{ out: string }>>} out 为 `git apply` 的输出(去尾空白)
+ */
+async function applyPatchArchive(cwd: string, patch: string, options: GitOptions = {}): Promise<OperationResult<{ out: string }>> {
+ let dir: string | undefined
+ try {
+ dir = await mkdtemp(join(tmpdir(), 'dsh-worktree-'))
+ const patchPath = join(dir, 'staged.patch')
+ // git() 捕获侧对 stdout 做了 trim()(补丁末尾换行被剥掉),git apply 要求 hunk 末尾
+ // 行有换行终止,否则报 "corrupt patch at line N"。这里补回一个末尾换行。
+ const archive = patch.endsWith('\n') ? patch : `${patch}\n`
+ await writeFile(patchPath, archive, 'utf8')
+ return await git(['apply', '--cached', '--binary', '--whitespace=nowarn', patchPath], cwd, options)
+ }
+ catch (error) {
+ return { ok: false, error: errorMessage(error) }
+ }
+ finally {
+ if (dir)
+ await rm(dir, { recursive: true, force: true })
+ }
+}
+
+/**
+ * 捕获 index 相对 HEAD 的暂存改动(binary patch)。用它而非 `git stash` 在工作树与
+ * 本地仓库之间搬运暂存内容:stash 是仓库级共享状态,一次 pop 进错 worktree 会互相
+ * 污染;diff/apply 只动 index 与受影响文件,且完全不触碰源侧工作区。
+ * @param {string} cwd
+ * @param {GitOptions} [options]
+ * @returns {Promise<OperationResult<{ patch: string }>>} patch 为空串表示无暂存内容
+ */
+export async function stagedPatch(cwd: string, options: GitOptions = {}): Promise<OperationResult<{ patch: string }>> {
+ // --no-renames 避免 rename 检测:搬迁语义下 delete+add 比 rename 更稳,且 apply 无需
+ // 精确匹配 rename 的相似度计算。
+ const result = await git(['diff', '--cached', '--binary', '--no-renames'], cwd, options)
+ if (!result.ok)
+ return result
+ return { ok: true, patch: result.out }
+}
+
+/**
+ * 在目标工作目录重建源侧暂存状态:先把 staged patch 应用到 index(不碰工作区),再仅
+ * 对 patch 涉及的路径把工作区同步为 index 内容(新增/修改写盘、删除移除文件),使目标
+ * `git status` 的暂存/未暂存分布与源侧一致。绝不触碰 patch 之外的路径,避免覆盖目标
+ * 目录里用户已有的未提交改动。
+ * @param {string} cwd
+ * @param {string} patch
+ * @param {GitOptions} [options]
+ * @returns {Promise<OperationResult<{ out: string }>>} out 为受影响路径列表(换行分隔)
+ */
+export async function applyStagedPatch(cwd: string, patch: string, options: GitOptions = {}): Promise<OperationResult<{ out: string }>> {
+ if (!patch.trim())
+ return { ok: true, out: '' }
+ const applied = await applyPatchArchive(cwd, patch, options)
+ if (!applied.ok)
+ return applied
+ // apply 后 index 相对 HEAD 的差异就是被携带的路径集合(与源侧暂存文件一致)。
+ const names = await git(['diff', '--cached', '--name-only', '-z'], cwd, options)
+ if (!names.ok)
+ return names
+ const paths = names.out.split('\0').filter(Boolean)
+ if (paths.length === 0)
+ return { ok: true, out: '' }
+
+ // 仍在 index 中的路径(新增/修改):checkout-index 从 index 写盘;已从 index 删除的
+ // 路径(暂存删除):移除工作区残留文件,避免其变成 untracked 扰乱状态。
+ const trackedRaw = await git(['ls-files', '-z', '--', ...paths], cwd, options)
+ if (!trackedRaw.ok)
+ return trackedRaw
+ const tracked = new Set(trackedRaw.out.split('\0').filter(Boolean))
+ const inIndex = paths.filter(path => tracked.has(path))
+ const deleted = paths.filter(path => !tracked.has(path))
+ if (inIndex.length > 0) {
+ const written = await git(['checkout-index', '-f', '--', ...inIndex], cwd, options)
+ if (!written.ok)
+ return written
+ }
+ for (const relative of deleted) {
+ try {
+ await rm(join(cwd, relative), { force: true })
+ }
+ catch {
+ /* 文件本就不存在时忽略 */
+ }
+ }
+ return { ok: true, out: paths.join('\n') }
+}
+
+/**
+ * 把源工作目录的暂存内容完整搬到目标工作目录(创建:源仓库→新工作树;检出:工作树→
+ * 本地仓库)。只搬运 index 状态;未暂存与未跟踪改动按设计不携带。
+ * @param {string} sourceCwd
+ * @param {string} targetCwd
+ * @param {GitOptions} [options]
+ * @returns {Promise<OperationResult<{ carried: string[] }>>} carried 为被携带的路径列表
+ */
+export async function carryStagedChanges(sourceCwd: string, targetCwd: string, options: GitOptions = {}): Promise<OperationResult<{ carried: string[] }>> {
+ const captured = await stagedPatch(sourceCwd, options)
+ if (!captured.ok)
+ return captured
+ if (!captured.patch.trim())
+ return { ok: true, carried: [] }
+ const applied = await applyStagedPatch(targetCwd, captured.patch, options)
+ if (!applied.ok)
+ return applied
+ return { ok: true, carried: applied.out ? applied.out.split('\n').filter(Boolean) : [] }
+}
+
+export async function gitToplevel(path: string): Promise<string | null> {
+ const result = await git(['rev-parse', '--show-toplevel'], path)
+ return result.ok ? resolve(result.out) : null
+}
+
+export function projectDirname(projectPath: string): string {
+ return basename(resolve(projectPath))
+}
+
+export async function shortHead(worktreePath: string): Promise<string> {
+ const result = await git(['rev-parse', '--short', 'HEAD'], worktreePath)
+ return result.ok ? result.out : '?'
+}
+
+export async function headSubject(worktreePath: string): Promise<string> {
+ const result = await git(['log', '-1', '--pretty=%s'], worktreePath)
+ return result.ok && result.out ? result.out : '?'
+}
diff --git a/packages/dsh-tauri-worktree/src/index.ts b/packages/dsh-tauri-worktree/src/index.ts
new file mode 100644
index 00000000..2937e122
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/index.ts
@@ -0,0 +1,1021 @@
+/**
+ * dsh-tauri-worktree 宿主侧(node half):会话级 Git Worktree 隔离。
+ *
+ * 架构(two-half 插件,参照 dsh-tauri 的分层 + worktree-mgr / dsh-worktree-panel 的
+ * 宿主技法):
+ * - 本文件(node half)注册 host 能力:工具、HTTP 路由、系统提示注入;
+ * - `src/client/`(browser half)渲染 UI(模式选择 / 处理状态 / Surface / 弹窗 /
+ * 会话列表图标),经 /api/dsh-worktree/* 与本 half 通信。
+ *
+ * 职责:
+ * 1. 根据「项目路径 + 会话 ID」计算唯一 hash,在 `~/.dsh/worktrees/[hash]/[dirname]`
+ * 用 `git worktree add --detach` 创建隔离工作树;
+ * 2. 维护 per-session 绑定(WeakMap 活对象 + 磁盘 ledger 持久化);
+ * 3. 注册 `create_worktree` / `checkout_worktree` / `discard_worktree` 工具(Agent 自发调用);
+ * 4. 系统提示注入 `is_worktree: true`;
+ * 5. 暴露 /api/dsh-worktree/* 给客户端(create / status / checkout / discard)。
+ *
+ * 检出语义(已与用户确认):「检出本地」= 在工作树分支上保留全部改动,在本地仓库
+ * 创建/切换到 `dsh/<branch>` 分支,Agent 继续在本地仓库工作;主分支不受影响。
+ */
+
+import type {
+ Binding,
+ CheckoutInfo,
+ CheckoutOptions,
+ EnsureOptions,
+ HostContext,
+ OperationResult,
+ PendingHandoff,
+ PluginConfig,
+ WorktreeParams,
+} from './types.js'
+import { createHash, randomUUID } from 'node:crypto'
+import { existsSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { isAbsolute, join } from 'node:path'
+import { routeHandler, withConnectionAuth } from 'dsh-tauri'
+import { WORKTREE_API_PREFIX, WORKTREE_BRANCH_NAME_PATTERN, WORKTREE_SECTION_ORDER } from './constants.js'
+import { applyStagedPatch, carryStagedChanges, git, gitToplevel, headSubject, projectDirname, shortHead, stagedPatch } from './git.js'
+import {
+ clearPendingCheckoutContext,
+ loadCheckoutContextsSync,
+ loadLedger,
+ loadLedgerSync,
+ saveLedger,
+ setPendingCheckoutContext,
+} from './storage.js'
+
+/** 插件名(诊断元数据,与导出的 name 一致)。 */
+export const name = 'dsh-tauri-worktree'
+
+/**
+ * 需要的宿主服务:
+ * tools 工具注册表(注册 create_worktree / checkout_worktree / discard_worktree)
+ * systemPrompt 系统提示注入(is_worktree: true)
+ * webServer HTTP 路由(/api/dsh-worktree/*,客户端经此调用)
+ * sessions 当前会话枚举/查找(绑定工作树)
+ * workspaceRegistry注册工作树为 DSH 工作区(可选,增强归类)
+ */
+export const inject = ['tools', 'systemPrompt', 'webServer', 'sessions', 'workspaceRegistry', 'agents', 'connection']
+
+/** API 路由前缀(客户端同源 fetch)。 */
+export const API_PREFIX = WORKTREE_API_PREFIX
+
+/** 分支名校验(本地分支 dsh/<slug>)。 */
+const BRANCH_NAME_RE = WORKTREE_BRANCH_NAME_PATTERN
+
+/** 计算 hash:项目路径 + 会话 ID → sha256 前 12 位。 */
+export function computeHash(projectPath: string, sessionId: string): string {
+ return createHash('sha256').update(`${projectPath}:${sessionId}`).digest('hex').slice(0, 12)
+}
+
+/** 工作树落盘目录:`<home>/worktrees/<hash>/<dirname>`。 */
+export function worktreePath(worktreesRoot: string, hash: string, dirname: string): string {
+ return join(worktreesRoot, 'worktrees', hash, dirname)
+}
+
+/** 工作树展示用相对标识 `[hash]/[dirname]`。 */
+export function worktreeKey(hash: string, dirname: string): string {
+ return `${hash}/${dirname}`
+}
+
+// ---------------------------------------------------------------------------
+// 会话解析
+// ---------------------------------------------------------------------------
+
+/**
+ * 从 ctx 拿到当前会话对象(优先用传入的 session,其次由 id 查 sessions)。
+ * @param {any} ctx
+ * @param {string} sessionId
+ * @returns {any} 会话对象(查不到时 undefined)
+ */
+function findSession(ctx: HostContext, sessionId: string): any {
+ if (!sessionId)
+ return undefined
+ try {
+ return ctx.sessions.get(sessionId) ?? ctx.sessions.list().find((session: any) => session.id === sessionId)
+ }
+ catch {
+ return undefined
+ }
+}
+
+/**
+ * 解析会话的项目根路径:优先 session.header.cwd / session.cwd,其次 workspaceRegistry
+ * 按该路径解析工作区根。会话未知或没有任何路径信息时返回 null(调用方按「未知」处理)。
+ *
+ * 设计原因:新建会话/应用启动存在竞态——客户端列表已出现会话,但宿主 SessionStore 尚无
+ * 该会话或 header.cwd 尚未落定。此时绝不能静默回退 process.cwd() 猜测:宿主进程的工作
+ * 目录未必是 git 仓库,一旦误判 isGit: false,客户端会永久隐藏工作树模式选择器,直到
+ * 刷新后才由真实 header.cwd 纠正。返回 null 让客户端保持默认(git)并稍后重试。
+ * @param {any} ctx
+ * @param {any} session
+ * @returns {Promise<string | null>} 项目根路径;会话无路径信息时返回 null
+ */
+async function resolveProjectPath(ctx: HostContext, session: any): Promise<string | null> {
+ const cwd = typeof session?.header?.cwd === 'string'
+ ? session.header.cwd
+ : typeof session?.cwd === 'string'
+ ? session.cwd
+ : ''
+ if (!cwd)
+ return null
+ if (isAbsolute(cwd))
+ return cwd
+ try {
+ const ws = await ctx.workspaceRegistry.resolveByPath(cwd)
+ if (ws?.path)
+ return ws.path
+ }
+ catch {
+ /* registry 不可用时忽略 */
+ }
+ return cwd
+}
+
+// ---------------------------------------------------------------------------
+// 工作树创建
+// ---------------------------------------------------------------------------
+
+/**
+ * 创建工作树(幂等):已存在则复用并返回已存在标记。
+ * @param {any} ctx
+ * @param {string} worktreesRoot
+ * @param {string} projectPath
+ * @param {string} sessionId
+ * @param {{ signal?: AbortSignal, sourceSessionId?: string, branchName?: string }} [opts]
+ * @returns {Promise<{ ok: boolean, error?: string, binding?: any, log?: string[], existed?: boolean }>} 创建/复用结果
+ */
+export async function ensureWorktree(
+ ctx: HostContext,
+ worktreesRoot: string,
+ projectPath: string,
+ sessionId: string,
+ opts: EnsureOptions = {},
+): Promise<OperationResult<{ binding: Binding, log: string[], existed: boolean }>> {
+ const root = await gitToplevel(projectPath)
+ if (!root)
+ return { ok: false, error: `项目路径不是 git 仓库顶层:${projectPath}` }
+
+ const hash = computeHash(projectPath, sessionId)
+ const dirname = projectDirname(projectPath)
+ const path = worktreePath(worktreesRoot, hash, dirname)
+
+ const ledger = await loadLedger(worktreesRoot)
+ const existing = ledger[sessionId]
+ if (existing && existsSync(existing.worktreePath)) {
+ return { ok: true, binding: existing, existed: true, log: [] }
+ }
+
+ // 若目录残留但 git 未注册(被打断),先清掉再重建。
+ if (existsSync(path)) {
+ await git(['worktree', 'prune'], root)
+ }
+
+ const requestedBranch = String(opts.branchName ?? '').trim()
+ if (requestedBranch && !BRANCH_NAME_RE.test(requestedBranch)) {
+ return { ok: false, error: `非法分支名:${requestedBranch}` }
+ }
+ const branchName = requestedBranch
+ ? (requestedBranch.startsWith('dsh/') ? requestedBranch : `dsh/${requestedBranch.replace(/^\/+/, '')}`)
+ : ''
+ if (branchName === 'dsh/')
+ return { ok: false, error: '分支名不能为空' }
+ if (branchName) {
+ const exists = await git(['rev-parse', '--verify', '--quiet', `refs/heads/${branchName}`], root, { signal: opts.signal })
+ if (exists.ok)
+ return { ok: false, error: `分支已存在:${branchName}` }
+ }
+
+ const log = ['Starting worktree creation']
+ const addArgs = branchName
+ ? ['worktree', 'add', '-b', branchName, path, 'HEAD']
+ : ['worktree', 'add', '--detach', path, 'HEAD']
+ const add = await git(addArgs, root, { signal: opts.signal })
+ if (!add.ok)
+ return { ok: false, error: `创建工作树失败:${add.error}` }
+
+ // 可选携带源仓库暂存内容:工作树默认从 HEAD 干净检出,用户已暂存的改动不会出现;
+ // carryStaged 打开时把 index 状态搬进新工作树(只搬已暂存,未暂存/未跟踪不携带)。
+ // 失败则回滚刚创建的 worktree,避免留下「创建成功但内容不完整」的半成品。
+ if (opts.carryStaged === true) {
+ const carried = await carryStagedChanges(root, path, { signal: opts.signal })
+ if (!carried.ok) {
+ await git(['worktree', 'remove', '--force', path], root, { signal: opts.signal })
+ await git(['worktree', 'prune'], root, { signal: opts.signal })
+ return { ok: false, error: `携带暂存内容失败,工作树已回滚:${carried.error}` }
+ }
+ if (carried.carried.length > 0)
+ log.push(`Carried staged changes (${carried.carried.length} file(s)) from the source repository`)
+ }
+
+ // UI 预选流程保持 detached;Agent 工具提供 branch_name 时直接在 dsh/* 分支工作。
+ const head = await git(['rev-parse', '--abbrev-ref', 'HEAD'], path)
+ const activeBranch = head.ok ? head.out : (branchName || '(detached)')
+ log.push(branchName
+ ? `Preparing worktree (branch ${branchName})`
+ : `Preparing worktree (detached HEAD ${await shortHead(path)})`)
+ log.push(`HEAD is now at ${await shortHead(path)} ${await headSubject(path)}`)
+ log.push(`Worktree created at ${path}`)
+
+ const binding = {
+ sessionId,
+ sourceSessionId: opts.sourceSessionId || sessionId,
+ hash,
+ dirname,
+ worktreePath: path,
+ projectPath: root,
+ branchName: activeBranch,
+ ownsBranch: Boolean(branchName),
+ createdAt: new Date().toISOString(),
+ log,
+ }
+ ledger[sessionId] = binding
+ await saveLedger(worktreesRoot, ledger)
+
+ // 不注册成普通 DSH Workspace:否则「新建会话」会复用 blank worktree 会话,
+ // 造成默认进入工作树。隔离会话直接以 sessions.create({ cwd }) 绑定此路径。
+
+ return { ok: true, binding, log, existed: false }
+}
+
+// ---------------------------------------------------------------------------
+// 检出本地 / 放弃
+// ---------------------------------------------------------------------------
+
+/** 解析工作树绑定(兼容 sessionId 或 worktreeHashDirname 定位)。 */
+async function resolveBinding(worktreesRoot: string, sessionId?: string, key?: string): Promise<{ binding: Binding | null }> {
+ const ledger = await loadLedger(worktreesRoot)
+ if (sessionId && ledger[sessionId])
+ return { binding: ledger[sessionId] }
+ if (key) {
+ for (const binding of Object.values(ledger)) {
+ if (binding.hash && binding.dirname && `${binding.hash}/${binding.dirname}` === key) {
+ return { binding }
+ }
+ }
+ }
+ return { binding: null }
+}
+
+/** 清理旧版本创建的普通 Workspace 注册;仅注销记录,不删除目录或会话。 */
+async function unregisterWorktreeWorkspace(ctx: HostContext, path: string): Promise<void> {
+ try {
+ const workspace = await ctx.workspaceRegistry.resolveByPath(path)
+ if (workspace?.id)
+ await ctx.workspaceRegistry.delete(workspace.id)
+ }
+ catch {
+ /* 未注册或路径已不存在时无需处理 */
+ }
+}
+
+/**
+ * 检出本地:在工作树分支保留改动,本地仓库创建/切换用户指定的分支。
+ * @param {any} ctx
+ * @param {string} worktreesRoot
+ * @param {{ worktree_hash_dirname?: string, sessionId?: string, branch_name?: string }} params
+ * @param {{ signal?: AbortSignal, beforeRemove?: (checkout: { branch: string, projectPath: string, worktreePath: string }) => Promise<{ ok: boolean, error?: string }> }} [opts]
+ * @returns {Promise<{ ok: boolean, error?: string, branch?: string, projectPath?: string, worktreePath?: string }>} 检出结果
+ */
+export async function checkoutToLocal(
+ ctx: HostContext,
+ worktreesRoot: string,
+ params: WorktreeParams,
+ opts: CheckoutOptions = {},
+): Promise<OperationResult<{ branch: string, projectPath: string, worktreePath: string }>> {
+ const { binding } = await resolveBinding(worktreesRoot, params.sessionId, params.worktreeHashDirname)
+ if (!binding)
+ return { ok: false, error: `未找到绑定的工作树` }
+ if (!existsSync(binding.worktreePath))
+ return { ok: false, error: `工作树目录不存在:${binding.worktreePath}` }
+
+ const root = binding.projectPath
+ // 本地分支名完全使用调用方输入;UI 默认填 `dsh/`,但用户可删除该前缀。
+ const branch = String(params.branch_name ?? binding.branchName ?? '').trim()
+ if (!branch || branch.endsWith('/'))
+ return { ok: false, error: `分支名不能为空或以 / 结尾:${branch}` }
+ const validBranch = await git(['check-ref-format', '--branch', branch], root, { signal: opts.signal })
+ if (!validBranch.ok)
+ return { ok: false, error: `非法分支名:${branch}` }
+
+ // 1) 在改动 ref 前完成安全预检。主工作区必须干净,避免 git checkout 把本地改动
+ // 静默带到功能分支;隔离工作树仅允许 committed 内容和显式携带的 staged 内容。
+ const mainStatus = await git(['status', '--porcelain=v1'], root, { signal: opts.signal })
+ if (!mainStatus.ok)
+ return { ok: false, error: `读取本地主工作区状态失败:${mainStatus.error}` }
+ if (mainStatus.out)
+ return { ok: false, error: '本地主工作区存在未提交改动;请先提交或清理后再检出工作树' }
+ const worktreeStatus = await git(['status', '--porcelain=v1'], binding.worktreePath, { signal: opts.signal })
+ if (!worktreeStatus.ok)
+ return { ok: false, error: `读取隔离工作树状态失败:${worktreeStatus.error}` }
+ const dirtyRows = worktreeStatus.out.split('\n').filter(Boolean)
+ const unsupportedRows = dirtyRows.filter(row => !/^[ACDMRT] /.test(row))
+ if (unsupportedRows.length > 0)
+ return { ok: false, error: '隔离工作树存在未暂存或未跟踪改动;请先提交这些改动再检出,避免删除工作树时丢失内容' }
+ if (dirtyRows.length > 0 && opts.carryStaged !== true)
+ return { ok: false, error: '隔离工作树存在已暂存改动;请启用 carry_staged 或先提交这些改动再检出' }
+
+ const worktreeHead = await git(['rev-parse', 'HEAD'], binding.worktreePath, { signal: opts.signal })
+ if (!worktreeHead.ok)
+ return { ok: false, error: `读取工作树 HEAD 失败:${worktreeHead.error}` }
+ const prev = await git(['symbolic-ref', '--quiet', '--short', 'HEAD'], root, { signal: opts.signal })
+ if (!prev.ok)
+ return { ok: false, error: '本地主工作区当前处于 detached HEAD;请先切换到本地分支再检出工作树' }
+ const prevBranch = prev.out
+ // 显式标注联合类型,保证 `ok` 判别后两端各自可访问 error/patch(含 ok:boolean 的
+ // 泛化联合无法据此收窄到 error 分支)。
+ const carriedPatch: OperationResult<{ patch: string }> = opts.carryStaged === true
+ ? await stagedPatch(binding.worktreePath, { signal: opts.signal })
+ : { ok: true, patch: '' }
+ if (!carriedPatch.ok)
+ return { ok: false, error: `读取工作树暂存内容失败:${carriedPatch.error}` }
+
+ // 2) Agent 创建的工作树已经拥有其功能分支。先把工作树 detach 以释放该分支,再在
+ // 本地主工作区切到同一个现有分支;不能把“分支已存在”误判成冲突并复制第二个分支。
+ // 其他已存在分支仍安全拒绝,绝不静默重置用户分支指针。
+ const branchRef = await git(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], root, { signal: opts.signal })
+ const handsOffOwnedBranch = binding.ownsBranch && binding.branchName === branch
+ let detachedOwnedBranch = false
+ let createdBranch = false
+ if (handsOffOwnedBranch) {
+ if (!branchRef.ok)
+ return { ok: false, error: `工作树拥有的本地分支不存在,拒绝重建以避免覆盖状态:${branch}` }
+ if (branchRef.out !== worktreeHead.out)
+ return { ok: false, error: `工作树 HEAD 与其本地分支指针不一致,拒绝检出:${branch}` }
+ const activeBranch = await git(['symbolic-ref', '--quiet', '--short', 'HEAD'], binding.worktreePath, { signal: opts.signal })
+ if (!activeBranch.ok || activeBranch.out !== branch)
+ return { ok: false, error: `工作树未签出其记录的本地分支,拒绝检出:${branch}` }
+ const detached = await git(['checkout', '--detach'], binding.worktreePath, { signal: opts.signal })
+ if (!detached.ok)
+ return { ok: false, error: `释放工作树分支失败:${detached.error}` }
+ detachedOwnedBranch = true
+ }
+ else {
+ if (branchRef.ok)
+ return { ok: false, error: `本地分支已存在且不属于当前工作树,为避免覆盖其提交而拒绝检出:${branch}` }
+ const created = await git(['branch', branch, worktreeHead.out], root, { signal: opts.signal })
+ if (!created.ok)
+ return { ok: false, error: `创建本地分支失败:${created.error}` }
+ createdBranch = true
+ }
+
+ const restoreSourceBranch = async (): Promise<string> => {
+ if (!detachedOwnedBranch)
+ return ''
+ const restored = await git(['checkout', branch], binding.worktreePath)
+ return restored.ok ? '' : `;工作树分支自动恢复失败:${restored.error}`
+ }
+ const removeCreatedBranch = async (): Promise<string> => {
+ if (!createdBranch)
+ return ''
+ const removed = await git(['branch', '-D', branch], root)
+ return removed.ok ? '' : `;新建分支自动清理失败:${removed.error}`
+ }
+ const rollbackHandoff = async (resetTarget = false): Promise<string> => {
+ const failures: string[] = []
+ if (resetTarget) {
+ const reset = await git(['reset', '--hard', 'HEAD'], root)
+ if (!reset.ok)
+ failures.push(`清理目标分支暂存状态失败:${reset.error}`)
+ }
+ const switchedBack = await git(['checkout', prevBranch], root, { signal: opts.signal })
+ if (!switchedBack.ok) {
+ failures.push(`恢复本地主分支失败:${switchedBack.error}`)
+ }
+ else {
+ const sourceRecovery = detachedOwnedBranch ? await restoreSourceBranch() : await removeCreatedBranch()
+ if (sourceRecovery)
+ failures.push(sourceRecovery.replace(/^;/, ''))
+ }
+ return failures.length > 0 ? `;${failures.join(';')}` : ''
+ }
+
+ // 3) 本地主工作区切到移交或新建的分支。失败时恢复原工作树的分支占用,或清理本次
+ // 新建的分支,保证重试不会因残留状态再次失败。
+ const check = await git(['checkout', branch], root, { signal: opts.signal })
+ if (!check.ok) {
+ const recovery = detachedOwnedBranch ? await restoreSourceBranch() : await removeCreatedBranch()
+ return { ok: false, error: `切换到本地分支失败:${check.error}${recovery}` }
+ }
+
+ // 3.5) carryStaged:把工作树已暂存内容应用到本地检出,只动补丁涉及的路径,不覆盖
+ // 本地其他未提交改动。失败时回滚到检出前分支并保留工作树,便于重试。
+ if (carriedPatch.patch.trim()) {
+ const applied = await applyStagedPatch(root, carriedPatch.patch, { signal: opts.signal })
+ if (!applied.ok) {
+ const recovery = await rollbackHandoff(true)
+ return { ok: false, error: `携带暂存内容失败,工作树已保留:${applied.error}${recovery}` }
+ }
+ }
+
+ // Preserve the worktree until the local session has been created successfully.
+ if (opts.beforeRemove) {
+ const prepared = await opts.beforeRemove({ branch, projectPath: root, worktreePath: binding.worktreePath })
+ if (!prepared.ok) {
+ const recovery = await rollbackHandoff(Boolean(carriedPatch.patch.trim()))
+ return { ok: false, error: `Failed to create the local handback session; the worktree was preserved: ${prepared.error}${recovery}` }
+ }
+ }
+
+ // 4) 注销旧版本可能创建的普通 Workspace 记录,再移除工作树。
+ await unregisterWorktreeWorkspace(ctx, binding.worktreePath)
+ const removed = await git(['worktree', 'remove', '--force', binding.worktreePath], root, { signal: opts.signal })
+ if (!removed.ok)
+ return { ok: false, error: `删除工作树失败,绑定已保留以便重试:${removed.error}` }
+ await git(['worktree', 'prune'], root, { signal: opts.signal })
+
+ // 5) 解除绑定。
+ const ledger = await loadLedger(worktreesRoot)
+ delete ledger[binding.sessionId]
+ await saveLedger(worktreesRoot, ledger)
+
+ return { ok: true, branch, projectPath: root, worktreePath: binding.worktreePath }
+}
+
+/**
+ * 把工作树会话的完整对话历史带回本地仓库:以工作树会话的全部事件为 seed 创建
+ * 继承会话,cwd 指向本地项目路径,并归属源 Workspace。
+ *
+ * 背景:UI「检出本地」完成后会归档工作树会话。若只是打开 ledger 里的源会话,
+ * 界面流程(模式选择器迁移草稿)创建的源会话是空白会话(0 轮对话),归档后用户
+ * 会看到「变成新会话、会话信息全部丢失」。本函数在归档前先创建继承会话,保证
+ * 检出后仍能看到并继续完整对话。
+ *
+ * @param {any} ctx
+ * @param {string} worktreesRoot
+ * @param {string} sessionId 工作树会话 id(其事件将被继承)
+ * @param {string} projectPath 检出后的本地项目路径(新会话 cwd)
+ * @param {{ branch?: string, worktreePath?: string }} [checkoutInfo] 首条消息的一次性检出上下文
+ * @returns {Promise<{ ok: boolean, error?: string, targetSessionId?: string }>} 继承会话 id(创建失败时 ok=false)
+ */
+export async function handbackWorktreeSession(
+ ctx: HostContext,
+ worktreesRoot: string,
+ sessionId: string,
+ projectPath: string,
+ checkoutInfo: CheckoutInfo = {},
+): Promise<OperationResult<{ targetSessionId: string }>> {
+ const agent = ctx.agents?.get?.(sessionId)
+ const sourceSession = agent?.session ?? findSession(ctx, sessionId)
+ if (!sourceSession)
+ return { ok: false, error: `未找到工作树会话:${sessionId}` }
+ const targetSessionId = `session-${randomUUID()}`
+ try {
+ const presets = ctx.get?.('agentPresets')
+ const parentPreset = agent
+ ? (presets?.composedPreset(agent.ctx) ?? sourceSession.header?.agentPreset)
+ : sourceSession.header?.agentPreset
+ const seed = Array.isArray(sourceSession.events) ? sourceSession.events : []
+ const options: any = {
+ sessionId: targetSessionId,
+ seed,
+ meta: {
+ cwd: projectPath,
+ parentSession: sourceSession.id,
+ seedLength: seed.length,
+ ...(parentPreset ? { agentPreset: parentPreset } : {}),
+ },
+ agentOptions: agent?.options ?? {},
+ }
+ if (agent && presets && parentPreset) {
+ // setup may return a transaction; do not leak composeFrom()'s preset id.
+ options.setup = (agentCtx: any) => {
+ presets.composeFrom(agentCtx, agent.ctx)
+ }
+ }
+ await ctx.agents.create(options)
+ const workspace = await ctx.workspaceRegistry.resolveByPath(projectPath)
+ if (workspace)
+ await workspace.attachSession(targetSessionId)
+ await setPendingCheckoutContext(worktreesRoot, targetSessionId, {
+ projectPath,
+ branch: checkoutInfo.branch,
+ worktreePath: checkoutInfo.worktreePath,
+ checkedOutAt: new Date().toISOString(),
+ })
+ return { ok: true, targetSessionId }
+ }
+ catch (error) {
+ return { ok: false, error: error instanceof Error ? error.message : String(error) }
+ }
+}
+
+/**
+ * 检出本地(UI 流程):本地分支切换后、删除工作树之前,先用本地 cwd 创建新会话,
+ * 并把工作树会话的完整事件作为 seed 覆盖过去。只有新会话创建成功才删除工作树。
+ * @param {any} ctx
+ * @param {string} worktreesRoot
+ * @param {{ worktree_hash_dirname?: string, sessionId?: string, branch_name?: string }} params
+ * @param {{ signal?: AbortSignal }} [opts]
+ * @returns {Promise<{ ok: boolean, error?: string, branch?: string, projectPath?: string, targetSessionId?: string, warning?: string }>} 检出 + 带回结果
+ */
+export async function checkoutToLocalAndHandback(
+ ctx: HostContext,
+ worktreesRoot: string,
+ params: WorktreeParams,
+ opts: CheckoutOptions = {},
+): Promise<OperationResult<{ branch: string, projectPath: string, targetSessionId?: string }>> {
+ const sessionId = String(params.sessionId ?? '')
+ let targetSessionId
+ const checkout = await checkoutToLocal(ctx, worktreesRoot, params, {
+ ...opts,
+ beforeRemove: async (prepared) => {
+ const handback = await handbackWorktreeSession(ctx, worktreesRoot, sessionId, prepared.projectPath, {
+ branch: prepared.branch,
+ worktreePath: prepared.worktreePath,
+ })
+ if (handback.ok)
+ targetSessionId = handback.targetSessionId
+ return handback
+ },
+ })
+ if (!checkout.ok)
+ return checkout
+ return { ok: true, branch: checkout.branch, projectPath: checkout.projectPath, targetSessionId }
+}
+
+/**
+ * 放弃更改:删除工作树并解除绑定(会话保留)。
+ * @param {any} ctx
+ * @param {string} worktreesRoot
+ * @param {{ worktree_hash_dirname?: string, sessionId?: string }} params
+ * @param {{ signal?: AbortSignal }} [opts]
+ * @returns {Promise<{ ok: boolean, error?: string, worktreePath?: string }>} 放弃结果
+ */
+export async function discardWorktree(
+ ctx: HostContext,
+ worktreesRoot: string,
+ params: WorktreeParams,
+ opts: { signal?: AbortSignal } = {},
+): Promise<OperationResult<{ worktreePath: string }>> {
+ const { binding } = await resolveBinding(worktreesRoot, params.sessionId, params.worktreeHashDirname)
+ if (!binding)
+ return { ok: false, error: `未找到绑定的工作树` }
+
+ await unregisterWorktreeWorkspace(ctx, binding.worktreePath)
+ if (existsSync(binding.worktreePath)) {
+ const removed = await git(['worktree', 'remove', '--force', binding.worktreePath], binding.projectPath, { signal: opts.signal })
+ if (!removed.ok)
+ return { ok: false, error: `删除工作树失败,绑定已保留以便重试:${removed.error}` }
+ await git(['worktree', 'prune'], binding.projectPath, { signal: opts.signal })
+ }
+ // create_worktree(branch_name) 新建的 dsh/* 分支属于临时工作树;放弃时一并删除。
+ // UI detached 流程和旧 ledger 没有 ownsBranch,不碰其任何本地分支。
+ if (binding.ownsBranch && binding.branchName) {
+ await git(['branch', '-D', binding.branchName], binding.projectPath, { signal: opts.signal })
+ }
+
+ const ledger = await loadLedger(worktreesRoot)
+ delete ledger[binding.sessionId]
+ await saveLedger(worktreesRoot, ledger)
+
+ return { ok: true, worktreePath: binding.worktreePath }
+}
+
+// ---------------------------------------------------------------------------
+// 工具定义(Agent 自发调用)
+// ---------------------------------------------------------------------------
+
+/** 文本渲染助手:渲染成模型可见文本。 */
+function textBlock(text: string): Array<{ type: 'text', text: string }> {
+ return [{ type: 'text', text }]
+}
+
+/**
+ * turn/end 后完成工作树会话交接。此时 sourceSession.events 已包含触发工具的完整 turn,
+ * 可安全作为新会话 seed;在开放 turn 内复制会得到不平衡的会话日志。
+ */
+export async function completeWorktreeHandoff(
+ ctx: HostContext,
+ worktreesRoot: string,
+ handoff: PendingHandoff,
+): Promise<void> {
+ const { sourceAgent, targetSessionId, binding } = handoff
+ const sourceSession = sourceAgent.session
+ try {
+ const presets = ctx.get?.('agentPresets')
+ const parentPreset = presets?.composedPreset(sourceAgent.ctx) ?? sourceSession.header.agentPreset
+ const seed = sourceSession.events
+ const handle = await ctx.agents.create({
+ sessionId: targetSessionId,
+ seed,
+ meta: {
+ cwd: binding.worktreePath,
+ parentSession: sourceSession.id,
+ seedLength: seed.length,
+ ...(parentPreset ? { agentPreset: parentPreset } : {}),
+ },
+ agentOptions: sourceAgent.options ?? {},
+ setup: (agentCtx: any) => {
+ if (presets && parentPreset)
+ presets.composeFrom(agentCtx, sourceAgent.ctx)
+ },
+ })
+ const workspace = await ctx.workspaceRegistry.resolveByPath(binding.projectPath)
+ if (workspace)
+ await workspace.attachSession(targetSessionId)
+ handle.agent.followup({
+ id: `message-${randomUUID()}`,
+ role: 'user',
+ content: [{
+ type: 'text',
+ text: 'The task has moved to an isolated worktree session. Continue the user request from the inherited context without explaining the handoff again.',
+ }],
+ source: { kind: 'user' },
+ })
+ }
+ catch (error) {
+ // 未发布时可以完整回滚;已发布时保留工作树,避免正在运行的新会话丢失 cwd。
+ if (!ctx.agents.get(targetSessionId)) {
+ await discardWorktree(ctx, worktreesRoot, { sessionId: targetSessionId })
+ }
+ const message = error instanceof Error ? error.message : String(error)
+ ctx.logger?.error?.(`create_worktree handoff failed for ${targetSessionId}: ${message}`)
+ }
+}
+
+/** 组装三个工具定义(create_worktree / checkout_worktree / discard_worktree)。 */
+export function createToolSet(
+ ctx: HostContext,
+ config: PluginConfig,
+ pendingHandoffs: Map<string, PendingHandoff> = new Map(),
+): any[] {
+ const worktreesRoot = config.worktreesRoot || join(homedir(), '.dsh')
+
+ return [
+ {
+ name: 'create_worktree',
+ description:
+ 'Use only when the user explicitly asks to work in a worktree and the current session is local. '
+ + 'It creates an isolated worktree and hands the full context to a new session after the current turn. '
+ + 'Do not call it from an existing worktree session.',
+ parameters: {
+ type: 'object',
+ properties: {
+ branch_name: {
+ type: 'string',
+ description: 'New worktree branch, for example `dsh/feature-xyz`; the `dsh/` prefix is added when omitted.',
+ },
+ carry_staged: {
+ type: 'boolean',
+ description: 'Whether to carry the source repository\'s staged (index) changes into the new worktree, '
+ + 'so the isolated session starts from the same staged state. Only staged changes are carried; '
+ + 'unstaged and untracked changes stay in the source repository. Default false.',
+ default: false,
+ },
+ },
+ required: ['branch_name'],
+ },
+ output: {
+ schema: {
+ type: 'object',
+ additionalProperties: true,
+ properties: {
+ ok: { type: 'boolean' },
+ targetSessionId: { type: 'string' },
+ worktreePath: { type: 'string' },
+ branch: { type: 'string' },
+ warning: { type: 'string' },
+ error: { type: 'string' },
+ },
+ required: ['ok'],
+ },
+ render: (_args: unknown, value: any) => value.ok
+ ? textBlock(`✅ Created worktree ${value.branch}; the UI will switch to the inherited worktree session after this turn.`)
+ : textBlock(`❌ Failed to create worktree: ${value.error}`),
+ },
+ async execute(args: any, exec: any) {
+ const sourceAgent = exec?.agent
+ const sourceSession = sourceAgent?.session
+ if (!sourceAgent || !sourceSession)
+ return { ok: false, error: 'create_worktree requires a current agent session' }
+ if (loadLedgerSync(worktreesRoot)[sourceSession.id])
+ return { ok: false, error: 'The current session is already in a worktree' }
+
+ const targetSessionId = `session-${randomUUID()}`
+ const projectPath = await resolveProjectPath(ctx, sourceSession)
+ if (!projectPath)
+ return { ok: false, error: '无法解析当前会话的工作目录:会话尚未就绪,请稍后重试' }
+ const created = await ensureWorktree(ctx, worktreesRoot, projectPath, targetSessionId, {
+ sourceSessionId: sourceSession.id,
+ branchName: String(args.branch_name ?? ''),
+ carryStaged: args.carry_staged === true,
+ signal: exec?.signal,
+ })
+ if (!created.ok)
+ return { ok: false, error: created.error }
+
+ pendingHandoffs.set(sourceSession.id, {
+ sourceAgent,
+ targetSessionId,
+ binding: created.binding,
+ })
+
+ return {
+ ok: true,
+ targetSessionId,
+ worktreePath: created.binding.worktreePath,
+ branch: created.binding.branchName,
+ }
+ },
+ },
+ {
+ name: 'checkout_worktree',
+ description:
+ 'User-authorized operation only. Call this tool only after a direct human user explicitly requests or approves checkout. '
+ + 'Task completion, a merged PR, or inferred convenience is not permission to call it. When checkout would be a natural next step, '
+ + 'such as after a PR is merged, you may ask the user whether they want to check out the worktree; wait for their approval before calling. '
+ + 'Bring the current isolated worktree back to the local repository, preserve its changes on the worktree branch, '
+ + 'create or switch to the requested local branch, and remove the isolated worktree. The main branch is unchanged.',
+ parameters: {
+ type: 'object',
+ properties: {
+ worktree_hash_dirname: {
+ type: 'string',
+ description: 'Worktree key in `[hash]/[dirname]` form, as shown in the session context.',
+ },
+ branch_name: {
+ type: 'string',
+ description: 'Local branch name, such as `dsh/feature-xyz` or `feature-xyz`; used exactly as provided.',
+ },
+ carry_staged: {
+ type: 'boolean',
+ description: 'Whether to carry the worktree\'s staged (index) changes into the checked-out local branch '
+ + 'before the worktree is removed. Committed work is always carried; staged-only work would otherwise '
+ + 'be lost with the removed worktree. Default false.',
+ default: false,
+ },
+ },
+ required: ['worktree_hash_dirname', 'branch_name'],
+ },
+ output: {
+ schema: {
+ type: 'object',
+ additionalProperties: true,
+ properties: {
+ ok: { type: 'boolean' },
+ branch: { type: 'string' },
+ error: { type: 'string' },
+ },
+ required: ['ok'],
+ },
+
+ render: (_args: unknown, value: any) => {
+ if (!value.ok)
+ return textBlock(`❌ Checkout failed: ${value.error}`)
+ return textBlock(`✅ Checked out local branch ${value.branch}; the worktree was removed.`)
+ },
+ },
+ async execute(args: any, exec: any) {
+ const r = await checkoutToLocal(ctx, worktreesRoot, {
+ worktree_hash_dirname: String(args.worktree_hash_dirname ?? ''),
+ sessionId: exec?.agent?.session?.id,
+ branch_name: String(args.branch_name ?? ''),
+ }, {
+ signal: exec?.signal,
+ carryStaged: args.carry_staged === true,
+ })
+ if (!r.ok)
+ return { ok: false, error: r.error }
+ return { ok: true, branch: r.branch, projectPath: r.projectPath }
+ },
+ },
+ ]
+}
+
+// ---------------------------------------------------------------------------
+// HTTP 路由(客户端 /api/dsh-worktree/*)
+// ---------------------------------------------------------------------------
+
+/** 构建路由列表。 */
+export function buildRoutes(ctx: HostContext, config: PluginConfig): any[] {
+ const worktreesRoot = config.worktreesRoot || join(homedir(), '.dsh')
+
+ const routes = [
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/status`,
+ handler: routeHandler(async (body, req) => {
+ const url = new URL(req.url ?? '/', 'http://localhost')
+ const sessionId = String(url.searchParams.get('sessionId') ?? body.sessionId ?? '')
+ const ledger = await loadLedger(worktreesRoot)
+ const binding = ledger[sessionId] ?? null
+ const activeBinding = binding && existsSync(binding.worktreePath) ? binding : null
+ const session = findSession(ctx, sessionId)
+ const projectPath = binding?.projectPath ?? (await resolveProjectPath(ctx, session))
+ // 会话工作目录不在 git 仓库内时禁止工作树:isGit 供客户端隐藏模式选择器并强制本地模式。
+ // 会话未知(新建/启动竞态,尚无 cwd)时不猜测:isGit 置 null,客户端保持默认并稍后
+ // 重试,避免把 git 目录误判成非 git 而隐藏工作树模式选择器。
+ const isGit = projectPath ? Boolean(await gitToplevel(projectPath)) : null
+ return [200, activeBinding
+ ? {
+ mode: 'worktree',
+ hash: activeBinding.hash,
+ dirname: activeBinding.dirname,
+ worktreeKey: worktreeKey(activeBinding.hash, activeBinding.dirname),
+ worktreePath: activeBinding.worktreePath,
+ projectPath,
+ sourceSessionId: activeBinding.sourceSessionId,
+ log: Array.isArray(activeBinding.log) ? activeBinding.log : [],
+ isGit,
+ }
+ : { mode: 'local', projectPath: projectPath ?? '', isGit }]
+ }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/create`,
+ handler: routeHandler(async (body) => {
+ const sessionId = String(body.sessionId ?? '')
+ const sourceSessionId = String(body.sourceSessionId ?? sessionId)
+ if (!sessionId)
+ return [400, { error: '缺少 sessionId' }]
+ const sourceSession = findSession(ctx, sourceSessionId)
+ const projectPath = await resolveProjectPath(ctx, sourceSession)
+ if (!projectPath)
+ return [400, { error: '无法解析会话工作目录:会话尚未就绪,请稍后重试' }]
+ const r = await ensureWorktree(ctx, worktreesRoot, projectPath, sessionId, {
+ sourceSessionId,
+ carryStaged: body.carryStaged === true,
+ })
+ if (!r.ok)
+ return [400, { error: r.error }]
+ return [200, {
+ ok: true,
+ hash: r.binding.hash,
+ dirname: r.binding.dirname,
+ worktreeKey: worktreeKey(r.binding.hash, r.binding.dirname),
+ worktreePath: r.binding.worktreePath,
+ projectPath: r.binding.projectPath,
+ sourceSessionId: r.binding.sourceSessionId,
+ log: r.log,
+ existed: r.existed,
+ }]
+ }, { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/attach`,
+ handler: routeHandler(async (body) => {
+ const sessionId = String(body.sessionId ?? '')
+ if (!sessionId)
+ return [400, { error: '缺少 sessionId' }]
+ const ledger = await loadLedger(worktreesRoot)
+ const binding = ledger[sessionId]
+ if (!binding)
+ return [404, { error: '未找到绑定的工作树' }]
+ const workspace = await ctx.workspaceRegistry.resolveByPath(binding.projectPath)
+ if (!workspace)
+ return [404, { error: `未找到源工作区:${binding.projectPath}` }]
+ await workspace.attachSession(sessionId)
+ return [200, { ok: true, workspaceId: workspace.id }]
+ }, { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/checkout`,
+ handler: routeHandler(async (body) => {
+ // UI 检出:git 检出 + 把工作树会话完整历史带回本地新会话(targetSessionId)。
+ // body.carryStaged 可选:把工作树已暂存内容携带回本地检出。
+ const r = await checkoutToLocalAndHandback(ctx, worktreesRoot, {
+ sessionId: String(body.sessionId ?? ''),
+ worktree_hash_dirname: String(body.worktreeHashDirname ?? ''),
+ branch_name: String(body.branchName ?? ''),
+ }, { carryStaged: body.carryStaged === true })
+ if (!r.ok)
+ return [400, { error: r.error }]
+ return [200, {
+ ok: true,
+ branch: r.branch,
+ projectPath: r.projectPath,
+ targetSessionId: r.targetSessionId,
+ }]
+ }, { mutate: true }),
+ },
+ {
+ kind: 'exact',
+ path: `${API_PREFIX}/discard`,
+ handler: routeHandler(async (body) => {
+ const r = await discardWorktree(ctx, worktreesRoot, {
+ sessionId: String(body.sessionId ?? ''),
+ worktree_hash_dirname: String(body.worktreeHashDirname ?? ''),
+ })
+ if (!r.ok)
+ return [400, { error: r.error }]
+ return [200, { ok: true }]
+ }, { mutate: true }),
+ },
+ ]
+ return routes.map(route => ({
+ ...route,
+ handler: withConnectionAuth(ctx.connection, route.handler, 'dsh-tauri-worktree'),
+ }))
+}
+
+// ---------------------------------------------------------------------------
+// 插件入口
+// ---------------------------------------------------------------------------
+
+/**
+ * 插件体:注册工具、HTTP 路由与系统提示注入。
+ * @param {any} ctx - 客户端根上下文(注入 tools/systemPrompt/webServer/sessions/workspaceRegistry)。
+ * @param {Record<string, unknown>} [config] - 插件行配置(worktreesRoot 等)。
+ */
+export function apply(ctx: HostContext, config: PluginConfig = {}): void {
+ const cfg = config ?? {}
+ const worktreesRoot = typeof cfg.worktreesRoot === 'string' && cfg.worktreesRoot
+ ? cfg.worktreesRoot
+ : join(homedir(), '.dsh')
+
+ // 1) 工具注册。create_worktree 的交接延迟到源 turn/end,确保 seed 是完整日志。
+ const pendingHandoffs = new Map<string, PendingHandoff>()
+ // 只有 provider 确实参与过模型组装的会话,才允许在 turn/end 消费一次性上下文。
+ // 新继承会话发布、列表同步或其他空转事件不能提前清除它。
+ const injectedCheckoutContexts = new Set<string>()
+ for (const tool of createToolSet(ctx, cfg, pendingHandoffs)) {
+ ctx.tools.register(tool)
+ }
+ ctx.on('session/event', (session: any, event: any) => {
+ if (event.type !== 'turn/end')
+ return
+ const handoff = pendingHandoffs.get(session.id)
+ if (handoff) {
+ pendingHandoffs.delete(session.id)
+ void completeWorktreeHandoff(ctx, worktreesRoot, handoff)
+ }
+ // 仅当 systemPrompt.context provider 已实际返回过检出信息,才在该轮结束后消费。
+ // 否则新会话发布时出现的既有/空转 turn/end 会在用户首条消息前误删上下文。
+ if (injectedCheckoutContexts.delete(session.id))
+ void clearPendingCheckoutContext(worktreesRoot, session.id)
+ })
+
+ // 2) 自愈旧版本遗留:只注销普通 Workspace 记录,不删除工作树或会话。
+ ctx.effect(() => {
+ const ledger = loadLedgerSync(worktreesRoot)
+ void Promise.all(Object.values(ledger).map(binding => unregisterWorktreeWorkspace(ctx, binding.worktreePath)))
+ }, 'dsh-tauri-worktree: unregister legacy worktree workspaces')
+
+ // 3) 检出后的第一条用户消息:作为 DSH dynamic runtime context 注入,而不是
+ // 主动 followup 启动额外 turn。目标会话的 header.cwd 已绑定 projectPath。
+ ctx.systemPrompt.context({
+ name: 'plugin:dsh-tauri-worktree:checkout',
+ order: WORKTREE_SECTION_ORDER,
+ text: (context: any) => {
+ const sessionId = context?.scope?.session?.id
+ if (!sessionId)
+ return ''
+ const checkout = loadCheckoutContextsSync(worktreesRoot)[sessionId]
+ if (!checkout)
+ return ''
+ injectedCheckoutContexts.add(sessionId)
+ return (
+ `Worktree checkout completed.\n`
+ + `is_worktree: false\n`
+ + `Removed worktree: ${checkout.worktreePath ?? 'unknown'}\n`
+ + `Current local project directory: ${checkout.projectPath}\n`
+ + `Current local branch: ${checkout.branch ?? 'unknown'}\n\n`
+ + `Continue this request in the local project directory. Do not use the removed worktree path.`
+ )
+ },
+ })
+
+ // 4) 系统提示注入:处于工作树时会话的上下文标记 is_worktree: true。
+ ctx.systemPrompt.section({
+ name: 'plugin:dsh-tauri-worktree',
+ order: WORKTREE_SECTION_ORDER,
+ // 每次组装按调用作用域重算:scope 是该 Agent 时读其会话的绑定状态。
+ text: (context: any) => {
+ const session = context?.scope?.session
+ const sessionId = session?.id
+ if (!sessionId)
+ return ''
+ const ledger = loadLedgerSync(worktreesRoot)
+ const binding = ledger[sessionId]
+ if (!binding)
+ return ''
+ return (
+ `This session is running in an isolated worktree.\n`
+ + `is_worktree: true\n`
+ + `Worktree key: ${worktreeKey(binding.hash, binding.dirname)}\n`
+ + `Worktree path: ${binding.worktreePath}\n`
+ + `Project path: ${binding.projectPath}\n\n`
+ + `Make code changes inside the bound worktree and use its path as the shell workdir. `
+ + `The worktree contains only tracked files: node_modules and generated build dirs are not carried over, `
+ + `so if the project needs its dependencies, run the package manager install (e.g. \`pnpm install\`) inside the worktree first. `
+ + `checkout_worktree is user-authorized only: call it only after a direct human user explicitly requests or approves checkout. `
+ + `Task completion, a merged PR, or inferred convenience is not permission to call it. When checkout would be a natural next step, `
+ + `such as after a PR is merged, you may ask the user whether they want to check out the worktree; wait for their approval before calling.`
+ )
+ },
+ })
+
+ // 5) HTTP 路由注册(客户端 UI 经此调用 create/status/checkout/discard)。
+ ctx.effect(() => {
+ const disposers = buildRoutes(ctx, cfg).map(route => ctx.webServer.register(route))
+ return () => {
+ for (const dispose of disposers) dispose()
+ }
+ })
+}
diff --git a/packages/dsh-tauri-worktree/src/storage.ts b/packages/dsh-tauri-worktree/src/storage.ts
new file mode 100644
index 00000000..800402d0
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/storage.ts
@@ -0,0 +1,76 @@
+import type { CheckoutContext, CheckoutContexts, Ledger } from './types.js'
+import { randomUUID } from 'node:crypto'
+import { readFileSync } from 'node:fs'
+import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'
+import { join } from 'node:path'
+import process from 'node:process'
+
+const LEDGER_NAME = 'ledger.json'
+const CHECKOUT_CONTEXT_NAME = 'checkout-context.json'
+
+function ledgerPath(worktreesRoot: string): string {
+ return join(worktreesRoot, LEDGER_NAME)
+}
+
+function checkoutContextPath(worktreesRoot: string): string {
+ return join(worktreesRoot, CHECKOUT_CONTEXT_NAME)
+}
+
+function parseRecord<T>(value: string): Record<string, T> {
+ const parsed: unknown = JSON.parse(value)
+ return parsed && typeof parsed === 'object' ? parsed as Record<string, T> : {}
+}
+
+export async function loadLedger(worktreesRoot: string): Promise<Ledger> {
+ try {
+ return parseRecord(await readFile(ledgerPath(worktreesRoot), 'utf8'))
+ }
+ catch {
+ return {}
+ }
+}
+
+export function loadLedgerSync(worktreesRoot: string): Ledger {
+ try {
+ return parseRecord(readFileSync(ledgerPath(worktreesRoot), 'utf8'))
+ }
+ catch {
+ return {}
+ }
+}
+
+export async function saveLedger(worktreesRoot: string, ledger: Ledger): Promise<void> {
+ await mkdir(worktreesRoot, { recursive: true })
+ await writeFile(ledgerPath(worktreesRoot), `${JSON.stringify(ledger, null, 2)}\n`)
+}
+
+export function loadCheckoutContextsSync(worktreesRoot: string): CheckoutContexts {
+ try {
+ return parseRecord(readFileSync(checkoutContextPath(worktreesRoot), 'utf8'))
+ }
+ catch {
+ return {}
+ }
+}
+
+async function saveCheckoutContexts(worktreesRoot: string, contexts: CheckoutContexts): Promise<void> {
+ await mkdir(worktreesRoot, { recursive: true })
+ const path = checkoutContextPath(worktreesRoot)
+ const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`
+ await writeFile(temporary, `${JSON.stringify(contexts, null, 2)}\n`)
+ await rename(temporary, path)
+}
+
+export async function setPendingCheckoutContext(worktreesRoot: string, sessionId: string, context: CheckoutContext): Promise<void> {
+ const contexts = loadCheckoutContextsSync(worktreesRoot)
+ contexts[sessionId] = context
+ await saveCheckoutContexts(worktreesRoot, contexts)
+}
+
+export async function clearPendingCheckoutContext(worktreesRoot: string, sessionId: string): Promise<void> {
+ const contexts = loadCheckoutContextsSync(worktreesRoot)
+ if (!contexts[sessionId])
+ return
+ delete contexts[sessionId]
+ await saveCheckoutContexts(worktreesRoot, contexts)
+}
diff --git a/packages/dsh-tauri-worktree/src/types.ts b/packages/dsh-tauri-worktree/src/types.ts
new file mode 100644
index 00000000..928aec3c
--- /dev/null
+++ b/packages/dsh-tauri-worktree/src/types.ts
@@ -0,0 +1,74 @@
+export type HostContext = any
+
+export type JsonBody = Record<string, unknown>
+
+export interface PluginConfig {
+ worktreesRoot?: string
+}
+
+export interface Binding {
+ sessionId: string
+ sourceSessionId: string
+ hash: string
+ dirname: string
+ worktreePath: string
+ projectPath: string
+ branchName: string
+ ownsBranch: boolean
+ createdAt: string
+ log: string[]
+}
+
+export type Ledger = Record<string, Binding>
+
+export interface CheckoutContext {
+ projectPath: string
+ branch?: string
+ worktreePath?: string
+ checkedOutAt: string
+}
+
+export type CheckoutContexts = Record<string, CheckoutContext>
+
+export interface GitOptions {
+ timeout?: number
+ signal?: AbortSignal
+}
+
+export interface EnsureOptions extends GitOptions {
+ sourceSessionId?: string
+ branchName?: string
+ /** 是否把源仓库已暂存(index)内容携带进新工作树;默认 false。 */
+ carryStaged?: boolean
+}
+
+export interface CheckoutOptions extends GitOptions {
+ beforeRemove?: (checkout: { branch: string, projectPath: string, worktreePath: string }) => Promise<OperationResult<any>>
+ /** 是否把工作树已暂存(index)内容携带回本地检出;默认 false。 */
+ carryStaged?: boolean
+}
+
+export interface CheckoutInfo {
+ branch?: string
+ worktreePath?: string
+}
+
+export interface PendingHandoff {
+ sourceAgent: any
+ targetSessionId: string
+ binding: Binding
+}
+
+export type OperationResult<T extends object = Record<string, never>>
+ = | ({ ok: true } & T)
+ | { ok: false, error: string }
+
+export interface WorktreeParams {
+ worktree_hash_dirname?: string
+ worktreeHashDirname?: string
+ sessionId?: string
+ branch_name?: string
+}
+
+export type RouteResult = [number, unknown]
+export type RouteFunction = (body: JsonBody, req: import('node:http').IncomingMessage) => Promise<RouteResult>
diff --git a/packages/dsh-tauri-worktree/tsdown.config.ts b/packages/dsh-tauri-worktree/tsdown.config.ts
new file mode 100644
index 00000000..db7f42c0
--- /dev/null
+++ b/packages/dsh-tauri-worktree/tsdown.config.ts
@@ -0,0 +1,3 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig()
diff --git a/packages/dsh-tauri/README.md b/packages/dsh-tauri/README.md
new file mode 100644
index 00000000..95519575
--- /dev/null
+++ b/packages/dsh-tauri/README.md
@@ -0,0 +1,16 @@
+# dsh-tauri
+
+`dsh-tauri` 是 DSH Tauri 桌面壳的基础插件。它提供一个无宿主行为的 host half,以及运行在 DSH iframe 中的客户端消息桥。
+
+## 功能
+
+- 将宿主导航栏的侧边栏开关转发至 `layout.toggleSidebar`。
+- 将后退、前进命令转发至浏览器历史记录。
+- 向宿主回报侧边栏折叠状态和历史边界。
+- 隐藏与桌面导航栏重复的官方折叠控件。
+- 在插件自身异常时向宿主报告,避免静默失败。
+
+## 相关包
+
+- [`dsh-tauri-ui`](../dsh-tauri-ui):桌面化 UI。
+- [`dsh-tauri-worktree`](../dsh-tauri-worktree):会话级 Git worktree。
diff --git a/packages/dsh-tauri/cordis.patch.yml b/packages/dsh-tauri/cordis.patch.yml
new file mode 100644
index 00000000..d11b6bb0
--- /dev/null
+++ b/packages/dsh-tauri/cordis.patch.yml
@@ -0,0 +1,3 @@
+- insert:
+ - id: dsh-tauri
+ name: dsh-tauri
diff --git a/packages/dsh-tauri/package.json b/packages/dsh-tauri/package.json
new file mode 100644
index 00000000..b183ec9c
--- /dev/null
+++ b/packages/dsh-tauri/package.json
@@ -0,0 +1,62 @@
+{
+ "name": "dsh-tauri",
+ "type": "module",
+ "version": "0.6.7",
+ "author": "Hairyf <[email protected]>",
+ "license": "MIT",
+ "homepage": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins#readme",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git"
+ },
+ "bugs": "https://github.com/dsh-tauri-desk/dsh-tauri-plugins/issues",
+ "keywords": [
+ "dsh",
+ "plugin",
+ "dsh-plugin",
+ "tauri",
+ "deepseek-harness",
+ "bridge"
+ ],
+ "sideEffects": false,
+ "exports": {
+ ".": "./dist/index.js",
+ "./client": {
+ "types": "./dist/client.d.cts",
+ "default": "./dist/client.cjs"
+ },
+ "./package.json": "./package.json"
+ },
+ "main": "./dist/index.js",
+ "module": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "README.md",
+ "cordis.patch.yml",
+ "dist"
+ ],
+ "dsh": {
+ "client": {
+ "inject": [
+ "@deepseek-ai/dsh-client-runtime",
+ "@deepseek-ai/dsh-client-ui-layout"
+ ],
+ "platform": "web"
+ },
+ "bundle": {
+ "patch": "./cordis.patch.yml"
+ }
+ },
+ "scripts": {
+ "build": "tsdown",
+ "dev": "tsdown --watch",
+ "prepublishOnly": "nr build",
+ "start": "tsx src/index.ts",
+ "typecheck": "tsc"
+ },
+ "devDependencies": {
+ "css-render": "catalog:ui",
+ "dsh-tauri-tsdown": "workspace:*",
+ "tsdown": "catalog:cli"
+ }
+}
diff --git a/packages/dsh-tauri/src/client/bridge.ts b/packages/dsh-tauri/src/client/bridge.ts
new file mode 100644
index 00000000..1fb4804e
--- /dev/null
+++ b/packages/dsh-tauri/src/client/bridge.ts
@@ -0,0 +1,256 @@
+/**
+ * 导航桥核心(iframe 内):宿主(桌面壳层 ShellNavBar)↔ dsh 应用的消息协议。
+ *
+ * 消息(postMessage,双向):
+ * - 宿主 → iframe(命令):`{ source: 'dsh-desktop', type }`
+ * - `dsh://sidebar:toggle` 切换侧边栏(转发 ctx.layout.toggleSidebar)
+ * - `dsh://page:prev` 后退(会话访问栈回退)
+ * - `dsh://page:next` 前进(会话访问栈前进)
+ * - iframe → 宿主(事件):`{ source: 'dsh-nav-bridge', type, ... }`
+ * - `dsh://sidebar:collapsed` `{ collapsed }` 侧边栏折叠状态
+ * - `dsh://page:firsted` `{ firsted }` 已到访问栈最前(宿主应禁用后退)
+ * - `dsh://page:lasted` `{ lasted }` 已到访问栈最后(宿主应禁用前进)
+ *
+ * 页面模型:dsh 应用不产生浏览器历史(无 pushState/hash 路由),因此「页面」=
+ * 侧边栏当前选中的会话(`[role="treeitem"][aria-selected="true"]`)。本桥观察
+ * 选中会话变化维护一个**会话访问栈**(纯内存):用户点击会话 → 截断前进记录后
+ * 追加新页并上报;后退/前进 → 点击栈内对应会话行让应用切回。
+ *
+ * 本桥与桌面端注入脚本(NAV_SHIM_JS)语义完全一致;插件加载后设置
+ * `window.__dsh_tauri_bridge__`,注入脚本据此让位(避免命令/事件双重执行)。
+ * 宿主仅接受 iframe 直接发来的消息(event.source === window.parent)。
+ *
+ * 桥内代码路径(观测器回调、导航、命令分发)统一经 `error.ts` 上报宿主:
+ * key 与桌面端 `use-iframe-shim.ts` 校验保持一致,宿主持久化后「插件」面板
+ * 显示 danger 标记,避免静默失败。
+ */
+import type { NavBridgeHandlers, Page } from './types'
+import {
+ CMD_NEXT,
+ CMD_PREV,
+ CMD_TOGGLE,
+ EVENT_PAGE_FIRSTED,
+ EVENT_PAGE_LASTED,
+ EVENT_SIDEBAR_COLLAPSED,
+ SESSION_LABEL_PATTERNS,
+ SRC_BRIDGE,
+ SRC_HOST,
+ TRACK_INTERVAL_MS,
+ TRACK_MAX_TRIES,
+} from './constants'
+import { guard, reportPluginError } from './error'
+
+export type { NavBridgeHandlers } from './types'
+
+/**
+ * 安装导航桥:设置接管标记、挂载命令监听、侧边栏状态观察与会话访问栈跟踪。
+ * @returns 卸载函数(插件重载/停用时清理,桌面端注入脚本随即恢复接管)。
+ */
+export function setupNavBridge(handlers: NavBridgeHandlers): () => void {
+ // 接管标记:置位后桌面端 NAV_SHIM_JS 的命令与事件都让位
+ window.__dsh_tauri_bridge__ = true
+
+ function post(message: Record<string, unknown>): void {
+ try {
+ window.parent.postMessage(Object.assign({ source: SRC_BRIDGE }, message), '*')
+ }
+ catch {
+ // 宿主已销毁等场景静默
+ }
+ }
+
+ // ── AppFrame:dsh 应用布局的根(shell.overlay 的父节点)───────
+ function findFrame(): HTMLElement | null {
+ const overlay = document.querySelector<HTMLElement>('[data-shell-overlay]')
+ return overlay ? (overlay.parentElement as HTMLElement | null) : null
+ }
+
+ // ── 侧边栏折叠状态(观察 AppFrame 的 data-sidebar-collapsed)────
+ function collapsedOf(): boolean {
+ const frame = findFrame()
+ return !!(frame && frame.hasAttribute('data-sidebar-collapsed'))
+ }
+
+ const sidebarObserver = new MutationObserver(guard(() => {
+ post({ type: EVENT_SIDEBAR_COLLAPSED, collapsed: collapsedOf() })
+ }))
+
+ // ── 会话访问栈(页面模型,纯内存)────────────────────────────
+ let pages: Page[] = []
+ let position = 0
+ let lastKey: string | null = null
+ /** 本桥触发的导航(后退/前进)落位中,观察器不应记录新页面。 */
+ let suppress = false
+
+ // 当前选中的会话行(AppFrame 侧边栏列内)
+ function currentSelected(): HTMLElement | null {
+ const frame = findFrame()
+ const col = frame ? frame.firstElementChild : null
+ if (!col)
+ return null
+ return col.querySelector<HTMLElement>('[role="treeitem"][aria-selected="true"]')
+ }
+
+ // 行标题:从行内菜单按钮 aria-label 提取(zh/en),失败回退整行文本
+ function rowTitle(row: HTMLElement | null): string {
+ if (!row)
+ return ''
+ const btn = row.querySelector<HTMLElement>('button[aria-label]')
+ const label = btn ? (btn.getAttribute('aria-label') || '') : ''
+ for (const pattern of SESSION_LABEL_PATTERNS) {
+ const match = pattern.exec(label)
+ if (match)
+ return match[1]!.trim()
+ }
+ return label || (row.textContent || '').trim()
+ }
+
+ // 按标题找会话行(行元素被重建后的兜底)
+ function findRowByTitle(title: string): HTMLElement | null {
+ if (!title)
+ return null
+ const frame = findFrame()
+ const col = frame ? frame.firstElementChild : null
+ if (!col)
+ return null
+ const rows = col.querySelectorAll<HTMLElement>('[role="treeitem"]')
+ for (const row of rows) {
+ if (rowTitle(row) === title)
+ return row
+ }
+ return null
+ }
+
+ function reportPage(): void {
+ post({ type: EVENT_PAGE_FIRSTED, firsted: position <= 0 })
+ post({ type: EVENT_PAGE_LASTED, lasted: position >= pages.length - 1 })
+ }
+
+ // 用户导航到新会话:截断前进记录后追加
+ function pushPage(key: string, el: HTMLElement | null): void {
+ pages = pages.slice(0, position + 1).concat([{ key, el }])
+ position = pages.length - 1
+ reportPage()
+ }
+
+ // 后退/前进:切到栈内目标页(点击对应会话行让应用落位)
+ function navigateTo(index: number): void {
+ try {
+ if (index < 0 || index >= pages.length)
+ return
+ const page = pages[index]!
+ position = index
+ const target = page.el && page.el.isConnected ? page.el : findRowByTitle(page.key ?? '')
+ if (target) {
+ suppress = true
+ target.click()
+ }
+ reportPage()
+ }
+ catch (error) {
+ // 行元素被重建/点击触发应用异常等:上报宿主,栈内记录保持一致
+ reportPluginError(error, 'runtime')
+ }
+ }
+
+ const onDomChange = guard(() => {
+ const sel = currentSelected()
+ const key = rowTitle(sel)
+ if (key === lastKey)
+ return
+ lastKey = key
+ if (suppress) {
+ // 本桥导航落位:同步当前页记录(行元素可能被 React 重建)
+ suppress = false
+ if (pages[position] !== undefined) {
+ pages[position] = { key, el: sel }
+ }
+ return
+ }
+ // 用户主动切换会话(无选中 = 欢迎/归档态,不入栈)
+ if (key)
+ pushPage(key, sel)
+ })
+
+ const pageObserver = new MutationObserver(onDomChange)
+
+ // 初始化:应用挂载前无会话树,轮询补报直到拿到 AppFrame
+ function startTrack(): boolean {
+ try {
+ const frame = findFrame()
+ if (!frame)
+ return false
+ sidebarObserver.observe(frame, { attributes: true, attributeFilter: ['data-sidebar-collapsed'] })
+ post({ type: EVENT_SIDEBAR_COLLAPSED, collapsed: collapsedOf() })
+
+ const sel = currentSelected()
+ const key = rowTitle(sel)
+ lastKey = key
+ // 根页:当前选中的会话(无选中时以「欢迎页」为根,首个会话打开即入栈)
+ pages = [{ key: key || null, el: sel }]
+ position = 0
+ pageObserver.observe(document.body, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeFilter: ['aria-selected'],
+ })
+ reportPage()
+ return true
+ }
+ catch (error) {
+ // 布局结构异常等:上报宿主并返回 false,轮询会继续补报直到成功
+ reportPluginError(error, 'runtime')
+ return false
+ }
+ }
+
+ // ── 宿主命令接收 ──────────────────────────────────────────────
+ function onMessage(event: MessageEvent<unknown>): void {
+ // 只接受宿主窗口直发的命令;不兼容多层嵌套 iframe
+ if (event.source !== window.parent)
+ return
+ const data = event.data as { source?: string, type?: string } | null
+ if (!data || typeof data !== 'object' || data.source !== SRC_HOST)
+ return
+ try {
+ switch (data.type) {
+ case CMD_TOGGLE:
+ handlers.toggleSidebar()
+ break
+ case CMD_PREV:
+ navigateTo(position - 1)
+ break
+ case CMD_NEXT:
+ navigateTo(position + 1)
+ break
+ }
+ }
+ catch (error) {
+ // 命令处理(layout 切换/导航)抛错:上报宿主,不中断后续命令
+ reportPluginError(error, 'runtime')
+ }
+ }
+ window.addEventListener('message', onMessage)
+
+ // ── 初始化 + 应用晚挂载的轮询补报 ──────────────────────────
+ let trackTimer: ReturnType<typeof setInterval> | undefined
+ if (!startTrack()) {
+ let tries = 0
+ trackTimer = setInterval(() => {
+ if (startTrack() || ++tries > TRACK_MAX_TRIES) {
+ clearInterval(trackTimer)
+ }
+ }, TRACK_INTERVAL_MS)
+ }
+
+ // ── 卸载 ──────────────────────────────────────────────────────
+ return () => {
+ delete window.__dsh_tauri_bridge__
+ window.removeEventListener('message', onMessage)
+ sidebarObserver.disconnect()
+ pageObserver.disconnect()
+ if (trackTimer !== undefined)
+ clearInterval(trackTimer)
+ }
+}
diff --git a/packages/dsh-tauri/src/client/compat.ts b/packages/dsh-tauri/src/client/compat.ts
new file mode 100644
index 00000000..947cb40d
--- /dev/null
+++ b/packages/dsh-tauri/src/client/compat.ts
@@ -0,0 +1,151 @@
+import type { ClientContext } from './types'
+
+type RuntimeObject = Record<string, unknown>
+export type StartSession = (workspaceId?: string) => unknown
+
+/** Read a service without triggering Cordis' inject-only property guard. */
+function lookup(ctx: ClientContext, name: string): unknown {
+ const anyCtx = ctx as unknown as { get?: (name: string) => unknown } & RuntimeObject
+ try {
+ return typeof anyCtx.get === 'function' ? anyCtx.get(name) : anyCtx[name]
+ }
+ catch {
+ return undefined
+ }
+}
+
+/** Resolve the navigation method across Alpha and rc.2 service layouts. */
+export function resolveStartSession(ctx: ClientContext): StartSession | undefined {
+ const uiWorkspace = lookup(ctx, 'uiWorkspace') as RuntimeObject | undefined
+ const workspaces = lookup(ctx, 'workspaces') as RuntimeObject | undefined
+ const owner = uiWorkspace ?? workspaces
+ const fn = owner?.startSession
+ return typeof fn === 'function' ? (workspaceId?: string) => fn.call(owner, workspaceId) : undefined
+}
+
+/** Adapt alpha's nested list/navigation services to the rc.2 plugin contract. */
+export function compat(ctx: ClientContext): ClientContext {
+ const safeLookup = (name: string): unknown => lookup(ctx, name)
+
+ // Inline Alpha Detection: 判断当前环境是否为 Alpha 版本
+ const alphaSessions = safeLookup('sessions') as RuntimeObject | undefined
+ const isAlpha
+ = (alphaSessions?.list !== undefined && typeof alphaSessions.getSnapshot !== 'function')
+ || safeLookup('uiWorkspace') !== undefined
+
+ if (!isAlpha)
+ return ctx
+
+ // 补全当前环境的对象引用
+ const rawSessions = (alphaSessions ?? {}) as RuntimeObject
+ const rawWorkspaces = (safeLookup('workspaces') ?? {}) as RuntimeObject
+ const uiWorkspace = safeLookup('uiWorkspace') as RuntimeObject | undefined
+ const uiSession = safeLookup('uiSession') as RuntimeObject | undefined
+
+ // Inline Auto-Bind Proxy: 为 snapshot 绑定 Proxy 实例
+ const createBoundProxy = (target: unknown): RuntimeObject | undefined => {
+ if (!target || (typeof target !== 'object' && typeof target !== 'function'))
+ return undefined
+ return new Proxy(target as object, {
+ get(t, p, r) {
+ const member = Reflect.get(t, p, r)
+ return typeof member === 'function' ? member.bind(t) : member
+ },
+ }) as RuntimeObject
+ }
+
+ const list = createBoundProxy(rawSessions.list)
+ const workspaceList = createBoundProxy(rawWorkspaces.list)
+
+ // 映射 sessions 适配层
+ const sessions = new Proxy(rawSessions as object, {
+ get(target, prop, receiver) {
+ if (prop === 'list')
+ return list
+ if (prop === 'getSnapshot')
+ return () => (list?.getSnapshot as (() => unknown) | undefined)?.()
+ if (prop === 'subscribe')
+ return (l: () => void) => (list?.subscribe as ((cb: () => void) => unknown) | undefined)?.(l)
+ if (prop === 'provideInfo')
+ return (id: string) => provideInfo(rawSessions, id, uiSession)
+ const member = Reflect.get(target, prop, receiver)
+ return typeof member === 'function' ? member.bind(target) : member
+ },
+ }) as unknown as RuntimeObject
+
+ // 映射 workspaces 适配层
+ const workspaces = new Proxy(rawWorkspaces as object, {
+ get(target, prop, receiver) {
+ if (prop === 'list')
+ return workspaceList
+ if (prop === 'startSession') {
+ // rc.2 官方运行时的 workspaces 自身已提供 startSession;旧 alpha 才经由
+ // 独立的 uiWorkspace 服务暴露。优先 uiWorkspace,缺失时回退到 rawWorkspaces,
+ // 避免按钮点击被静默吞掉。
+ const owner = uiWorkspace ?? rawWorkspaces
+ const fn = owner.startSession
+ return typeof fn === 'function' ? (id?: string) => fn.call(owner, id) : undefined
+ }
+ if (prop === 'connectWorkspace') {
+ const owner = uiWorkspace ?? rawWorkspaces
+ const fn = owner.connectWorkspace
+ return typeof fn === 'function' ? (id: string) => fn.call(owner, id) : undefined
+ }
+
+ return Reflect.get(target, prop, receiver)
+ },
+ }) as unknown as RuntimeObject
+
+ // 返回最终的上下文代理对象
+ return new Proxy(ctx, {
+ get(target, prop, receiver) {
+ if (prop === 'sessions')
+ return sessions
+ if (prop === 'workspaces')
+ return workspaces
+ return Reflect.get(target, prop, receiver)
+ },
+ })
+}
+
+/**
+ * Alpha deliberately does not expose the old per-session info lookup. Try
+ * documented scope/provide implementations when a shell supplies one, but
+ * never make a plugin fail merely because that optional bridge is absent.
+ */
+function provideInfo(sessions: RuntimeObject, id: string, uiSession: RuntimeObject | undefined): unknown {
+ // Some desktop runtimes expose the complete per-session projection on the
+ // sessions service even though their list shape still looks like Alpha.
+ // Preserve that native path first; the adapter fallback below is only for
+ // runtimes that genuinely lack sessions.provideInfo().
+ const nativeProvideInfo = sessions.provideInfo
+ if (typeof nativeProvideInfo === 'function') {
+ try {
+ return nativeProvideInfo.call(sessions, id)
+ }
+ catch {
+ // The session may still be materializing; try the compatibility path.
+ }
+ }
+ const bindingFn = sessions.binding
+ const binding = typeof bindingFn === 'function' ? bindingFn.call(sessions, id) : undefined
+ if (!binding)
+ return undefined
+
+ const adapter = uiSession?.adapter as RuntimeObject | undefined
+ const resolveFn = adapter?.resolve
+
+ if (typeof resolveFn === 'function') {
+ try {
+ const projected = resolveFn.call(adapter, id) as RuntimeObject | undefined
+ const inputActions = (projected?.props as RuntimeObject | undefined)?.inputActions
+ if (inputActions !== undefined) {
+ return { props: { inputActions } }
+ }
+ }
+ catch {
+ // The binding can disappear while a newly-created session is materialized.
+ }
+ }
+ return undefined
+}
diff --git a/packages/dsh-tauri/src/client/constants.ts b/packages/dsh-tauri/src/client/constants.ts
new file mode 100644
index 00000000..b48c65c1
--- /dev/null
+++ b/packages/dsh-tauri/src/client/constants.ts
@@ -0,0 +1,44 @@
+/** 宿主 → iframe 命令的 source。 */
+export const SRC_HOST = 'dsh-desktop'
+
+/** iframe → 宿主事件的 source。 */
+export const SRC_BRIDGE = 'dsh-nav-bridge'
+
+/** 宿主命令类型。 */
+export const CMD_TOGGLE = 'dsh://sidebar:toggle'
+export const CMD_PREV = 'dsh://page:prev'
+export const CMD_NEXT = 'dsh://page:next'
+
+/** iframe → 宿主状态事件类型。 */
+export const EVENT_SIDEBAR_COLLAPSED = 'dsh://sidebar:collapsed'
+export const EVENT_PAGE_FIRSTED = 'dsh://page:firsted'
+export const EVENT_PAGE_LASTED = 'dsh://page:lasted'
+
+/** 应用晚挂载时的导航桥探测参数。 */
+export const TRACK_MAX_TRIES = 30
+export const TRACK_INTERVAL_MS = 500
+
+/** 会话行菜单按钮的 aria-label 模板(zh/en),用于提取标题与按标题找行。 */
+export const SESSION_LABEL_PATTERNS = [
+ /^会话“(.+)”的操作$/,
+ /^Session actions for (.+)$/,
+] as const
+
+/** 上报消息的 source key(宿主校验:`source === 'dsh-plugin-error-bridge'`)。 */
+export const ERROR_SRC = 'dsh-plugin-error-bridge'
+
+/** 上报消息的 type key(宿主校验:`type === 'dsh://plugin-error'`)。 */
+export const ERROR_TYPE = 'dsh://plugin-error'
+
+/** 插件 id(npm 包名):宿主错误注册表与插件列表的主键。 */
+export const PLUGIN_ID = 'dsh-tauri'
+
+/** 客户端插件元数据与生命周期标识。 */
+export const PLUGIN_INJECT = ['layout']
+export const SIDEBAR_TWEAKS_STYLE_ID = 'dsh-tauri:sidebar-tweaks'
+export const SIDEBAR_TWEAKS_EFFECT_ID = 'dsh-tauri: sidebar tweaks (hide collapse toggle, center brand)'
+export const NAV_BRIDGE_EFFECT_ID = 'dsh-tauri: nav bridge'
+
+/** 侧边栏稳定 ARIA 选择器。 */
+export const COLLAPSE_SIDEBAR_SELECTOR = 'button[aria-label="收起侧边栏"],button[aria-label="Collapse sidebar"]'
+export const NEW_SESSION_SELECTOR = 'button[aria-label="新建会话"],button[aria-label="New session"]'
diff --git a/packages/dsh-tauri/src/client/error.ts b/packages/dsh-tauri/src/client/error.ts
new file mode 100644
index 00000000..f7bf1c2d
--- /dev/null
+++ b/packages/dsh-tauri/src/client/error.ts
@@ -0,0 +1,57 @@
+/**
+ * 错误上报桥(iframe 内 → 桌面宿主)。
+ *
+ * 与桌面端 `use-iframe-shim.ts` 的协议逐字一致 —— 宿主只接受完全匹配的 key,
+ * 任何一处不一致都会被静默丢弃:
+ *
+ * { source: 'dsh-plugin-error-bridge', type: 'dsh://plugin-error', id, error, action }
+ *
+ * 宿主收到后经 `report_plugin_error` 持久化到插件错误注册表
+ * (plugin-errors.json,按插件 id 幂等覆盖并推送新列表),「插件」面板据此
+ * 给本插件显示 danger 标记与更新/卸载入口。
+ */
+import type { ErrorAction } from './types'
+import { ERROR_SRC, ERROR_TYPE, PLUGIN_ID } from './constants'
+
+export { ERROR_SRC, ERROR_TYPE, PLUGIN_ID } from './constants'
+export type { ErrorAction } from './types'
+
+/**
+ * 上报插件运行期错误到宿主。
+ * @param error 错误对象/消息(宿主截断保留 2000 字符)
+ * @param action 记录动作,默认 runtime
+ */
+export function reportPluginError(error: unknown, action: ErrorAction = 'runtime'): void {
+ const message = (error instanceof Error ? `${error.name}: ${error.message}` : String(error))
+ .trim()
+ .slice(0, 2000)
+ if (!message)
+ return
+ const payload = { source: ERROR_SRC, type: ERROR_TYPE, id: PLUGIN_ID, error: message, action }
+ try {
+ window.parent.postMessage(payload, '*')
+ }
+ catch {
+ // 宿主已销毁等场景静默(与导航桥 post 的行为一致)
+ }
+}
+
+/**
+ * 把可能抛错的回调包装成「捕获 + 上报 + 继续执行」的安全回调:
+ * 观测器/监听器回调一旦抛错会变成 uncaught error,宿主无从知晓;包装后统一
+ * 上报为本插件的 runtime 错误。
+ *
+ * 注意只包插件自身代码路径,**不**监听全局 error/unhandledrejection —— dsh
+ * 应用与本插件共享同一页面,全量捕获会把整个应用的异常都记到本插件名下,
+ * 污染宿主错误注册表。
+ */
+export function guard<T extends unknown[]>(fn: (...args: T) => void): (...args: T) => void {
+ return (...args: T) => {
+ try {
+ fn(...args)
+ }
+ catch (error) {
+ reportPluginError(error, 'runtime')
+ }
+ }
+}
diff --git a/packages/dsh-tauri/src/client/http.ts b/packages/dsh-tauri/src/client/http.ts
new file mode 100644
index 00000000..4f68c925
--- /dev/null
+++ b/packages/dsh-tauri/src/client/http.ts
@@ -0,0 +1,91 @@
+/**
+ * Shared JSON HTTP client for browser halves that call a plugin host route.
+ *
+ * This stays dependency-free because the client bundle is loaded by DSH's
+ * ModuleLoader; a small common primitive is safer than adding a copy of an
+ * HTTP library to every plugin's published client artifact.
+ */
+
+export interface JsonRequestOptions {
+ /** Abort the request after this many milliseconds; omit to disable timeout. */
+ timeoutMs?: number
+ /** Convert a failed response into the plugin's localized error message. */
+ errorMessage?: (status: number, body: unknown) => string
+ /** Convert an abort caused by timeout into the plugin's localized message. */
+ timeoutMessage?: string
+}
+
+function defaultErrorMessage(status: number, body: unknown): string {
+ if (body && typeof body === 'object' && !Array.isArray(body)) {
+ const error = (body as { error?: unknown }).error
+ if (typeof error === 'string' && error.length > 0)
+ return error
+ }
+ return `HTTP ${status}`
+}
+
+/**
+ * Request a JSON endpoint with consistent response decoding and timeout cleanup.
+ * Mutation callers must opt into their own retry policy; this helper never retries.
+ */
+export async function requestJson<T>(
+ baseUrl: string,
+ path: string,
+ init: RequestInit = {},
+ options: JsonRequestOptions = {},
+): Promise<T> {
+ const timeoutMs = options.timeoutMs
+ const timeoutEnabled = timeoutMs !== undefined && timeoutMs > 0
+ const controller = timeoutEnabled ? new AbortController() : undefined
+ let timedOut = false
+ let timeout: ReturnType<typeof setTimeout> | undefined
+
+ if (controller !== undefined) {
+ timeout = setTimeout(() => {
+ timedOut = true
+ controller.abort()
+ }, timeoutMs)
+ if (init.signal !== undefined) {
+ if (init.signal.aborted)
+ controller.abort()
+ else
+ init.signal.addEventListener('abort', () => controller.abort(), { once: true })
+ }
+ }
+
+ try {
+ const headers = new Headers(init.headers)
+ if (!headers.has('content-type') && init.body !== undefined)
+ headers.set('content-type', 'application/json')
+ const response = await fetch(`${baseUrl}${path}`, {
+ ...init,
+ headers,
+ ...(controller !== undefined ? { signal: controller.signal } : {}),
+ })
+ const text = await response.text()
+ const body: unknown = text.length > 0 ? JSON.parse(text) : undefined
+ if (!response.ok)
+ throw new Error((options.errorMessage ?? defaultErrorMessage)(response.status, body))
+ return body as T
+ }
+ catch (error) {
+ if (timedOut || (error instanceof Error && error.name === 'AbortError' && timeoutEnabled))
+ throw new Error(options.timeoutMessage ?? '请求超时')
+ throw error
+ }
+ finally {
+ if (timeout !== undefined)
+ clearTimeout(timeout)
+ }
+}
+
+/** Create a small path-bound client for one plugin API prefix. */
+export function createJsonClient(baseUrl: string, options: JsonRequestOptions = {}) {
+ return {
+ request: <T>(path: string, init?: RequestInit): Promise<T> => requestJson<T>(baseUrl, path, init, options),
+ post: <T>(path: string, body: unknown): Promise<T> => requestJson<T>(baseUrl, path, {
+ method: 'POST',
+ body: JSON.stringify(body),
+ }, options),
+ }
+}
diff --git a/packages/dsh-tauri/src/client/index.ts b/packages/dsh-tauri/src/client/index.ts
new file mode 100644
index 00000000..04b0abb6
--- /dev/null
+++ b/packages/dsh-tauri/src/client/index.ts
@@ -0,0 +1,92 @@
+import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
+/**
+ * dsh-tauri 客户端插件体(browser half):纯消息桥,无 UI、无运行时依赖。
+ *
+ * 桌面端顶部导航栏(shell-nav-bar.tsx)常驻在 Tauri 宿主,其左侧三个控件
+ * (侧边栏 / 后退 / 前进)通过 postMessage 操控 iframe 内的 dsh 应用;
+ * 本插件是 iframe 内的接收端:把命令转发给 dsh(侧边栏切换走
+ * `ctx.layout.toggleSidebar`,后退/前进走 `window.history`),并把 dsh 状态
+ * (侧边栏折叠、页面历史边界)回报给宿主。协议详见 `./bridge.ts`。
+ *
+ * 另:官方侧边栏 logo 行自带的「收起侧边栏」按钮与宿主顶部导航栏的侧边栏
+ * 开关重复,插件加载时用一条 CSS 规则把它隐藏(折叠态窄栏的「打开侧边栏」
+ * 按钮保留,窄栏恢复仍靠它);同时把品牌词标按钮(aria-label「新建会话」,
+ * CSS module 类名是生成哈希、不稳定)的内容改为水平居中。
+ *
+ * 服务依赖(inject):layout(侧边栏切换)。locale/slots 均不再需要。
+ */
+import type { ClientContext } from './types'
+import { CssRender } from 'css-render'
+import { setupNavBridge } from './bridge'
+import {
+ COLLAPSE_SIDEBAR_SELECTOR,
+ NAV_BRIDGE_EFFECT_ID,
+ NEW_SESSION_SELECTOR,
+ PLUGIN_ID,
+ PLUGIN_INJECT,
+ SIDEBAR_TWEAKS_EFFECT_ID,
+ SIDEBAR_TWEAKS_STYLE_ID,
+} from './constants'
+import { reportPluginError } from './error'
+
+/** 插件显示名(诊断元数据)。 */
+export const name = PLUGIN_ID
+
+/** 需要的客户端服务:layout(侧边栏切换)。 */
+export const inject = PLUGIN_INJECT
+
+export { compat, resolveStartSession } from './compat'
+export * from './store'
+
+export type * from './types'
+export { CssRender } from 'css-render'
+
+/**
+ * 插件体:接管导航桥(置位接管标记 → 挂命令监听/状态观察/历史跟踪)。
+ * @param ctx - 客户端根上下文。
+ */
+export function apply(ctx: ClientContext): void {
+ ;(window as Window & { ctx?: ClientContext }).ctx = ctx
+
+ ctx.effect(() => {
+ // 侧边栏 UI 微调(一律用稳定的 aria-label 属性选择器,不用生成哈希的
+ // CSS module 类名):
+ // 1. 隐藏 logo 行的「收起侧边栏」按钮:宿主导航栏已有侧边栏开关,应用内
+ // 这个折叠按钮属于重复控件。只匹配折叠态文案(zh/en),窄栏恢复用的
+ // 「打开侧边栏」按钮保留。
+ // 2. 品牌词标按钮(与工具栏「新建会话」按钮共用 aria-label,后者本就
+ // 居中,此规则对其是 no-op)默认 flex-start,改为水平居中。
+ // CSS 选择器天然覆盖 React 后续重渲染,卸载时移除样式。
+ let styleCleanup: (() => void) | undefined
+ try {
+ const cssr = CssRender()
+ const { c } = cssr
+ const style = c([
+ c(COLLAPSE_SIDEBAR_SELECTOR, { display: 'none !important' }),
+ c(NEW_SESSION_SELECTOR, { justifyContent: 'center !important' }),
+ ])
+ style.mount({ id: SIDEBAR_TWEAKS_STYLE_ID, head: true })
+ styleCleanup = () => style.unmount({ id: SIDEBAR_TWEAKS_STYLE_ID })
+ }
+ catch (error) {
+ // 插件自身代码路径异常:上报宿主,避免静默失败
+ reportPluginError(error, 'runtime')
+ }
+ return () => styleCleanup?.()
+ }, SIDEBAR_TWEAKS_EFFECT_ID)
+
+ ctx.effect(() => {
+ // 导航桥启动:初始化失败也上报(桥内部有各自的 guard/兜底轮询,这里只
+ // 兜 setupNavBridge 首次同步执行期间的异常)。
+ let navCleanup: (() => void) | undefined
+ try {
+ navCleanup = setupNavBridge({
+ toggleSidebar: () => { ctx.layout.toggleSidebar() },
+ })
+ }
+ catch (error) {
+ reportPluginError(error, 'runtime')
+ }
+ return () => navCleanup?.()
+ }, NAV_BRIDGE_EFFECT_ID)
+}
diff --git a/packages/dsh-tauri/src/client/store.ts b/packages/dsh-tauri/src/client/store.ts
new file mode 100644
index 00000000..deb8cd01
--- /dev/null
+++ b/packages/dsh-tauri/src/client/store.ts
@@ -0,0 +1,86 @@
+/**
+ * Framework-neutral external state store.
+ *
+ * This store is intentionally independent of React and Cordis so it can be
+ * shared by slot components, hydration/controllers, and DOM observers. React
+ * consumers can connect it with `useSyncExternalStore`.
+ *
+ * State updates are immutable: callers return the next state instead of
+ * mutating a draft. This avoids cloning the whole state tree for every update
+ * and makes the ownership of each state transition explicit.
+ */
+
+export type StoreUpdater<T> = (current: T) => T
+export type StoreValue<T> = T | StoreUpdater<T>
+export type StoreListener = () => void
+
+export interface ExternalStore<T> {
+ /** Returns the same reference until a real state change is committed. */
+ getSnapshot: () => T
+ /** Subscribes to committed state changes and returns an unsubscribe function. */
+ subscribe: (listener: StoreListener) => () => void
+ /** Replaces the state, or derives the next state from the current state. */
+ set: (next: StoreValue<T>) => void
+}
+
+/**
+ * Creates a small external store for state shared across independent plugin
+ * slots or non-React controllers.
+ */
+export function createExternalStore<T>(initial: T): ExternalStore<T> {
+ let state = initial
+ const listeners = new Set<StoreListener>()
+
+ function set(next: StoreValue<T>): void {
+ const nextState = typeof next === 'function'
+ ? (next as StoreUpdater<T>)(state)
+ : next
+
+ // Besides avoiding needless React renders, this preserves the
+ // useSyncExternalStore requirement that snapshots remain stable when
+ // nothing observable changed.
+ if (Object.is(nextState, state))
+ return
+
+ state = nextState
+ notify()
+ }
+
+ function subscribe(listener: StoreListener): () => void {
+ listeners.add(listener)
+ return () => {
+ listeners.delete(listener)
+ }
+ }
+
+ function notify(): void {
+ // Iterate over a snapshot so a listener may safely unsubscribe itself or
+ // another listener while notification is in progress.
+ for (const listener of [...listeners])
+ listener()
+ }
+
+ function getSnapshot(): T {
+ return state
+ }
+
+ return { getSnapshot, subscribe, set }
+}
+
+/**
+ * A deliberately tiny signal for invalidating derived UI such as locale
+ * revisions without allocating `{ rev: number }` snapshots.
+ */
+export interface RevisionSignal extends ExternalStore<number> {
+ bump: () => void
+}
+
+export function createRevisionSignal(initial = 0): RevisionSignal {
+ const store = createExternalStore(initial)
+ return {
+ ...store,
+ bump: () => {
+ store.set(revision => revision + 1)
+ },
+ }
+}
diff --git a/packages/dsh-tauri/src/client/types/bridge.ts b/packages/dsh-tauri/src/client/types/bridge.ts
new file mode 100644
index 00000000..56d38835
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/bridge.ts
@@ -0,0 +1,13 @@
+/** 宿主命令所需的业务面(由插件体注入 ctx.layout)。 */
+export interface NavBridgeHandlers {
+ toggleSidebar: () => void
+}
+
+/** 会话访问栈中的页面。 */
+export interface Page {
+ key: string | null
+ el: HTMLElement | null
+}
+
+/** 记录动作(与宿主 `PluginError.action` 语义一致)。 */
+export type ErrorAction = 'runtime' | 'install' | 'update' | 'remove'
diff --git a/packages/dsh-tauri/src/client/types/context.ts b/packages/dsh-tauri/src/client/types/context.ts
new file mode 100644
index 00000000..300319ea
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/context.ts
@@ -0,0 +1,8 @@
+import type { Context } from '@deepseek-ai/cordis'
+import type { ILayout, LocaleService } from './inject'
+
+/** Cordis context with the client services consumed by the Tauri plugins. */
+export type ClientContext = Context & {
+ locale: LocaleService
+ layout: ILayout
+}
diff --git a/packages/dsh-tauri/src/client/types/global.ts b/packages/dsh-tauri/src/client/types/global.ts
new file mode 100644
index 00000000..f9e000c0
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/global.ts
@@ -0,0 +1,8 @@
+declare global {
+ interface Window {
+ /** 插件接管标记:桌面端 NAV_SHIM_JS 检测到后停止收发,避免双重执行。 */
+ __dsh_tauri_bridge__?: boolean
+ }
+}
+
+export {}
diff --git a/packages/dsh-tauri/src/client/types/index.ts b/packages/dsh-tauri/src/client/types/index.ts
new file mode 100644
index 00000000..33c3e654
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/index.ts
@@ -0,0 +1,5 @@
+export * from './bridge'
+export * from './context'
+export * from './global'
+export * from './inject'
+export * from './runtime'
diff --git a/packages/dsh-tauri/src/client/types/inject.ts b/packages/dsh-tauri/src/client/types/inject.ts
new file mode 100644
index 00000000..76b25f0d
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/inject.ts
@@ -0,0 +1,7 @@
+export type { ILayout } from '@deepseek-ai/dsh-client-ui-layout/client'
+
+export interface LocaleService {
+ register: (namespace: string, locale: string, dict: Record<string, unknown>) => () => void
+ getLocale: () => { active: string }
+ subscribe: (onChange: () => void) => () => void
+}
diff --git a/packages/dsh-tauri/src/client/types/runtime.ts b/packages/dsh-tauri/src/client/types/runtime.ts
new file mode 100644
index 00000000..abf248ef
--- /dev/null
+++ b/packages/dsh-tauri/src/client/types/runtime.ts
@@ -0,0 +1,34 @@
+import type {
+ ISessions,
+ IWorkspaces,
+ SessionListState,
+ SessionSummary,
+ SlotRegistry,
+ WorkspaceId,
+} from '@deepseek-ai/dsh-client-runtime/client'
+
+/** Real runtime slot registry contract. */
+export type { SlotRegistry }
+/** Real runtime session list state and summary contracts. */
+export type { SessionListState, SessionSummary }
+/** Real runtime workspace identifier contract. */
+export type { WorkspaceId }
+/** Real runtime outward session/workspace faces. */
+export type { ISessions, IWorkspaces }
+
+/** Runtime session service projection used by legacy plugin helpers. */
+export interface SessionsRuntime {
+ list: {
+ getSnapshot: () => unknown
+ subscribe: (listener: () => void) => () => void
+ }
+}
+
+/** Runtime workspace service projection used by legacy plugin helpers. */
+export interface WorkspacesRuntime {
+ list: {
+ getSnapshot: () => unknown
+ subscribe: (listener: () => void) => () => void
+ }
+ startSession: (workspaceId?: WorkspaceId) => void
+}
diff --git a/packages/dsh-tauri/src/index.ts b/packages/dsh-tauri/src/index.ts
new file mode 100644
index 00000000..b97c336a
--- /dev/null
+++ b/packages/dsh-tauri/src/index.ts
@@ -0,0 +1,183 @@
+import type { IncomingMessage, ServerResponse } from 'node:http'
+import { Buffer } from 'node:buffer'
+import { spawn } from 'node:child_process'
+import process from 'node:process'
+
+export type JsonBody = Record<string, unknown>
+export type RouteResult = [number, unknown]
+export type RouteFunction = (body: JsonBody, req: IncomingMessage) => Promise<RouteResult>
+export type RouteHandler = (request: IncomingMessage, response: ServerResponse) => void | Promise<void>
+
+export interface ConnectionGate {
+ requestRejection: (request: IncomingMessage) => 401 | 403 | undefined
+}
+
+export class HttpError extends Error {
+ constructor(message: string, readonly statusCode: number) {
+ super(message)
+ this.name = 'HttpError'
+ }
+}
+
+const JSON_HEADERS = { 'content-type': 'application/json; charset=utf-8' }
+const DEFAULT_MAX_BODY_BYTES = 1024 * 1024
+
+/** Apply DSH's browser trust and authentication boundary before route logic. */
+export function withConnectionAuth(connection: ConnectionGate | undefined, handler: RouteHandler, _pluginName = 'dsh-tauri-plugin'): RouteHandler {
+ if (typeof connection?.requestRejection !== 'function')
+ return handler
+ return async (request, response) => {
+ const rejection = connection.requestRejection(request)
+ if (rejection !== undefined) {
+ response.writeHead(rejection)
+ response.end(rejection === 401 ? 'unauthorized' : 'forbidden')
+ return
+ }
+ await handler(request, response)
+ }
+}
+
+function isLoopback(request: IncomingMessage): boolean {
+ const address = request.socket?.remoteAddress ?? ''
+ return address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1'
+}
+
+export function readJsonBody(request: IncomingMessage, limit = DEFAULT_MAX_BODY_BYTES): Promise<JsonBody> {
+ return new Promise((resolve, reject) => {
+ const chunks: Buffer[] = []
+ let bytes = 0
+ let exceeded = false
+ request.on('data', (chunk: Uint8Array | string) => {
+ if (exceeded)
+ return
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)
+ bytes += buffer.byteLength
+ if (bytes > limit) {
+ exceeded = true
+ reject(new HttpError('请求体过大', 413))
+ return
+ }
+ chunks.push(buffer)
+ })
+ request.on('end', () => {
+ if (exceeded)
+ return
+ try {
+ const parsed: unknown = JSON.parse(Buffer.concat(chunks).toString('utf8') || '{}')
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
+ throw new HttpError('请求体必须是 JSON 对象', 400)
+ resolve(parsed as JsonBody)
+ }
+ catch (error) {
+ reject(error instanceof HttpError ? error : new HttpError('请求体不是有效的 JSON', 400))
+ }
+ })
+ request.on('error', reject)
+ })
+}
+
+export function sendJson(response: ServerResponse, status: number, payload: unknown, headers: Record<string, string> = {}): void {
+ response.writeHead(status, { ...JSON_HEADERS, ...headers })
+ response.end(status === 204 ? undefined : JSON.stringify(payload))
+}
+
+export function routeHandler(fn: RouteFunction, { mutate = false }: { mutate?: boolean } = {}): RouteHandler {
+ const allowedMethod = mutate ? 'POST' : 'GET'
+ return async (request, response) => {
+ if (request.method === 'OPTIONS') {
+ sendJson(response, 204, {}, { allow: `${allowedMethod}, OPTIONS` })
+ return
+ }
+ if (request.method !== allowedMethod) {
+ sendJson(response, 405, { error: `仅支持 ${allowedMethod} 请求` }, { allow: `${allowedMethod}, OPTIONS` })
+ return
+ }
+ if (mutate && !isLoopback(request)) {
+ sendJson(response, 403, { error: '变更操作仅限本机(127.0.0.1)调用' })
+ return
+ }
+ try {
+ const [code, payload] = await fn(mutate ? await readJsonBody(request) : {}, request)
+ sendJson(response, code, payload)
+ }
+ catch (error) {
+ const code = error instanceof HttpError ? error.statusCode : 500
+ sendJson(response, code, { error: error instanceof Error ? error.message : String(error) })
+ }
+ }
+}
+
+export function isSameOriginJsonRequest(request: IncomingMessage): { ok: true } | { ok: false, status: number, error: string } {
+ const contentType = request.headers['content-type'] || ''
+ if (!/^application\/json(?:\s*;|$)/i.test(contentType))
+ return { ok: false, status: 415, error: 'unsupported-media-type' }
+ const origin = request.headers.origin
+ const host = request.headers.host
+ if (origin && host) {
+ try {
+ if (new URL(origin).host !== host)
+ return { ok: false, status: 403, error: 'cross-origin-request' }
+ }
+ catch {
+ return { ok: false, status: 403, error: 'cross-origin-request' }
+ }
+ }
+ return { ok: true }
+}
+
+export function sameOrigin(request: IncomingMessage): boolean {
+ const origin = request.headers.origin
+ const host = request.headers.host
+ if (origin === undefined || host === undefined)
+ return false
+ try {
+ const parsed = new URL(origin)
+ return (parsed.protocol === 'http:' || parsed.protocol === 'https:') && parsed.host === host
+ }
+ catch {
+ return false
+ }
+}
+
+export function respond(response: ServerResponse, status: number, payload: unknown): void {
+ const body = JSON.stringify(payload)
+ response.writeHead(status, { ...JSON_HEADERS, 'content-length': Buffer.byteLength(body), 'cache-control': 'no-store' })
+ response.end(body)
+}
+
+export function safeWebUrl(value: unknown): string | null {
+ if (typeof value !== 'string')
+ return null
+ try {
+ const url = new URL(value)
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null
+ }
+ catch {
+ return null
+ }
+}
+
+function spawnDetached(command: string, args: string[]): Promise<void> {
+ return new Promise((resolve, reject) => {
+ const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsHide: true })
+ child.once('error', reject)
+ child.once('spawn', () => {
+ child.unref()
+ resolve()
+ })
+ })
+}
+
+export async function openUrl(url: string): Promise<void> {
+ if (process.platform === 'win32') {
+ await spawnDetached('rundll32.exe', ['url.dll,FileProtocolHandler', url])
+ return
+ }
+ await spawnDetached(process.platform === 'darwin' ? 'open' : 'xdg-open', [url])
+}
+
+/**
+ * dsh-tauri 宿主侧(node half):纯浏览器插件,无宿主行为。
+ * loader 按行名导入包根时需要一个可挂载的插件入口。
+ */
+export function apply(): void {}
diff --git a/packages/dsh-tauri/tsdown.config.ts b/packages/dsh-tauri/tsdown.config.ts
new file mode 100644
index 00000000..9a11b17d
--- /dev/null
+++ b/packages/dsh-tauri/tsdown.config.ts
@@ -0,0 +1,10 @@
+import { defineDshConfig } from 'dsh-tauri-tsdown'
+
+export default defineDshConfig({
+ // Client bundle inlines CJS deps (css-render/murmurhash) whose
+ // `exports.default` triggers publint's __esModule+default false positive.
+ publint: false,
+ client: {
+ dts: true,
+ },
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 04ff14f9..ff8764e2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4,6 +4,184 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
+catalogs:
+ build:
+ '@tailwindcss/postcss':
+ specifier: 4.1.11
+ version: 4.1.11
+ '@tailwindcss/vite':
+ specifier: 4.1.11
+ version: 4.1.11
+ '@vitejs/plugin-react':
+ specifier: ^4.6.0
+ version: 4.7.0
+ babel-plugin-react-compiler:
+ specifier: ^1.0.0
+ version: 1.0.0
+ tailwindcss:
+ specifier: 4.1.11
+ version: 4.1.11
+ tsx:
+ specifier: ^4.23.12
+ version: 4.23.12
+ vite:
+ specifier: ^7.0.4
+ version: 7.3.6
+ cli:
+ publint:
+ specifier: ^0.3.16
+ version: 0.3.24
+ tsdown:
+ specifier: ^0.17.3
+ version: 0.17.4
+ typescript:
+ specifier: ~5.8.3
+ version: 5.8.3
+ dsh:
+ '@deepseek-ai/cordis':
+ specifier: 4.0.1
+ version: 4.0.1
+ '@deepseek-ai/dsh-client-runtime':
+ specifier: 0.1.1-rc.2
+ version: 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-layout':
+ specifier: 0.1.1-rc.2
+ version: 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-primitives':
+ specifier: 0.1.1-rc.2
+ version: 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-renderer':
+ specifier: 0.1.1-rc.2
+ version: 0.1.1-rc.2
+ '@deepseek-ai/dsh-skill-filesystem':
+ specifier: ^0.1.1-rc.1
+ version: 0.1.1-rc.2
+ lint:
+ '@antfu/eslint-config':
+ specifier: ^9.3.0
+ version: 9.3.0
+ '@eslint-react/eslint-plugin':
+ specifier: ^5.18.6
+ version: 5.18.6
+ eslint:
+ specifier: ^10.8.1
+ version: 10.8.1
+ eslint-plugin-react-refresh:
+ specifier: ^0.5.4
+ version: 0.5.4
+ knip:
+ specifier: ^6.32.2
+ version: 6.32.2
+ release:
+ bumpp:
+ specifier: 12.2.1
+ version: 12.2.1
+ changelogithub:
+ specifier: 15.0.5
+ version: 15.0.5
+ runtime:
+ '@gravity-ui/icons':
+ specifier: ^2.21.0
+ version: 2.21.0
+ '@hairy/react-lib':
+ specifier: ^1.52.0
+ version: 1.52.0
+ '@heroui/react':
+ specifier: ^3.2.4
+ version: 3.2.4
+ '@heroui/styles':
+ specifier: ^3.2.4
+ version: 3.2.4
+ '@overlastic/react':
+ specifier: ^0.9.0
+ version: 0.9.0
+ '@tanstack/react-query':
+ specifier: ^5.101.4
+ version: 5.101.4
+ i18next:
+ specifier: ^26.3.6
+ version: 26.3.6
+ react:
+ specifier: ^19.2.8
+ version: 19.2.8
+ react-dom:
+ specifier: ^19.2.8
+ version: 19.2.8
+ react-i18next:
+ specifier: ^17.0.11
+ version: 17.0.11
+ react-if-lite:
+ specifier: ^0.1.0
+ version: 0.1.0
+ react-use:
+ specifier: ^17.6.1
+ version: 17.6.1
+ tailwind-variants:
+ specifier: ^3.3.1
+ version: 3.3.1
+ valtio-define:
+ specifier: ^1.4.1
+ version: 1.4.1
+ tauri:
+ '@tauri-apps/api':
+ specifier: ^2.11.1
+ version: 2.11.1
+ '@tauri-apps/cli':
+ specifier: ^2.11.4
+ version: 2.11.4
+ '@tauri-apps/plugin-clipboard-manager':
+ specifier: ^2.3.2
+ version: 2.3.2
+ testing:
+ vitest:
+ specifier: ^4.1.11
+ version: 4.1.11
+ yaml:
+ specifier: ^2.9.0
+ version: 2.9.0
+ types:
+ '@types/node':
+ specifier: ^22.10.0
+ version: 22.20.1
+ '@types/react':
+ specifier: ^19.2.18
+ version: 19.2.18
+ '@types/react-dom':
+ specifier: ^19.2.4
+ version: 19.2.4
+ ui:
+ css-render:
+ specifier: ^0.15.14
+ version: 0.15.14
+ dompurify:
+ specifier: ^3.4.13
+ version: 3.4.14
+ marked:
+ specifier: ^18.0.10
+ version: 18.0.11
+ utils:
+ '@hairy/utils':
+ specifier: ^1.52.0
+ version: 1.52.0
+ citty:
+ specifier: ^0.2.2
+ version: 0.2.2
+ consola:
+ specifier: ^3.4.2
+ version: 3.4.2
+ dotenv:
+ specifier: ^17.4.2
+ version: 17.4.2
+ pathe:
+ specifier: ^2.0.3
+ version: 2.0.3
+ smol-toml:
+ specifier: ^1.3.1
+ version: 1.8.0
+ tinyexec:
+ specifier: ^1.3.0
+ version: 1.3.0
+
patchedDependencies:
bumpp:
hash: 362685edd02f1561e78b740e2b4c1ec2bd8e266eb2e26a64055ae305cac1c3ac
@@ -14,133 +192,311 @@ importers:
.:
dependencies:
'@gravity-ui/icons':
- specifier: ^2.21.0
+ specifier: catalog:runtime
version: 2.21.0([email protected])
'@hairy/react-lib':
- specifier: ^1.52.0
+ specifier: catalog:runtime
'@hairy/utils':
- specifier: ^1.52.0
+ specifier: catalog:utils
version: 1.52.0
'@heroui/react':
- specifier: ^3.2.4
+ specifier: catalog:runtime
'@heroui/styles':
- specifier: ^3.2.4
+ specifier: catalog:runtime
'@overlastic/react':
- specifier: ^0.9.0
+ specifier: catalog:runtime
'@tanstack/react-query':
- specifier: ^5.101.4
+ specifier: catalog:runtime
version: 5.101.4([email protected])
'@tauri-apps/api':
- specifier: ^2.11.1
+ specifier: catalog:tauri
version: 2.11.1
'@tauri-apps/plugin-clipboard-manager':
- specifier: ^2.3.2
+ specifier: catalog:tauri
version: 2.3.2
i18next:
- specifier: ^26.3.6
+ specifier: catalog:runtime
version: 26.3.6([email protected])
react:
- specifier: ^19.2.8
+ specifier: catalog:runtime
version: 19.2.8
react-dom:
- specifier: ^19.2.8
+ specifier: catalog:runtime
version: 19.2.8([email protected])
react-i18next:
- specifier: ^17.0.11
+ specifier: catalog:runtime
react-if-lite:
- specifier: ^0.1.0
+ specifier: catalog:runtime
version: 0.1.0([email protected])
react-use:
- specifier: ^17.6.1
+ specifier: catalog:runtime
tailwind-variants:
- specifier: ^3.3.1
+ specifier: catalog:runtime
valtio-define:
- specifier: ^1.4.1
+ specifier: catalog:runtime
version: 1.4.1(@types/[email protected])([email protected])
devDependencies:
'@antfu/eslint-config':
- specifier: ^9.3.0
+ specifier: catalog:lint
+ '@deepseek-ai/cordis':
+ specifier: catalog:dsh
+ version: 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-client-runtime':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-client-ui-layout':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](ffa4142e95dc748529b8e9b13f0fdc9c))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-client-ui-primitives':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-client-ui-renderer':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))([email protected])
+ '@deepseek-ai/dsh-skill-filesystem':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(48868494a4b9bcea1966f12a762e8376)
'@eslint-react/eslint-plugin':
- specifier: ^5.18.6
+ specifier: catalog:lint
'@tailwindcss/postcss':
- specifier: 4.1.11
+ specifier: catalog:build
version: 4.1.11
'@tailwindcss/vite':
- specifier: 4.1.11
+ specifier: catalog:build
'@tauri-apps/cli':
- specifier: ^2.11.4
+ specifier: catalog:tauri
version: 2.11.4
'@types/node':
- specifier: ^22.10.0
+ specifier: catalog:types
version: 22.20.1
'@types/react':
- specifier: ^19.2.18
+ specifier: catalog:types
version: 19.2.18
'@types/react-dom':
- specifier: ^19.2.4
+ specifier: catalog:types
version: 19.2.4(@types/[email protected])
'@vitejs/plugin-react':
- specifier: ^4.6.0
+ specifier: catalog:build
babel-plugin-react-compiler:
- specifier: ^1.0.0
+ specifier: catalog:build
version: 1.0.0
bumpp:
- specifier: 12.2.1
+ specifier: catalog:release
version: 12.2.1(patch_hash=362685edd02f1561e78b740e2b4c1ec2bd8e266eb2e26a64055ae305cac1c3ac)
changelogithub:
- specifier: 15.0.5
+ specifier: catalog:release
version: 15.0.5
citty:
- specifier: ^0.2.2
+ specifier: catalog:utils
version: 0.2.2
consola:
- specifier: ^3.4.2
+ specifier: catalog:utils
version: 3.4.2
dotenv:
- specifier: ^17.4.2
+ specifier: catalog:utils
version: 17.4.2
eslint:
- specifier: ^10.8.1
+ specifier: catalog:lint
version: 10.8.1([email protected])
eslint-plugin-react-refresh:
- specifier: ^0.5.4
+ specifier: catalog:lint
knip:
- specifier: ^6.32.2
+ specifier: catalog:lint
version: 6.32.2
pathe:
- specifier: ^2.0.3
+ specifier: catalog:utils
version: 2.0.3
+ publint:
+ specifier: catalog:cli
+ version: 0.3.24
tailwindcss:
- specifier: 4.1.11
+ specifier: catalog:build
version: 4.1.11
tinyexec:
- specifier: ^1.3.0
+ specifier: catalog:utils
version: 1.3.0
tsx:
- specifier: ^4.23.12
+ specifier: catalog:build
version: 4.23.12
typescript:
- specifier: ~5.8.3
+ specifier: catalog:cli
version: 5.8.3
vite:
- specifier: ^7.0.4
+ specifier: catalog:build
vitest:
- specifier: ^4.1.11
+ specifier: catalog:testing
+ packages/dsh-tauri:
+ devDependencies:
+ css-render:
+ specifier: catalog:ui
+ version: 0.15.14
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-bundle:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ dsh-tauri-panel:
+ specifier: workspace:*
+ version: link:../dsh-tauri-panel
+ dsh-tauri-panel-extension:
+ specifier: workspace:*
+ version: link:../dsh-tauri-panel-extension
+ dsh-tauri-panel-placeholder:
+ specifier: workspace:*
+ version: link:../dsh-tauri-panel-placeholder
+ dsh-tauri-rightclick:
+ specifier: workspace:*
+ version: link:../dsh-tauri-rightclick
+ dsh-tauri-session:
+ specifier: workspace:*
+ version: link:../dsh-tauri-session
+ dsh-tauri-ui:
+ specifier: workspace:*
+ version: link:../dsh-tauri-ui
+ dsh-tauri-worktree:
+ specifier: workspace:*
+ version: link:../dsh-tauri-worktree
+
+ packages/dsh-tauri-panel:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-panel-extension:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ smol-toml:
+ specifier: catalog:utils
+ version: 1.8.0
+ yaml:
+ specifier: catalog:testing
+ version: 2.9.0
+ devDependencies:
+ '@deepseek-ai/cordis':
+ specifier: catalog:dsh
+ version: 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-skill-filesystem':
+ specifier: catalog:dsh
+ version: 0.1.1-rc.2(48868494a4b9bcea1966f12a762e8376)
+ dompurify:
+ specifier: catalog:ui
+ version: 3.4.14
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ marked:
+ specifier: catalog:ui
+ version: 18.0.11
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-panel-placeholder:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-rightclick:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-session:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-tsdown:
+ devDependencies:
+ tsdown:
+ specifier: catalog:cli
+ typescript:
+ specifier: catalog:cli
+ version: 5.8.3
+
+ packages/dsh-tauri-ui:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
+ packages/dsh-tauri-worktree:
+ dependencies:
+ dsh-tauri:
+ specifier: workspace:*
+ version: link:../dsh-tauri
+ devDependencies:
+ dsh-tauri-tsdown:
+ specifier: workspace:*
+ version: link:../dsh-tauri-tsdown
+ tsdown:
+ specifier: catalog:cli
+
packages:
@@ -331,6 +687,615 @@ packages:
resolution: {integrity: sha512-y7/yvZ2TPAnR9+jnc00klvNNLkJiXFFrQA/hlLCcxA9a2A4zQIOimyFQ9XfwYKiGD1fb5GY8vbKIIgO8d5Tb2A==}
engines: {node: '>= 20.12.0'}
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-bZ4S1YuOmwOeE97HnslQ6ggVQbaWz4GejJ8OcY4P/DIyc1Qhu/3Szt1XSw6c/pd37kRkxxJXGwt4cmCxWSBBuw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.2
+ '@deepseek-ai/cordis-plugin-loader': ^1.0.3
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-YNcHiH7TRFrgnRbQU7qdS1spABUFFHg04QpB9DdboPEjgKLTFfeEAvr6Y7qll3/nGgqywDQdk1tYshqKO0p1WQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.2
+ node-addon-require-builtin: ^0.1.4
+ peerDependenciesMeta:
+ node-addon-require-builtin:
+ optional: true
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-YBdskTU2Po1kru3GgcUWUbkTsPMA9LkSQDAY8rBkFJeajdgcQad3QPJZE26JyK99Xb6HaASvoXg2DSUTeN/0Nw==}
+ hasBin: true
+ peerDependencies:
+ '@deepseek-ai/cordis-plugin-include': ^1.0.6
+ '@deepseek-ai/cordis-plugin-loader': ^1.0.2
+ peerDependenciesMeta:
+ '@deepseek-ai/cordis-plugin-include':
+ optional: true
+ '@deepseek-ai/cordis-plugin-loader':
+ optional: true
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-qBo+ronVM6Eu2WNVJXi8JcMiqZ19T9BRIpV+5qJUFPXjGH/Z0QKcQMC/IZJ7L394YTOtJgcovbk9qP0w2GsBXQ==}
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-Pv+4p20Eol7Ds/n0OS0vjtChCWfFTJAMThxugXcEcLKEJ9WAtpI4mzWfLgjmeVXnwD2yvp6HlLKDrrQV9PIkww==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-88r3jkrbdwTgcP3MZLIUX458Ecu8JcLmZa7PtPszwf33yFoWlZvZmgjyn5ETHV55plNQ8gKMRm9a0RwzGGmzCw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/cordis-plugin-include': ^1.0.6
+ '@deepseek-ai/cordis-plugin-loader': ^1.0.2
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-atomic-write': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-home-paths': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-system-prompt': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-cC7lnJe7JgPFcreNXxcxLMxQd78LnpVO9ZXROjZsGRQN1zGH6i/DduI892F1am85IfzzO+XTxMwwUHmfwamb0g==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-system-prompt': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-i/e/Ecg1QCjMePUFHBfjRQU3NbDV0IdORwQbQD6RpiirzyvAIm4vvZgmW/FfgkO2XYJHHIVjo3i1i0YaHPcQag==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-client-connection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-registry': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-mtmMxA0TZwTjy46E2DF0kmsPCXVq6RBhrwEHWXBaRzc0DLjnYqmJODrZ0X+XwXOkwFZtDxWSv/uheiIsXf8now==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-agent-presets': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-api-gateway': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-commands': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-cordis-host-runner': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-credentials': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-file-reference': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-goal': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-host-plugin-inventory': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-message-feedback': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-reference': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-registry': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-QqNSF0+Ddn6qWY480dlilwEy6FLv3JKEWx1UQgoNJrxD4y54SDRzqBQB9yDXWKOoOGyC+05TN6/Px10GNIzMWA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-rCYAt8QsawP1yfDCU7XxNwYT/XWvyFsxYrkwhLLkdfW83QVD0CQHizSkTQE7RFX74nKUD1z3sTLfnLr7xneArw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-8vXsAXoUdzKAgvd/E9DgyT6HKmR6ZM4rtJ3fs/XoJ6n2kBk4tWil8Lv+jxCMWJeMOnTJF55gu2+NWQ3ECFPtJw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-YX2WLA/aZdDQsien4Zo7IHTEfYVJ+4QhRXbgA6BrRUM23NSP/+V3K00dQYyQVsF3ZwocE5uyvlZvbYeg1Iz4ug==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-attachment': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-commands': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-host-apiproxy': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-host-webserver': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-tools': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-AMoR4FwMPLmt6WlYd4m0PCoxXj4qqMhpElBQZSc3r3NyGCZIuleU8tCG1xphGtr/w9mA1Y0kUX7Ftdmf7yV4FQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-api-remotes': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-connection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-settings': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-o1FH7Rlns0Xaxh4SBOWZ1wpa0ViGw6DXWNm5NFpsBTGYD94RGdIrud3QxgrfzmQKLzu33gvS8JL/IjqbzWyYsg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-api-remotes': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-attachment': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-connection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-commands': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-host-apiproxy': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm-retry': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-title': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-tools': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-registry': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-y7xSQyQYGuahLyJcSXpB+JbH1F5lGEc3L9K8cjLy5vd/L9N6gLFLWyeGdlGxxM4jxRt1+rAHDDZ/zl7b8GC5zQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-client-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-theme': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-vCWEha1yhY//26j/LppHC/xZrU6MOuw6lcI4bJr5L7ppbY8h7GAR24ozBr+4ESMtQ5OmsvqGnsa/Kj5ZjSLfEQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-yCpJWKrA4DLd9lwHuUUIdId8H9Vcoq6xtQoNh3UxOYy4KDeoKbcMsRpOOShlnkxdJYGKOoRk3GpRaDw5RPlrwA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-client-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-WqEQkyjW467leTJoA31BgqM+nALI3JnrvN1IXDhJuKd8E9nXhTLJcRgDrovEUkh2cjbHF8g8gQJ5Qafg9PzJiQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-api-remotes': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-connection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-gRKI92D+EZtOy7UBkRfNvyL4e/3HikZ7exQSfgGpLEJ278/aXMvStNbL5ZgWVC41+MSZsBUk3dZAfbXNjelz2g==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-api-remotes': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-connection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-locale': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-settings': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-host-webserver': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-settings': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-SgFresqH5UABzRQZ7tOfqzOLMHF7089VeH+mfcwNQH5peOavgEKrAGOYz/9RnISH0XmMrj/x177t8gfO8Uvo/w==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-BOIe4Sht9rmMv1a6b3GWjWBbeWr7PtHlAy41vgpaymvUUuzOapOIA648ZMGCI/crRIt72Umev2FHtSwCNSbYZg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-attachment': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-LV5GAIx7GO8DCRivnN2bmLmuucsYDG+ifG18BaXBqsVKdrzmaIu5o+CBxQAI2bX1N6mfBenLxmvCnROkyumLTg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-commands': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-+AQGegPy+gdtcjTTPxDDYwAFUn6BB1J/MFFbmpPr+WIqJoDyVsuCDe8Rr8mCJmxs12CmTZXXSOE03LW203W8fA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-tools': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-aeVBaH07rox7NuSNbSqbz8g0eNb2IIhNbrZngj/VxUsr/TR9TXOq7lm1CL6SBUDlstGw3vNWeXyhim/DmA5iSQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-8Pd4SNHhV6OlbwfV5K4qmFb709I0Z68qgaUQJ7zM4BTjClNe1/dktQnETtWPfqbPTx/2sNKXM1rz4WXuROrIfQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-8j+6MffvCHATLQrhAVfc9rKyunKu/O7mjjJzmdsUSdID7V4iUYMwqPamhlAyI+tfohZu/vcforKzCRIZGmCYug==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-sandbox': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-lSHTh4vfS6eRb9to/y+bjRf2+0QkNpY3tHJ29HMTewR9fJYZsEVVu4Hc+GPhPEjF7RpiD35/sKx+akijtDasyg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-lGsP7sbnu20AiRAb+gxYiKx9oa9r1D/8Fr6BwWHXpaPx6ZE4Qg0+ybh5SZVfGQ+XhLcQisu3nwWemEjtTJGiig==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-dplRnGGXXsQYFQ1KMHymAM0iaxuE9Z153JHYcGEgOwXNkS3HA20gSi3yMt6fz+zi/cMHYXvY1JQhS54BTc761A==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent-presets': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-cordis-host-runner': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-m3puwS+bvJQ1eASdpEEwlQqKa9znhBSgtoSSI0GZN5VMynZVl7E31HMltENz3QC2Nd+C3bh7vNjrJFtumUDsLQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-Hud9ezW0bexWfhX7C+c5rdUDX1xzbEGDzj1lGQyj/QxdrxHYHjGrJq3tLRyvN6K4FSmEdG2IBKdQGCOLVrIthA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/cordis-plugin-loader': ^1.0.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-t9MrjC65QHiiWhG9V8UZxgfE/aWYhJHHrIM0kbTvtXxg4tLGIKo/upHp7iiag65F3HTkVLrH/DUyPMi4v2ZA7g==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-l+1Om/EDFyMjhgSuEx2WDLLA2fia/+ga9mBTCoT/MMslsnWaK5G0/lWwbwlTBSaJ6OfmYc3DuBgox8DbgIGHRQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-SXvDJMvcUrGrlzIyE7j8/lI4Pj1nDe/UOR8C05Zagp+/0R8p46n6KylySvZdPAFENV5t8WX3Fw3eOaS4No0+wQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-a13Fpmn8HFy8LCjl6gljaNPxcVjO/R+/uMPDl0QLjwQcHWVyGW38ZA8jP5iRuFgdyNNXpyxLWuZXi/0VOH00tA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-timeout': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-ASJfjIdZbIXvLwi3rGo+eZb/GxMVV/WO5/XVD3B96mT8EIzrlw3+nMR6/CvmJVzcycKQ2XN0wj7jD6TasPRySA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-attachment': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-timeout': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-GzxDiNvyUVs/bbbm+Hr3MfuU3wM8ErRF5z9XadnSGPYZvipZDAMrvrS5v6JgOUaZt6ApBpEMJ4xVgIel1VnGYQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-storage-domain': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-GIknPrwU7vZOUQ2o/ES7Z0uUhUrZGp/yigKP+RXEu41VI9tcybiXQAA8CEdDFmNQ11R2wfYQhr3WO5vy35akWg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-tCni+bTEp/FWokfz3fqn4p6SzHn6pkY6H3HkS9UY5PHrztUE1ESUQUp41kIVtwUhRmJU7yissqjxe6kLDB6t2Q==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-rnO2RqZ+ycpwrXrXlMcrhWAICdui3ZVTjNQ8eZrOPE18hAbX3tw0nLFq26sBjMSnBfDQHNZ4VaFpt0p8qhkPWQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-Xy3ejL6dwVSluZL7XOWy76ya4pCw1uHwxodDK4O9XiQUiUV4FBXnt0aNJUtMeAFN0c1YujxxCmRniMvuuNn1Nw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-dxdYxRfmK5jWtiFFabqRNb/jGGjkXyF2djI7O8IIKmDVjhQiv170zpvhbAhRUuqClEdseCtbQpLBrRm2blzt3g==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-timeout': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-UvCRpIb+LoQI/nCLof17xc2P2KuZoucU3VuzfAukfsF3dYZAy5OP7jrCRdVZIvjRfvFUd7G+awdS9sWbnjcolg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-storage-domain': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-SNaOrjRS4RMXocna6uL33TeS/uhcQ7jDJtJZ1HyDPL06mXUdAgje2MVt8OZCh6dH95xIiqpQQm+KjzeiQnhYSQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-QxQFRg/KnrZnYiO7fNtTJVTakuGs9ZFRkGGgYuNPzSz1pRqiohGNE/JZzBtq+HMv38RRTRZrM4aIOUV8OgqoXQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-title': ^0.1.1-rc.2
+ peerDependenciesMeta:
+ '@deepseek-ai/dsh-session-persistence':
+ optional: true
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-c9mz19ndxjVxSnXEhmJwGDjyKG4oNmu4Sfneix8OUJ+mAr3jIgb/QZZ8rYEc8Bi+Dd1z7Wr90IeWOBF0nolU3A==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-compaction': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-output-retention': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-query': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-qHv+9nE6J/piHsWwckmbJBS1sJjunCWsv00arhsgjW1XMLCHxG6QOB+U48P4EBZjve798Tz8AQIlWZy+9T8XmA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-4/cv6X9HPhm47eyRhCu/WZwzrtJKegk5J+0xaxcZ9i8S0smdxP57tqy8a0jkSshLQn7BzMFxneQrlYExrLrDhQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-typert-protocol': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-iGdKEt91Im3gE7xA9CzRfTJsPcFcxDeDOCLhAjzbpjEv7TAjx/EoYP7lPtiy+QmOjKSKy206SEtAKol9PXWbOw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/schemastery': ^3.18.1
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-eyQGv4046c392kIvOCom+gvJpiFbkWsf/VqB7dCQXTZrdXEx99P8oOm3jsagnllcLKYyZVVETs75pPgznye/iw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-fs': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-home-paths': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-skill': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-FACjlOqdsWX+0RtSs3RWrdY0QQEpPJrBfvxUbWSh7E8UyCM8dKdIbsQnuXIjsAgC7GgYp7lyFDSCMovQ3ARp8g==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-9/3OuaZpxf9NZWhrARpgZ7UBa03pPaTIiDBw+SfESfwVk42NNLVCQgvnEbrWoNwdtzmv0aYCEV23sKwwlQ0LBA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-storage': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-ptJ1ss8spF+Y2VXjsMV37Qh1+hviYWZylDvXtfEBXjLbPi/BP3dktT4B6OMIAD1rRN+0A4HdTqJBgLk7Gp1rig==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-CNa0WuFCR69TMnBKYQInz49/olDSaVHiYkDTyTuDh7YW7Y80/f/HjQe5G0fQaqZMLla3IUSXCIPl5EssWmjcQw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-agent-presets': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-jobs': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-sandbox': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-sandbox-policy': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-projection-cache': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-tools': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-user-approval': ^0.1.1-rc.2
+ peerDependenciesMeta:
+ '@deepseek-ai/dsh-agent-presets':
+ optional: true
+ '@deepseek-ai/dsh-jobs':
+ optional: true
+ '@deepseek-ai/dsh-sandbox':
+ optional: true
+ '@deepseek-ai/dsh-sandbox-policy':
+ optional: true
+ '@deepseek-ai/dsh-session-persistence':
+ optional: true
+ '@deepseek-ai/dsh-session-projection':
+ optional: true
+ '@deepseek-ai/dsh-session-projection-cache':
+ optional: true
+ '@deepseek-ai/dsh-user-approval':
+ optional: true
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-on4hjAlYI5uX9q7Sf95YkMMBVe6heywtA/H50ksrIMUub8U2B98hO9iQpHhjwIO1F1vu+5pLcPvRr6yUGGmtXQ==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-RrouVgU3G5gXr9zHhpThkMG6YKdcRJzXXdPm1dq3ioBxbvxlfMSfNY4tN8lWMJxLyGtvWkPra0HQX+YWxvdOOA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-0GGL4D55MwYDepzZMOI3L0ycu5b2qr96GL0Y7snwhAnpK2Di61rbX3fJE+PB3ZrovGX0csIRdt9n3iJZDVtDrw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-code-runtime': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-system-prompt': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-user-approval': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-lxBssDc5Pz1qBE5kuIyaArA7AvIPq9rpaVclylodiSzVJe95e2xruBg73tflyjtd8y00toet+DLgQ6tSSsq6Kw==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-ATZu3i7UId+ktsWW3pUFm5Hi1fVsRXFmByATVPp2RlxH1zjxXnauVW6k70ZwU/4FOsphRzo65SXOlAXA+natYg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-SdsO4Rs+NeJFoertkVilXBACREOLfkKPJJznYKqDhJxeRo38RJ56dtj0Xd0/6rERmsQiMck4Bwdrzg1ubUqPNA==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-scope': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-system-prompt': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-9lYoB7qCFE+Vvgwjny3MnRfS7QUefOspj4KpE3b30DAAJfxwrU4hRtLCHOKxyurF01qrkoEBBpXn4H5ilXYTKg==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-agent': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-llm': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-jBUob4H5TZAiExq9YNVCglKAFmAKMtd1UbyqFfnZZ1Owm+3c3NbAXY947MHiD6NwCwFEW1y7FjrFj66UQvG90A==}
+ peerDependencies:
+ '@deepseek-ai/cordis': ^4.0.1
+ '@deepseek-ai/dsh-brand': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-invariants': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-session-persistence': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-storage': ^0.1.1-rc.2
+ '@deepseek-ai/dsh-storage-domain': ^0.1.1-rc.2
+
+ '@deepseek-ai/[email protected]':
+ resolution: {integrity: sha512-njDtZsznjYxok7KLLlHOPyuv2efdWVbSflAHgztSfbMsg+CVraEoRe2DjOCgClYv3ZCSm7WXoaUkbB/+RY7tWQ==}
+
resolution: {integrity: sha512-JQkeXoZA12f9WM2H4t4IobIRqlPvYLeNAjZF6raFu2vmD5YoyuzKmwsLZNJ4g/39c3v1Se2ad3o+oq4y2et/RA==}
peerDependencies:
@@ -342,15 +1307,27 @@ packages:
oxlint:
optional: true
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==}
+ '@emnapi/[email protected]':
+ resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==}
+ '@emotion/[email protected]':
+ resolution: {integrity: sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==}
+
'@es-joy/[email protected]':
resolution: {integrity: sha512-vgqlMGNNhZxwDYbUNIHj3Hskb4R28iqdXx90ufHyt/NeuTQkeqjTDslAs9I0/GCAfbxP5BpH5WsL1R1fht5Lxg==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
@@ -880,6 +1857,12 @@ packages:
cpu: [x64]
os: [win32]
+ '@oxc-project/[email protected]':
+ resolution: {integrity: sha512-nuFhqlUzJX+gVIPPfuE6xurd4lST3mdcWOhyK/rZO0B9XWMKm79SuszIQEnSMmmDhq1DC8WWVYGVd+6F93o1gQ==}
+
+ '@oxc-project/[email protected]':
+ resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==}
+
'@oxc-project/[email protected]':
resolution: {integrity: sha512-u6JZdLBTLotrNC9Vd6vPssINdzcCzleKAH6EJKImQb7GtYvX5keN2dxkoK44stCc4tffE6QQRtZTXVSzsLUlWA==}
@@ -990,6 +1973,10 @@ packages:
resolution: {integrity: sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA==}
engines: {node: ^14.18.0 || >=16.0.0}
+ '@publint/[email protected]':
+ resolution: {integrity: sha512-4EDEmvxWtgsCnnVeBvtFIFZtUhPPt1+bA9JrSwU4Sa//6oKtzCSlGGXYJr44OD9aGISymbieJ4mCKHUygUDU+g==}
+ engines: {node: '>=18'}
+
'@quansync/[email protected]':
resolution: {integrity: sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ==}
@@ -1134,9 +2121,191 @@ packages:
peerDependencies:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-Ok9V8o7o6YfSdTTYA/uHH30r3YtOxLD6G3wih/U9DO0ucBBFq8WPt/DslU53OgfteLRHITZny9N/qCUxMf9kjQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [android]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-s70pVGhw4zqGeFnXWvAzJDlvxhlRollagdCCKRgOsgUOH3N1l0LIxf83AtGzmb5SiVM4Hjl5HyarMRfdfj3DaQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [android]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-yIsKqMz0CtRnVa6x3Pa+mzTihr4Ty+Z6HfPbZ7RVbk1Uxnco4+CUn7Qbm/5SBol1JD/7nvY8rphAgyAi7Lj6Vg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-4ksWc9n0mhlZpZ9PMZgTGjeOPRu8MB1Z3Tz0Mo02eWfWCHMW1zN82Qz/pL/rC+yQa+8ZnutMF0JjJe7PjwasYw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-GTXe+mxsCGUnJOFMhfGWmefP7Q9TpYUseHvhAhr21nCTgdS8jPsvirb0tJwM3lN0/u/cg7bpFNa16fQrjKrCjQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [darwin]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-SUSDOI6WwUVNcWxd02QEBjLdY1VPHvlEkw6T/8nYG322iYWCTxRb1vzk4E+mWWYehTp7ERibq54LSJGjmouOsw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [darwin]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-9Tmp7bBvKqyDkMcL4e089pH3RsjD3SUungjmqWtyhNOxoQMh0fSmINTyYV8KXtE+JkxYMPWvnEt+/mfpVCkk8w==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [freebsd]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-hwnz3nw9dbJ05EDO/PvcjaaewqqDy7Y1rn1UO81l8iIK1GjenME75dl16ajbvSSMfv66WXSRCYKIqfgq2KCfxw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [freebsd]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-a1y5fiB0iovuzdbjUxa7+Zcvgv+mTmlGGC4XydVIsyl48eoxgaYkA3l9079hyTyhECsPq+mbr0gVQsFU11OJAQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [linux]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-IS+W7epTcwANmFSQFrS1SivEXHtl1JtuQA9wlxrZTcNi6mx+FDOYrakGevvvTwgj2JvWiK8B29/qD9BELZPyXQ==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm]
+ os: [linux]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-bpIGX+ov9PhJYV+wHNXl9rzq4F0QvILiURn0y0oepbQx+7stmQsKA0DhPGwmhfvF856wq+gbM8L92SAa/CBcLg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-e6usGaHKW5BMNZOymS1UcEYGowQMWcgZ71Z17Sl/h2+ZziNJ1a9n3Zvcz6LdRyIW5572wBCTH/Z+bKuZouGk9Q==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-bGe5EBB8FVjHBR1mOLOPEFg1Lp3//7geqWkU5NIhxe+yH0W8FVrQ6WRYOap4SUTKdklD/dC4qPLREkMMQ855FA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-b/CgbwAJpmrRLp02RPfhbudf5tZnN9nsPWK82znefso832etkem8H7FSZwxrOI9djcdTP7U6YfNhbRnh7djErg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [linux]
+ libc: [musl]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-4EII1iNGRUN5WwGbF/kOh/EIkoDN9HsupgLQoXfY+D1oyJm7/F4t5PYU5n8SWZgG0FEwakyM8pGgwcBYruGTlA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-AH8oq3XqQo4IibpVXvPeLDI5pzkpYn0WiZAfT05kFzoJ6tQNzwRdDYQ45M8I/gslbodRZwW8uxLhbSBbkv96rA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [s390x]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-qL+63WKVQs1CMvFedlPt0U9PiEKJOAL/bsHMKUDS6Vp2Q+YAv/QLPu8rcvkfIMvQ0FPU2WL0aX4eWwF6e/GAnA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-cLnjV3xfo7KslbU41Z7z8BH/E1y5mzUYzAqih1d1MDaIGZRCMqTijqLv76/P7fyHuvUcfGsIpqCdddbxLLK9rA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [glibc]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-VGl9JIGjoJh3H8Mb+7xnVqODajBmrdOOb9lxWXdcmxyI+zjB2sux69br0hZJDTyLJfvBoYm439zPACYbCjGRmw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-0phclDw1spsL7dUB37sIARuis2tAgomCJXAHZlpt8PXZ4Ba0dRP1e+66lsRqrfhISeN9bEGNjQs+T/Fbd7oYGw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [linux]
+ libc: [musl]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-B4iIserJXuSnNzA5xBLFUIjTfhNy7d9sq4FUMQY3GhQWGVhS2RWWzzDnkSU6MUt7/aHUrep0CdQfXUJI9D3W7A==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [openharmony]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-0ag/hEgXOwgw4t8QyQvUCxvEg+V0KBcA6YuOx9g0r02MprutRF5dyljgm3EmR02O292UX7UeS6HzWHAl6KgyhA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [openharmony]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-BUjAEgpABEJXilGq/BPh7jeU3WAJ5o15c1ZEgHaDWSz3LB881LQZnbNJHmUiM4d1JQWMYYyR1Y490IBHi2FPJg==}
+ engines: {node: '>=14.0.0'}
+ cpu: [wasm32]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-LEXei6vo0E5wTGwpkJ4KoT3OZJRnglwldt5ziLzOlc6qqb55z4tWNq2A+PFqCJuvWWdP53CVhG1Z9NtToDPJrA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [wasm32]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-s27uU7tpCWSjHBnxyVXHt3rMrQdJq5MHNv3BzsewCIroIw3DJFjMH1dzCPPMUFxnh1r52Nf9IJ/eWp6LDoyGcw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [win32]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-gUmyzBl3SPMa6hrqFUth9sVfcLBlYsbMzBx5PlexMroZStgzGqlZ26pYG89rBb45Mnia+oil6YAIFeEWGWhoZA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [arm64]
+ os: [win32]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-cjWL/USPJ1g0en2htb4ssMjIycc36RvdQAx1WlXnS6DpULswiUTVXPDesTifSKYSyvx24E0YqQkEm0K/M2Z/AA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [win32]
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-3hkiolcUAvPB9FLb3UZdfjVVNWherN1f/skkGWJP/fgSQhYUZpSIRr0/I8ZK9TkF3F7kxvJAk0+IcKvPHk9qQg==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ cpu: [x64]
+ os: [win32]
+
'@rolldown/[email protected]':
resolution: {integrity: sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-vENRlFU4YbrwVqNDZ7fLvy+JR1CRkyr01jhSiDpE1u6py3OMzQfztQU2jxykW3ALNxO4kSlqIDeYyD0Y9RcQeQ==}
+
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==}
+
'@rollup/[email protected]':
resolution: {integrity: sha512-RrPokAb7dmbxFoeO3TloqHyOjgye8RkBhSqmp4aJMIex4c9r46ZstPnleDQOq1t46VOVjwIuwNogIqbodV1Vvg==}
cpu: [arm]
@@ -1275,6 +2444,37 @@ packages:
cpu: [x64]
os: [win32]
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-QCR4q2ZO/ILJEuwiBMel4wdcTDb1JGwfjKTxPDF6x8ixOaluPrVqIn06C99AcRPhmYlBR56d/Fb+GN58GzExpg==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-FbOjFJp9VLdo1Wevs10BBtVxiTWwNLqZh5Gkhjgda/ioL15YOgeSl9n+6XMa3qRlPQzfhFNe641SrynFHYG0nQ==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-EcOQkxdxGQrc1Row/cC2c96/v1dbZqGnEVu1qTuT/MJmp6+cXCvQussowVmCv5Tqr3KuY3c7IbM6HTW3LJ1k9w==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-ePic0yfAJGOF83D5wBHK/00EjK65oahBYxFk5epgq33WRv7X9UuxLEV8PtR0szC0z8dl7INIpIodB99JRFlR+A==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-m0wBeLDQDeIxRdUmrCPdQqfuUamDwRL5isCfYbguKD6NiaKpVbsv+3J81DyIKgNW5h4WAIIr8T4EkgQrBBxvaQ==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-w8UHjeUnIR965KMWJHUPXOc2mNJUnK3vpVLYLvw5IYU2mnTTJ89E24OrJDBNiJDQ0qzb0tc4l7mrIXx5cFeIyw==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-UEJxmRR++MAGR6hugn0vgVS2W/6lWAts84FFSrnlH9sP0LNol7E5+NQ792pH8liWUhyMyjhTgSUH3k7iD7tc5g==}
+ engines: {node: '>=20'}
+
+ '@shikijs/[email protected]':
+ resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
+
'@sindresorhus/[email protected]':
resolution: {integrity: sha512-TeheYy0ILzBEI/CO55CP6zJCSdSWeRtGnHy8U8dWSUH4I68iqTsy7HkMktR4xakThc9jotkPQUXT4ITdbV7cHA==}
engines: {node: '>=18'}
@@ -1557,6 +2757,9 @@ packages:
resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
+
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
@@ -1619,6 +2822,9 @@ packages:
resolution: {integrity: sha512-fkv8dHRDqfGtTHuJeebdrQ7cX6Ad4WAS00rgHh9UGvMycF1mjBfsxry1XsLIFhWZ6Judlh6UdzK+TYlbpCXgnA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@ungap/[email protected]':
+ resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==}
+
'@vitejs/[email protected]':
resolution: {integrity: sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==}
engines: {node: ^14.18.0 || >=16.0.0}
@@ -1701,6 +2907,9 @@ packages:
resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==}
+ resolution: {integrity: sha512-vcZjxvvVoxTeR5XBNJB38oTu/7eDCZlwdz32N1eNgpyPF7j/Z7Idf+CUwQOkKKpJ7RJyjxgLHCM7vdIK0iCNMQ==}
+
resolution: {integrity: sha512-BJ8/l4R5LRE7hW9WdSuGYrLSHi2ynxeFpDFbH0K/CgNeY/tyhk+vO6TYxXC5r5CpUhNVX310xzPsN/H9lCdfOA==}
engines: {node: '>=14'}
@@ -1713,6 +2922,9 @@ packages:
resolution: {integrity: sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==}
engines: {node: '>=14'}
+ resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
+
resolution: {integrity: sha512-xXAd7G2Mll5W8uo37GETpQ2VrE84M181Z7ugHFGQnJZ50M2mbOv0osSZ9VsSgPfJQ+LVG0prSi0th+ELMsno7Q==}
@@ -1724,6 +2936,10 @@ packages:
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==}
+ engines: {node: '>=20.19.0'}
+
resolution: {integrity: sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==}
@@ -1746,6 +2962,9 @@ packages:
resolution: {integrity: sha512-5PAPTTmMpMEb+GuMb5DebfBkipRGyIW9+gtwEBSoDA9xkhHILm04+hZQ702pMksu3d8YAuGkmgTzQWcKqTPScA==}
+ resolution: {integrity: sha512-KxgKcZPfrtzJDDALHPguGpGJUrzdgpymyiQQgzFjWreHMOpWrnFNVREr5J48x2DBh8ZVioscrV1SBkDipGiX+Q==}
+
resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}
@@ -1791,6 +3010,10 @@ packages:
magicast:
optional: true
+ resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-tixWYgm5ZoOD+3g6UTea91eow5z6AAHaho3g0V9CNSNb45gM8SmflpAc+GRd1InC4AqN/07Unrgp56Y94N9hJQ==}
engines: {node: '>=20.19.0'}
@@ -1817,6 +3040,12 @@ packages:
engines: {node: ^22.19.0 || ^24.11.0 || >=26.0.0}
hasBin: true
+ resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==}
+
+ resolution: {integrity: sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==}
+
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
@@ -1856,6 +3085,9 @@ packages:
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
+ resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}
+
resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==}
engines: {node: '>= 12'}
@@ -1910,6 +3142,9 @@ packages:
resolution: {integrity: sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==}
+ resolution: {integrity: sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==}
+
resolution: {integrity: sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==}
engines: {node: '>=8.0.0'}
@@ -1919,6 +3154,9 @@ packages:
engines: {node: '>=4'}
hasBin: true
+ resolution: {integrity: sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw==}
+
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
@@ -1980,6 +3218,9 @@ packages:
resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}
+ resolution: {integrity: sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg==}
+
resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==}
engines: {node: '>=12'}
@@ -1988,6 +3229,15 @@ packages:
resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==}
+ engines: {node: '>=20.19.0'}
+ peerDependencies:
+ oxc-resolver: '>=11.0.0'
+ peerDependenciesMeta:
+ oxc-resolver:
+ optional: true
+
resolution: {integrity: sha512-bNglH7lPH5l+yHOes7Zr4VqxhOy4BQ9ZBUX4VdoFgxMpzJk7W1ZoO3Vgd9Pxa9PyjQ76sfm2aKH/nzEcCNRlew==}
@@ -2327,6 +3577,9 @@ packages:
picomatch:
optional: true
+ resolution: {integrity: sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==}
+
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
engines: {node: '>=16.0.0'}
@@ -2415,6 +3668,15 @@ packages:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
+ resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==}
+
+ resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==}
+
+ resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
+
resolution: {integrity: sha512-kig+rMn/QOVRvr7c86gQ8lWXq+Hkv6CbAH1hLu+RG338StTpE8Z0b44SDVaqVu7HGKf27frdmUYEs9hTUX/cLQ==}
@@ -2424,6 +3686,9 @@ packages:
resolution: {integrity: sha512-0zHsZJrK7S3K2aucXWL6ycoYJ/iNtIcFHC/nYQgFklPtrv5LpJctIiSCroWZWeuoXvuyFdzp6KzjJQ+OT5MfFw==}
+ resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}
+
resolution: {integrity: sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw==}
@@ -2447,6 +3712,13 @@ packages:
resolution: {integrity: sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw==}
engines: {node: '>= 4'}
+ resolution: {integrity: sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==}
+
+ resolution: {integrity: sha512-B6Lc2s6yApwnD2/pMzFh/d5AVjdsDXjgkeJ766FmFuJELIGHNycKRj+l3A39yZPM4CchqNCB4RITEAYB1KUM6A==}
+ engines: {node: '>=20.19.0'}
+
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
engines: {node: '>=0.8.19'}
@@ -2522,6 +3794,10 @@ packages:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
+ resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==}
+ hasBin: true
+
resolution: {integrity: sha512-uQu/fXVqVaMg6gM8/E5G5+eygVcZ1NV0Z51CvqhNa2bDWxvHMl484ETr6vph4oPyC+KUcbP/w2W2pewfCiR9aQ==}
engines: {node: '>=20.0.0'}
@@ -2675,6 +3951,11 @@ packages:
resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==}
+ resolution: {integrity: sha512-HnslJfsZkRPBDJRHvVtAaWlZHEpSu7u8LgQuJCELjRKuWR+hpq4A7sLq3p8HaI9ypVoXDXxV34CsQJEe1+J5Aw==}
+ engines: {node: '>= 20'}
+ hasBin: true
+
resolution: {integrity: sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==}
@@ -2708,6 +3989,9 @@ packages:
resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==}
+ resolution: {integrity: sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==}
+
resolution: {integrity: sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==}
@@ -2915,6 +4199,12 @@ packages:
resolution: {integrity: sha512-65S/5gk9YSsaRjcyf7Nfa6h/d3E8/1gslpXfI4W7Dxn/oap8IKRuNT5VXkLQ1YFKIEg4apRY4Pj6aiwFzrDdmw==}
+ resolution: {integrity: sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==}
+
+ resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==}
+
resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
engines: {node: '>=18'}
@@ -3025,9 +4315,17 @@ packages:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
+ resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==}
+
resolution: {integrity: sha512-V9plBAt3qjMlS1+nC8771KNf6oJ12gExvaxnNzN/9yVRLdTv/lc+oJlnSzrdYDAvBfTStPCoiaCOTmTs0adv7Q==}
+ resolution: {integrity: sha512-9zS56KrKBoqi5Qt8h92uMP8TTM9AYZSgnmCo4u2priMqkOZvQnTsziZ2p5LJ2ywbYkAjoCDp2jda9u4cgFefIw==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
@@ -3060,6 +4358,11 @@ packages:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
+ resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==}
+ peerDependencies:
+ react: ^18.3.1
+
resolution: {integrity: sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==}
peerDependencies:
@@ -3116,6 +4419,10 @@ packages:
react: '*'
react-dom: '*'
+ resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==}
engines: {node: '>=0.10.0'}
@@ -3132,6 +4439,15 @@ packages:
resolution: {integrity: sha512-J8rn6v4DBb2nnFqkqwy6/NnTYMcgLA+sLr0iIO41qpv0n+ngb7ksag2tMRl0inb1bbO/esUwzW1vbJi7K0sI0g==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
+ resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==}
+
+ resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==}
+
+ resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==}
+
resolution: {integrity: sha512-sZuz1dYW/ZsfG17WSAG7eS85r5a0dDsvg+7BiiYR5o6lKCAtUrEwdmRmaGF6rwVj3LcmAeYkOWKEPlbPzN3Y3A==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
@@ -3150,6 +4466,35 @@ packages:
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
+ resolution: {integrity: sha512-7UpdiICFd/BhdjKtDPeakCFRk6pbkTGFe0Z6u01egt4c8aoO+JoPGF1Smc+JRuCH2s5j5hBdteBi0e10G0xQdQ==}
+ engines: {node: '>=20.19.0'}
+ peerDependencies:
+ '@ts-macro/tsc': ^0.3.6
+ '@typescript/native-preview': '>=7.0.0-dev.20250601.1'
+ rolldown: ^1.0.0-beta.51
+ typescript: ^5.0.0
+ vue-tsc: ~3.1.0
+ peerDependenciesMeta:
+ '@ts-macro/tsc':
+ optional: true
+ '@typescript/native-preview':
+ optional: true
+ typescript:
+ optional: true
+ vue-tsc:
+ optional: true
+
+ resolution: {integrity: sha512-Qd9c2p0XKZdgT5AYd+KgAMggJ8ZmCs3JnS9PTMWkyUfteKlfmKtxJbWTHkVakxwXs1Ub7jrRYVeFeF7N0sQxyw==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ hasBin: true
+
+ resolution: {integrity: sha512-ZrT53oAKrtA4+YtBWPQbtPOxIbVDbxT0orcYERKd63VJTF13zPcgXTvD4843L8pcsI7M6MErt8QtON6lrB9tyA==}
+ engines: {node: ^20.19.0 || >=22.12.0}
+ hasBin: true
+
resolution: {integrity: sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
@@ -3162,6 +4507,13 @@ packages:
resolution: {integrity: sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==}
+ engines: {node: '>=6'}
+
+ resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==}
+
resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==}
@@ -3197,6 +4549,10 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-Mb/GvXPHBAXdgGIcnfU5L3ldpn1XcxrGkPHwqgRx17/I2XRfqlFKk2vGkHWINn1kdXvzJZeuO3is6I9KLPFm0g==}
+ engines: {node: '>=20'}
+
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
@@ -3219,6 +4575,9 @@ packages:
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}
+
resolution: {integrity: sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==}
@@ -3252,6 +4611,9 @@ packages:
resolution: {integrity: sha512-xSJq+BS52SaFFAVxuStmx6n5aYZU571uYUnUrPXkPFCfdHyZMMlbP2v2Wx5sNBnAVzq/2+0+mcBLBa3Xa5ubYw==}
+ resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==}
+
resolution: {integrity: sha512-SlyRoSkdh1dYP0PzclLE7r0M9sgbFKKMFXpFRUMNuKhQSbC6VQIGzq3E0qsfvGJaUFJPGv6Ws1NZ/haTAjfbMA==}
engines: {node: '>=12'}
@@ -3346,6 +4708,13 @@ packages:
resolution: {integrity: sha512-A5F0cM6+mDleacLIEUkmfpkBbnHJFV1d2rprHU2MXNk7mlxHq2zGojA+SRvQD1RoMo9gqjZPWEaKG4v1BQ48lw==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
+ resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
+ hasBin: true
+
+ resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==}
+
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
@@ -3358,6 +4727,32 @@ packages:
resolution: {integrity: sha512-6s5V71mX8qBUmlgbrfL33xDUwO0fq48rxAu2LBE11WBeGdpCPOsXksQbZJHvHwhrd3QjUusd3mAOM5Gg0mFBLg==}
+ resolution: {integrity: sha512-z+kNuv1rwM1POQIufDUVrdNc/uGy0ueRVafCyDH39IdHxin4JXgB8DNGSPoqdIpcOpqUoRbNreK8NxENFmlhKw==}
+ engines: {node: '>=20.19.0'}
+ deprecated: Including an unexpected breaking change (copy behavior)
+ hasBin: true
+ peerDependencies:
+ '@arethetypeswrong/core': ^0.18.1
+ '@vitejs/devtools': ^0.0.0-alpha.19
+ publint: ^0.3.0
+ typescript: ^5.0.0
+ unplugin-lightningcss: ^0.4.0
+ unplugin-unused: ^0.5.0
+ peerDependenciesMeta:
+ '@arethetypeswrong/core':
+ optional: true
+ '@vitejs/devtools':
+ optional: true
+ publint:
+ optional: true
+ typescript:
+ optional: true
+ unplugin-lightningcss:
+ optional: true
+ unplugin-unused:
+ optional: true
+
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -3401,6 +4796,9 @@ packages:
resolution: {integrity: sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==}
+ resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}
+
resolution: {integrity: sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==}
@@ -3413,6 +4811,16 @@ packages:
resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==}
+ resolution: {integrity: sha512-h9FxYVpztY/wwq+bauLOh6Y3CWu2IVeRLq5lxzneBiIU9Tn86OGp9xiQrGhnYspAmg5dzdY0Cc8+Y70kuTARCg==}
+ engines: {node: '>=20.19.0'}
+ hasBin: true
+ peerDependencies:
+ synckit: ^0.11.11
+ peerDependenciesMeta:
+ synckit:
+ optional: true
+
resolution: {integrity: sha512-ZZ61DsRsOnakl74HAmp3oSN4aXUmEWXf+i/yv0h7tIBfICc3VdrFErQKUUKPgu3AMsTUMbcongALEN4l6GSUrQ==}
hasBin: true
@@ -3422,6 +4830,11 @@ packages:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
+ resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+
resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==}
peerDependencies:
@@ -3466,6 +4879,12 @@ packages:
resolution: {integrity: sha512-sXMwN6DMHeouPfCxkxWkKAmxphWKEenHYY5H1nIBzU3PmDsmJp6kBXJdshjVdpMZuWCmL9SH7KFRx29AylpP6g==}
engines: {node: '>=18.12.0'}
+ resolution: {integrity: sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==}
+
+ resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
+
resolution: {integrity: sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==}
engines: {node: ^20.19.0 || >=22.12.0}
@@ -3578,6 +4997,18 @@ packages:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==}
+ engines: {node: '>=10.0.0'}
+ peerDependencies:
+ bufferutil: ^4.0.1
+ utf-8-validate: '>=5.0.2'
+ peerDependenciesMeta:
+ bufferutil:
+ optional: true
+ utf-8-validate:
+ optional: true
+
resolution: {integrity: sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==}
engines: {node: '>=18'}
@@ -3612,6 +5043,21 @@ packages:
resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
+ resolution: {integrity: sha512-QFJWJMdlETcI69paJwhSMJz7PPWjVP8Sjhclxmxmxv/RYI7ZOvR5BHX+ktH0we9gTWQMxcne8q1OY8xxz604gw==}
+ engines: {node: '>=12.7.0'}
+ peerDependencies:
+ '@types/react': '>=16.8'
+ immer: '>=9.0'
+ react: '>=16.8'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ immer:
+ optional: true
+ react:
+ optional: true
+
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
@@ -3823,17 +5269,663 @@ snapshots:
'@babel/helper-string-parser': 7.29.7
'@babel/helper-validator-identifier': 7.29.7
- '@clack/[email protected]':
+ '@clack/[email protected]':
+ dependencies:
+ fast-wrap-ansi: 0.2.2
+ sisteransi: 1.0.5
+
+ '@clack/[email protected]':
+ dependencies:
+ '@clack/core': 1.4.3
+ fast-string-width: 3.0.2
+ fast-wrap-ansi: 0.2.2
+ sisteransi: 1.0.5
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected])':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cordis-plugin-loader': 1.0.3(@deepseek-ai/[email protected])
+ '@deepseek-ai/cosmokit': 1.8.3
+ js-yaml: 4.3.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cosmokit': 1.8.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected])':
+ dependencies:
+ '@deepseek-ai/cosmokit': 1.8.3
+ '@standard-schema/spec': 1.1.0
+ optionalDependencies:
+ '@deepseek-ai/cordis-plugin-include': 1.0.7(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cordis-plugin-loader': 1.0.3(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected]': {}
+
+ '@deepseek-ai/[email protected](edacf9f8ba0c27e3b4f69fb1bdbd2388)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](7f53f19a99d4833cbc7f611eb4726ee4)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cordis-plugin-include': 1.0.7(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cordis-plugin-loader': 1.0.3(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-atomic-write': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-home-paths': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-system-prompt': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/schemastery': 3.18.2
+ js-yaml: 4.3.2
+
+ '@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-system-prompt': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-client-connection': 0.1.1-rc.2(9b40f28fccfb9ee3f86188afc9586c29)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-typert-registry': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+
+ '@deepseek-ai/[email protected](1846128d6a9437517cd6caf5e578f4a3)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-agent-presets': 0.1.1-rc.2(7f53f19a99d4833cbc7f611eb4726ee4)
+ '@deepseek-ai/dsh-api-gateway': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-commands': 0.1.1-rc.2(0ecd3a66a950f0a38490382753aa1d93)
+ '@deepseek-ai/dsh-cordis-host-runner': 0.1.1-rc.2(c90d5f481a921221b380b90110ccbd94)
+ '@deepseek-ai/dsh-credentials': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-file-reference': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-goal': 0.1.1-rc.2(a40f169b35a63b1d25a94e0ed91514fe)
+ '@deepseek-ai/dsh-host-plugin-inventory': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-message-feedback': 0.1.1-rc.2(b957b1ba06764ef01eadad39e9185151)
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session-reference': 0.1.1-rc.2(535ff208b76500c8770cfd701efd9f97)
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-typert-registry': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](9b40f28fccfb9ee3f86188afc9586c29)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-attachment': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-commands': 0.1.1-rc.2(0ecd3a66a950f0a38490382753aa1d93)
+ '@deepseek-ai/dsh-host-apiproxy': 0.1.1-rc.2(31605019b0807ffb9f5c95b68812bee9)
+ '@deepseek-ai/dsh-host-webserver': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-tools': 0.1.1-rc.2(119bc70f73f8eddebfaa6b47561adeb3)
+ '@deepseek-ai/schemastery': 3.18.2
+ ws: 8.21.3
+ transitivePeerDependencies:
+ - bufferutil
+ - utf-8-validate
+
+ '@deepseek-ai/[email protected](797927102698be5b9d8c746716117375)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-api-remotes': 0.1.1-rc.2(1846128d6a9437517cd6caf5e578f4a3)
+ '@deepseek-ai/dsh-client-connection': 0.1.1-rc.2(9b40f28fccfb9ee3f86188afc9586c29)
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-client-ui-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](1846128d6a9437517cd6caf5e578f4a3))(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-api-remotes': 0.1.1-rc.2(1846128d6a9437517cd6caf5e578f4a3)
+ '@deepseek-ai/dsh-attachment': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-client-connection': 0.1.1-rc.2(9b40f28fccfb9ee3f86188afc9586c29)
+ '@deepseek-ai/dsh-commands': 0.1.1-rc.2(0ecd3a66a950f0a38490382753aa1d93)
+ '@deepseek-ai/dsh-host-apiproxy': 0.1.1-rc.2(31605019b0807ffb9f5c95b68812bee9)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-llm-retry': 0.1.1-rc.2(a0b14eb40667f7e2f3e22b89a59650a0)
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-session-title': 0.1.1-rc.2(54f3cb7dfcb0c20072924b6c262cea76)
+ '@deepseek-ai/dsh-tools': 0.1.1-rc.2(119bc70f73f8eddebfaa6b47561adeb3)
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-typert-registry': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ immer: 10.2.0
+ transitivePeerDependencies:
+ - '@types/react'
+ - react
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](ffa4142e95dc748529b8e9b13f0fdc9c))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-client-ui-theme': 0.1.1-rc.2(ffa4142e95dc748529b8e9b13f0fdc9c)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@shikijs/langs': 4.4.3
+ '@types/mdast': 4.0.4
+ anser: 2.3.5
+ clsx: 2.1.1
+ katex: 0.16.47
+ mdast-util-from-markdown: 2.0.3
+ mdast-util-gfm: 3.1.0
+ mdast-util-math: 3.0.0
+ micromark-core-commonmark: 2.0.3
+ micromark-extension-gfm: 3.0.0
+ micromark-extension-math: 3.1.0
+ micromark-factory-space: 2.0.1
+ micromark-util-character: 2.1.1
+ micromark-util-classify-character: 2.0.1
+ micromark-util-sanitize-uri: 2.0.1
+ micromark-util-symbol: 2.0.1
+ micromark-util-types: 2.0.2
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ shiki: 4.4.3
+ transitivePeerDependencies:
+ - supports-color
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))([email protected])':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ use-sync-external-store: 1.2.0([email protected])
+ transitivePeerDependencies:
+ - react
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](1846128d6a9437517cd6caf5e578f4a3))(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-api-remotes': 0.1.1-rc.2(1846128d6a9437517cd6caf5e578f4a3)
+ '@deepseek-ai/dsh-client-connection': 0.1.1-rc.2(9b40f28fccfb9ee3f86188afc9586c29)
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](ffa4142e95dc748529b8e9b13f0fdc9c)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-api-remotes': 0.1.1-rc.2(1846128d6a9437517cd6caf5e578f4a3)
+ '@deepseek-ai/dsh-client-connection': 0.1.1-rc.2(9b40f28fccfb9ee3f86188afc9586c29)
+ '@deepseek-ai/dsh-client-locale': 0.1.1-rc.2(797927102698be5b9d8c746716117375)
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2(e5adab2ae963dadab496762f294ed0d1)
+ '@deepseek-ai/dsh-client-ui-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](1846128d6a9437517cd6caf5e578f4a3))(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](e5adab2ae963dadab496762f294ed0d1))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-host-webserver': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+ clsx: 2.1.1
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](0ecd3a66a950f0a38490382753aa1d93)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-attachment': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](80d45efbb3b7de81b65c253ede5096fd)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-commands': 0.1.1-rc.2(0ecd3a66a950f0a38490382753aa1d93)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+
+ '@deepseek-ai/[email protected](c90d5f481a921221b380b90110ccbd94)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-tools': 0.1.1-rc.2(119bc70f73f8eddebfaa6b47561adeb3)
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](369bb7c3e084bdd2eec52747b4523f36)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-sandbox': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+
+ '@deepseek-ai/[email protected](a40f169b35a63b1d25a94e0ed91514fe)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](31605019b0807ffb9f5c95b68812bee9)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-agent-default-model': 0.1.1-rc.2(edacf9f8ba0c27e3b4f69fb1bdbd2388)
+ '@deepseek-ai/dsh-agent-presets': 0.1.1-rc.2(7f53f19a99d4833cbc7f611eb4726ee4)
+ '@deepseek-ai/dsh-api-remotes': 0.1.1-rc.2(1846128d6a9437517cd6caf5e578f4a3)
+ '@deepseek-ai/dsh-attachment': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-commands': 0.1.1-rc.2(0ecd3a66a950f0a38490382753aa1d93)
+ '@deepseek-ai/dsh-cordis-host-runner': 0.1.1-rc.2(c90d5f481a921221b380b90110ccbd94)
+ '@deepseek-ai/dsh-credentials': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-goal': 0.1.1-rc.2(a40f169b35a63b1d25a94e0ed91514fe)
+ '@deepseek-ai/dsh-host-directory-picker': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-jobs': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-native-command': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-session-projection-cache': 0.1.1-rc.2(5675a3df65adc346aa213cdd0bac196b)
+ '@deepseek-ai/dsh-session-query': 0.1.1-rc.2(d854f9afd763ce298cb594d238b23507)
+ '@deepseek-ai/dsh-session-title': 0.1.1-rc.2(54f3cb7dfcb0c20072924b6c262cea76)
+ '@deepseek-ai/dsh-settings': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-skill': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-subagent': 0.1.1-rc.2(efe37c49f3ccd66a82181eee8ecad3cb)
+ '@deepseek-ai/dsh-tools': 0.1.1-rc.2(119bc70f73f8eddebfaa6b47561adeb3)
+ '@deepseek-ai/dsh-user-approval': 0.1.1-rc.2(09871eaf880be2109e9d668352ef8c05)
+ '@deepseek-ai/dsh-user-questions': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))
+ '@deepseek-ai/dsh-workspace': 0.1.1-rc.2(ca1aef6913f66bb64a14405a8170db89)
+ '@deepseek-ai/schemastery': 3.18.2
+ fflate: 0.8.3
+ zod: 4.4.3
+ transitivePeerDependencies:
+ - '@deepseek-ai/dsh-api-gateway'
+ - '@deepseek-ai/dsh-code-runtime'
+ - '@deepseek-ai/dsh-file-reference'
+ - '@deepseek-ai/dsh-host-plugin-inventory'
+ - '@deepseek-ai/dsh-message-feedback'
+ - '@deepseek-ai/dsh-sandbox'
+ - '@deepseek-ai/dsh-sandbox-policy'
+ - '@deepseek-ai/dsh-scope'
+ - '@deepseek-ai/dsh-session-reference'
+ - '@deepseek-ai/dsh-storage'
+ - '@deepseek-ai/dsh-storage-domain'
+ - '@deepseek-ai/dsh-system-prompt'
+ - '@deepseek-ai/dsh-timeout'
+ - '@deepseek-ai/dsh-typert-protocol'
+ - '@deepseek-ai/dsh-typert-registry'
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/cordis-plugin-loader': 1.0.3(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+
+ '@deepseek-ai/[email protected](a0b14eb40667f7e2f3e22b89a59650a0)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-timeout': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-attachment': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-timeout': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](b957b1ba06764ef01eadad39e9185151)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-storage-domain': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-timeout': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+
+ '@deepseek-ai/[email protected](5675a3df65adc346aa213cdd0bac196b)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-storage-domain': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](d854f9afd763ce298cb594d238b23507)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-title': 0.1.1-rc.2(54f3cb7dfcb0c20072924b6c262cea76)
+ optionalDependencies:
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+
+ '@deepseek-ai/[email protected](535ff208b76500c8770cfd701efd9f97)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-compaction': 0.1.1-rc.2(80d45efbb3b7de81b65c253ede5096fd)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-output-retention': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-query': 0.1.1-rc.2(d854f9afd763ce298cb594d238b23507)
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](54f3cb7dfcb0c20072924b6c262cea76)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected])':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](48868494a4b9bcea1966f12a762e8376)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-fs': 0.1.1-rc.2(369bb7c3e084bdd2eec52747b4523f36)
+ '@deepseek-ai/dsh-home-paths': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-skill': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/schemastery': 3.18.2
+ chokidar: 5.0.0
+ yaml: 2.9.0
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-storage': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](efe37c49f3ccd66a82181eee8ecad3cb)':
dependencies:
- fast-wrap-ansi: 0.2.2
- sisteransi: 1.0.5
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-tools': 0.1.1-rc.2(119bc70f73f8eddebfaa6b47561adeb3)
+ zod: 4.4.3
+ optionalDependencies:
+ '@deepseek-ai/dsh-agent-presets': 0.1.1-rc.2(7f53f19a99d4833cbc7f611eb4726ee4)
+ '@deepseek-ai/dsh-jobs': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-sandbox': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-session-projection': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))
+ '@deepseek-ai/dsh-session-projection-cache': 0.1.1-rc.2(5675a3df65adc346aa213cdd0bac196b)
+ '@deepseek-ai/dsh-user-approval': 0.1.1-rc.2(09871eaf880be2109e9d668352ef8c05)
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](119bc70f73f8eddebfaa6b47561adeb3)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-code-runtime': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-system-prompt': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-user-approval': 0.1.1-rc.2(09871eaf880be2109e9d668352ef8c05)
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-typert-protocol': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ zod: 4.4.3
- '@clack/[email protected]':
+ '@deepseek-ai/[email protected](09871eaf880be2109e9d668352ef8c05)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-scope': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-system-prompt': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/schemastery': 3.18.2
+
+ '@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](c1537a8836b04097f168b024f1e38d85))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-agent': 0.1.1-rc.2(c1537a8836b04097f168b024f1e38d85)
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-llm': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+
+ '@deepseek-ai/[email protected](ca1aef6913f66bb64a14405a8170db89)':
+ dependencies:
+ '@deepseek-ai/cordis': 4.0.1(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-brand': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-invariants': 0.1.1-rc.2(@deepseek-ai/[email protected])
+ '@deepseek-ai/dsh-session': 0.1.1-rc.2(a4e4bb24a1f3580ac25e11cfa3c6b8cc)
+ '@deepseek-ai/dsh-session-persistence': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](a4e4bb24a1f3580ac25e11cfa3c6b8cc))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ '@deepseek-ai/dsh-storage': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))
+ '@deepseek-ai/dsh-storage-domain': 0.1.1-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])))
+ zod: 4.4.3
+
+ '@deepseek-ai/[email protected]':
dependencies:
- '@clack/core': 1.4.3
- fast-string-width: 3.0.2
- fast-wrap-ansi: 0.2.2
- sisteransi: 1.0.5
+ '@deepseek-ai/cosmokit': 1.8.3
+ '@standard-schema/spec': 1.1.0
dependencies:
@@ -3843,22 +5935,40 @@ snapshots:
optionalDependencies:
eslint: 10.8.1([email protected])
+ '@emnapi/[email protected]':
+ dependencies:
+ '@emnapi/wasi-threads': 1.2.1
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
'@emnapi/wasi-threads': 1.2.2
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
optional: true
+ '@emnapi/[email protected]':
+ dependencies:
+ tslib: 2.8.1
+ optional: true
+
'@emnapi/[email protected]':
dependencies:
tslib: 2.8.1
optional: true
+ '@emotion/[email protected]': {}
+
'@es-joy/[email protected]':
dependencies:
'@types/estree': 1.0.9
@@ -4250,6 +6360,13 @@ snapshots:
'@napi-rs/[email protected]':
optional: true
+ dependencies:
+ '@emnapi/core': 1.10.0
+ '@emnapi/runtime': 1.10.0
+ '@tybys/wasm-util': 0.10.3
+ optional: true
+
dependencies:
'@emnapi/core': 1.11.2
@@ -4325,6 +6442,10 @@ snapshots:
'@oxc-parser/[email protected]':
optional: true
+ '@oxc-project/[email protected]': {}
+
+ '@oxc-project/[email protected]': {}
+
'@oxc-project/[email protected]': {}
'@oxc-resolver/[email protected]':
@@ -4390,6 +6511,10 @@ snapshots:
'@pkgr/[email protected]': {}
+ '@publint/[email protected]':
+ dependencies:
+ tinyexec: 1.3.0
+
'@quansync/[email protected]':
dependencies:
quansync: 1.0.0
@@ -4528,8 +6653,105 @@ snapshots:
dependencies:
react: 19.2.8
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ dependencies:
+ '@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
+ transitivePeerDependencies:
+ - '@emnapi/core'
+ - '@emnapi/runtime'
+ optional: true
+
+ '@rolldown/[email protected]':
+ dependencies:
+ '@emnapi/core': 1.10.0
+ '@emnapi/runtime': 1.10.0
+ '@napi-rs/wasm-runtime': 1.2.3(@emnapi/[email protected])(@emnapi/[email protected])
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
+ '@rolldown/[email protected]':
+ optional: true
+
'@rolldown/[email protected]': {}
+ '@rolldown/[email protected]': {}
+
+ '@rolldown/[email protected]': {}
+
'@rollup/[email protected]':
optional: true
@@ -4605,6 +6827,46 @@ snapshots:
'@rollup/[email protected]':
optional: true
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/primitive': 4.4.3
+ '@shikijs/types': 4.4.3
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.5
+ hast-util-to-html: 9.0.5
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.4.3
+ '@shikijs/vscode-textmate': 10.0.2
+ oniguruma-to-es: 4.3.6
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.4.3
+ '@shikijs/vscode-textmate': 10.0.2
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.4.3
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.4.3
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.5
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/types': 4.4.3
+
+ '@shikijs/[email protected]':
+ dependencies:
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.5
+
+ '@shikijs/[email protected]': {}
+
'@sindresorhus/[email protected]': {}
@@ -4854,6 +7116,9 @@ snapshots:
dependencies:
csstype: 3.2.3
+ '@types/[email protected]':
+ optional: true
+
'@types/[email protected]': {}
@@ -4947,6 +7212,8 @@ snapshots:
'@typescript-eslint/types': 8.67.0
eslint-visitor-keys: 5.0.1
+ '@ungap/[email protected]': {}
+
dependencies:
'@babel/core': 7.29.7
@@ -5059,6 +7326,8 @@ snapshots:
json-schema-traverse: 0.4.1
uri-js: 4.4.1
+
@@ -5068,6 +7337,8 @@ snapshots:
+
@@ -5076,6 +7347,11 @@ snapshots:
+ dependencies:
+ '@babel/parser': 7.29.8
+ pathe: 2.0.3
+
dependencies:
'@babel/types': 7.29.8
@@ -5090,6 +7366,8 @@ snapshots:
+
@@ -5156,6 +7434,8 @@ snapshots:
pkg-types: 2.3.1
rc9: 3.0.1
+
@@ -5199,6 +7479,10 @@ snapshots:
transitivePeerDependencies:
- magicast
+
+
@@ -5235,6 +7519,8 @@ snapshots:
+
@@ -5277,6 +7563,11 @@ snapshots:
dependencies:
hyphenate-style-name: 1.1.0
+ dependencies:
+ '@emotion/hash': 0.8.0
+ csstype: 3.0.11
+
dependencies:
mdn-data: 2.0.14
@@ -5284,6 +7575,8 @@ snapshots:
+
@@ -5328,10 +7621,18 @@ snapshots:
'@babel/runtime': 7.29.7
csstype: 3.2.3
+ optionalDependencies:
+ '@types/trusted-types': 2.0.7
+
+ optionalDependencies:
+ oxc-resolver: 11.24.2
+
@@ -5804,6 +8105,8 @@ snapshots:
optionalDependencies:
picomatch: 4.0.5
+
dependencies:
flat-cache: 4.0.1
@@ -5881,6 +8184,26 @@ snapshots:
+ dependencies:
+ '@types/hast': 3.0.5
+ '@types/unist': 3.0.3
+ ccount: 2.0.1
+ comma-separated-tokens: 2.0.3
+ hast-util-whitespace: 3.0.0
+ html-void-elements: 3.0.0
+ mdast-util-to-hast: 13.2.1
+ property-information: 7.2.0
+ space-separated-tokens: 2.0.2
+ stringify-entities: 4.0.4
+ zwitch: 2.0.4
+
+ dependencies:
+ '@types/hast': 3.0.5
+
+
@@ -5889,6 +8212,8 @@ snapshots:
+
@@ -5903,6 +8228,10 @@ snapshots:
+
+
@@ -5964,6 +8293,10 @@ snapshots:
+ dependencies:
+ argparse: 2.0.1
+
@@ -6102,6 +8435,8 @@ snapshots:
+
dependencies:
'@types/mdast': 4.0.4
@@ -6211,6 +8546,18 @@ snapshots:
'@types/mdast': 4.0.4
unist-util-is: 6.0.1
+ dependencies:
+ '@types/hast': 3.0.5
+ '@types/mdast': 4.0.4
+ '@ungap/structured-clone': 1.4.0
+ devlop: 1.1.0
+ micromark-util-sanitize-uri: 2.0.1
+ trim-lines: 3.0.1
+ unist-util-position: 5.0.0
+ unist-util-visit: 5.1.0
+ vfile: 6.0.3
+
dependencies:
'@types/mdast': 4.0.4
@@ -6536,6 +8883,14 @@ snapshots:
+
+ dependencies:
+ oniguruma-parser: 0.12.2
+ regex: 6.1.0
+ regex-recursion: 6.0.2
+
dependencies:
default-browser: 5.5.1
@@ -6684,8 +9039,17 @@ snapshots:
object-assign: 4.1.1
react-is: 16.13.1
+
+ dependencies:
+ '@publint/pack': 0.1.7
+ package-manager-detector: 1.8.0
+ picocolors: 1.1.1
+ sade: 1.8.1
+
@@ -6730,6 +9094,12 @@ snapshots:
react-stately: 3.49.0([email protected])
use-sync-external-store: 1.6.0([email protected])
+ dependencies:
+ loose-envify: 1.4.0
+ react: 18.3.1
+ scheduler: 0.23.2
+
dependencies:
react: 19.2.8
@@ -6797,6 +9167,10 @@ snapshots:
ts-easing: 0.2.0
tslib: 2.8.1
+ dependencies:
+ loose-envify: 1.4.0
+
@@ -6809,6 +9183,16 @@ snapshots:
dependencies:
'@eslint-community/regexpp': 4.12.2
+ dependencies:
+ regex-utilities: 2.3.0
+
+
+ dependencies:
+ regex-utilities: 2.3.0
+
dependencies:
'@eslint-community/regexpp': 4.12.2
@@ -6824,6 +9208,66 @@ snapshots:
+ dependencies:
+ '@babel/generator': 7.29.8
+ '@babel/parser': 7.29.8
+ '@babel/types': 7.29.8
+ ast-kit: 2.2.0
+ birpc: 4.2.0
+ dts-resolver: 2.1.3([email protected])
+ get-tsconfig: 4.14.2
+ magic-string: 0.30.21
+ obug: 2.1.4
+ rolldown: 1.0.0-beta.53(@emnapi/[email protected])(@emnapi/[email protected])
+ optionalDependencies:
+ typescript: 5.8.3
+ transitivePeerDependencies:
+ - oxc-resolver
+
+ dependencies:
+ '@oxc-project/types': 0.101.0
+ '@rolldown/pluginutils': 1.0.0-beta.53
+ optionalDependencies:
+ '@rolldown/binding-android-arm64': 1.0.0-beta.53
+ '@rolldown/binding-darwin-arm64': 1.0.0-beta.53
+ '@rolldown/binding-darwin-x64': 1.0.0-beta.53
+ '@rolldown/binding-freebsd-x64': 1.0.0-beta.53
+ '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.53
+ '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.53
+ '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.53
+ '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.53
+ '@rolldown/binding-linux-x64-musl': 1.0.0-beta.53
+ '@rolldown/binding-openharmony-arm64': 1.0.0-beta.53
+ '@rolldown/binding-wasm32-wasi': 1.0.0-beta.53(@emnapi/[email protected])(@emnapi/[email protected])
+ '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.53
+ '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.53
+ transitivePeerDependencies:
+ - '@emnapi/core'
+ - '@emnapi/runtime'
+
+ dependencies:
+ '@oxc-project/types': 0.127.0
+ '@rolldown/pluginutils': 1.0.0-rc.17
+ optionalDependencies:
+ '@rolldown/binding-android-arm64': 1.0.0-rc.17
+ '@rolldown/binding-darwin-arm64': 1.0.0-rc.17
+ '@rolldown/binding-darwin-x64': 1.0.0-rc.17
+ '@rolldown/binding-freebsd-x64': 1.0.0-rc.17
+ '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.17
+ '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.17
+ '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.17
+ '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.17
+ '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.17
+ '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.17
+ '@rolldown/binding-linux-x64-musl': 1.0.0-rc.17
+ '@rolldown/binding-openharmony-arm64': 1.0.0-rc.17
+ '@rolldown/binding-wasm32-wasi': 1.0.0-rc.17
+ '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.17
+ '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.17
+
dependencies:
'@types/estree': 1.0.9
@@ -6862,6 +9306,14 @@ snapshots:
+ dependencies:
+ mri: 1.2.0
+
+ dependencies:
+ loose-envify: 1.4.0
+
@@ -6886,6 +9338,17 @@ snapshots:
+ dependencies:
+ '@shikijs/core': 4.4.3
+ '@shikijs/engine-javascript': 4.4.3
+ '@shikijs/engine-oniguruma': 4.4.3
+ '@shikijs/langs': 4.4.3
+ '@shikijs/themes': 4.4.3
+ '@shikijs/types': 4.4.3
+ '@shikijs/vscode-textmate': 10.0.2
+ '@types/hast': 3.0.5
+
@@ -6898,6 +9361,8 @@ snapshots:
+
@@ -6932,6 +9397,11 @@ snapshots:
+ dependencies:
+ character-entities-html4: 2.1.0
+ character-entities-legacy: 3.0.0
+
@@ -7012,6 +9482,10 @@ snapshots:
dependencies:
eslint-visitor-keys: 5.0.1
+
+
dependencies:
typescript: 5.8.3
@@ -7020,6 +9494,35 @@ snapshots:
+ dependencies:
+ ansis: 4.3.1
+ cac: 6.7.14
+ defu: 6.1.7
+ empathic: 2.0.1
+ hookable: 5.5.3
+ import-without-cache: 0.2.5
+ obug: 2.1.4
+ rolldown: 1.0.0-beta.53(@emnapi/[email protected])(@emnapi/[email protected])
+ semver: 7.8.5
+ tinyexec: 1.3.0
+ tinyglobby: 0.2.17
+ tree-kill: 1.2.2
+ unconfig-core: 7.5.0
+ unrun: 0.2.39([email protected])
+ optionalDependencies:
+ publint: 0.3.24
+ typescript: 5.8.3
+ transitivePeerDependencies:
+ - '@emnapi/core'
+ - '@emnapi/runtime'
+ - '@ts-macro/tsc'
+ - '@typescript/native-preview'
+ - oxc-resolver
+ - synckit
+ - vue-tsc
+
@@ -7061,6 +9564,10 @@ snapshots:
dependencies:
'@types/unist': 3.0.3
+ dependencies:
+ '@types/unist': 3.0.3
+
dependencies:
'@types/unist': 3.0.3
@@ -7081,6 +9588,12 @@ snapshots:
unist-util-is: 6.0.1
unist-util-visit-parents: 6.0.2
+ dependencies:
+ rolldown: 1.0.0-rc.17
+ optionalDependencies:
+ synckit: 0.11.13
+
dependencies:
browserslist: 4.28.8
@@ -7091,6 +9604,10 @@ snapshots:
dependencies:
punycode: 2.3.1
+ dependencies:
+ react: 19.2.8
+
dependencies:
react: 19.2.8
@@ -7130,6 +9647,16 @@ snapshots:
+ dependencies:
+ '@types/unist': 3.0.3
+ unist-util-stringify-position: 4.0.0
+
+ dependencies:
+ '@types/unist': 3.0.3
+ vfile-message: 4.0.3
+
dependencies:
esbuild: 0.28.2
@@ -7202,6 +9729,8 @@ snapshots:
+
dependencies:
is-wsl: 3.1.1
@@ -7225,4 +9754,12 @@ snapshots:
+ dependencies:
+ use-sync-external-store: 1.2.0([email protected])
+ optionalDependencies:
+ '@types/react': 19.2.18
+ immer: 10.2.0
+ react: 19.2.8
+
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 70d54e3f..73fcb88a 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -1,3 +1,5 @@
+catalogMode: prefer
+
shellEmulator: true
trustPolicy: no-downgrade
@@ -6,9 +8,97 @@ trustPolicy: no-downgrade
# package's adoption of trusted publishing and falsely read as a "trust downgrade".
trustPolicyIgnoreAfter: 525600
+# 让 pnpm deploy(无 --legacy)产出「注入式」的紧凑生产闭包:把 workspace 包作为依赖
+# 注入到产物 node_modules,而不是链接到共享存储,从而只捆绑插件及其真实生产依赖。
+inject-workspace-packages: true
+
+packages:
+ - 'packages/*'
+
patchedDependencies:
bumpp: patches/bumpp.patch
+# 命名 catalog 分组:按用途归类依赖,包内通过 `catalog:<分组>` 引用。
+catalogs:
+ # 构建工具链(Vite + Tailwind + TS 编译 + React 编译器)
+ build:
+ '@tailwindcss/postcss': 4.1.11
+ '@tailwindcss/vite': 4.1.11
+ '@vitejs/plugin-react': ^4.6.0
+ babel-plugin-react-compiler: ^1.0.0
+ tailwindcss: 4.1.11
+ tsx: ^4.23.12
+ vite: ^7.0.4
+ # CLI 构建工具(插件全部依赖 tsdown / typescript)
+ cli:
+ publint: ^0.3.16
+ tsdown: ^0.17.3
+ typescript: ~5.8.3
+ # dsh 生态(核心 + 客户端 UI/运行时 + 技能)
+ dsh:
+ '@deepseek-ai/cordis': 4.0.1
+ '@deepseek-ai/dsh-client-runtime': 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-layout': 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-primitives': 0.1.1-rc.2
+ '@deepseek-ai/dsh-client-ui-renderer': 0.1.1-rc.2
+ '@deepseek-ai/dsh-skill-filesystem': ^0.1.1-rc.1
+ # 代码质量 / lint(eslint stack + knip 死代码检测)
+ lint:
+ '@antfu/eslint-config': ^9.3.0
+ '@eslint-react/eslint-plugin': ^5.18.6
+ eslint: ^10.8.1
+ eslint-plugin-react-refresh: ^0.5.4
+ knip: ^6.32.2
+ # 发布流程
+ release:
+ bumpp: 12.2.1
+ changelogithub: 15.0.5
+ # 桌面端运行时与 UI 依赖(React 生态、状态、i18n、UI 组件库)
+ runtime:
+ '@gravity-ui/icons': ^2.21.0
+ '@hairy/react-lib': ^1.52.0
+ '@heroui/react': ^3.2.4
+ '@heroui/styles': ^3.2.4
+ '@overlastic/react': ^0.9.0
+ '@tanstack/react-query': ^5.101.4
+ i18next: ^26.3.6
+ react: ^19.2.8
+ react-dom: ^19.2.8
+ react-i18next: ^17.0.11
+ react-if-lite: ^0.1.0
+ react-use: ^17.6.1
+ tailwind-variants: ^3.3.1
+ valtio-define: ^1.4.1
+ # Tauri 相关
+ tauri:
+ '@tauri-apps/api': ^2.11.1
+ '@tauri-apps/cli': ^2.11.4
+ '@tauri-apps/plugin-clipboard-manager': ^2.3.2
+ # 测试
+ testing:
+ vitest: ^4.1.11
+ yaml: ^2.9.0
+ # TypeScript 类型定义
+ types:
+ '@types/node': ^22.10.0
+ '@types/react': ^19.2.18
+ '@types/react-dom': ^19.2.4
+ # UI 呈现(插件渲染富文本/样式)
+ ui:
+ css-render: ^0.15.14
+ dompurify: ^3.4.13
+ marked: ^18.0.10
+
+ # 工具库(根项目与插件共用)
+ utils:
+ '@hairy/utils': ^1.52.0
+ citty: ^0.2.2
+ consola: ^3.4.2
+ dotenv: ^17.4.2
+ pathe: ^2.0.3
+ smol-toml: ^1.3.1
+ tinyexec: ^1.3.0
+
allowBuilds:
'@tailwindcss/oxide': true
esbuild: true
diff --git a/scripts/build-plugins.ts b/scripts/build-plugins.ts
new file mode 100644
index 00000000..b59050fa
--- /dev/null
+++ b/scripts/build-plugins.ts
@@ -0,0 +1,121 @@
+import { spawnSync } from 'node:child_process'
+import { cpSync, existsSync, readFileSync, rmSync } from 'node:fs'
+import { join, resolve } from 'node:path'
+import process from 'node:process'
+
+const REPO_ROOT = resolve(import.meta.dirname, '..')
+const PACKAGES_ROOT = join(REPO_ROOT, 'packages')
+const BUNDLE_PACKAGE = join(PACKAGES_ROOT, 'dsh-tauri-bundle', 'package.json')
+const RESOURCE_ROOT = join(REPO_ROOT, 'src-tauri', 'resources')
+/** 运行期实际依赖的部署产物:`resources/node_modules/<name>`(Tauri 只捆绑 `resources/**`) */
+const DEPLOYED_NODE_MODULES = join(RESOURCE_ROOT, 'node_modules')
+
+function run(args: readonly string[]): void {
+ console.log(`[build:plugins] $ pnpm ${args.join(' ')}`)
+ const result = spawnSync('pnpm', args, {
+ cwd: REPO_ROOT,
+ stdio: 'inherit',
+ shell: process.platform === 'win32',
+ })
+ if (result.error !== undefined) {
+ throw new Error(`PNPM_START_FAILED: ${result.error.message}`)
+ }
+ if (result.status !== 0) {
+ throw new Error(`PNPM_COMMAND_FAILED: pnpm ${args.join(' ')} exited with ${result.status}`)
+ }
+}
+
+function bundledPackageNames(): string[] {
+ if (!existsSync(BUNDLE_PACKAGE)) {
+ throw new Error(`PLUGIN_BUNDLE_MANIFEST_MISSING: ${BUNDLE_PACKAGE}`)
+ }
+ const manifest = JSON.parse(readFileSync(BUNDLE_PACKAGE, 'utf8')) as {
+ dependencies?: Record<string, unknown>
+ }
+ const names = Object.keys(manifest.dependencies ?? {})
+ if (names.length === 0) {
+ throw new Error('PLUGIN_BUNDLE_EMPTY: dsh-tauri-bundle must depend on plugins')
+ }
+ return names
+}
+
+function verifyDeployedPackages(names: readonly string[], nodeModulesRoot: string): void {
+ for (const name of names) {
+ const packageJson = join(nodeModulesRoot, name, 'package.json')
+ if (!existsSync(packageJson)) {
+ throw new Error(`PLUGIN_DEPLOY_MISSING: ${packageJson}`)
+ }
+ const manifest = JSON.parse(readFileSync(packageJson, 'utf8')) as {
+ main?: unknown
+ dsh?: unknown
+ }
+ if (typeof manifest.dsh !== 'object' || manifest.dsh === null || Array.isArray(manifest.dsh)) {
+ throw new Error(`PLUGIN_DEPLOY_INVALID_DSH: ${packageJson}`)
+ }
+ if (typeof manifest.main === 'string' && !existsSync(join(nodeModulesRoot, name, manifest.main))) {
+ throw new Error(`PLUGIN_DEPLOY_MISSING_ENTRY: ${join(nodeModulesRoot, name, manifest.main)}`)
+ }
+ }
+}
+
+function main(): void {
+ const names = bundledPackageNames()
+ // 先生成最新 dist,再打包 production 闭包。部署到独立临时目录并校验通过后,
+ // 才把自包含的 node_modules 落到 `resources/node_modules`:任一环节失败即中止,
+ // 绝不留下半成品资源。
+ run([
+ '--filter',
+ './packages/*',
+ '--filter',
+ '!dsh-tauri-bundle',
+ '--filter',
+ '!dsh-tauri-tsdown',
+ '-r',
+ 'run',
+ 'build',
+ ])
+
+ // pnpm v10 的 deploy 默认命中「legacy」算法:把产物链接到全局共享存储,导致部署出
+ // 来的 node_modules 混入整个 workspace 的生产依赖(桌面壳的 React/UI 栈全部冗余)。
+ // 改为现代「注入式」deploy(`--config.inject-workspace-packages=true`),只把 bundle 的
+ // workspace 依赖及其真实生产闭包注入产物,得到紧凑可移植的 node_modules。
+ // 目标必须是空目录(src-tauri/resources 内含下发清单,不能直接部署)且为相对路径,
+ // 因此先部署到仓库内相对临时目录,再把自包含的 node_modules 落入 resources/node_modules。
+ const deployTarget = '.build-plugins-tmp'
+ const temp = join(REPO_ROOT, deployTarget)
+ rmSync(temp, { recursive: true, force: true })
+ rmSync(DEPLOYED_NODE_MODULES, { recursive: true, force: true })
+ try {
+ run([
+ '--filter',
+ 'dsh-tauri-bundle',
+ 'deploy',
+ '--prod',
+ '--config.inject-workspace-packages=true',
+ deployTarget,
+ ])
+ const deployed = join(temp, 'node_modules')
+ if (!existsSync(deployed)) {
+ throw new Error(`PLUGIN_DEPLOY_EMPTY: pnpm deploy did not produce node_modules at ${deployed}`)
+ }
+ cpSync(deployed, DEPLOYED_NODE_MODULES, { recursive: true, dereference: true })
+ verifyDeployedPackages(names, DEPLOYED_NODE_MODULES)
+ console.log(`[build:plugins] deployed ${names.length} plugins to ${RESOURCE_ROOT}`)
+ }
+ catch (error) {
+ // 部署失败则清理半成品,避免残留误导;成功时保留供 Tauri 打包。
+ rmSync(DEPLOYED_NODE_MODULES, { recursive: true, force: true })
+ throw error
+ }
+ finally {
+ rmSync(temp, { recursive: true, force: true })
+ }
+}
+
+try {
+ main()
+}
+catch (error) {
+ console.error(`[build:plugins] ${error instanceof Error ? error.message : error}`)
+ process.exitCode = 1
+}
diff --git a/scripts/prebuild.ts b/scripts/prebuild.ts
deleted file mode 100644
index 499fedc3..00000000
--- a/scripts/prebuild.ts
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * prebuild:把 `src-tauri/resources/internal-plugins.json` 中声明的内部插件
- * 制备为 production workspace,并通过 `pnpm deploy` 输出到
- * `resources/node_modules/<package-name>/`(随 `bundle.resources` 随安装包分发)。两种来源:
- *
- * - `github:owner/repo`:从上游仓库克隆、安装依赖并构建(源码形态的插件);
- * - npm 包名(`name[@version]`):从 npm registry 拉取已发布产物,并在隔离 staging
- * 中安装 production 依赖后一起搬运(发布包自带 lib/,如 [email protected])。
- *
- * 可通过 `DSH_RESOURCE_PLUGINS_DIR` 指定输出根目录,便于发布前独立验证资源包;未设置时
- * 默认输出到桌面端 Tauri resources 目录。
- *
- * 由 `pnpm build` 的 prebuild 生命周期自动触发(tauri 的 `beforeBuildCommand` 为
- * `pnpm build`,pnpm 先执行 `prebuild` 脚本)。应用启动时(service::plugin::internal)
- * 会核对内置插件是否已安装、安装路径是否仍指向该捆绑目录,未满足即强制重装。
- *
- * 约束:仅用 Node 内置模块(零新增依赖);需要 git 与 pnpm 在 PATH 上;
- * 构建机器需可访问 GitHub 与 npm registry。通过 `tsx scripts/prebuild.ts`
- * 直接运行(TS + ESM),无需预编译。
- */
-import { spawnSync } from 'node:child_process'
-import {
- cpSync,
- existsSync,
- mkdirSync,
- mkdtempSync,
- readdirSync,
- readFileSync,
- realpathSync,
- rmSync,
- writeFileSync,
-} from 'node:fs'
-import { tmpdir } from 'node:os'
-import { join, resolve } from 'node:path'
-import process from 'node:process'
-
-interface InternalPlugin {
- id: string
- spec: string
-}
-
-const REPO_ROOT = resolve(import.meta.dirname, '..')
-const INTERNAL_PLUGINS_FILE = join(REPO_ROOT, 'src-tauri', 'resources', 'internal-plugins.json')
-const RESOURCE_ROOT = resolve(process.env.DSH_RESOURCE_PLUGINS_DIR ?? join(REPO_ROOT, 'src-tauri', 'resources'))
-const BUNDLE_ROOT = join(RESOURCE_ROOT, 'node_modules')
-const GIT_URL_RE = /^github:([^#/]+\/[^#/]+)(?:#.*)?$/
-
-function die(message: string): never {
- console.error(`[prebuild] ${message}`)
- process.exit(1)
-}
-
-/** 同步执行命令,非零退出码即终止构建(内置插件缺失是发布缺陷,必须响亮失败)。 */
-function run(program: string, args: readonly string[], cwd: string): void {
- console.log(`[prebuild] $ ${program} ${args.join(' ')}`)
- const result = spawnSync(program, [...args], {
- cwd,
- stdio: 'inherit',
- shell: process.platform === 'win32',
- })
- if (result.error !== undefined) {
- die(`${program} 启动失败: ${result.error.message}`)
- }
- if (result.status !== 0) {
- die(`${program} ${args.join(' ')} 退出码 ${result.status}`)
- }
-}
-
-/** `github:owner/repo[#ref]` → 可克隆的 https URL(忽略 ref,拉默认分支最新)。 */
-function githubUrl(spec: string): string {
- const match = GIT_URL_RE.exec(spec)
- if (match === null) {
- die(`internal 插件 spec 必须是 github:owner/repo 形式,当前为: ${spec}`)
- }
- const repo = match[1].replace(/\.git$/, '')
- return `https://github.com/${repo}.git`
-}
-
-/** `name[@version]`(含 scoped `@scope/name[@version]`)→ 裸包名,用于定位 node_modules。 */
-function npmPackageName(spec: string): string {
- const at = spec.indexOf('@', spec.startsWith('@') ? spec.indexOf('/') + 1 : 0)
- return at === -1 ? spec : spec.slice(0, at)
-}
-
-/**
- * 从 npm registry 拉取已发布产物:临时工程里 `pnpm add <spec>`,产物即
- * `node_modules/<name>/`(发布包自带 lib/ 等运行必需文件,无需再构建)。
- * 依赖 pnpm 在 PATH 上(与 git 来源流程同一前提)。
- */
-function fetchNpmPackage(preset: InternalPlugin, temp: string): string {
- const project = join(temp, 'project')
- mkdirSync(project, { recursive: true })
- writeFileSync(join(project, 'package.json'), JSON.stringify({ private: true }))
- run('pnpm', ['add', preset.spec, '--ignore-scripts'], project)
- const pkgDir = join(project, 'node_modules', npmPackageName(preset.spec))
- if (!existsSync(join(pkgDir, 'package.json'))) {
- die(`${preset.id}: npm 安装后未找到产物 ${pkgDir}`)
- }
- console.log(`[prebuild] ${preset.id}: 来源 npm ${preset.spec}`)
- return pkgDir
-}
-
-/**
- * 拷贝构建产物:优先 `files` 白名单(只发运行必需:lib/、patch 文件、README),
- * 缺失白名单时拷贝整目录但排除 `.git` 等开发噪声;依赖不从构建 workspace
- * 复制,而是在 bundle staging 内重新生成 production 闭包。`package.json` 恒在
- * (它是 `pnpm add link:<dir>` 的包名/入口来源)。
- */
-function collectBundle(preset: InternalPlugin, clone: string, dest: string): void {
- mkdirSync(dest, { recursive: true })
-
- const manifest = JSON.parse(readFileSync(join(clone, 'package.json'), 'utf8')) as Record<string, unknown>
- const rawFiles = manifest.files
- const files = Array.isArray(rawFiles)
- ? rawFiles.filter((f): f is string => typeof f === 'string')
- : undefined
- const skip = new Set(['.git', '.gitignore', '.npmrc'])
- const entries = files !== undefined && files.length > 0
- ? files
- : readdirSync(clone).filter(name => !skip.has(name) && !name.endsWith('.tsbuildinfo'))
-
- for (const name of entries) {
- const src = join(clone, name)
- if (!existsSync(src)) {
- die(`${preset.id}: 白名单产物缺失 ${src}`)
- }
- cpSync(src, join(dest, name), { recursive: true, dereference: true })
- }
- // 拷贝后置,确保即使白名单里没有 package.json 它也一定存在
- cpSync(join(clone, 'package.json'), join(dest, 'package.json'), { dereference: true })
-}
-
-/** 检查依赖闭包未携带指向临时目录、store 或 checkout 的外部链接。 */
-/** 在 bundle 自身目录安装生产依赖;不复用构建 workspace,避免带入 dev 依赖。 */
-function verifyPortableBundle(preset: InternalPlugin, dest: string): void {
- const packageFile = join(dest, 'package.json')
- if (!existsSync(packageFile)) {
- die(`${preset.id}: bundle 缺少 package.json`)
- }
- const manifest = JSON.parse(readFileSync(packageFile, 'utf8')) as Record<string, unknown>
- const dependencySections = ['dependencies', 'optionalDependencies', 'peerDependencies']
- for (const section of dependencySections) {
- const deps = manifest[section]
- if (deps !== undefined && typeof deps !== 'object') {
- die(`${preset.id}: package.json 的 ${section} 不是对象`)
- }
- }
- const entry = typeof manifest.main === 'string' ? manifest.main : undefined
- if (entry !== undefined && !existsSync(join(dest, entry))) {
- die(`${preset.id}: 入口不存在 ${entry}`)
- }
- for (const section of dependencySections) {
- const deps = manifest[section]
- if (deps !== undefined && typeof deps === 'object' && deps !== null) {
- for (const [name, spec] of Object.entries(deps)) {
- if (typeof spec === 'string' && (spec.startsWith('workspace:') || spec.startsWith('catalog:'))) {
- die(`${preset.id}: 最终 package.json 仍包含不可搬运依赖协议 ${name}=${spec}`)
- }
- }
- }
- }
- const walk = (dir: string): void => {
- for (const item of readdirSync(dir, { withFileTypes: true })) {
- const path = join(dir, item.name)
- if (item.isSymbolicLink()) {
- const target = realpathSync(path)
- const root = realpathSync(dest)
- if (target !== root && !target.startsWith(`${root}/`) && !target.startsWith(`${root}\\`)) {
- die(`${preset.id}: 依赖链接越出 bundle 根目录 ${path} -> ${target}`)
- }
- }
- else if (item.isDirectory()) {
- walk(path)
- }
- }
- }
- walk(dest)
-}
-
-/** 构建单个 internal 插件:git 来源(克隆 → 装依赖 → 构建)或 npm 来源(拉产物)。 */
-function buildPlugin(preset: InternalPlugin, tempRoot: string): string {
- const temp = join(tempRoot, preset.id)
- mkdirSync(temp, { recursive: true })
- let source: string
- if (preset.spec.startsWith('github:')) {
- const clone = join(temp, preset.id)
- run('git', ['clone', '--depth', '1', '--quiet', githubUrl(preset.spec), clone], temp)
-
- const revision = spawnSync('git', ['-C', clone, 'rev-parse', '--short', 'HEAD'], { encoding: 'utf8' })
- if (revision.status === 0) {
- console.log(`[prebuild] ${preset.id}: 来源修订 ${revision.stdout.trim()}`)
- }
-
- // 注意:pnpm ≥10 默认拦截依赖的构建脚本(esbuild/原生模块需在插件仓库
- // 的 pnpm-workspace.yaml 配 onlyBuiltDependencies 放行);纯 JS/TS 插件不受影响。
- run('pnpm', ['install'], clone)
- const manifest = JSON.parse(readFileSync(join(clone, 'package.json'), 'utf8')) as {
- scripts?: Record<string, string>
- }
- if (manifest.scripts?.build !== undefined) {
- run('pnpm', ['run', 'build'], clone)
- }
- source = clone
- }
- else {
- source = fetchNpmPackage(preset, temp)
- }
-
- const staging = join(temp, 'bundle')
- collectBundle(preset, source, staging)
- verifyPortableBundle(preset, staging)
- console.log(`[prebuild] ${preset.id}: 产物已就绪 → ${staging}`)
- return staging
-}
-
-function verifyDeployedPlugins(internal: InternalPlugin[]): void {
- for (const plugin of internal) {
- const packageDir = join(BUNDLE_ROOT, npmPackageName(plugin.spec))
- if (!existsSync(join(packageDir, 'package.json'))) {
- die(`${plugin.id}: deploy 产物缺失 ${packageDir}`)
- }
- }
-}
-
-function main(): void {
- if (!existsSync(INTERNAL_PLUGINS_FILE)) {
- die(`未找到内部插件清单 ${INTERNAL_PLUGINS_FILE}`)
- }
- const internal = JSON.parse(readFileSync(INTERNAL_PLUGINS_FILE, 'utf8')) as InternalPlugin[]
- if (internal.length === 0) {
- console.log('[prebuild] 内部插件清单为空,跳过')
- return
- }
- console.log(`[prebuild] 拉取 ${internal.length} 个 internal 插件: ${internal.map(p => p.id).join(', ')}`)
- const tempRoot = mkdtempSync(join(tmpdir(), 'dsh-internal-plugins-'))
- const workspace = join(tempRoot, 'workspace')
- mkdirSync(workspace, { recursive: true })
- const dependencies: Record<string, string> = {}
- try {
- for (const plugin of internal) {
- const bundle = buildPlugin(plugin, workspace)
- const manifest = JSON.parse(readFileSync(join(bundle, 'package.json'), 'utf8')) as { name?: string, version?: string }
- if (typeof manifest.name !== 'string' || typeof manifest.version !== 'string') {
- die(`${plugin.id}: package.json 缺少 name/version`)
- }
- dependencies[manifest.name] = `file:${bundle.replace(/\\/g, '/')}`
- }
- writeFileSync(join(workspace, 'package.json'), JSON.stringify({ private: true, dependencies }, null, 2))
- run('pnpm', ['install', '--ignore-scripts'], workspace)
- rmSync(BUNDLE_ROOT, { recursive: true, force: true })
- mkdirSync(RESOURCE_ROOT, { recursive: true })
- const deployTarget = 'deploy'
- run('pnpm', ['--filter', '.', 'deploy', '--prod', '--legacy', deployTarget], workspace)
- cpSync(join(workspace, deployTarget, 'node_modules'), BUNDLE_ROOT, { recursive: true, dereference: true })
- rmSync(join(workspace, deployTarget), { recursive: true, force: true })
- verifyDeployedPlugins(internal)
- console.log(`[prebuild] 完成 → ${BUNDLE_ROOT}`)
- }
- finally {
- rmSync(tempRoot, { recursive: true, force: true })
- }
-}
-
-main()
diff --git a/scripts/predev.i18n.ts b/scripts/predev.i18n.ts
deleted file mode 100644
index 0cf496bd..00000000
--- a/scripts/predev.i18n.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import process from 'node:process'
-
-export type PredevLocale = 'en-US' | 'zh-CN'
-
-const messages = {
- 'en-US': {
- 'command.description': 'Prepare the internal plugin environment and forward Tauri CLI commands',
- 'command.yes': 'Skip confirmation before cloning internal plugins',
- 'command.lang': 'Set the command language',
- 'env.configured': 'Updated .env: DEV_INTERNAL_PLUGINS_DIR={dir}',
- 'git.checking': 'Checking submodule updates: {dir}',
- 'git.latest': 'dsh-tauri-plugins is up to date',
- 'git.updated': 'dsh-tauri-plugins has been updated',
- 'plugin.confirm': 'DEV_INTERNAL_PLUGINS_DIR is not set. Clone dsh-tauri-plugins as a submodule?',
- 'plugin.invalid_dir': 'The directory exists but is not a Git submodule: {dir}',
- 'plugin.exists': 'Submodule directory already exists: {dir}',
- },
- 'zh-CN': {
- 'command.description': '准备内置插件环境并转发 Tauri CLI 命令',
- 'command.yes': '跳过内置插件拉取确认',
- 'command.lang': '设置命令语言',
- 'env.configured': '已设置 .env:DEV_INTERNAL_PLUGINS_DIR={dir}',
- 'git.checking': '检查子模块更新:{dir}',
- 'git.latest': 'dsh-tauri-plugins 已是最新版本',
- 'git.updated': 'dsh-tauri-plugins 已更新',
- 'plugin.confirm': '你的内置环境目录 DEV_INTERNAL_PLUGINS_DIR 环境未设置,是否拉取 dsh-tauri-plugins 作为子模块?',
- 'plugin.invalid_dir': '目录已存在但不是 Git 子模块:{dir}',
- 'plugin.exists': '子模块目录已存在:{dir}',
- },
-} as const
-
-export type PredevMessageKey = keyof typeof messages['en-US']
-
-export function detectLocale(explicitLocale?: string): PredevLocale {
- if (explicitLocale === 'en-US' || explicitLocale === 'zh-CN')
- return explicitLocale
-
- const environmentLocale = process.env.LC_ALL
- || process.env.LC_MESSAGES
- || process.env.LANG
- || new Intl.DateTimeFormat().resolvedOptions().locale
-
- return environmentLocale.toLowerCase().replace('_', '-').startsWith('zh') ? 'zh-CN' : 'en-US'
-}
-
-export function translate(
- locale: PredevLocale,
- key: PredevMessageKey,
- replacements: Record<string, string> = {},
-): string {
- return Object.entries(replacements).reduce(
- (message, [name, value]) => message.split(`{${name}}`).join(value),
- messages[locale][key] as string,
- )
-}
diff --git a/scripts/predev.ts b/scripts/predev.ts
deleted file mode 100644
index 59bbdd64..00000000
--- a/scripts/predev.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { appendFileSync, existsSync } from 'node:fs'
-import process from 'node:process'
-import { defineCommand, runCommand } from 'citty'
-import { consola } from 'consola'
-import { config as loadDotenv } from 'dotenv'
-import { join, resolve } from 'pathe'
-import { x } from 'tinyexec'
-import { detectLocale, translate } from './predev.i18n'
-
-// ==========================================
-// 1. 配置与初始化
-// ==========================================
-const REPO_ROOT = resolve(import.meta.dirname, '..')
-const ENV_FILE = join(REPO_ROOT, '.env')
-const SUBMODULE_DIR = 'source/dsh-tauri-plugins' // 修正拼写: soruce -> source
-const PLUGINS_DIR = `${SUBMODULE_DIR}/packages`
-const SUBMODULE_PATH = join(REPO_ROOT, SUBMODULE_DIR)
-const SUBMODULE_URL = 'https://github.com/dsh-tauri-desk/dsh-tauri-plugins.git'
-const ENV_KEY = 'DEV_INTERNAL_PLUGINS_DIR'
-
-// 加载 .env 变量到 process.env
-loadDotenv({ path: ENV_FILE, quiet: true })
-
-// 智能识别语言设置
-const rawArgs = process.argv.slice(2)
-const langArg = rawArgs.find(arg => arg.startsWith('--lang='))?.slice(7)
- ?? (rawArgs.includes('--lang') ? rawArgs[rawArgs.indexOf('--lang') + 1] : undefined)
-
-let locale = detectLocale(langArg)
-
-// ==========================================
-// 2. 核心函数 (仅保留 2 个)
-// ==========================================
-
-/**
- * 命令执行器 (兼顾普通执行与输出捕获)
- */
-async function exec(program: string, args: readonly string[], cwd = REPO_ROOT, capture = false): Promise<string> {
- if (!capture)
- consola.info(`$ ${program} ${args.join(' ')}`)
- const result = await x(program, args, {
- throwOnError: true,
- nodeOptions: { cwd, env: process.env, stdio: capture ? undefined : 'inherit' },
- })
- return capture ? result.stdout.trim() : ''
-}
-
-/**
- * 确保插件目录与环境配置就绪
- */
-async function ensureInternalPlugins(skipPrompt: boolean): Promise<void> {
- // 1. Git 子模块检查与同步
- if (existsSync(join(SUBMODULE_PATH, '.git'))) {
- consola.start(translate(locale, 'git.checking', { dir: SUBMODULE_DIR }))
- await exec('git', ['fetch', '--quiet'], SUBMODULE_PATH)
-
- const [localRev, upstreamRev] = await Promise.all([
- exec('git', ['rev-parse', 'HEAD'], SUBMODULE_PATH, true),
- exec('git', ['rev-parse', '@{upstream}'], SUBMODULE_PATH, true),
- ])
-
- if (localRev === upstreamRev) {
- consola.success(translate(locale, 'git.latest'))
- }
- else {
- await exec('git', ['pull', '--ff-only'], SUBMODULE_PATH)
- consola.success(translate(locale, 'git.updated'))
- }
- }
-
- // 2. 环境变量检测与快捷设置
- if (process.env[ENV_KEY]?.trim())
- return
-
- const confirm = skipPrompt || await consola.prompt(
- translate(locale, 'plugin.confirm'),
- { type: 'confirm', initial: false, cancel: 'reject' },
- )
- if (!confirm)
- return
-
- // 3. 克隆/校验子模块
- if (!existsSync(SUBMODULE_PATH)) {
- await exec('git', ['submodule', 'add', '-f', SUBMODULE_URL, SUBMODULE_DIR])
- }
- else if (!existsSync(join(SUBMODULE_PATH, '.git'))) {
- throw new Error(translate(locale, 'plugin.invalid_dir', { dir: SUBMODULE_DIR }))
- }
- else {
- consola.info(translate(locale, 'plugin.exists', { dir: SUBMODULE_DIR }))
- }
-
- // 4. 利用 dotenv 协作写回环境配置
- const separator = existsSync(ENV_FILE) ? '\n' : ''
- appendFileSync(ENV_FILE, `${separator}${ENV_KEY}=${PLUGINS_DIR}\n`, 'utf8')
- process.env[ENV_KEY] = PLUGINS_DIR
- consola.success(translate(locale, 'env.configured', { dir: PLUGINS_DIR }))
-}
-
-// ==========================================
-// 3. CLI 主流程
-// ==========================================
-
-const command = defineCommand({
- meta: {
- name: 'predev',
- description: translate(locale, 'command.description'),
- },
- args: {
- yes: { type: 'boolean', description: translate(locale, 'command.yes') },
- lang: { type: 'enum', options: ['en-US', 'zh-CN'], description: translate(locale, 'command.lang') },
- },
- async run({ args, rawArgs }) {
- locale = detectLocale(args.lang)
-
- const isDev = rawArgs[0] === 'dev'
- // 剔除内部预处理参数
- const tauriArgs = isDev
- ? rawArgs.filter((arg, i) => arg !== '--yes' && arg !== '--lang' && !arg.startsWith('--lang=') && rawArgs[i - 1] !== '--lang')
- : rawArgs
-
- if (isDev) {
- await ensureInternalPlugins(args.yes === true)
- }
-
- await exec('tauri', tauriArgs)
- },
-})
-
-runCommand(command, { rawArgs }).catch((err: unknown) => {
- consola.error(err instanceof Error ? err.message : err)
- process.exitCode = 1
-})
diff --git a/src-tauri/resources/README.md b/src-tauri/resources/README.md
index 25e5bc6c..01054db8 100644
--- a/src-tauri/resources/README.md
+++ b/src-tauri/resources/README.md
@@ -79,7 +79,8 @@ Plugins that must ship *with* the installer and are treated as part of the app
(auto-installed and auto-healed at startup) live in `internal-plugins.json`,
separate from the community preset list. Add an extra `package` field when the
real npm name differs from `id`. The entries are bundled at build time by
-`scripts/prebuild.ts` into `resources/internal-plugins/<id>/` (via
+`scripts/build-plugins.ts` (via `pnpm deploy` of the workspace packages listed in
+`packages/dsh-tauri-bundle`) into `resources/node_modules/<name>` (via
`bundle.resources`) and never appear in the first-run checklist. On startup the
app removes the legacy `resources/preset-plugins/` directory left by upgrades.
See the [built-in plugin guide](../../docs/BUILTIN_PLUGINS.md) for the full
diff --git a/src-tauri/src/service/plugin/install/spec.rs b/src-tauri/src/service/plugin/install/spec.rs
index 23064786..0b2274ad 100644
--- a/src-tauri/src/service/plugin/install/spec.rs
+++ b/src-tauri/src/service/plugin/install/spec.rs
@@ -25,8 +25,8 @@ pub(super) fn bundled_dir_of(
/// 路径正确性由 [`crate::service::plugin::internal::ensure`] 启动自愈核对);
/// 普通插件沿用清单声明。
///
-/// 捆绑目录缺失时返回错误:内置插件缺失意味着构建期 prebuild 未执行或产物被
-/// 删,属发布缺陷而非用户侧的普通安装失败,错误前缀便于区分。
+/// 捆绑目录缺失时返回错误:内置插件缺失意味着构建期 build:plugins 未执行或产物
+/// 被删,属发布缺陷而非用户侧的普通安装失败,错误前缀便于区分。
pub(super) fn preset_spec_for_install(
preset: &PreinstallPluginInfo,
bundled_dir: Option<PathBuf>,
@@ -36,7 +36,7 @@ pub(super) fn preset_spec_for_install(
}
let dir = bundled_dir.ok_or_else(|| {
format!(
- "BUNDLED_PLUGIN_MISSING: no bundled dir for internal plugin {} (run scripts/prebuild.ts at build time)",
+ "BUNDLED_PLUGIN_MISSING: no bundled dir for internal plugin {} (run pnpm build:plugins at build time)",
preset.id
)
})?;
@@ -78,7 +78,7 @@ pub(super) fn normalize_git_spec(spec: &str) -> String {
/// - Windows:`shell:true` 时 Node 只把参数按空格拼接、不做引号转义(官方文档
/// DEP0190:arguments are not escaped, only concatenated)。内置插件的依赖是
/// `link:<应用安装目录>`,而 Windows 安装目录常含空格(如
-/// `G:\Deepseek Harness Desktop\resources\internal-plugins\dsh-tauri`),拼进
+/// `G:\Deepseek Harness Desktop\resources\node_modules\dsh-tauri`),拼进
/// shell 后会被切碎成多个 spec,pnpm 报 `ERR_PNPM_SPEC_NOT_SUPPORTED` / 装成
/// 错误依赖,导致启动自愈每轮都重装(死循环)。包一层双引号让 cmd 把整条
/// spec 视为一个参数;pnpm 解析后自行剥离引号,落盘 `package.json` 的值仍是
diff --git a/src-tauri/src/service/plugin/internal/mod.rs b/src-tauri/src/service/plugin/internal/mod.rs
index 5a0e0bb8..0fa315ee 100644
--- a/src-tauri/src/service/plugin/internal/mod.rs
+++ b/src-tauri/src/service/plugin/internal/mod.rs
@@ -1,11 +1,12 @@
//! 内置插件启动自愈:随安装包分发的内置插件(条目位于
-//! `internal-plugins.json`,产物目录 `resources/internal-plugins/<id>` 由构建期
-//! `scripts/prebuild.ts` 拉取)在服务启动前核对「是否已安装 + 安装路径是否仍
-//! 指向当前捆绑目录」:未安装 / 路径不正确 / 用户卸载后残留缺失 → 一律走常规
-//! 安装流程强制重装,保证桌面外壳依赖的桥接层(如 dsh-tauri)随包可用。
+//! `internal-plugins.json`,产物目录 `resources/node_modules/<name>` 由构建期
+//! `scripts/build-plugins.ts` 的 `pnpm deploy` 打包)在服务启动前核对
+//! 「是否已安装 + 安装路径是否仍指向当前捆绑目录」:未安装 / 路径不正确 / 用户
+//! 卸载后残留缺失 → 一律走常规安装流程强制重装,保证桌面外壳依赖的桥接层
+//! (如 dsh-tauri)随包可用。
//!
-//! debug 构建可用仓库根 `.env` 的 `DEV_INTERNAL_PLUGINS_DIR` 把安装目标指到
-//! 本地插件源码(热更新迭代,见 [`super::preset::bundled_plugin_dir`])。
+//! debug 构建会自动发现仓库根 `packages/*` 中非私有且含 `dsh` 对象的包,把安装
+//! 目标指到本地插件源码(热更新迭代,见 [`super::preset::bundled_plugin_dir`])。
//!
//! 为什么放在启动而非安装流程:安装是用户主动行为,内置插件是应用自身的完整性
//! 要求——用户怎么卸载、何时卸载都不影响下次启动自动恢复,无需任何用户操作。
@@ -35,7 +36,7 @@ mod manifest;
/// 核对并强制安装缺失/路径不正确/被卸载的内置插件,在服务进程启动前调用。
///
/// 最佳努力:任何失败只记告警(调用方不阻断启动);捆绑目录缺失(开发环境未跑
-/// prebuild)时跳过,交由常规引导流程处理;批量待装列表为空则不触发任何安装。
+/// build:plugins)时跳过,交由常规引导流程处理;批量待装列表为空则不触发任何安装。
/// 内置插件阶段事件载荷:除开始/结束外定期发送 heartbeat,令前端只在安装确实
/// 无进展时触发 inactivity deadline,同时仍受绝对上限约束。
#[derive(serde::Serialize, Clone)]
@@ -529,11 +530,11 @@ async fn ensure_inner(
let mut need: Vec<(String, String, PathBuf)> = Vec::new();
for preset in internal {
let Some(bundled) = bundled_plugin_dir(app_handle, &preset.id) else {
- // 未找到内置插件目录:release 说明构建期 prebuild 未拉取(发布缺陷,
- // 由 prebuild 响亮失败);debug 可用 .env 的 DEV_INTERNAL_PLUGINS_DIR
- // 指向本地源码目录,未配置/缺 id 时跳过(「找不到则不装」)。
+ // 未找到内置插件目录:release 说明构建期 build:plugins 未打包(发布
+ // 缺陷,由 build:plugins 响亮失败);debug 自动发现 packages/* 中非私有
+ // 且含 dsh 对象的包,未命中时跳过(「找不到则不装」)。
log::warn!(
- "INTERNAL_PLUGIN_BUNDLE_MISSING: {}(release 需构建期 prebuild;debug 可配 .env DEV_INTERNAL_PLUGINS_DIR)",
+ "INTERNAL_PLUGIN_BUNDLE_MISSING: {}(release 需构建期 build:plugins;debug 无匹配的 packages/* 包)",
preset.id
);
continue;
diff --git a/src-tauri/src/service/plugin/preset.rs b/src-tauri/src/service/plugin/preset.rs
index 4ef93b5b..8c9b813f 100644
--- a/src-tauri/src/service/plugin/preset.rs
+++ b/src-tauri/src/service/plugin/preset.rs
@@ -7,7 +7,7 @@
use serde::Deserialize;
use std::collections::HashSet;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use tauri::{AppHandle, Manager};
use crate::config;
@@ -27,16 +27,13 @@ pub struct PreinstallPluginInfo {
pub id: String,
/// 传给 `dsh plugin add` 的依赖形式(npm 包名或 git 依赖形式)
pub spec: String,
- /// 内置插件:条目来自 `resources/internal-plugins.json`,产物由构建期
- /// `scripts/prebuild.ts` 从上游仓库拉取到 `resources/internal-plugins/<id>/`
- /// 随安装包分发,安装固定走 `link:` 本地
- /// 依赖;启动时强制核对「已安装 + 路径指向当前捆绑目录」,不满足即自动
- /// 重装(用户卸载后重启应用同样恢复),因此不出现在首次引导的勾选清单里。
+ /// 内置插件:条目来自发布清单,或 debug 下仓库根 `packages/*` 中带有
+ /// 有效 `dsh` 对象的 workspace 包。内置插件固定从本地捆绑目录安装,启动时
+ /// 强制核对「已安装 + 路径指向当前捆绑目录」,因此不出现在首次引导清单里。
#[serde(default)]
pub internal: bool,
/// 安装进 profile 后实际出现在 `dependencies`/`bundles` 里的包名。
- /// 默认与 `id` 相同;仅当 npm 包名与预设 id 不一致时(如 scoped 包
- /// `@scope/name`)才需要显式指定,供“已安装”检测使用。
+ /// 默认与 `id` 相同;scoped 包或 id 与包名不同时显式指定。
#[serde(default)]
pub package: Option<String>,
pub name: String,
@@ -56,6 +53,190 @@ pub struct PreinstallPluginInfo {
pub win_only: bool,
}
+/// debug workspace 插件 package.json 中用于生成内置元数据的字段。
+#[cfg(debug_assertions)]
+#[derive(Clone, Deserialize, Default)]
+struct DevPluginPackageJson {
+ #[serde(default)]
+ name: Option<String>,
+ /// `private: true` 的包(bundler、工具包与演示占位插件)不参与内置插件发现
+ #[serde(default)]
+ private: bool,
+ #[serde(default)]
+ description: Option<String>,
+ #[serde(default)]
+ homepage: Option<String>,
+ #[serde(default)]
+ repository: Option<serde_json::Value>,
+ #[serde(default)]
+ dsh: Option<serde_json::Value>,
+}
+
+#[cfg(debug_assertions)]
+struct DevPluginCandidate {
+ info: PreinstallPluginInfo,
+ directory: PathBuf,
+}
+
+#[cfg(debug_assertions)]
+fn dev_plugins_root() -> PathBuf {
+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+ .join("..")
+ .join("packages")
+}
+
+#[cfg(debug_assertions)]
+fn normalize_dev_repo_url(value: &str) -> String {
+ let mut url = value.trim().to_string();
+ if let Some(rest) = url.strip_prefix("git+") {
+ url = rest.to_string();
+ }
+ if let Some(rest) = url.strip_prefix("git://") {
+ url = format!("https://{rest}");
+ }
+ if let Some(rest) = url.strip_suffix(".git") {
+ url = rest.to_string();
+ }
+ url
+}
+
+#[cfg(debug_assertions)]
+fn dev_repo_url(manifest: &DevPluginPackageJson) -> String {
+ let repository = manifest.repository.as_ref().and_then(|repository| {
+ repository
+ .as_str()
+ .or_else(|| repository.get("url").and_then(serde_json::Value::as_str))
+ });
+ repository
+ .or(manifest.homepage.as_deref())
+ .map(normalize_dev_repo_url)
+ .unwrap_or_default()
+}
+
+/// 扫描指定 workspace 根目录下的开发插件。
+///
+/// 只有 package.json 可解析、非私有(无 `private: true`)、name 非空且 `dsh` 是
+/// 对象的目录才是内置插件;扫描失败只跳过当前目录,不阻断桌面端启动。目录名不
+/// 参与插件身份判定,因此 package.name 与目录名不一致时仍使用真实 npm 包名作为
+/// id、依赖键和 node_modules 路径。`private: true` 的包(bundler、工具包与演示
+/// 占位插件)不是可发布的内置插件,即使含 `dsh` 也一并忽略。
+#[cfg(debug_assertions)]
+fn discover_dev_internal_plugins_at(root: &Path) -> Vec<DevPluginCandidate> {
+ let Ok(entries) = std::fs::read_dir(root) else {
+ return Vec::new();
+ };
+ let mut entries: Vec<_> = entries
+ .filter_map(Result::ok)
+ .filter_map(|entry| {
+ entry
+ .file_type()
+ .ok()
+ .filter(|file_type| file_type.is_dir())
+ .map(|_| entry)
+ })
+ .collect();
+ entries.sort_by_key(|entry| entry.file_name());
+
+ let mut seen = HashSet::new();
+ entries
+ .into_iter()
+ .filter_map(|entry| {
+ let directory = entry.path();
+ let manifest_path = directory.join("package.json");
+ let raw = std::fs::read_to_string(&manifest_path).ok()?;
+ let manifest = match serde_json::from_str::<DevPluginPackageJson>(&raw) {
+ Ok(manifest) => manifest,
+ Err(error) => {
+ log::warn!(
+ "DEV_INTERNAL_PLUGIN_MANIFEST_INVALID: {}: {error}",
+ manifest_path.display()
+ );
+ return None;
+ }
+ };
+ if manifest.private {
+ return None;
+ }
+ if !manifest
+ .dsh
+ .as_ref()
+ .is_some_and(serde_json::Value::is_object)
+ {
+ return None;
+ }
+ // 先借出 repository/homepage 计算 repo_url,再消费 name / description:
+ // 三者都来自同一 manifest,顺序错开会在部分移动后再借用。
+ let repo_url = dev_repo_url(&manifest);
+ let name = manifest.name.filter(|name| !name.trim().is_empty())?;
+ if !seen.insert(name.clone()) {
+ log::warn!("DEV_INTERNAL_PLUGIN_DUPLICATE: {name}");
+ return None;
+ }
+ let info = PreinstallPluginInfo {
+ id: name.clone(),
+ spec: name.clone(),
+ internal: true,
+ package: Some(name.clone()),
+ name: name.clone(),
+ description: manifest.description.unwrap_or_default(),
+ repo_url,
+ recommended: false,
+ fix: false,
+ default_checked: false,
+ win_only: false,
+ };
+ Some(DevPluginCandidate { info, directory })
+ })
+ .collect()
+}
+
+#[cfg(debug_assertions)]
+fn discover_dev_internal_plugins() -> Vec<DevPluginCandidate> {
+ discover_dev_internal_plugins_at(&dev_plugins_root())
+}
+
+/// 按 id 定位仓库根 `packages/<name>` 下的开发插件源码目录(debug 专用)。
+///
+/// 返回整个扫描结果再按 id 匹配:发现的候选已由 package.json 校验过,因此命中即
+/// 目录有效。重扫描是磁盘开销,但仅 debug 构建、且目录数很少,安全。
+#[cfg(debug_assertions)]
+fn dev_plugin_dir(id: &str) -> Option<PathBuf> {
+ discover_dev_internal_plugins()
+ .into_iter()
+ .find(|candidate| candidate.info.id == id)
+ .map(|candidate| candidate.directory)
+}
+
+/// 把仓库根 `packages/*` 发现的内置插件合并进静态 `internal-plugins.json` 清单。
+///
+/// 同名 dev 候选覆盖静态条目(开发时以仓库源码为准,安装目标指到 `packages/`);
+/// 未在静态清单中出现的 dev 插件会被追加,保证 debug 观察到的内置插件集合
+/// 以仓库源码为准,与 release(只认随包分发的静态清单)共用同一套安装/自愈逻辑。
+#[cfg(debug_assertions)]
+fn merge_dev_internal_plugins(internal: Vec<PreinstallPluginInfo>) -> Vec<PreinstallPluginInfo> {
+ merge_dev_internal_plugins_at(&dev_plugins_root(), internal)
+}
+
+/// [`merge_dev_internal_plugins`] 的根目录参数化版本,便于单测注入临时扫描根。
+#[cfg(debug_assertions)]
+fn merge_dev_internal_plugins_at(
+ root: &Path,
+ mut internal: Vec<PreinstallPluginInfo>,
+) -> Vec<PreinstallPluginInfo> {
+ let mut by_id: std::collections::HashMap<String, DevPluginCandidate> =
+ discover_dev_internal_plugins_at(root)
+ .into_iter()
+ .map(|candidate| (candidate.info.id.clone(), candidate))
+ .collect();
+ for plugin in internal.iter_mut() {
+ if let Some(candidate) = by_id.remove(&plugin.id) {
+ *plugin = candidate.info;
+ }
+ }
+ internal.extend(by_id.into_values().map(|candidate| candidate.info));
+ internal
+}
+
/// 在资源根目录下查找清单:先探测扁平布局(exe 同级),再探测
/// `resources/` 子目录布局(Tauri 2 的 `bundle.resources` 按相对路径保留前缀)。
fn find_manifest_in_resource_root(root: &std::path::Path, file_name: &str) -> Option<PathBuf> {
@@ -108,7 +289,10 @@ fn find_bundled_in_root(root: &std::path::Path, id: &str) -> Option<PathBuf> {
return Some(legacy);
}
let flat_legacy = base.join(BUNDLED_PLUGINS_DIR).join(id);
- flat_legacy.join("package.json").exists().then_some(flat_legacy)
+ flat_legacy
+ .join("package.json")
+ .exists()
+ .then_some(flat_legacy)
};
probe(root).or_else(|| {
let deployed = root.join("node_modules").join(id);
@@ -116,20 +300,21 @@ fn find_bundled_in_root(root: &std::path::Path, id: &str) -> Option<PathBuf> {
})
}
-/// 定位内置插件捆绑目录:优先随安装包分发的资源目录,回落到源码
-/// `resources/internal-plugins/<id>`(开发机未跑 prebuild 时作为源码兜底)。
+/// 定位内置插件捆绑目录:debug 优先命中仓库根 `packages/*` 源码目录;
+/// release/兜底按 `resources/node_modules/<name>`(构建期 `pnpm deploy` 产物)查找,
+/// 旧版 `resources/internal-plugins/<id>` 仅作兼容回退。
///
-/// 用于安装(`install.rs` 生成 `file:` 依赖)与启动自愈(`internal.rs` 核对路径)。
+/// 用于安装(`install.rs` 生成 `link:` 依赖)与启动自愈(`internal.rs` 核对路径)。
///
-/// **开发覆盖(仅 debug 构建)**:仓库根 `.env` 声明 `DEV_INTERNAL_PLUGINS_DIR=<dir>`
-/// 时,`<dir>/<id>` 命中即以本地插件源码目录为安装目标——pnpm `file:` 依赖是
-/// junction(目录联接),改源码 + 重启服务即热更新,无需提交子插件 git、无需
-/// prebuild;设置但缺该 id 返回 None(跳过,不回落随包目录),让开发者显式感知。
+/// **开发覆盖(仅 debug 构建)**:仓库根 `packages/*` 中非私有且含 `dsh` 对象的
+/// 包自动成为内置插件,本函数对 id 命中即返回其源码目录 `packages/<dir>`——pnpm
+/// `link:` 依赖是目录联接(junction),改源码 + 重启服务即热更新,无需提交子插件
+/// git、无需构建期打包;仓库里不存在该 id 时回落随包目录,让开发与发布共用一套
+/// 兜底逻辑。
pub(crate) fn bundled_plugin_dir(app_handle: &AppHandle, id: &str) -> Option<PathBuf> {
#[cfg(debug_assertions)]
- if let Some(root) = dev_internal_plugins_dir() {
- let dev = root.join(id);
- return dev.join("package.json").exists().then_some(dev);
+ if let Some(dir) = dev_plugin_dir(id) {
+ return Some(dir);
}
if let Ok(dir) = app_handle.path().resource_dir() {
if let Some(candidate) = find_bundled_in_root(&dir, id) {
@@ -193,45 +378,6 @@ fn remove_legacy_candidates(
}
}
-/// 开发模式内置插件源码根目录:读取 `<仓库根>/.env` 的 `DEV_INTERNAL_PLUGINS_DIR`。
-/// 仅 debug 构建生效(release 恒用随包目录,不受构建机环境影响)。
-///
-/// `.env` 属于本地个人配置,不入库(见仓库 `.gitignore`);`<仓库根>` 由编译期
-/// `CARGO_MANIFEST_DIR`(即 `src-tauri`)的上层目录得到,只在开发机成立。
-#[cfg(debug_assertions)]
-fn dev_internal_plugins_dir() -> Option<PathBuf> {
- let env_file = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("..")
- .join(".env");
- let content = std::fs::read_to_string(env_file).ok()?;
- parse_dev_internal_dir(&content)
-}
-
-/// 从 `.env` 文本解析 `DEV_INTERNAL_PLUGINS_DIR`(纯函数,便于单测):
-/// 支持 `KEY=VALUE` / `KEY = VALUE`(键值两侧空白容忍)、值可选单/双引号包裹;
-/// `#` 起始行与空行跳过;显式置空(`KEY=`)视为未设置;缺键返回 None。
-#[cfg(debug_assertions)]
-fn parse_dev_internal_dir(content: &str) -> Option<PathBuf> {
- for line in content.lines() {
- let line = line.trim();
- if line.is_empty() || line.starts_with('#') {
- continue;
- }
- let Some((key, value)) = line.split_once('=') else {
- continue;
- };
- if key.trim() != "DEV_INTERNAL_PLUGINS_DIR" {
- continue;
- }
- let value = value.trim().trim_matches('"').trim_matches('\'');
- if value.is_empty() {
- return None;
- }
- return Some(PathBuf::from(value));
- }
- None
-}
-
/// 内置插件的安装依赖形式:`link:<绝对路径>`(正斜杠、去尾部斜杠)。
///
/// 用 `link:` 而非 `file:`:pnpm 会把 `file:D:/...`(Windows 盘符冒号)当相对
@@ -292,9 +438,16 @@ fn load_manifest(
}
/// 读取预设与内部插件清单并合并;内部属性由文件归属决定,不依赖 JSON 字段。
+///
+/// **开发覆盖(仅 debug 构建)**:仓库根 `packages/*` 中非私有且含 `dsh` 对象的
+/// workspace 包会按 id 覆盖静态内部清单条目,未登记的新插件一并追加,因此开发时
+/// 观察到的内置插件集合以仓库源码为准,与 release(只认随包清单)逻辑一致。
pub(crate) fn load_presets(app_handle: &AppHandle) -> Vec<PreinstallPluginInfo> {
let mut plugins = load_manifest(app_handle, PRESET_PLUGINS_FILE, false);
- plugins.extend(load_manifest(app_handle, INTERNAL_PLUGINS_FILE, true));
+ let internal = load_manifest(app_handle, INTERNAL_PLUGINS_FILE, true);
+ #[cfg(debug_assertions)]
+ let internal = merge_dev_internal_plugins(internal);
+ plugins.extend(internal);
plugins
}
@@ -551,7 +704,7 @@ mod tests {
#[test]
fn bundled_dir_discovers_nested_layout() {
- // 与 internal 文件一致:先探测 {root}/resources/internal-plugins/<id>
+ // 兼容布局:{root}/resources/internal-plugins/<id>(旧版捆绑目录)仍应命中
let dir = std::env::temp_dir().join(format!("dsh-bundled-nested-{}", std::process::id()));
let nested = dir
.join("resources")
@@ -583,7 +736,7 @@ mod tests {
#[test]
fn bundled_dir_requires_package_json() {
- // 无 package.json 的目录不是有效产物(prebuild 未执行)
+ // 无 package.json 的目录不是有效产物(build:plugins 未执行)
let dir = std::env::temp_dir().join(format!("dsh-bundled-empty-{}", std::process::id()));
std::fs::create_dir_all(dir.join(BUNDLED_PLUGINS_DIR).join("dsh-tauri"))
.expect("create empty dir");
@@ -622,47 +775,6 @@ mod tests {
);
}
- #[cfg(debug_assertions)]
- #[test]
- fn dev_internal_dir_parses_plain_and_quoted_values() {
- assert_eq!(
- parse_dev_internal_dir("DEV_INTERNAL_PLUGINS_DIR=C:/dev/plugins\n"),
- Some(PathBuf::from("C:/dev/plugins"))
- );
- // 键值两侧空白 + 引号包裹
- assert_eq!(
- parse_dev_internal_dir("DEV_INTERNAL_PLUGINS_DIR = \"C:/my plugins\"\n"),
- Some(PathBuf::from("C:/my plugins"))
- );
- assert_eq!(
- parse_dev_internal_dir("DEV_INTERNAL_PLUGINS_DIR='D:/dev/plugins'\r\n"),
- Some(PathBuf::from("D:/dev/plugins"))
- );
- }
-
- #[cfg(debug_assertions)]
- #[test]
- fn dev_internal_dir_skips_comment_and_other_keys() {
- let content = "# comment\n\nVITE_FOO=1\nDEV_INTERNAL_PLUGINS_DIR=E:/plugins\n";
- assert_eq!(
- parse_dev_internal_dir(content),
- Some(PathBuf::from("E:/plugins"))
- );
- }
-
- #[cfg(debug_assertions)]
- #[test]
- fn dev_internal_dir_unset_when_missing_key_or_empty_value() {
- // 其它键或注释:视为未设置
- assert_eq!(parse_dev_internal_dir("FOO=bar\n"), None);
- assert_eq!(
- parse_dev_internal_dir("# DEV_INTERNAL_PLUGINS_DIR=C:/x\n"),
- None
- );
- // 显式置空:同样视为未设置(关闭覆盖)
- assert_eq!(parse_dev_internal_dir("DEV_INTERNAL_PLUGINS_DIR=\n"), None);
- }
-
#[test]
fn fnv1a_matches_known_vectors() {
// FNV-1a 64-bit 标准测试向量
@@ -710,4 +822,195 @@ mod tests {
_ => false,
}
}
+
+ /// 写入一个带 `dsh` 对象的开发包 manifest。
+ #[cfg(debug_assertions)]
+ fn write_dev_manifest(dir: &Path, name: &str) {
+ std::fs::create_dir_all(dir).expect("create dev package dir");
+ let manifest = serde_json::json!({
+ "name": name,
+ "description": "desc",
+ "dsh": {"client": {"inject": ["x"]}},
+ });
+ std::fs::write(
+ dir.join("package.json"),
+ serde_json::to_string(&manifest).expect("serialize dev manifest"),
+ )
+ .expect("write dev manifest");
+ }
+
+ #[cfg(debug_assertions)]
+ fn temp_dev_root(label: &str) -> PathBuf {
+ let root = std::env::temp_dir().join(format!("dsh-dev-{label}-{}", std::process::id()));
+ std::fs::remove_dir_all(&root).ok();
+ std::fs::create_dir_all(&root).expect("create temp dev root");
+ root
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_empty_root_returns_none() {
+ let root = temp_dev_root("empty");
+ assert!(discover_dev_internal_plugins_at(&root).is_empty());
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_skips_invalid_manifest() {
+ let root = temp_dev_root("invalid");
+ let dir = root.join("bad");
+ std::fs::create_dir_all(&dir).expect("create dir");
+ std::fs::write(dir.join("package.json"), "{ not json").expect("write bad manifest");
+ assert!(discover_dev_internal_plugins_at(&root).is_empty());
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_skips_when_missing_or_invalid_dsh_value() {
+ let root = temp_dev_root("dsh");
+ // 无 dsh 字段
+ std::fs::create_dir_all(root.join("no-dsh")).expect("create dir");
+ std::fs::write(
+ root.join("no-dsh").join("package.json"),
+ r#"{"name":"no-dsh","description":"x"}"#,
+ )
+ .expect("write manifest");
+ // dsh 非对象:字符串 / 数组 / null
+ for (name, dsh) in [
+ ("str-dsh", r#""x""#),
+ ("arr-dsh", "[]"),
+ ("null-dsh", "null"),
+ ] {
+ std::fs::create_dir_all(root.join(name)).expect("create dir");
+ std::fs::write(
+ root.join(name).join("package.json"),
+ format!(r#"{{"name":"{name}","dsh":{dsh}}}"#),
+ )
+ .expect("write manifest");
+ }
+ assert!(discover_dev_internal_plugins_at(&root).is_empty());
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_skips_private_manifest() {
+ let root = temp_dev_root("private");
+ // private: true 的包(bundler / 工具包 / 演示占位插件)即使含 dsh 也忽略
+ std::fs::create_dir_all(root.join("placeholder")).expect("create dir");
+ std::fs::write(
+ root.join("placeholder").join("package.json"),
+ r#"{"name":"placeholder","private":true,"dsh":{"client":{"inject":["x"]}}}"#,
+ )
+ .expect("write manifest");
+ assert!(discover_dev_internal_plugins_at(&root).is_empty());
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_discovers_real_package_name_regardless_of_dirname() {
+ let root = temp_dev_root("name");
+ // 目录名与真实 npm 包名不同:id/依赖键以 package.name 为准
+ write_dev_manifest(&root.join("some-dir"), "@scope/dsh-plugin");
+ let found = discover_dev_internal_plugins_at(&root);
+ assert_eq!(found.len(), 1);
+ assert_eq!(found[0].info.id, "@scope/dsh-plugin");
+ assert_eq!(found[0].info.spec, "@scope/dsh-plugin");
+ assert_eq!(found[0].info.package.as_deref(), Some("@scope/dsh-plugin"));
+ assert!(found[0].info.internal);
+ assert!(found[0].directory.ends_with("some-dir"));
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_dedups_by_package_name() {
+ let root = temp_dev_root("dedup");
+ // 两个目录声明同名包:后者被跳过(DEV_INTERNAL_PLUGIN_DUPLICATE)
+ write_dev_manifest(&root.join("a"), "dsh-tauri");
+ write_dev_manifest(&root.join("b"), "dsh-tauri");
+ let found = discover_dev_internal_plugins_at(&root);
+ assert_eq!(found.len(), 1);
+ assert_eq!(found[0].info.id, "dsh-tauri");
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_sorts_by_directory_name() {
+ let root = temp_dev_root("sort");
+ write_dev_manifest(&root.join("b-plugin"), "b");
+ write_dev_manifest(&root.join("a-plugin"), "a");
+ let found = discover_dev_internal_plugins_at(&root);
+ let ids: Vec<&str> = found.iter().map(|c| c.info.id.as_str()).collect();
+ assert_eq!(ids, vec!["a", "b"]);
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_sets_repo_url_from_repository_object() {
+ let root = temp_dev_root("repo");
+ let dir = root.join("repo-plugin");
+ std::fs::create_dir_all(&dir).expect("create dir");
+ std::fs::write(
+ dir.join("package.json"),
+ r#"{"name":"repo-plugin","repository":{"url":"git+https://github.com/x/repo.git"},"dsh":{"client":{"inject":["x"]}}}"#,
+ )
+ .expect("write manifest");
+ let found = discover_dev_internal_plugins_at(&root);
+ assert_eq!(found.len(), 1);
+ assert_eq!(found[0].info.repo_url, "https://github.com/x/repo");
+ std::fs::remove_dir_all(&root).ok();
+ }
+
+ #[cfg(debug_assertions)]
+ #[test]
+ fn dev_discovery_merge_overrides_static_entry_and_appends_new() {
+ let root = temp_dev_root("merge");
+ // 静态清单:dsh-tauri(待被 dev 覆盖) + 缺失 dev 的 keep-static
+ // dev 候选:dsh-tauri(覆盖) + brand-new(追加)
+ write_dev_manifest(&root.join("dsh-tauri"), "dsh-tauri");
+ write_dev_manifest(&root.join("brand-new"), "brand-new");
+ let static_internal = vec![
+ PreinstallPluginInfo {
+ id: "dsh-tauri".into(),
+ spec: "dsh-tauri".into(),
+ internal: true,
+ package: Some("dsh-tauri".into()),
+ name: "dsh-tauri".into(),
+ description: "static desc".into(),
+ repo_url: "static".into(),
+ recommended: false,
+ fix: false,
+ default_checked: false,
+ win_only: false,
+ },
+ PreinstallPluginInfo {
+ id: "keep-static".into(),
+ spec: "keep-static".into(),
+ internal: true,
+ package: Some("keep-static".into()),
+ name: "keep-static".into(),
+ description: String::new(),
+ repo_url: String::new(),
+ recommended: false,
+ fix: false,
+ default_checked: false,
+ win_only: false,
+ },
+ ];
+ // 把 dev 扫描根临时指向临时目录,借助 discover 函数合并
+ let merged = merge_dev_internal_plugins_at(&root, static_internal);
+ let ids: std::collections::HashSet<&str> = merged.iter().map(|p| p.id.as_str()).collect();
+ assert_eq!(ids.len(), 3);
+ let dsh = merged.iter().find(|p| p.id == "dsh-tauri").unwrap();
+ assert_eq!(dsh.description, "desc"); // dev 覆盖静态
+ assert!(merged.iter().any(|p| p.id == "brand-new")); // 追加上去
+ assert!(merged.iter().any(|p| p.id == "keep-static")); // 静态未覆盖项保留
+ std::fs::remove_dir_all(&root).ok();
+ }
}
diff --git a/src-tauri/src/service/workflow/launch.rs b/src-tauri/src/service/workflow/launch.rs
index 997415df..a5625a1b 100644
--- a/src-tauri/src/service/workflow/launch.rs
+++ b/src-tauri/src/service/workflow/launch.rs
@@ -394,7 +394,7 @@ pub async fn launch(app_handle: tauri::AppHandle) -> Result<(), String> {
// 内置插件自愈:随包分发的内置插件(dsh-tauri 等)必须在服务进程加载插件
// 前就绪——核对「已安装 + 安装路径指向当前捆绑目录」,未安装、路径不正确
// 或用户卸载后重启,一律强制重装(见 service::plugin::internal)。最佳
- // 努力:失败只告警,不阻断启动(核心功能缺失是发布缺陷,由 prebuild 报错)。
+ // 努力:失败只告警,不阻断启动(核心功能缺失是发布缺陷,由 build:plugins 报错)。
if let Err(e) = crate::service::plugin::ensure_internal_plugins(&app_handle).await {
log::warn!("ensure internal plugins failed: {e}");
}
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index ec89ce8e..9ff0823c 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -13,7 +13,7 @@
"status.loading": "Loading plugins…",
"status.loading_plugins": "Loading plugins…",
"status.loading_internal": "Loading internal plugins…",
- "status.loading_process": "Starting Harness service…",
+ "status.loading_process": "Starting Harness…",
"status.loading_client_modules": "Waiting for Harness…",
"status.internal_waiting": "Waiting to check internal plugins.",
"status.internal_checking": "Checking {{total}} internal plugins.",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 521efb9c..4890ebac 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -13,7 +13,7 @@
"status.loading": "Loading plugins…",
"status.loading_plugins": "Loading plugins…",
"status.loading_internal": "Loading internal plugins…",
- "status.loading_process": "Starting Harness service…",
+ "status.loading_process": "Starting Harness…",
"status.loading_client_modules": "Waiting for Harness…",
"status.internal_waiting": "Waiting for internal plugins…",
"status.internal_checking": "Checking {{total}} internal plugins…",