dsh-ops-kit 0.0.0-stage → 0.3.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.
@@ -0,0 +1,4 @@
1
+ # Contribution layer for dsh-ops-kit.
2
+ - insert:
3
+ - id: dsh-ops-kit
4
+ name: dsh-ops-kit
package/docs/DETAIL.md ADDED
@@ -0,0 +1,42 @@
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.
@@ -0,0 +1,134 @@
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 秒内能找到入口
package/icon.svg ADDED
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Ops kit">
2
+ <rect width="64" height="64" rx="14" fill="#0f2f2a"/>
3
+ <g fill="none" stroke="#5ee0b5" stroke-width="3" stroke-linecap="round">
4
+ <rect x="14" y="12" width="36" height="12" rx="3"/>
5
+ <rect x="14" y="26" width="36" height="12" rx="3"/>
6
+ <path d="M20 18h1M20 32h1"/>
7
+ </g>
8
+ <path d="M22 50l6 6 14-14" fill="none" stroke="#5ee0b5" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
9
+ </svg>