dsh-ops-kit 0.3.1 → 0.3.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/README.md CHANGED
@@ -96,8 +96,8 @@ dsh plugin --profile desktop add dsh-ops-kit
96
96
  ```
97
97
 
98
98
  A task-oriented walkthrough (setup checks, the ten panel pages, setting defaults,
99
- data sensitivity, troubleshooting) is in
100
- [docs/USAGE.zh-CN.md](docs/USAGE.zh-CN.md) — written in Chinese.
99
+ data sensitivity, troubleshooting) is in [docs/USAGE.md](docs/USAGE.md), also
100
+ available in Chinese: [docs/USAGE.zh-CN.md](docs/USAGE.zh-CN.md).
101
101
 
102
102
  Local development install (directory):
103
103
 
package/README.zh-CN.md CHANGED
@@ -6,7 +6,7 @@
6
6
  插件默认不保存任何凭据。
7
7
 
8
8
  > **完整使用说明见 [docs/USAGE.zh-CN.md](docs/USAGE.zh-CN.md)** —— 前置条件怎么验、面板十个子页各干什么、
9
- > 设置项默认值、数据放在哪有多敏感、以及连不上时怎么排障。
9
+ > 设置项默认值、数据放在哪有多敏感、以及连不上时怎么排障。(英文版:[docs/USAGE.md](docs/USAGE.md))
10
10
 
11
11
  🔒 表示该操作需要 `confirm: true`,缺了会直接拒绝执行,而不是在下一轮再问你。
12
12
 
package/docs/DETAIL.md CHANGED
@@ -1,71 +1 @@
1
- # Ops kit — server operations from a chat
2
-
3
- ## What it is
4
-
5
- A DeepSeek Harness bundle for running Linux servers without leaving the
6
- conversation. It contributes **34 agent tools and a sidebar panel**, and it
7
- never needs an agent installed on the target host.
8
-
9
- Authentication is either your existing SSH key / ssh-agent (through the system
10
- `ssh` client in `BatchMode`, so the plugin never reads your key files) or a
11
- password you store per host (through the plugin's own `ssh2` client, the only
12
- path that keeps a secret on disk).
13
-
14
- ## What it adds
15
-
16
- - **Inventory and connect** — host list, connectivity/latency test, public-key
17
- installation, a read-only scan of ports, services, containers, nginx sites,
18
- java processes, crontab and mounts.
19
- - **Look at a host, read-only** — status snapshot, parallel check of every host,
20
- 0–100 health score, CPU/memory/disk samples, top processes, directory sizes,
21
- log tails, file listings, certificate expiry, and a plain-language diagnosis.
22
- - **Change something, with confirm guards** — one shell command, the same command
23
- across hosts, systemd start/stop/restart, docker restart, killing a pid,
24
- journal cleanup, and monitor management. Everything that changes state
25
- requires `confirm: true` and fails closed instead of asking in a second turn.
26
- - **Config and files** — read a config file, write one after backing it up, and
27
- diff or roll back any `.bak.<ts>` version.
28
- - **Backups, certificates, schedule, deploy** — MySQL dump or directory archive
29
- with retention and restore, certificate probing with `certbot renew --dry-run`,
30
- crontab editing, and git pull → build → restart → health check with automatic
31
- rollback when the health check fails.
32
- - **Alerts and AI** — delivery to Feishu / DingTalk / WeCom / any webhook with
33
- per-channel levels and 10-minute dedupe, plus a natural-language `ops_ask` that
34
- runs read-only commands itself.
35
-
36
- ## Panel
37
-
38
- A sidebar page with ten sub-pages per host: overview, monitor, config, apps,
39
- logs, files, terminal (a real PTY), backups, tasks and deploy. The overview runs
40
- one host or all hosts and records each run in history. Restart, stop, restore and
41
- rollback all ask for confirmation in the panel first.
42
-
43
- ## Requirements
44
-
45
- - macOS or Linux host running DSH with `ssh` on `PATH`.
46
- - Key or ssh-agent authentication already working for each host (`ssh -o
47
- BatchMode=yes user@host true` must succeed) — or `ssh2` present in the profile
48
- if you use stored passwords.
49
- - Remote Linux with `systemctl` for the service tools; Docker is optional and
50
- detected per call. Privileged actions need the host configured with
51
- `sudo: true` and `sudo -n` allowed on the target.
52
-
53
- ## Data and safety
54
-
55
- State lives in `$DSH_HOME/ops-kit/` (default `~/.dsh/ops-kit/`), deliberately
56
- outside the profile so upgrading or removing the bundle never loses the
57
- inventory: `hosts.json`, `config.json`, `history.json`, `state.json`,
58
- `alerts.json`, `channels.json`, and — only when passwords are used —
59
- `secrets.json`.
60
-
61
- `secrets.json` and `channels.json` are mode 0600. Passwords in `secrets.json`
62
- are **base64-encoded, not encrypted**; treat that file as a secret. Webhook URLs
63
- are secrets too, which is why `channels.json` is 0600.
64
-
65
- Tool output is clipped at 8 KB with an explicit truncation marker.
66
-
67
- ## Limitations
68
-
69
- - SSH only: no cloud provider APIs, no Docker Compose or k8s orchestration.
70
- - Metric retention is a bounded row cap, not a time-series database.
71
- - Windows targets need an SSH server with a POSIX-like shell.
1
+ ![Ops panel: three hosts with status dots, a health gauge with sub-scores, metric sparklines and a confirm-guarded shield](preview.svg)
@@ -0,0 +1 @@
1
+ ![运维面板:三台主机带状态点,中间是健康分圆环与三项子分数,右侧是三条指标曲线和表示「改状态需确认」的盾牌](preview.svg)
package/docs/USAGE.md ADDED
@@ -0,0 +1,211 @@
1
+ # dsh-ops-kit — usage guide
2
+
3
+ Written for someone who has just installed the plugin and wants one server under
4
+ control. Tool parameters are deliberately not listed here: that is the schema the
5
+ model reads, and it drifts. This covers **prerequisites, the everyday flows, the
6
+ settings and troubleshooting**.
7
+
8
+ ---
9
+
10
+ ## 1. Prerequisites (read this first — it prevents half the support questions)
11
+
12
+ The plugin reaches a host one of two ways. Decide which one applies:
13
+
14
+ | Path | Needs | Use when |
15
+ |---|---|---|
16
+ | **Key / ssh-agent** (default) | the system `ssh` can log in without a password (`ssh user@ip` just works) | most cases, preferred |
17
+ | **Password** | the `ssh2` package present in this profile | temporary hosts, no key set up yet |
18
+
19
+ Verify it in **your own terminal** before blaming the plugin:
20
+
21
+ ```bash
22
+ ssh -o BatchMode=yes user@ip 'echo ok' # prints ok only when it truly works
23
+ ```
24
+
25
+ `BatchMode=yes` matters — the plugin runs that way. Anything that would prompt
26
+ interactively (an unknown host key, a password request) fails the plugin outright
27
+ instead of asking.
28
+
29
+ ### Also required
30
+
31
+ - **A POSIX shell on the target.** A Windows host only works if it runs an SSH
32
+ server with a POSIX-like shell.
33
+ - **Passwordless sudo for privileged actions.** Set `sudo: true` on the host and
34
+ allow `sudo -n` on the target (NOPASSWD). Otherwise restart/stop actions fail
35
+ with a permission error; read-only tools are unaffected.
36
+
37
+ ---
38
+
39
+ ## 2. Five minutes to first result
40
+
41
+ ### Add a host
42
+
43
+ ```text
44
+ ops_hosts action=add name=web-1 host=10.0.0.11 user=deploy key=~/.ssh/id_ed25519 defaultHost=true
45
+ ```
46
+
47
+ IP + user + password also works (stored in `secrets.json`), but key auth is
48
+ preferred.
49
+
50
+ ### Prove the connection
51
+
52
+ ```text
53
+ ops_ssh_test host=web-1
54
+ ```
55
+
56
+ Returns `ok`, latency and the auth kind actually used. **Do not continue until
57
+ this is `ok`** — go back to section 1.
58
+
59
+ > If you added a password and got `ssh2 is not installed in this profile`, that
60
+ > profile lacks `ssh2`. Install it, or switch to keys — `ops_ssh_install_key
61
+ > host=web-1` pushes this machine's public key using the stored password, after
62
+ > which the password is no longer needed.
63
+
64
+ ### Look at it
65
+
66
+ ```text
67
+ ops_status host=web-1
68
+ ```
69
+
70
+ One call: uptime and load, memory, root disk, failed systemd units, containers.
71
+
72
+ Every host at once:
73
+
74
+ ```text
75
+ ops_check_all
76
+ ```
77
+
78
+ ### Open the panel
79
+
80
+ The **Ops** page in the sidebar. It lists hosts, runs one host or all of them,
81
+ and is described in section 3.
82
+
83
+ ---
84
+
85
+ ## 3. The ten panel pages
86
+
87
+ Click a host from the overview; the left side has ten sub-pages:
88
+
89
+ | Page | What it does |
90
+ |---|---|
91
+ | **Overview** | health score, key metrics, certificate expiry, backup state |
92
+ | **Monitor** | this host's checks (http / port / process / service / script), add, remove, test |
93
+ | **Config** | browse common config files; writing backs the old one up as `.bak.<ts>`; history and rollback |
94
+ | **Apps** | running services and containers with Logs / Restart / Stop |
95
+ | **Logs** | tail of a systemd unit or any log file |
96
+ | **Files** | directory listing with sizes and mtimes |
97
+ | **Terminal** | a real SSH PTY in the page (needs `ssh2`) |
98
+ | **Backups** | list, restore in one click, delete |
99
+ | **Tasks** | visual crontab editing |
100
+ | **Deploy** | one-click job: git pull → build → restart → health check |
101
+
102
+ **Restart, stop, restore and rollback all ask for confirmation first.**
103
+
104
+ ---
105
+
106
+ ## 4. Saying it in plain language
107
+
108
+ You never need the tool names:
109
+
110
+ ```text
111
+ 看一下 web-1 的状态
112
+ web-1 上 nginx 最近 50 行日志
113
+ 磁盘满了,看看 / 下面谁占的空间
114
+ 把 web-1 上的 my-api 重启一下(我确认)
115
+ 所有机器上跑一下 uptime
116
+ web-1 的证书还有几天
117
+ ```
118
+
119
+ ### Question-style diagnosis
120
+
121
+ ```text
122
+ ops_ask host=web-1 question="mysql 还活着吗,为什么连不上"
123
+ ```
124
+
125
+ The model picks **read-only** commands itself and answers. A command that would
126
+ change state comes back as "needs confirmation" instead of being executed.
127
+
128
+ ### Batch
129
+
130
+ ```text
131
+ ops_batch command="df -h" hosts=[web-1,web-2]
132
+ ```
133
+
134
+ Omit `hosts` to target every host. Destructive commands need `confirm`.
135
+
136
+ ### Backups
137
+
138
+ ```text
139
+ ops_backup host=web-1 action=backup type=mysql database=app
140
+ ops_backup host=web-1 action=list
141
+ ```
142
+
143
+ Defaults to `/home/backup`, keeps 7 copies; restore and delete both require
144
+ confirmation.
145
+
146
+ ---
147
+
148
+ ## 5. Settings (`ops_config`)
149
+
150
+ Called with no arguments it returns the effective values. Defaults:
151
+
152
+ | Key | Default | Range | Meaning |
153
+ |---|---|---|---|
154
+ | `enabled` | `true` | — | run the scheduled background checks |
155
+ | `intervalMinutes` | `10` | 1–1440 | background check interval (minutes) |
156
+ | `diskWarnPercent` | `90` | 50–99 | alert when root disk exceeds this |
157
+ | `metricsMinutes` | `5` | 1–60 | metric sampling interval (minutes) |
158
+ | `timeoutSec` | `25` | 5–300 | general request timeout |
159
+ | `scanSec` | `90` | 10–600 | inventory scan timeout (raise for many or slow hosts) |
160
+ | `actionSec` | `45` | 10–600 | action and log-read timeout |
161
+ | `quickCommands` | 6 common commands | up to 12 | shortcuts under the terminal |
162
+ | `aiEnabled` | `true` | — | enable the `ops_ask` AI diagnosis |
163
+ | `aiProvider` / `aiModel` | empty = DSH default model | — | which model the ops AI uses |
164
+
165
+ ---
166
+
167
+ ## 6. Where the data lives, and how sensitive it is
168
+
169
+ Everything is under `$DSH_HOME/ops-kit/` (default `~/.dsh/ops-kit/`),
170
+ **deliberately outside the profile**, so upgrading or removing the plugin never
171
+ loses it.
172
+
173
+ | File | Contents | Sensitivity |
174
+ |---|---|---|
175
+ | `hosts.json` | host inventory | low |
176
+ | `secrets.json` | passwords, **base64-encoded, not encrypted**, mode 0600 | **high — treat as a key** |
177
+ | `channels.json` | alert webhook URLs, mode 0600 | **high — the URL is a secret** |
178
+ | `history.json` | history of every check run | low |
179
+ | `config.json` | the settings above | low |
180
+ | `state.json`, `alerts.json` | scheduler state and alert log | low |
181
+
182
+ `secrets.json` is **not encrypted**: anyone who can read that file has your
183
+ server passwords. Prefer key authentication, or make sure the account on this
184
+ machine is trustworthy.
185
+
186
+ ---
187
+
188
+ ## 7. Troubleshooting
189
+
190
+ | Symptom | Cause and fix |
191
+ |---|---|
192
+ | `ops_ssh_test` fails but typing `ssh` works | the plugin runs in `BatchMode` and never answers prompts. Add the host key to `known_hosts`, or switch to keys |
193
+ | `ssh2 is not installed in this profile` | password path without `ssh2`. Install it, or use keys (`ops_ssh_install_key`) |
194
+ | restart reports a permission error | host not configured with `sudo: true`, or the target does not allow `sudo -n` |
195
+ | a truncation marker at the end of output | output over 8 KB was clipped. Narrow the request (`lines=`, a tighter command) rather than raising the cap |
196
+ | scheduled checks never run | `enabled` in `ops_config`; also check whether `scanSec` is too low and everything times out |
197
+ | alerts never arrive | expired webhook URL (group bots reset theirs), level mismatch, or the same alert was sent within 10 minutes |
198
+ | the panel opens but is empty | confirm the plugin is loaded in that session and that `/ops-kit/api` is not blocked by a reverse proxy |
199
+
200
+ ---
201
+
202
+ ## 8. What happens with state-changing actions
203
+
204
+ | Action | Requires |
205
+ |---|---|
206
+ | start / stop / restart a service, restart a container | `confirm: true` |
207
+ | `ops_run` with a destructive command (`rm -rf /`, `mkfs`, `dd` to a device, `shutdown`/`reboot`) | `confirm: true`, otherwise refused outright |
208
+ | backup restore and delete, config rollback, one-click deploy | `confirm: true` |
209
+ | health checks, `ops_status`, `ops_check_all`, `ops_ssh_test`, `ops_ask` | read-only, no confirmation |
210
+
211
+ The principle: **reading is always free, writing needs a human nod.**
@@ -0,0 +1,53 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300" role="img" aria-label="Ops panel: three hosts with status dots, a health gauge, metric sparklines and a confirm-guarded shield">
2
+ <rect x="0" y="0" width="640" height="300" rx="16" fill="#F5F7FA"/>
3
+ <rect x="0.5" y="0.5" width="639" height="299" rx="16" fill="none" stroke="#E3E7ED"/>
4
+
5
+ <!-- host list -->
6
+ <rect x="48" y="48" width="170" height="204" rx="12" fill="#FFFFFF" stroke="#E3E7ED"/>
7
+
8
+ <circle cx="70" cy="82" r="5" fill="#22C55E"/>
9
+ <rect x="86" y="75" width="86" height="7" rx="3.5" fill="#DCE2EA"/>
10
+ <rect x="86" y="89" width="54" height="7" rx="3.5" fill="#EDF1F6"/>
11
+
12
+ <circle cx="70" cy="136" r="5" fill="#F59E0B"/>
13
+ <rect x="86" y="129" width="74" height="7" rx="3.5" fill="#DCE2EA"/>
14
+ <rect x="86" y="143" width="46" height="7" rx="3.5" fill="#EDF1F6"/>
15
+
16
+ <circle cx="70" cy="190" r="5" fill="#94A3B8"/>
17
+ <rect x="86" y="183" width="94" height="7" rx="3.5" fill="#DCE2EA"/>
18
+ <rect x="86" y="197" width="60" height="7" rx="3.5" fill="#EDF1F6"/>
19
+
20
+ <!-- health gauge -->
21
+ <rect x="232" y="48" width="176" height="204" rx="12" fill="#FFFFFF" stroke="#E3E7ED"/>
22
+ <circle cx="320" cy="112" r="34" fill="none" stroke="#E9EDF2" stroke-width="11"/>
23
+ <circle cx="320" cy="112" r="34" fill="none" stroke="#2563EB" stroke-width="11"
24
+ stroke-linecap="round" stroke-dasharray="153.8 59.8"
25
+ transform="rotate(-90 320 112)"/>
26
+ <polyline points="308,112 316,120 332,102" fill="none" stroke="#16A34A"
27
+ stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
28
+
29
+ <rect x="252" y="166" width="136" height="8" rx="4" fill="#E9EDF2"/>
30
+ <rect x="252" y="166" width="104" height="8" rx="4" fill="#2563EB"/>
31
+ <rect x="252" y="184" width="136" height="8" rx="4" fill="#E9EDF2"/>
32
+ <rect x="252" y="184" width="86" height="8" rx="4" fill="#22C55E"/>
33
+ <rect x="252" y="202" width="136" height="8" rx="4" fill="#E9EDF2"/>
34
+ <rect x="252" y="202" width="58" height="8" rx="4" fill="#F59E0B"/>
35
+
36
+ <!-- metrics and confirm guard -->
37
+ <rect x="422" y="48" width="170" height="204" rx="12" fill="#FFFFFF" stroke="#E3E7ED"/>
38
+
39
+ <polyline points="446,112 468,94 490,104 512,80 534,92 556,72 578,84"
40
+ fill="none" stroke="#2563EB" stroke-width="2.5"
41
+ stroke-linecap="round" stroke-linejoin="round"/>
42
+ <polyline points="446,132 468,122 490,130 512,116 534,124 556,112 578,118"
43
+ fill="none" stroke="#22C55E" stroke-width="2.5"
44
+ stroke-linecap="round" stroke-linejoin="round"/>
45
+ <polyline points="446,150 468,146 490,150 512,142 534,148 556,140 578,144"
46
+ fill="none" stroke="#F59E0B" stroke-width="2.5"
47
+ stroke-linecap="round" stroke-linejoin="round"/>
48
+
49
+ <path d="M507 168 l28 11 v24 c0 17 -13 28 -28 34 c-15 -6 -28 -17 -28 -34 v-24 z"
50
+ fill="#ECFDF5" stroke="#22C55E" stroke-width="2.5" stroke-linejoin="round"/>
51
+ <polyline points="495,197 504,206 520,188" fill="none" stroke="#16A34A"
52
+ stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
53
+ </svg>
package/locale/zh.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "meta": {
3
3
  "title": "运维工具包",
4
4
  "description": "在对话里管服务器:34 个工具加侧栏面板,覆盖 SSH 清单、健康检查、日志与进程、备份恢复、证书、计划任务、一键发布和飞书/钉钉/企业微信告警;改状态的操作一律要求确认。",
5
- "detail": "docs/DETAIL.md"
5
+ "detail": "docs/DETAIL.zh.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ops-kit",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Server operations kit for DeepSeek Harness: server cards, health charts, config browser, app manager and plain-language AI diagnosis — over SSH, no agent install.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,6 +18,9 @@
18
18
  "cordis.patch.yml",
19
19
  "locale/*.json",
20
20
  "docs/DETAIL.md",
21
+ "docs/DETAIL.zh.md",
22
+ "docs/preview.svg",
23
+ "docs/USAGE.md",
21
24
  "docs/USAGE.zh-CN.md",
22
25
  "icon.svg",
23
26
  "README.md",
@@ -61,5 +64,13 @@
61
64
  "bugs": {
62
65
  "url": "https://github.com/shenlongze/dsh-ops-kit/issues"
63
66
  },
64
- "author": "shenlongze"
67
+ "author": "shenlongze",
68
+ "peerDependencies": {
69
+ "ssh2": "^1.16.0"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "ssh2": {
73
+ "optional": true
74
+ }
75
+ }
65
76
  }