@gluztm/dsh-guard 0.0.0-stage → 2.4.0
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 +674 -0
- package/README.en.md +48 -0
- package/README.md +51 -2
- package/assets/icon.png +0 -0
- package/bin/dsh-guard.mjs +66 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +856 -0
- package/lib/index.mjs +283 -0
- package/lib/inspector.mjs +552 -0
- package/package.json +87 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @gluztm/dsh-guard — Official Companion Plugin for DSHGuard
|
|
2
|
+
|
|
3
|
+
[](../../LICENSE)
|
|
4
|
+
[](#install-into-dsh)
|
|
5
|
+
|
|
6
|
+
[简体中文](README.md) · [DSHGuard Main Repository](../../README.en.md)
|
|
7
|
+
|
|
8
|
+
`@gluztm/dsh-guard` is the official read-only companion plugin for **[DSHGuard](https://github.com/gluztm/DSHGuard)**. It brings a native **DSH Web UI sidebar panel**, **3 read-only Agent tools**, a **`/guard` slash command**, and a **standalone CLI** that work cross-platform across Windows, macOS, and Linux:
|
|
9
|
+
|
|
10
|
+
- **Web UI Sidebar & Extension Panel (`lib/client.js`)**: Adapts cleanly to DSH light/dark themes (`--dsw-alias-*` tokens) with an inline EN/ZH toggle:
|
|
11
|
+
- **Dual-Track Manifest Audit**: Checks Web and Desktop `package.json` (`dsh.bundles` vs. `dependencies`), disabled entries, and `cordis.patch.yml` YAML integrity.
|
|
12
|
+
- **Masked Credential Readiness (Zero Secret Read)**: Verifies whether `apiKeyEnv` keys referenced in `cordis.patch.yml` are non-empty inside `.credentials.yaml` — **without ever reading, slicing, logging, or returning secret values**.
|
|
13
|
+
- **Pre-Change Snapshot History**: Lists recent DSHGuard pre-change snapshots stored under `~/.dsh-guard/snapshots/`.
|
|
14
|
+
- **Windows Supervisor Bridge**: On Windows, launches local out-of-band `DSHGuard.exe` in one click for crash rescue, snapshot rollback, or CC Switch import; on macOS/Linux (or when not yet installed), points cleanly to the official GitHub Releases download.
|
|
15
|
+
- **Agent Tools & `/guard` Command**:
|
|
16
|
+
- `dsh_guard_status`: Read-only health check and diagnostics across Web & Desktop tracks
|
|
17
|
+
- `dsh_guard_snapshots`: Pre-change snapshot listing filtered by track
|
|
18
|
+
- `dsh_guard_open`: Locate or launch local Windows `DSHGuard.exe`, or return the official release link
|
|
19
|
+
- `/guard [status|snapshots|open]`: Quick slash-command access
|
|
20
|
+
|
|
21
|
+
> Scoped package note: the unscoped name `dsh-guard` is already taken by another author on npm, so this official companion package uses `@gluztm/dsh-guard` and distributes signed release `.tgz` tarballs directly via [GitHub Release 2.4.0](https://github.com/gluztm/DSHGuard/releases/tag/2.4.0).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Install into DSH
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
# Add to DSH Web profile (Sidebar UI + Agent tools + /guard)
|
|
29
|
+
dsh plugin --profile web add https://github.com/gluztm/DSHGuard/releases/download/2.4.0/dsh-guard-2.4.0.tgz
|
|
30
|
+
|
|
31
|
+
# Add to DSH Desktop profile
|
|
32
|
+
dsh plugin --profile desktop add https://github.com/gluztm/DSHGuard/releases/download/2.4.0/dsh-guard-2.4.0.tgz
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Standalone CLI (Node.js >= 18)
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
node packages/dsh-guard/bin/dsh-guard.mjs status
|
|
39
|
+
node packages/dsh-guard/bin/dsh-guard.mjs snapshots --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Security & Read-Only Boundaries
|
|
45
|
+
|
|
46
|
+
- **Zero Secret Leakage**: Only inspects key names and empty/non-empty presence in `.credentials.yaml`. Secret values never enter tool responses, HTTP payloads, or logs.
|
|
47
|
+
- **Same-Origin Request Gating**: HTTP routes (`/api/dsh-guard/overview` and `/api/dsh-guard/open`) enforce DSH's `connection.requestRejection` check and never accept arbitrary filesystem path parameters from HTTP callers.
|
|
48
|
+
- **Strictly Read-Only**: Never mutates DSH profiles or third-party plugins. Config/plugin mutations, snapshot rollback, and CC Switch import remain isolated in the out-of-band Windows `DSHGuard.exe` supervisor.
|
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gluztm/dsh-guard — DSH 守护壳官方伴生插件
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](../../LICENSE)
|
|
4
|
+
[](#安装到-dsh)
|
|
5
|
+
|
|
6
|
+
[English](README.en.md) · [DSHGuard 主仓主页](../../README.md)
|
|
7
|
+
|
|
8
|
+
`@gluztm/dsh-guard` 是 **[DSHGuard(DSH 守护壳)](https://github.com/gluztm/DSHGuard)** 的官方只读伴生插件,兼顾 **DSH Web UI 侧边栏可视化面板**、**Agent 只读工具**、**/guard 聊天命令** 与 **独立体检 CLI**,跨平台(Windows / macOS / Linux)均可使用:
|
|
9
|
+
|
|
10
|
+
- **Web UI 右侧栏 / 面板(`lib/client.js`)**:安装后自动出现在 DSH 右侧工具栏与扩展面板中,深浅色主题自适应(`--dsw-alias-*` 令牌)且支持一键中/英切换:
|
|
11
|
+
- **Web / 桌面双轨配置对账**:检查 `package.json` 依赖清单与 `dsh.bundles` 漂移、禁用插件数及 `cordis.patch.yml` YAML 语法完整度;
|
|
12
|
+
- **凭据脱敏就绪度(零秘密读取)**:仅核对 `.credentials.yaml` 中的键是否非空、是否覆盖 `cordis.patch.yml` 引用的 `apiKeyEnv`,**绝不读取、截断或传输任何真实密钥内容**;
|
|
13
|
+
- **变更前快照历史**:展示本机 `~/.dsh-guard/snapshots/` 下的最近预检与操作前快照;
|
|
14
|
+
- **守护壳联动**:在 Windows 本机可一键唤起进程外 `DSHGuard.exe`(执行崩溃救援、快照回滚、8 套模型预设与 CC Switch 导入);在 macOS / Linux 或未安装桌面壳时显示 GitHub Releases 官方下载指引。
|
|
15
|
+
- **Agent 只读工具 & `/guard` 命令**:
|
|
16
|
+
- `dsh_guard_status`:跨 Web / 桌面双轨的只读体检与诊断建议
|
|
17
|
+
- `dsh_guard_snapshots`:读取按端分类的变更前快照列表
|
|
18
|
+
- `dsh_guard_open`:定位或唤起本机 Windows `DSHGuard.exe`(未安装时返回官方下载链接)
|
|
19
|
+
- `/guard [status|snapshots|open]`:聊天内直达命令
|
|
20
|
+
|
|
21
|
+
> 为什么包名是 `@gluztm/dsh-guard`?因为无作用域名称 `dsh-guard` 在 npm 上已被其他作者占用,为避免社区清单路由冲突,伴生插件统一采用 `@gluztm/dsh-guard` 命名并随 [GitHub Release 2.4.0](https://github.com/gluztm/DSHGuard/releases/tag/2.4.0) 直接分发签名 `.tgz` 安装包。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 安装到 DSH
|
|
26
|
+
|
|
27
|
+
### 方式 A:通过 `awesome-dsh-plugin` 插件市场(推荐)
|
|
28
|
+
|
|
29
|
+
在 DSH 桌面端 / Web 端「插件市场」搜索 **`@gluztm/dsh-guard`** 一键安装,或在终端直接从 GitHub Release 安装:
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
# 安装到 DSH Web 版(包含右侧栏面板 + 工具 + /guard)
|
|
33
|
+
dsh plugin --profile web add https://github.com/gluztm/DSHGuard/releases/download/2.4.0/dsh-guard-2.4.0.tgz
|
|
34
|
+
|
|
35
|
+
# 同步安装到 DSH 桌面版
|
|
36
|
+
dsh plugin --profile desktop add https://github.com/gluztm/DSHGuard/releases/download/2.4.0/dsh-guard-2.4.0.tgz
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 方式 B:从源码子包本地运行只读 CLI(Node.js >= 18)
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
node packages/dsh-guard/bin/dsh-guard.mjs status
|
|
43
|
+
node packages/dsh-guard/bin/dsh-guard.mjs snapshots --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 隐私与安全边界
|
|
49
|
+
|
|
50
|
+
- **严格零秘密泄露**:插件仅检查 `.credentials.yaml` 中的环境键名与是否非空,从不读取、切片、打印或通过 HTTP/工具返回值输出任何 API Key、Token 或完整配置文件原文。
|
|
51
|
+
- **同源校验鉴权**:服务端暴露的 `/api/dsh-guard/overview` 与 `/api/dsh-guard/open` 路由复用 DSH 的 `connection.requestRejection` 校验,仅使用服务端 `DSH_HOME` / `DSHGUARD_HOME` 环境变量路径,不接受外部路径参数。
|
|
52
|
+
- **只读原则**:本插件不会改写 DSH 配置、卸载或更新第三方插件;所有高风险变更(装卸更新、快照回滚、CC Switch 多源导入)均交由进程外的 Windows 桌面壳 `DSHGuard.exe` 先自动存档后隔离执行。
|
package/assets/icon.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
formatHealthText,
|
|
4
|
+
formatSnapshotsText,
|
|
5
|
+
inspectHealth,
|
|
6
|
+
inspectSnapshots,
|
|
7
|
+
openGuard,
|
|
8
|
+
} from '../lib/inspector.mjs'
|
|
9
|
+
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const args = argv.slice(2)
|
|
12
|
+
let command = 'status'
|
|
13
|
+
let dshHome = null
|
|
14
|
+
let guardHome = null
|
|
15
|
+
let snapshotsDir = null
|
|
16
|
+
let target = 'all'
|
|
17
|
+
let limit = 20
|
|
18
|
+
let launch = false
|
|
19
|
+
let json = false
|
|
20
|
+
let help = false
|
|
21
|
+
|
|
22
|
+
for (let i = 0; i < args.length; i++) {
|
|
23
|
+
const a = args[i]
|
|
24
|
+
if (a === '--help' || a === '-h') help = true
|
|
25
|
+
else if (a === '--json') json = true
|
|
26
|
+
else if (a === '--launch') launch = true
|
|
27
|
+
else if (a === '--dsh-home' && i + 1 < args.length) dshHome = args[++i]
|
|
28
|
+
else if (a === '--guard-home' && i + 1 < args.length) guardHome = args[++i]
|
|
29
|
+
else if (a === '--snapshots-dir' && i + 1 < args.length) snapshotsDir = args[++i]
|
|
30
|
+
else if (a === '--target' && i + 1 < args.length) target = args[++i]
|
|
31
|
+
else if (a === '--limit' && i + 1 < args.length) limit = Number(args[++i]) || 20
|
|
32
|
+
else if (!a.startsWith('-')) command = a
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { command, dshHome, guardHome, snapshotsDir, target, limit, launch, json, help }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const opts = parseArgs(process.argv)
|
|
39
|
+
|
|
40
|
+
if (opts.help) {
|
|
41
|
+
console.log([
|
|
42
|
+
'dsh-guard — Companion read-only inspector & snapshot bridge for DSHGuard',
|
|
43
|
+
'',
|
|
44
|
+
'Usage:',
|
|
45
|
+
' dsh-guard status [--target all|web|desktop] [--dsh-home <dir>] [--guard-home <dir>] [--json]',
|
|
46
|
+
' dsh-guard snapshots [--target all|web|desktop] [--limit N] [--guard-home <dir>] [--json]',
|
|
47
|
+
' dsh-guard open [--launch] [--guard-home <dir>] [--json]',
|
|
48
|
+
].join('\n'))
|
|
49
|
+
process.exit(0)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (opts.command === 'snapshots') {
|
|
53
|
+
const report = inspectSnapshots(opts)
|
|
54
|
+
console.log(opts.json ? JSON.stringify(report, null, 2) : formatSnapshotsText(report))
|
|
55
|
+
process.exit(0)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (opts.command === 'open') {
|
|
59
|
+
const res = openGuard(opts)
|
|
60
|
+
console.log(opts.json ? JSON.stringify(res, null, 2) : res.message)
|
|
61
|
+
process.exit(0)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const health = inspectHealth(opts)
|
|
65
|
+
console.log(opts.json ? JSON.stringify(health, null, 2) : formatHealthText(health))
|
|
66
|
+
process.exit(0)
|
package/cordis.patch.yml
ADDED