dsh-ops-kit 0.3.0 → 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
@@ -1,47 +1,91 @@
1
1
  # dsh-ops-kit
2
2
 
3
- Server operations from a DeepSeek Harness chat, with no SDK and no credentials
4
- stored by the plugin.
5
-
6
- ## What it adds
7
-
8
- | Tool | What it does | Changes state |
9
- |---|---|---|
10
- | `ops_hosts` | list / add / remove SSH hosts (`~/.dsh/ops-kit/hosts.json`) | only that file |
11
- | `ops_status` | uptime + load, memory, root disk, failed systemd units, Docker containers | no |
12
- | `ops_check_all` | all hosts in parallel, one summary row each, appends to history | no |
13
- | `ops_batch` | one command on several hosts in parallel, bounded row per host | yes (destructive commands need `confirm`) |
14
- | `ops_run` | one shell command over SSH, returns stdout/stderr/exit code | yes (destructive commands need `confirm`) |
15
- | `ops_service` | `systemctl status/logs/start/stop/restart` on a unit | start/stop/restart need `confirm` |
16
- | `ops_docker` | `docker ps/logs/inspect/restart` | restart needs `confirm` |
17
- | `ops_backup` | MySQL dump / directory archive, list, restore, delete (retention N) | yes, `confirm` in the panel |
18
- | `ops_health` | 0–100 score plus the issues worth fixing first | no |
19
- | `ops_channels` | alert delivery to Feishu / DingTalk / WeCom / any webhook | no (test send only) |
20
- | `ops_cert` | certificate days left, certbot dry run or real renewal | renewal changes state |
21
- | `ops_cron` | list / add / remove crontab entries | yes |
22
- | `ops_file_history` | `.bak` versions of a config file, diff, rollback | rollback changes state |
23
- | `ops_deploy` | git pull → build → restart → health check, auto rollback | yes |
24
- | `ops_ask` | natural-language question; the model runs read-only commands itself | read-only |
25
- | `ops_monitors` | http / port / process / service / script heartbeat checks | yes |
26
- | `ops_ssh_test` | connectivity + latency + auth kind | no |
27
- | `ops_ai_models` | providers and models the ops AI can use | no |
3
+ **English** | [简体中文](README.zh-CN.md)
4
+
5
+ Server operations from a DeepSeek Harness chat: **34 tools plus a sidebar panel**,
6
+ no SDK, and no credentials stored by the plugin.
7
+
8
+ 🔒 marks an action that needs `confirm: true` — the tool fails closed instead of
9
+ asking in a second turn.
10
+
11
+ ## Connect and inventory
12
+
13
+ | Tool | What it does |
14
+ |---|---|
15
+ | `ops_hosts` | list / add / update / remove SSH hosts (`~/.dsh/ops-kit/hosts.json`) |
16
+ | `ops_ssh_test` | connectivity, latency and the auth kind actually used |
17
+ | `ops_ssh_install_key` | install this machine's public key using the stored password |
18
+ | `ops_inventory` | read-only scan: listening ports, services, containers, nginx sites, java processes, crontab, mounts |
19
+
20
+ ## Look at a host (read-only)
21
+
22
+ | Tool | What it does |
23
+ |---|---|
24
+ | `ops_status` | uptime + load, memory, root disk, failed systemd units, containers |
25
+ | `ops_check_all` | every host in parallel, one summary row each, appends to history |
26
+ | `ops_health` | 0–100 score plus the issues worth fixing first |
27
+ | `ops_metrics` | CPU / memory / disk samples over a window (capped at 20 000 rows) |
28
+ | `ops_ps` | top processes by CPU or memory |
29
+ | `ops_disk` | directory sizes one level below a path |
30
+ | `ops_logs` | journal unit or log-file tail |
31
+ | `ops_files` | directory listing with sizes and mtimes |
32
+ | `ops_ssl` | certificate subject, issuer, expiry for one domain |
33
+ | `ops_diagnose` | plain-language diagnosis with suggested next actions |
34
+
35
+ ## Change something
36
+
37
+ | Tool | What it does |
38
+ |---|---|
39
+ | `ops_run` | one shell command; a destructive denylist needs 🔒 |
40
+ | `ops_batch` | the same command on several hosts in parallel |
41
+ | `ops_service` | `systemctl status/logs/start/stop/restart` (start/stop/restart 🔒) |
42
+ | `ops_docker` | `docker ps/logs/inspect/restart` (restart 🔒) |
43
+ | `ops_kill` | TERM / KILL / HUP one pid 🔒 |
44
+ | `ops_cleanup` | vacuum the journal, truncate rotated logs 🔒 |
45
+ | `ops_monitors` | http / port / process / service / script heartbeat checks |
46
+
47
+ ## Config and files
48
+
49
+ | Tool | What it does |
50
+ |---|---|
51
+ | `ops_config` | scheduler settings: interval, disk threshold, timeouts, quick commands, AI model |
52
+ | `ops_config_file` | read one configuration file |
53
+ | `ops_save_config` | write a config file after backing it up 🔒 |
54
+ | `ops_file_history` | `.bak.<ts>` versions of a file, diff, rollback 🔒 |
55
+
56
+ ## Backups, certificates, schedule, deploy
57
+
58
+ | Tool | What it does |
59
+ |---|---|
60
+ | `ops_backup` | MySQL dump or directory archive, list, restore, delete, retention N |
61
+ | `ops_cert` | certificate days left, `certbot renew --dry-run`, real renewal |
62
+ | `ops_cron` | list / add / remove crontab entries |
63
+ | `ops_deploy` | git pull → build → restart → health check, automatic rollback |
64
+
65
+ ## Alerts and AI
66
+
67
+ | Tool | What it does |
68
+ |---|---|
69
+ | `ops_channels` | alert delivery to Feishu / DingTalk / WeCom / any webhook, plus test send |
70
+ | `ops_alerts` | recent alerts from the scheduled checks |
71
+ | `ops_ask` | natural-language question; the model runs read-only commands itself |
72
+ | `ops_ai_command` | turn an intent into ONE command, without executing it |
73
+ | `ops_ai_models` | providers and models the ops AI can use |
28
74
 
