srvgov-cli 0.1.1 → 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.
Files changed (2) hide show
  1. package/README.md +73 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -23,9 +23,14 @@ checksums by default.
23
23
  ```bash
24
24
  srvgov ctx set dev --server ssh://alice@example.com:22 --identity-file ~/.ssh/id_ed25519 -o json
25
25
  srvgov ctx use dev -o json
26
+ srvgov status -o json
27
+ srvgov ports -o json
28
+ srvgov logs --unit sshd --since "1 hour ago" --lines 50 -o json
29
+ srvgov svc status sshd -o json
30
+ srvgov file stat /etc/hosts -o json
26
31
  srvgov exec --dry-run "uptime" -o json
27
32
  srvgov exec "uptime" -o json
28
- srvgov audit --limit 20 -o json
33
+ srvgov audit query --limit 20 -o json
29
34
  ```
30
35
 
31
36
  Use `-o json` for automation and AI agents.
@@ -72,6 +77,73 @@ Portable context export uses `srvgov.io/ctx-export/v1`. Literal password and
72
77
  SSH identity passphrase values are redacted by default; credstore references are
73
78
  preserved. `--include-credentials` is limited to plain-yaml contexts.
74
79
 
80
+ ## Observe Before Acting
81
+
82
+ The observation commands turn common read-only SSH output into stable JSON:
83
+
84
+ ```bash
85
+ srvgov status -o json
86
+ srvgov ports -o json
87
+ srvgov logs --unit nginx --since "30 minutes ago" --priority warning --lines 100 -o json
88
+ srvgov logs --file /var/log/nginx/error.log --grep "upstream" --lines 100 -o json
89
+ ```
90
+
91
+ Each underlying remote command is independently classified and authorized
92
+ through the same governance path as `exec`; probes are never joined with shell
93
+ operators. `ports` falls back from `ss` to `netstat`. Unit logs fall back from
94
+ `journalctl` to `systemctl status` when journalctl is unavailable. No command
95
+ adds `sudo`; unavailable PID/process fields remain empty. Log text, process
96
+ names, generated command text, caller output, and audit records are redacted.
97
+
98
+ ## Service Control
99
+
100
+ `svc` exposes only a fixed service-operation whitelist. Unit names are treated
101
+ as literal shell words, and every generated `systemctl` command goes through
102
+ the same classifier and authorization path as `exec`.
103
+
104
+ ```bash
105
+ # R0 read, still audited
106
+ srvgov svc status nginx -o json
107
+
108
+ # R2 change: human-supplied reason, ticket, and confirmation
109
+ srvgov svc restart nginx \
110
+ --reason "apply reviewed configuration" --ticket OPS-123 --yes -o json
111
+ ```
112
+
113
+ Available actions are `status`, `start`, `stop`, `restart`, `reload`, `enable`,
114
+ and `disable`, for one unit at a time. Protected contexts raise service changes
115
+ from R2 to R3 and additionally require human-supplied `--allow-destructive`.
116
+ `svc` does not expose power, isolate, mask, or arbitrary systemctl operations.
117
+
118
+ ## File Operations
119
+
120
+ File reads are structured R0 operations and remain audited:
121
+
122
+ ```bash
123
+ srvgov file read /etc/hosts --max-bytes 1048576 -o json
124
+ srvgov file stat /etc/hosts -o json
125
+ srvgov file list /var/log -o json
126
+ ```
127
+
128
+ Writes use `tee -- '<path>'` with content streamed over SSH stdin. They are R2
129
+ for ordinary paths and R3 for sensitive paths such as SSH authorization files,
130
+ shell dotfiles, and crontabs.
131
+
132
+ ```bash
133
+ printf '%s\n' 'enabled=true' | srvgov file write /tmp/app.conf \
134
+ --reason "update reviewed configuration" --ticket OPS-123 --yes -o json
135
+
136
+ srvgov file write /tmp/app.conf --content "enabled=true" \
137
+ --reason "update reviewed configuration" --ticket OPS-123 --yes -o json
138
+ ```
139
+
140
+ Without `--content`, stdin is the file content and explicit `--yes` is required
141
+ before authorization. With `--content`, stdin is never read and interactive
142
+ confirmation remains available. Write output and audit records never contain
143
+ file content; audit stores only the redacted path, byte count, and SHA-256.
144
+ Writes are direct and non-atomic; temporary-file plus rename is not implemented
145
+ in this release. `file` never uses SFTP and never adds `sudo`.
146
+
75
147
  ## Governed Execution
76
148
 
77
149
  Preview without connecting or executing:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "srvgov-cli",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Governed remote server command execution CLI for AI agents",
5
5
  "bin": {
6
6
  "srvgov": "bin/srvgov-cli.js",