@linxin666/dsh-client-ui-plugin-manager 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, zhu1090093659
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # node scripts/verify-docs.mjs --write <dir>
5
+ README.md: b13f2e5952d50659cd099b70e6d13750eafb6315
6
+ README.zh.md: d9534ef2b8d5c632b4494ea468216e7d29ee2fd9
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @linxin666/dsh-client-ui-plugin-manager
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git, lists installed plugins with next-start enable switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.
6
+
7
+ ## What it does
8
+
9
+ - Registers a `Plugin manager` tab in the official Plugins settings section (the `settings.plugins.tab` slot, order 20), next to the official installer tab.
10
+ - Dual-channel transport: on runtimes with the official installer services (DSHCode and the 1.0.4 checkout web), every operation rides the official `/plugin-installer` and `/plugin-control` loopback RPC channels; on the npm-published web runtime those channels do not exist, so the package's host half mounts a loopback-fenced HTTP gateway that spawns the official `dsh plugin` CLI for installs/removals (the single writer) and writes `disabled` override rows for enablement.
11
+ - Installs plugins from an npm package name or a git repository URL, with progress.
12
+ - Lists installed user plugins with next-start enable switches, update checks (registry, npm sources), updates, and uninstall.
13
+ - Shows the built-in product switches when the official plugin-control surface exists.
14
+ - Surfaces install-time conflict actions: the product-snapshot diff around each install (official mode) or the profile layer diff around each CLI run (gateway mode), with undo for reversible actions and an `Ask the agent to fix` handoff on every conflict row.
15
+ - Protects the next boot on the npm runtime: after each install the gateway verifies the dependency actually landed, rejects duplicate entry-id claims and insert rows naming unresolvable packages, and composes the profile with the CLI's `--dump-config` preflight; a conflicting or failing install is rolled back through the official remove path (the existing plugins are never touched), with the error and repair handoff on the error row.
16
+ - Renders the boot-failure ring per plugin with `Ask the agent to fix` (a repair conversation over the plugin install root) and `Copy error`; the npm web runtime keeps no failure ring, so only install errors offer the repair handoff there.
17
+ - Shows the host's safe-mode banner and the `Restore normal mode` affordance (the web build applies it at the next manual restart).
18
+
19
+ ## Install
20
+
21
+ ### From npm (recommended)
22
+
23
+ ```sh
24
+ dsh plugin --profile web add @linxin666/dsh-client-ui-plugin-manager
25
+ ```
26
+
27
+ ### From the repository (development)
28
+
29
+ ```sh
30
+ git clone https://github.com/zhu1090093659/dsh-web-ui.git
31
+ cd dsh-web-ui
32
+ pnpm install && pnpm -r build
33
+ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
34
+ ```
35
+
36
+ Restart `dsh web`; the tab appears in the settings page's Plugins section.
37
+
38
+ ## Config
39
+
40
+ The tab carries no configuration namespace. Enablement switches and installs apply at the next restart.
41
+
42
+ ## Cordis service
43
+
44
+ The browser half provides the shared dual-channel face as the cordis service `pluginManager`, so sibling client plugins can drive and observe plugin management without re-implementing the channel detection. Consume it with `ctx.inject(['pluginManager'], cb)` and read `ctx.pluginManager`:
45
+
46
+ - `isLoopback: boolean` — whether this browser has loopback authority to use the host routes.
47
+ - `list(): Promise<InstalledPluginItem[]>` — read the installed snapshot.
48
+ - `install(spec): Promise<InstalledPluginItem>` — install one plugin from an npm spec or git URL.
49
+ - `uninstall(id): Promise<InstalledPluginItem[]>` — remove one plugin.
50
+ - `status(): Promise<InstallProgressItem>` — read the current install/update progress.
51
+ - `onChange(cb): () => void` — subscribe to successful mutations; fires after `install()`, `update()`, `uninstall()`, or `setEnabled()` resolves, and returns the unsubscribe function.
52
+
53
+ The contract source of truth is `src/core/service.ts` (`PluginManagerService`). The service is provided for the plugin's lifetime and disappears when the plugin is unloaded. The service and the Plugin manager tab share one face, so `onChange` subscribers observe mutations from both.
54
+
55
+ ## Known limitations
56
+
57
+ - Loopback-only: on a LAN or remote browser the tab renders a local-only notice (the same boundary the official installer tab enforces; the gateway refuses non-loopback requests with 403).
58
+ - On the npm-published web runtime, gateway writes go through the official CLI, so the `dsh` binary must be on the host process PATH; installs of git sources can take minutes and run as background jobs.
59
+ - On the npm-published web runtime there is no boot-failure ring and no safe mode: those surfaces degrade to empty, and only install errors offer the repair handoff.
60
+ - Enablement on the npm runtime writes bare `disabled` override rows into the profile's cordis.patch.yml; the runtime's loader honors them at the next start, but this path is less exercised than the official desktop writer's.
61
+ - The web build has no in-place restart: changes apply at the next manual restart.
62
+ - Install-time conflict detection reports what the install actually changed (product rows in official mode, profile rows and bundle entries in gateway mode). On the npm runtime, duplicate insert-id claims are detected after install and the new plugin is rolled back automatically (a shared id can never be `disabled` away: the loader's duplicate check has no disabled exemption); on official runtimes the host's own rules and the boot-failure ring own that case.
63
+ - The npm runtime's boot preflight (`--dump-config`) catches composition failures, and the static insert check catches insert rows naming packages that resolve nowhere; runtime import/apply failures still surface only at the next real start, where official runtimes keep the failure ring and the npm runtime does not.
64
+ - Duplicate-mount safeguard (gateway mode): the official CLI's bundle reconciliation re-adds every bundle-declaring dependency to `dsh.profile.bundles` after any install/remove — including packages the composition already mounts through a patch row (the family aggregate mounts `dsh-better-sidebar` as a row), which would double-mount and fail the next boot (`duplicate prefix route`). After every successful CLI mutation the gateway strips exactly the newly added, already-row-mounted bundles entries back out (the manifest write goes through backup + tmp + atomic rename), reports one notice per stripped entry on the job result, and leaves normal installs' bundles entries — and every entry the user had before — untouched.
65
+ - The wire shapes mirror the official installer tab protocol; on drift the tolerant parsers degrade to error rows rather than misbehaving.
66
+ - The repair conversation's workspace keeps its path-derived default title.
67
+
68
+ ## Security model
69
+
70
+ - Trust boundary is the loopback fence: every gateway route requires a loopback socket address, a loopback Host header, and a non-cross-site origin (socket + Host + Origin + `sec-fetch-site`), the same authority the official installer channels enforce. There is no browser-reachable path from a remote origin.
71
+ - Mutation routes (install / remove / set-enabled) carry no token: the loopback authority *is* the local user, matching the official channels. Any local process can therefore drive plugin installs and removals, and npm installs run package install scripts — treat the gateway as local code execution by design and never expose it beyond loopback.
72
+ - Install specs and package ids are rejected when they contain shell metacharacters (`& | < >`, quotes, backtick, control characters). The gateway always spawns the official CLI without a shell; on Windows it resolves the npm-generated `dsh.cmd` to `node.exe` + the package `bin.js` so paths with spaces survive and `cmd.exe` never re-parses arguments. Residual upstream note: the official CLI itself forwards to pnpm with a `cmd.exe` shell on Windows, which this package cannot change — the metachar validation is the mitigation inside this repository.
73
+ - Mutations are serialized through one queue, so concurrent jobs never interleave their before/after profile captures. An install is only `done` when the new dependency actually landed in the profile (and a removal only when it is gone); a success exit code alone is never trusted.
74
+ - Conflict handling is owner-aware: a duplicate entry id or an insert row naming an unresolvable package rolls the *new* package back through the official remove path. The gateway never writes `disabled` rows for a shared id (such rows cannot stop the loader's duplicate check and would flag the existing owner).
75
+ - The boot preflight (`--dump-config`) composes patch layers without importing entries: it catches composition failures, not import-time failures, which still surface at the first real boot.
76
+ - The profile name (from `--profile` / `DSH_PROFILE`) is validated against path traversal before any file is touched; patch writes go through a backup copy plus tmp-write + atomic rename (`cordis.patch.yml.bak-plugin-manager`).
77
+ - The duplicate-mount safeguard writes only the profile manifest's `dsh.profile.bundles`, under the same backup + tmp-write + atomic-rename discipline as patch writes (`package.json.bak-plugin-manager`). It removes only entries the CLI just added that duplicate an existing patch-row mount, and a failed safeguard write fails the job visibly rather than silently leaving a boot-breaking state.
78
+
79
+ ## License
80
+
81
+ BSD-3-Clause.
package/README.zh.md ADDED
@@ -0,0 +1,81 @@
1
+ # @linxin666/dsh-client-ui-plugin-manager
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 面向 dsh web GUI「插件」设置分区的插件管理器 Tab:从 npm 或 git 安装插件,列出已装插件并提供下次启动生效的启用开关,如实呈现安装时冲突动作并支持撤销,失败一键转交修复会话。
6
+
7
+ ## 功能
8
+
9
+ - 在官方「插件」设置分区注册「插件管理」Tab(`settings.plugins.tab` 槽位,order 20,与官方安装器 Tab 并列)。
10
+ - 双通道传输:带官方安装器服务的运行时(DSHCode 与 1.0.4 checkout 版 web)走官方 `/plugin-installer`、`/plugin-control` loopback RPC 通道;npm 发布的官方 web 没有这些通道,本包的 host 半区挂载 loopback 门禁的 HTTP 网关——安装/卸载 spawn 官方 `dsh plugin` CLI(唯一写入器),启停写入 `disabled` 覆盖行。
11
+ - 从 npm 包名或 git 仓库 URL 安装插件,带进度。
12
+ - 列出已装用户插件:下次启动生效的启用开关、更新检查(npm 源走 registry)、更新与卸载。
13
+ - 官方 plugin-control 面存在时展示内置产品开关。
14
+ - 安装时冲突对账:官方模式对产品快照前后 diff;网关模式对每次 CLI 运行前后的 profile 层 diff,可撤销的动作给一键撤销,每条冲突都给「让 Agent 修复」转交。
15
+ - 按插件渲染启动失败环:「让 Agent 修复」(以插件安装根为工作区的修复会话)与「复制错误」;npm web 运行时没有失败环,只有安装错误提供修复转交。
16
+ - 显示宿主安全模式横幅与「恢复正常模式」操作(web 端在下次手动重启时生效)。
17
+ - npm 运行时保护下次启动:安装后网关校验依赖真实落盘、拒绝重复入口 id 认领与引用不可解析包的 insert 行,并用 CLI 的 `--dump-config` 做组合预检;冲突或失败的安装会经官方 remove 路径自动回滚(绝不触碰现有插件),错误行带修复转交。
18
+
19
+ ## 安装
20
+
21
+ ### 从 npm 安装(推荐)
22
+
23
+ ```sh
24
+ dsh plugin --profile web add @linxin666/dsh-client-ui-plugin-manager
25
+ ```
26
+
27
+ ### 从仓库安装(开发调试)
28
+
29
+ ```sh
30
+ git clone https://github.com/zhu1090093659/dsh-web-ui.git
31
+ cd dsh-web-ui
32
+ pnpm install && pnpm -r build
33
+ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
34
+ ```
35
+
36
+ 重启 `dsh web` 后,设置页「插件」分区出现该 Tab。
37
+
38
+ ## 配置
39
+
40
+ 本 Tab 不携带配置命名空间。开关与安装在下次重启后生效。
41
+
42
+ ## cordis 服务
43
+
44
+ 浏览器半区把共享的双通道 face 以 cordis 服务名 `pluginManager` 提供,兄弟客户端插件无需重复实现通道探测即可驱动与观察插件管理。用 `ctx.inject(['pluginManager'], cb)` 注入并读取 `ctx.pluginManager`:
45
+
46
+ - `isLoopback: boolean` — 本浏览器是否具有使用 host 路由的 loopback 权威。
47
+ - `list(): Promise<InstalledPluginItem[]>` — 读取已装快照。
48
+ - `install(spec): Promise<InstalledPluginItem>` — 从 npm spec 或 git URL 安装一个插件。
49
+ - `uninstall(id): Promise<InstalledPluginItem[]>` — 卸载一个插件。
50
+ - `status(): Promise<InstallProgressItem>` — 读取当前安装/更新进度。
51
+ - `onChange(cb): () => void` — 订阅成功变更;`install()`、`update()`、`uninstall()`、`setEnabled()` 任一成功 resolve 后触发,返回退订函数。
52
+
53
+ 契约事实源在 `src/core/service.ts`(`PluginManagerService`)。服务随插件生命周期提供,插件卸载即消失。服务与「插件管理」Tab 共享同一个 face,因此 `onChange` 订阅者对两侧发起的变更都能收到通知。
54
+
55
+ ## 已知限制
56
+
57
+ - 仅限本机:LAN 或远程浏览器只显示「仅限本机操作」提示(与官方安装器 Tab 同一边界;网关对非 loopback 请求返回 403)。
58
+ - npm 发布的官方 web 上,网关写入经官方 CLI 执行,因此 host 进程 PATH 里必须有 `dsh`;git 源安装可能耗时数分钟,以后台任务运行。
59
+ - npm 发布的官方 web 没有启动失败环与安全模式:这两处界面降级为空,只有安装错误提供修复转交。
60
+ - npm 运行时上的启停会在 profile 的 cordis.patch.yml 写入裸 `disabled` 覆盖行;该运行时 loader 在下次启动时认读这些行,但这条路径不如官方桌面写入器经过充分锻炼。
61
+ - web 端无壳内重启:变更在下次手动重启后生效。
62
+ - 安装时冲突检测报告安装实际改了什么(官方模式为产品行;网关模式为 profile 行与 bundle 条目)。npm 运行时上重复 insert id 认领在安装后即被检出并自动回滚新插件(共享 id 写 disabled 无法阻止 loader 的重复检查,只会误伤现有插件);官方运行时由官方规则与失败环处置该类冲突。
63
+ - npm 运行时的启动预检(`--dump-config`)能抓组合失败,静态 insert 检查能抓引用不存在包的 insert 行;真正的运行时 import/apply 失败仍要到下次启动才暴露,官方运行时靠失败环呈现,npm 运行时没有失败环。
64
+ - 重复挂载保护(网关模式):官方 CLI 的 bundle 对账会在任何安装/卸载后把所有声明 `dsh.bundle` 的依赖重新加进 `dsh.profile.bundles`——包括组合树里已由 patch 行挂载的包(全家桶聚合包以行挂载 `dsh-better-sidebar`),下次启动会重复挂载而失败(`duplicate prefix route`)。每次 CLI 变更成功后,网关只把「本次新增且已被 patch 行挂载」的 bundles 条目剥除(清单写入走备份 + tmp + 原子 rename),并在任务结果上为每个被剥除的条目发一条 notice;正常安装的 bundles 条目与用户此前已有的条目一律不动。
65
+ - wire 形状镜像官方安装器 Tab 协议;漂移时宽容解析器降级为错误行,不误操作。
66
+ - 修复会话工作区保留路径派生的默认标题。
67
+
68
+ ## 安全模型
69
+
70
+ - 信任边界是 loopback 门禁:每条网关路由都要求 loopback socket 地址、loopback Host 头与非跨站来源(socket + Host + Origin + `sec-fetch-site` 四重),与官方安装器通道同一权威。远程来源的浏览器没有可达路径。
71
+ - 变更类路由(install / remove / set-enabled)不带 token:loopback 权威即本机用户,与官方通道同模型。因此任何本机进程都能驱动插件安装与卸载,且 npm 安装会执行包的 install 脚本——请将本网关视为「设计上即本机代码执行」,绝不暴露到 loopback 之外。
72
+ - 安装 spec 与包 id 含 shell 元字符(`& | < >`、引号、反引号、控制字符)时一律拒绝。网关在所有平台无 shell spawn 官方 CLI;Windows 下把 npm 生成的 `dsh.cmd` 解析为 `node.exe` + 包内 `bin.js`,含空格路径不被截断、`cmd.exe` 不再二次解析参数。上游残留说明:官方 CLI 内部向 pnpm 转发时在 Windows 上仍走 `cmd.exe` shell,本仓库无法改变——元字符校验即本仓库内的缓解。
73
+ - 变更经同一队列串行,并发任务的 before/after profile 快照绝不交错。安装只有在依赖真实落入 profile 后才判 done(卸载以依赖消失为准),绝不轻信成功退出码。
74
+ - 冲突处置是 owner-aware 的:重复入口 id 或引用不可解析包的 insert 行会经官方 remove 路径回滚**新**包;网关绝不对共享 id 写 `disabled` 行(那既阻止不了 loader 的重复检查,又会误伤现有插件)。
75
+ - 启动预检(`--dump-config`)只组合 patch 层、不 import 条目:能抓组合失败,抓不到 import 期失败——后者仍在首次真实启动时暴露。
76
+ - profile 名(来自 `--profile` / `DSH_PROFILE`)在任何文件读写前做路径穿越校验;patch 写入走备份 + tmp + 原子 rename(`cordis.patch.yml.bak-plugin-manager`)。
77
+ - 重复挂载保护只写 profile 清单的 `dsh.profile.bundles`,与 patch 写入同一纪律(备份 + tmp + 原子 rename,备份为 `package.json.bak-plugin-manager`);只移除 CLI 刚加入且与既有 patch 行挂载重复的条目;保护写回失败会让任务显式失败,绝不静默留下破坏下次启动的状态。
78
+
79
+ ## 许可证
80
+
81
+ BSD-3-Clause。
@@ -0,0 +1,7 @@
1
+ # bundle patch for the dsh-plugin-manager plugin: inserts its plugin row into the web
2
+ # profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
3
+ # manifest field); install with
4
+ # `dsh plugin --profile web add link:<repo>/packages/dsh-plugin-manager`.
5
+ - insert:
6
+ - id: ui-plugin-manager
7
+ name: '@linxin666/dsh-client-ui-plugin-manager'