29
75
  ## Design
30
76
 
31
- - **Zero dependencies.** It uses the system `ssh` client in `BatchMode`, so key
32
- or ssh-agent authentication must already work. No passwords, no private keys
33
- are stored.
34
- - **Password or key.** A host can be added with only IP + user + password; the
35
- plugin connects through its own `ssh2` client, so no key setup is needed. A
36
- host without a stored password uses the system `ssh` client and your keys.
37
- Passwords live in `$DSH_HOME/ops-kit/secrets.json` with mode 0600; they are
38
- base64-encoded, not encrypted, so treat that file as a secret.
77
+ - **No SDK, no credential storage by default.** Key authentication goes through
78
+ the system `ssh` client in `BatchMode`, so the plugin never reads your keys.
79
+ Password authentication uses the plugin's own `ssh2` client and is the only
80
+ case where a secret is stored (see below).
81
+ - **Password or key.** A host can be added with only IP + user + password; that
82
+ path needs `ssh2` present in the profile. A host without a stored password
83
+ uses the system `ssh` client and your keys or agent.
39
84
  - **Inventory outside the profile.** Hosts live in
40
85
  `$DSH_HOME/ops-kit/hosts.json` (default `~/.dsh/ops-kit/hosts.json`), so
41
86
  upgrading or removing the plugin does not lose them.
42
87
  - **Read/write separation.** Health checks are always read-only. Anything that
43
- changes a service or container requires `confirm: true`, and `ops_run`
44
- refuses a short list of destructive commands without it.
88
+ changes a service or container requires `confirm: true`.
45
89
  - **Bounded output.** Tool results are clipped at 8 KB with an explicit
46
90
  truncation marker, so a runaway log line cannot flood the model context.
47
91
 
@@ -51,6 +95,10 @@ stored by the plugin.
51
95
  dsh plugin --profile desktop add dsh-ops-kit
52
96
  ```
53
97
 
98
+ A task-oriented walkthrough (setup checks, the ten panel pages, setting defaults,
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
+
54
102
  Local development install (directory):
55
103
 
56
104
  ```
@@ -59,14 +107,13 @@ Plugins → Add plugin → select this directory
59
107
 
60
108
  ## Panel
61
109
 
62
- The bundle also ships a sidebar page (**Ops**) that lists hosts, adds or removes
63
- them, runs one host's health check, or checks every host at once. Runs are
64
- recorded in `$DSH_HOME/ops-kit/history.json` and shown at the bottom of the page.
65
- The panel talks to the host half through `/ops-kit/api/*`.
110
+ The bundle ships a sidebar page (**Ops**) with ten sub-pages per host: overview,
111
+ monitor, config, apps, logs, files, terminal (real PTY), backups, tasks, deploy.
112
+ The overview lists hosts and runs one host or all hosts at once; runs are
113
+ recorded in `$DSH_HOME/ops-kit/history.json`. The panel talks to the host half
114
+ through `/ops-kit/api/*`.
66
115
 
67
- It also carries a batch-command box (pick hosts or leave all), and a per-host
68
- **Actions** panel that lists running systemd services and containers with
69
- Logs / Restart / Stop buttons. Restart and stop ask for confirmation first.
116
+ Restart, stop, restore and rollback all ask for confirmation in the panel first.
70
117
 
71
118
  ## First run
72
119
 
@@ -82,18 +129,13 @@ nginx 最近 50 行日志
82
129
  把 web-1 上的 my-api 重启一下(我确认)
83
130
  ```
84
131
 
85
- ## Limits (deliberately not implemented yet)
132
+ ## Limits (deliberately not implemented)
86
133
 
87
- - No interactive PTY: long interactive sessions need the terminal panel plugins.
88
- - No cloud APIs (Aliyun/Tencent/AWS). This kit only speaks SSH.
89
- - No metric history or alerting: `ops_status` is a point-in-time snapshot.
134
+ - No cloud APIs (Aliyun / Tencent / AWS). This kit only speaks SSH.
135
+ - No application-level deploys beyond `ops_deploy` (no Docker Compose, no k8s).
90
136
  - No Windows remoting: SSH to Windows works only if the host runs an SSH server
91
137
  with a POSIX-like shell.
92
-
93
- ## License
94
-
95
- MIT
96
-
138
+ - Metric retention is a bounded row cap, not a time-series database.
97
139
 
98
140
  ## 0.3.0 — backups, health score, certificates, cron, config history, deploy
99
141
 
@@ -109,9 +151,6 @@ MIT
109
151
  - **One-click deploy.** git pull → build → restart → health check, with an
110
152
  automatic rollback to the previous commit when the health check fails.
111
153
 
112
- Panel navigation: overview → server detail with ten sub-pages
113
- (summary, monitor, config, apps, logs, files, terminal, backups, tasks, deploy).
114
-
115
154
  ## Alert delivery
116
155
 
117
156
  Alerts produced by the scheduler (host down, disk pressure, failed units, monitor
@@ -124,3 +163,7 @@ failures, certificate expiry) are pushed to the configured channels:
124
163
  Each channel chooses which levels it receives (critical / warning / info). The
125
164
  same alert is not resent within 10 minutes. Channels live in
126
165
  `~/.dsh/ops-kit/channels.json` with mode 0600, because the URL itself is a secret.
166
+
167
+ ## License
168
+
169
+ MIT
@@ -0,0 +1,154 @@
1
+ # dsh-ops-kit
2
+
3
+ [English](README.md) | **简体中文**
4
+
5
+ 在 DeepSeek Harness 的对话里做服务器运维:**34 个工具 + 一个侧栏面板**,无需安装 SDK,
6
+ 插件默认不保存任何凭据。
7
+
8
+ > **完整使用说明见 [docs/USAGE.zh-CN.md](docs/USAGE.zh-CN.md)** —— 前置条件怎么验、面板十个子页各干什么、
9
+ > 设置项默认值、数据放在哪有多敏感、以及连不上时怎么排障。(英文版:[docs/USAGE.md](docs/USAGE.md))
10
+
11
+ 🔒 表示该操作需要 `confirm: true`,缺了会直接拒绝执行,而不是在下一轮再问你。
12
+
13
+ ## 连接与清单
14
+
15
+ | 工具 | 作用 |
16
+ |---|---|
17
+ | `ops_hosts` | 列出 / 添加 / 修改 / 删除 SSH 主机(`~/.dsh/ops-kit/hosts.json`) |
18
+ | `ops_ssh_test` | 连通性、延迟,以及实际使用的认证方式 |
19
+ | `ops_ssh_install_key` | 用已存的密码把本机公钥装到目标机 |
20
+ | `ops_inventory` | 只读盘点:监听端口、服务、容器、nginx 站点、java 进程、crontab、挂载 |
21
+
22
+ ## 只看不改(只读)
23
+
24
+ | 工具 | 作用 |
25
+ |---|---|
26
+ | `ops_status` | 运行时长与负载、内存、根分区磁盘、失败的 systemd 单元、容器 |
27
+ | `ops_check_all` | 并行检查所有主机,每台一行摘要,并写入历史 |
28
+ | `ops_health` | 0–100 健康分,附最该先修的几条问题 |
29
+ | `ops_metrics` | 某个时间窗内的 CPU / 内存 / 磁盘采样(上限 2 万行) |
30
+ | `ops_ps` | 按 CPU 或内存排序的进程 |
31
+ | `ops_disk` | 某个目录下一层的空间占用 |
32
+ | `ops_logs` | systemd 单元或日志文件的尾部 |
33
+ | `ops_files` | 目录列表,带大小与修改时间 |
34
+ | `ops_ssl` | 某域名的证书主体、签发者、到期时间 |
35
+ | `ops_diagnose` | 用大白话给出诊断和建议的下一步 |
36
+
37
+ ## 会改状态的
38
+
39
+ | 工具 | 作用 |
40
+ |---|---|
41
+ | `ops_run` | 执行一条 shell 命令;破坏性命令 🔒 |
42
+ | `ops_batch` | 在多台主机上并行执行同一条命令 |
43
+ | `ops_service` | `systemctl status/logs/start/stop/restart`(启停与重启 🔒) |
44
+ | `ops_docker` | `docker ps/logs/inspect/restart`(重启 🔒) |
45
+ | `ops_kill` | 对单个 pid 发 TERM / KILL / HUP 🔒 |
46
+ | `ops_cleanup` | 整理 journal、截断已轮转日志 🔒 |
47
+ | `ops_monitors` | http / 端口 / 进程 / 服务 / 脚本 心跳检查 |
48
+
49
+ ## 配置与文件
50
+
51
+ | 工具 | 作用 |
52
+ |---|---|
53
+ | `ops_config` | 调度设置:检查间隔、磁盘阈值、各类超时、常用命令、AI 模型 |
54
+ | `ops_config_file` | 读取一个配置文件 |
55
+ | `ops_save_config` | 写入配置文件,写前自动备份 🔒 |
56
+ | `ops_file_history` | 文件的 `.bak.<ts>` 历史版本、差异、回滚 🔒 |
57
+
58
+ ## 备份、证书、计划任务、发布
59
+
60
+ | 工具 | 作用 |
61
+ |---|---|
62
+ | `ops_backup` | MySQL 导出或目录打包、列出、恢复、删除、保留 N 份 |
63
+ | `ops_cert` | 证书剩余天数、`certbot renew --dry-run`、正式续期 |
64
+ | `ops_cron` | 列出 / 新增 / 删除 crontab 条目 |
65
+ | `ops_deploy` | git pull → 构建 → 重启 → 健康检查,失败自动回滚 |
66
+
67
+ ## 告警与 AI
68
+
69
+ | 工具 | 作用 |
70
+ |---|---|
71
+ | `ops_channels` | 告警推送到飞书 / 钉钉 / 企业微信 / 任意 webhook,可测试发送 |
72
+ | `ops_alerts` | 定时检查产生的近期告警 |
73
+ | `ops_ask` | 自然语言提问,由模型自己执行只读命令 |
74
+ | `ops_ai_command` | 把意图转成一条命令,但不执行 |
75
+ | `ops_ai_models` | 运维 AI 可用的 provider 与模型 |
76
+
77
+ ## 设计取向
78
+
79
+ - **无 SDK,默认不存凭据。** 密钥认证走系统 `ssh` 客户端(`BatchMode`),插件完全
80
+ 不读你的密钥文件。密码认证走插件自带的 `ssh2` 客户端,也是唯一会落盘密钥的场景。
81
+ - **密码或密钥皆可。** 只填 IP + 用户名 + 密码就能添加主机;这条路径要求该 profile
82
+ 里已有 `ssh2`。没有存密码的主机则走系统 `ssh` 和你的密钥 / agent。
83
+ - **清单放在 profile 之外。** 主机信息存在 `$DSH_HOME/ops-kit/hosts.json`
84
+ (默认 `~/.dsh/ops-kit/hosts.json`),升级或卸载插件都不会丢。
85
+ - **读写分离。** 健康检查永远只读;任何改变服务或容器状态的操作都需要 `confirm: true`。
86
+ - **输出有上限。** 结果超过 8 KB 会被截断并显式标注,避免一行失控日志冲爆上下文。
87
+
88
+ ## 安装
89
+
90
+ ```bash
91
+ dsh plugin --profile desktop add dsh-ops-kit
92
+ ```
93
+
94
+ 本地开发安装(目录方式):
95
+
96
+ ```
97
+ Plugins → Add plugin → 选中该目录
98
+ ```
99
+
100
+ ## 面板
101
+
102
+ bundle 提供一个侧栏页面(**Ops**),每台主机十个子页:概览、监控、配置、应用、
103
+ 日志、文件、终端(真 PTY)、备份、计划任务、发布。概览页可跑单机或全部主机的检查,
104
+ 每次运行记录到 `$DSH_HOME/ops-kit/history.json`。面板通过 `/ops-kit/api/*` 与 Host 侧通信。
105
+
106
+ 重启、停止、恢复、回滚在面板里都会先要求确认。
107
+
108
+ ## 首次使用
109
+
110
+ ```text
111
+ ops_hosts action=add name=web-1 host=10.0.0.11 user=deploy key=~/.ssh/id_ed25519 defaultHost=true
112
+ ```
113
+
114
+ 然后直接问就行:
115
+
116
+ ```text
117
+ 看一下 web-1 的状态
118
+ nginx 最近 50 行日志
119
+ 把 web-1 上的 my-api 重启一下(我确认)
120
+ ```
121
+
122
+ ## 刻意未做的部分
123
+
124
+ - **不接云厂商 API**(阿里云 / 腾讯云 / AWS):这套工具只说 SSH。
125
+ - **不做超出 `ops_deploy` 的应用级发布**:不碰 Docker Compose,也不碰 k8s。
126
+ - **不做 Windows 远程**:只有当 Windows 主机自己跑了 SSH 服务且提供类 POSIX shell 时才行。
127
+ - **指标保留是行数上限,不是时序数据库。**
128
+
129
+ ## 0.3.0 —— 备份、健康分、证书、计划任务、配置历史、一键发布
130
+
131
+ - **备份与恢复。** 数据库用 `mysqldump`,目录用 `tar.gz`,默认存在 `/home/backup`,
132
+ 保留 N 份,一键恢复。
133
+ - **健康分。** 每台主机 0–100,附最要紧的两三条问题,显示在服务器详情页。
134
+ - **证书。** 探测每个 nginx `server_name` 的到期日;正式续期前先
135
+ `certbot renew --dry-run`;在 14 / 7 / 3 天时告警。
136
+ - **计划任务。** 服务器 crontab 可在面板里查看和编辑。
137
+ - **配置历史。** 每个 `.bak.<ts>` 版本都能做差异对比并回滚。
138
+ - **一键发布。** git pull → 构建 → 重启 → 健康检查;健康检查失败时自动回滚到上一个提交。
139
+
140
+ ## 告警推送
141
+
142
+ 调度器产生的告警(主机失联、磁盘压力、单元失败、监控失败、证书到期)会推送到已配置的渠道:
143
+
144
+ - `feishu` → `{"msg_type":"text","content":{"text":...}}`
145
+ - `dingtalk` / `wecom` → `{"msgtype":"text","text":{"content":...}}`
146
+ - `webhook` → `{"text":...,"alerts":[...]}`,给其余任意接收方
147
+
148
+ 每个渠道可单独选择接收哪些级别(critical / warning / info)。同一条告警 10 分钟内
149
+ 不会重复发送。渠道配置在 `~/.dsh/ops-kit/channels.json`,权限 0600 —— 因为 webhook
150
+ URL 本身就是密钥。
151
+
152
+ ## 许可证
153
+
154
+ MIT
package/docs/DETAIL.md CHANGED
@@ -1,42 +1 @@
1
- # Ops kit — server operations from chat
2
-
3
- ## What it is
4
-
5
- A host-only DeepSeek Harness bundle. It contributes five tools and no UI. Every
6
- remote action goes through the system `ssh` client in `BatchMode`, so the plugin
7
- never sees a password or a key file.
8
-
9
- ## Tools
10
-
11
- - `ops_hosts` — the inventory. `action=list|add|remove`, stored in
12
- `$DSH_HOME/ops-kit/hosts.json` (default `~/.dsh/ops-kit/hosts.json`).
13
- - `ops_status` — one call returns uptime/load, memory, root disk, failed systemd
14
- units and running containers. Read-only by construction: it runs a fixed
15
- command string.
16
- - `ops_run` — one free-form command. A short denylist (filesystem formatting,
17
- `rm -rf /`, `dd` to a block device, shutdown/reboot) requires `confirm=true`.
18
- - `ops_service` — `systemctl` status/logs/start/stop/restart for one unit.
19
- - `ops_docker` — `docker ps/logs/inspect/restart`.
20
-
21
- `start`, `stop`, `restart` and `docker restart` all require `confirm=true`; the
22
- tool fails closed when it is missing rather than asking in a second turn.
23
-
24
- ## Requirements
25
-
26
- - macOS or Linux host running DSH.
27
- - `ssh` on `PATH`, and key/agent authentication already working for each host.
28
- - Remote Linux with `systemctl` for the service tools; Docker is optional and
29
- detected per call.
30
-
31
- ## Data and safety
32
-
33
- Hosts are stored as plain JSON with no secrets: name, host, user, port, key
34
- path, and a `sudo` flag. The plugin does not store passwords and has no network
35
- client of its own. Sudo actions run as `sudo -n`, so they fail instead of
36
- hanging on a password prompt.
37
-
38
- ## Limitations
39
-
40
- - Point-in-time only: no metric retention, no alerting.
41
- - No PTY, no file transfer (use an SSH workspace plugin for that).
42
- - Windows targets need an SSH server with a POSIX 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,192 @@
1
+ # dsh-ops-kit 使用说明
2
+
3
+ 面向「第一次装上、想把一台服务器管起来」的人。
4
+ 工具参数不在这里罗列 —— 那是模型读的 schema,会随版本变;这里只写**前置条件、典型流程、设置项和排障**。
5
+
6
+ ---
7
+
8
+ ## 1. 前置条件(先看这条,能省掉一半排障)
9
+
10
+ 插件连服务器有两条路径,先确定你走哪条:
11
+
12
+ | 路径 | 需要什么 | 适合 |
13
+ |---|---|---|
14
+ | **密钥 / ssh-agent**(默认) | 本机系统 `ssh` 能免密登录目标机(`ssh 用户@IP` 直接进去) | 大多数情况,推荐 |
15
+ | **密码** | 该 profile 里已装有 `ssh2` 包 | 临时机器、还没配密钥 |
16
+
17
+ 先在**自己终端**里验一下,这一步过了插件才可能通:
18
+
19
+ ```bash
20
+ ssh -o BatchMode=yes 用户@IP 'echo ok' # 输出 ok 才算通
21
+ ```
22
+
23
+ `BatchMode=yes` 很关键 —— 插件就是用这个模式跑的,凡是会弹交互提示(比如首次连接确认主机指纹、或要求输密码)的情况,插件会**直接失败**。
24
+
25
+ ### 还要满足
26
+
27
+ - **目标机有 POSIX shell**:Windows 机器只有当它自己跑了 SSH 服务且带类 POSIX shell 时才行。
28
+ - **需要 root 的操作要免密 sudo**:在主机配置里打开 `sudo: true`,且目标机允许 `sudo -n`(NOPASSWD)。否则「重启服务」这类动作会以权限错误失败,读操作不受影响。
29
+
30
+ ---
31
+
32
+ ## 2. 五分钟跑通
33
+
34
+ ### 第一步:加主机
35
+
36
+ ```text
37
+ ops_hosts action=add name=web-1 host=10.0.0.11 user=deploy key=~/.ssh/id_ed25519 defaultHost=true
38
+ ```
39
+
40
+ 只填 IP + 用户 + 密码也能加(会存进 `secrets.json`),但建议走密钥。
41
+
42
+ ### 第二步:验连通
43
+
44
+ ```text
45
+ ops_ssh_test host=web-1
46
+ ```
47
+
48
+ 返回 `ok`、延迟、以及实际用的认证方式。**这一步不通就别往下走**,先回到第 1 节。
49
+
50
+ > 如果加了密码、但连不上并提示 `ssh2 is not installed in this profile`,说明这个 profile 缺 `ssh2`。要么装上它,要么改用密钥(此时可先跑 `ops_ssh_install_key host=web-1`,用已存的密码把本机公钥装上去,之后就不需要密码了)。
51
+
52
+ ### 第三步:看一眼
53
+
54
+ ```text
55
+ ops_status host=web-1
56
+ ```
57
+
58
+ 一次给出:运行时长与负载、内存、根分区磁盘、失败的 systemd 单元、Docker 容器。
59
+
60
+ 想一次看全部主机:
61
+
62
+ ```text
63
+ ops_check_all
64
+ ```
65
+
66
+ ### 第四步:打开面板
67
+
68
+ 侧边栏 **Ops** 页。这里能增删主机、跑单机检查、批量下命令;后面第 3 节细说。
69
+
70
+ ---
71
+
72
+ ## 3. 面板十个子页
73
+
74
+ 从「多机概览」点进某台机器,左侧是十个子页:
75
+
76
+ | 子页 | 干什么 |
77
+ |---|---|
78
+ | **概览** | 健康分、关键指标、证书到期、备份状态 |
79
+ | **监控** | 该机的监控项(http / 端口 / 进程 / 服务 / 脚本),可增删测 |
80
+ | **配置** | 浏览常见配置文件,改之前自动备份 `.bak.<时间戳>`,可看历史并回滚 |
81
+ | **应用** | 正在跑的服务与容器,带 日志 / 重启 / 停止 |
82
+ | **日志** | systemd 单元或任意日志文件的尾部 |
83
+ | **文件** | 目录列表、大小、修改时间 |
84
+ | **终端** | 网页里的 SSH 终端(需要 `ssh2`) |
85
+ | **备份** | 备份列表、一键恢复、删除 |
86
+ | **计划任务** | crontab 可视化增删 |
87
+ | **发布** | 一键发布任务:git pull → 构建 → 重启 → 健康检查 |
88
+
89
+ **重启 / 停止 / 回滚 / 恢复都会先弹确认**,不会点了就执行。
90
+
91
+ ---
92
+
93
+ ## 4. 常用任务怎么说
94
+
95
+ 不需要记工具名,直接说人话:
96
+
97
+ ```text
98
+ 看一下 web-1 的状态
99
+ web-1 上 nginx 最近 50 行日志
100
+ 磁盘满了,看看 / 下面谁占的空间
101
+ 把 web-1 上的 my-api 重启一下(我确认)
102
+ 所有机器上跑一下 uptime
103
+ web-1 的证书还有几天
104
+ ```
105
+
106
+ ### 提问式诊断
107
+
108
+ ```text
109
+ ops_ask host=web-1 question="mysql 还活着吗,为什么连不上"
110
+ ```
111
+
112
+ 模型会自己挑**只读**命令去查并给结论;遇到要改状态的命令,它只返回「需要确认」,不会擅自执行。
113
+
114
+ ### 批量
115
+
116
+ ```text
117
+ ops_batch command="df -h" hosts=[web-1,web-2]
118
+ ```
119
+
120
+ 不给 `hosts` 就是全部主机。破坏性命令必须带 `confirm`。
121
+
122
+ ### 备份
123
+
124
+ ```text
125
+ ops_backup host=web-1 action=backup type=mysql database=app
126
+ ops_backup host=web-1 action=list
127
+ ```
128
+
129
+ 默认存在 `/home/backup`,默认保留 7 份,恢复和删除都要确认。
130
+
131
+ ---
132
+
133
+ ## 5. 设置项(`ops_config`)
134
+
135
+ 留空调用就是读当前值。默认值如下:
136
+
137
+ | 键 | 默认 | 范围 | 说明 |
138
+ |---|---|---|---|
139
+ | `enabled` | `true` | — | 是否开启后台定时检查 |
140
+ | `intervalMinutes` | `10` | 1–1440 | 后台检查间隔(分钟) |
141
+ | `diskWarnPercent` | `90` | 50–99 | 根分区超过此比例告警 |
142
+ | `metricsMinutes` | `5` | 1–60 | 指标采样间隔(分钟) |
143
+ | `timeoutSec` | `25` | 5–300 | 通用请求超时 |
144
+ | `scanSec` | `90` | 10–600 | 清单扫描超时(主机多或慢时调大) |
145
+ | `actionSec` | `45` | 10–600 | 动作与取日志超时 |
146
+ | `quickCommands` | 6 条常用命令 | 最多 12 条 | 终端下方的快捷键 |
147
+ | `aiEnabled` | `true` | — | 是否启用 `ops_ask` 的 AI 诊断 |
148
+ | `aiProvider` / `aiModel` | 空 = 用 DSH 默认模型 | — | 指定运维 AI 用哪个模型 |
149
+
150
+ ---
151
+
152
+ ## 6. 数据存在哪、有多敏感
153
+
154
+ 全部在 `$DSH_HOME/ops-kit/`(默认 `~/.dsh/ops-kit/`),**刻意放在 profile 之外**,所以升级或卸载插件都不会丢。
155
+
156
+ | 文件 | 内容 | 敏感度 |
157
+ |---|---|---|
158
+ | `hosts.json` | 主机清单 | 低 |
159
+ | `secrets.json` | 密码,**base64 编码而非加密**,权限 0600 | **高,等同密钥** |
160
+ | `channels.json` | 告警渠道 URL,权限 0600 | **高,URL 本身就是密钥** |
161
+ | `history.json` | 每次检查的历史 | 低 |
162
+ | `config.json` | 上面那张设置表 | 低 |
163
+ | `state.json` / `alerts.json` | 调度状态与告警记录 | 低 |
164
+
165
+ 请注意 `secrets.json` 里**不是加密的**:任何能读这个文件的人都能拿到服务器密码。要么改用密钥认证,要么确保这台机器的账户权限是干净的。
166
+
167
+ ---
168
+
169
+ ## 7. 排障
170
+
171
+ | 现象 | 原因与处理 |
172
+ |---|---|
173
+ | `ops_ssh_test` 不通,但手敲 `ssh` 能进 | 插件用 `BatchMode`,不处理交互。把主机指纹先加进 `known_hosts`,或改用密钥 |
174
+ | 提示 `ssh2 is not installed in this profile` | 用的是密码路径但 profile 里没 `ssh2`。装 `ssh2`,或改用密钥(`ops_ssh_install_key`) |
175
+ | 重启服务报权限错误 | 主机没开 `sudo: true`,或目标机不允 `sudo -n` |
176
+ | 结果末尾有截断标记 | 输出超 8 KB 被裁掉了。缩小范围(`lines=`、更精确的命令)而不是调大上限 |
177
+ | 定时检查没动静 | `ops_config` 里 `enabled` 是否为 true;`scanSec` 是否太小导致大面积超时 |
178
+ | 告警没到 | 渠道 URL 是否过期(群机器人会重置);级别是否匹配;相同告警 10 分钟内不重发 |
179
+ | 面板打不开有数据但空 | 检查该会话是否加载了本插件,以及 `/ops-kit/api` 是否被反代拦截 |
180
+
181
+ ---
182
+
183
+ ## 8. 会改变状态的操作用了会怎样
184
+
185
+ | 操作 | 需要 |
186
+ |---|---|
187
+ | 启停 / 重启服务、重启容器 | `confirm: true` |
188
+ | `ops_run` 执行破坏性命令(`rm -rf /`、`mkfs`、`dd` 写设备、`shutdown`/`reboot`) | `confirm: true`,否则直接拒绝 |
189
+ | 备份恢复与删除、配置回滚、一键发布 | `confirm: true` |
190
+ | 健康检查、`ops_status`、`ops_check_all`、`ops_ssh_test`、`ops_ask` | 只读,不需要确认 |
191
+
192
+ 设计原则是**读操作永远可以随便跑,写操作必须有人点头**。
@@ -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/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Ops kit",
4
- "description": "Server operations from chat: SSH host inventory, health checks, systemd services and Docker, with confirm guards on state-changing actions.",
4
+ "description": "Run Linux servers from the chat: 34 tools and a sidebar panel covering SSH inventory, health checks, logs and processes, backups and restore, certificates, cron, one-click deploy and Feishu/DingTalk/WeCom alerts — every state-changing action asks for confirmation.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "运维工具包",
4
- "description": "在对话里做服务器运维:SSH 主机清单、健康检查、systemd 服务与 Docker;改状态的操作需要显式确认。",
5
- "detail": "docs/DETAIL.md"
4
+ "description": "在对话里管服务器:34 个工具加侧栏面板,覆盖 SSH 清单、健康检查、日志与进程、备份恢复、证书、计划任务、一键发布和飞书/钉钉/企业微信告警;改状态的操作一律要求确认。",
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.0",
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",
@@ -17,9 +17,14 @@
17
17
  "client.js",
18
18
  "cordis.patch.yml",
19
19
  "locale/*.json",
20
- "docs",
20
+ "docs/DETAIL.md",
21
+ "docs/DETAIL.zh.md",
22
+ "docs/preview.svg",
23
+ "docs/USAGE.md",
24
+ "docs/USAGE.zh-CN.md",
21
25
  "icon.svg",
22
26
  "README.md",
27
+ "README.zh-CN.md",
23
28
  "LICENSE"
24
29
  ],
25
30
  "keywords": [
@@ -59,5 +64,13 @@
59
64
  "bugs": {
60
65
  "url": "https://github.com/shenlongze/dsh-ops-kit/issues"
61
66
  },
62
- "author": "shenlongze"
67
+ "author": "shenlongze",
68
+ "peerDependencies": {
69
+ "ssh2": "^1.16.0"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "ssh2": {
73
+ "optional": true
74
+ }
75
+ }
63
76
  }
package/docs/ROADMAP.md DELETED
@@ -1,134 +0,0 @@
1
- # dsh-ops-kit 功能规划(除告警外)
2
-
3
- > 目标用户:不懂 Linux 的站长 / 小团队负责人。
4
- > 交互原则:**只看看、点点、说人话**,不出现命令行和原始输出。
5
- > 本文对比 1Panel、宝塔、Uptime Kuma 的成熟做法,标出我们缺什么、先做什么。
6
-
7
- ## 一、现状盘点(v0.2.x 已具备)
8
-
9
- | 域 | 已有能力 |
10
- |---|---|
11
- | 连接 | 多主机、密钥/密码、连接测试、终端(真 PTY)、命令控制台、keepalive |
12
- | 监控 | CPU/内存/磁盘/负载/Swap/网络/IO/进程数/TCP/运行时长、历史曲线、每台机器趋势 |
13
- | 巡检 | 端口、服务、Docker、Nginx 站点、Java 进程、Cron、挂载、SSL 到期 |
14
- | 服务监控 | http / port / process / service / script 五类、间隔可配、失败写告警 |
15
- | 运维动作 | 服务启停、容器操作、磁盘清理、进程查看/结束、日志尾随、SSL 检测 |
16
- | 文件 | 浏览、下载/上传(8MB)、配置读取/写入(自动备份 .bak) |
17
- | AI | 智能诊断、对话式问答(只读自动执行)、命令生成、`?` 前缀模式、模型可选 |
18
- | 设置 | 主机管理、常用命令、AI 模型、巡检频率 |
19
-
20
- **结论**:看得见的部分基本齐了;**看不见的(备份、审计、证书、发布、计划任务)和"出事后怎么救"是空的。**
21
-
22
- ## 二、竞品对照(调研结论)
23
-
24
- | 能力 | 1Panel | 宝塔 | Uptime Kuma | dsh-ops-kit |
25
- |---|---|---|---|---|
26
- | 主机监控 | ✅ | ✅ | — | ✅ |
27
- | 网站/域名管理 | ✅ | ✅ | — | ⚠️ 只读清单 |
28
- | 数据库管理/备份 | ✅ 一键备份恢复 + 云存储 | ✅ | — | ❌ |
29
- | 文件管理 | ✅ | ✅ | — | ✅(无解压/编辑大文件) |
30
- | 计划任务 | ✅ | ✅ | — | ❌(只看得到 cron) |
31
- | 应用商店 / 一键部署 | ✅ | ✅ | — | ❌ |
32
- | 安全模块(WAF、入侵检测) | ⚠️ X Pack | ✅ 免费 | — | ❌ |
33
- | 证书自动续期 | ✅ | ✅ | — | ⚠️ 只告警 |
34
- | 告警外发 | ✅ | ✅ | ✅ | ❌(下一步) |
35
- | AI 助手 | ⚠️ 新加 | ✅ 11.7 新增全局 AI | — | ✅ 原生 |
36
- | 多机管理 | ⚠️ X Pack | ⚠️ | ✅ 多探针 | ✅ |
37
-
38
- 来源:
39
- - 1Panel 100 版本说明(应用商店、网站分组、数据库备份加密、计划任务、多机 X-Pack)https://blog.fit2cloud.com/?p=e85626a9-4293-4224-a81e-07232e411cd3
40
- - 1Panel 功能概览(主机监控、文件、数据库、容器、大模型管理、一键备份恢复)https://pkg.go.dev/github.com/1Panel-dev/1Panel@v1.10.27-lts
41
- - 宝塔 11.7.0 更新(面板多处 AI 助手、安全模块、网站统计)https://docs.bt.cn/update-log/linux-panel-11-7-0
42
- - Uptime Kuma 的 MCP 封装(监视器增删改、心跳记录)https://www.mcpworld.com/zh/detail/0490511ba1c563c5db30b5993ec4d11d
43
-
44
- **差异化机会**:1Panel/宝塔都要在服务器上装一个面板(占资源、暴露端口、要维护),我们**不装 agent,纯 SSH**;且 AI 是原生的,不是外挂。所以产品定位应是"**不装东西的远程运维助手**",而不是再做一个面板。
45
-
46
- ## 三、差距清单(按小白价值排序)
47
-
48
- > 更新:P0-1 ~ P0-3、P1-4 ~ P1-6 已于 0.3.0 实现(见 CHANGELOG)。
49
-
50
- ### P0|出事能救回来(没有这个不敢用)
51
-
52
- 1. **备份与恢复**
53
- - MySQL / MariaDB 逻辑备份(`mysqldump --single-transaction`),可选单库或全部
54
- - 网站目录 / 指定目录打包备份(排除日志、缓存)
55
- - 保留策略:最近 N 份 / N 天,自动清理
56
- - 一键恢复(恢复到临时库校验后再切,或覆盖前自动再备份一份)
57
- - 面板:列表、立即备份、下载、恢复、删除;失败原因用中文说明
58
- - 验收:给公司服务器配"每天 03:00 备份 mysqld + /www/wwwroot",保留 7 份,列表能看到大小与耗时
59
-
60
- 2. **一键体检 + 健康评分**
61
- - 首页每台机器一个分数(0–100)+ 一句话结论 + 待办清单(最多 3 条)
62
- - 检查项:磁盘水位、内存/交换、失败服务、证书剩余天数、端口暴露、root 登录、防火墙、备份是否成功、上次备份时间
63
- - 每条待办可点「让 AI 解释」「一键修复」(白名单动作)
64
- - 验收:首页能回答"这台机器现在有什么问题、先做哪件事"
65
-
66
- 3. **证书到期与续期**
67
- - 扫描 80/443 站点证书,显示剩余天数(已有基础)
68
- - 支持 certbot 续期(`certbot renew --dry-run` 先预演,再实际续期)
69
- - 到期前 14/7/3 天写告警
70
-
71
- ### P1|日常省事
72
-
73
- 4. **计划任务(可视化 cron)**
74
- - 读服务器 crontab(已有),支持新增/停用/删除,语法用表单生成(每天/每周/每月 + 时间 + 命令)
75
- - 面板内本地任务:备份、清理、体检、自定义工作流
76
- - 执行历史:最近 20 次,成功/失败/输出摘要
77
-
78
- 5. **配置变更历史 / 回滚**
79
- - 现在写入会留 `.bak.<ts>`,但没有界面
80
- - 面板:文件变更记录、diff 预览、一键回滚到上一版
81
-
82
- 6. **部署发布(把代码更新上去)**
83
- - 表单:目录、拉取方式(git pull / 上传 zip)、构建命令、重启服务、健康检查 URL
84
- - 一键发布 + 失败自动回滚到上一个版本
85
- - 与既有 `dsh-server-deploy` 打通,复用它的配置
86
-
87
- 7. **日志中心**
88
- - 多来源聚合(nginx access/error、应用日志、journal)
89
- - 关键字过滤 + 时间范围 + 错误聚类(相同堆栈合并计数)
90
- - "最近 1 小时有哪些报错"一键回答
91
-
92
- ### P2|安全与主动通知
93
-
94
- 8. **告警外发**(已定最后做)
95
- - 飞书 / 钉钉 / 企业微信机器人 + SMTP 邮件
96
- - 测试按钮、静默时段、同类合并(10 分钟内同错误只发一次)
97
-
98
- 9. **日报 / 周报**
99
- - 每天早上推送:磁盘趋势、备份结果、失败服务、证书到期
100
- - 一周容量预测:"按目前速度,磁盘还能用 18 天"
101
-
102
- 10. **登录与暴露面审计**
103
- - 最近登录记录(成功/失败)、fail2ban 状态、SSH 密码登录是否开启
104
- - 公网暴露端口清单 + 风险提示(如 3306/6379 对外)
105
-
106
- ### P3|扩展
107
-
108
- 11. **Docker 应用模板**(MySQL/Redis/PostgreSQL/WordPress/Node 一键起)
109
- 12. **MCP / CLI 导出**:把 `ops_*` 包成 MCP server 和命令行,让 Codex/Claude Code/OpenClaw 也能用(复用同一份配置)
110
- 13. **团队版**:多用户、角色权限、操作审计、凭据加密保管(这是收费点)
111
-
112
- ## 四、不建议做(或明确不做)
113
-
114
- - **WAF / 入侵检测 / 病毒扫描**:和云厂商安全组、宝塔冲突,维护成本极高
115
- - **自建面板 agent**:违背"不装东西"的定位
116
- - **DNS / 域名注册管理**:直接跳转到云厂商控制台即可
117
- - **K8s / 大规模集群编排**:目标用户不碰
118
- - **计费/账单**:需要云厂商 API key,敏感且各家不同
119
-
120
- ## 五、建议的落地顺序
121
-
122
- ```
123
- 现在 ──► 备份与恢复(P0-1)──► 一键体检 + 评分(P0-2)──► 证书续期(P0-3)
124
- ──► 计划任务(P1-4)──► 配置回滚(P1-5)──► 发布(P1-6)
125
- ──► 告警外发(P2-8)──► 日报(P2-9)──► 审计(P2-10)
126
- ──► 应用模板 / MCP 导出 / 团队版
127
- ```
128
-
129
- 每项都遵循同一套验收标准:
130
-
131
- 1. 不需要命令行;所有失败有一句中文原因
132
- 2. 危险动作二次确认 + 可回滚
133
- 3. AI 能解释这项功能在做什么
134
- 4. 面板上 30 秒内能找到入口