@tutti-os/nexight-devops 0.5.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/README.md ADDED
@@ -0,0 +1,237 @@
1
+ # @tutti-os/nexight-devops
2
+
3
+ `nexight-devops` is a TypeScript CLI for Nexight DevOps workflows.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @tutti-os/nexight-devops
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ ```bash
14
+ nexight-devops --help
15
+ nexight-devops --version
16
+ nexight-devops doctor
17
+ nexight-devops onboard
18
+ nexight-devops onboard --set-mode aws
19
+ nexight-devops onboard --set-mode gh
20
+ nexight-devops onboard --set-mode locale
21
+ nexight-devops onboard --set-mode admin
22
+ nexight-devops onboard --set-mode datafinder
23
+ nexight-devops update-version
24
+ nexight-devops admin auth login
25
+ nexight-devops admin auth whoami
26
+ nexight-devops admin system health
27
+ nexight-devops admin app list --brand nextop --query design
28
+ nexight-devops admin app detail --brand nextop --app-id vibe-design --include latest,versions
29
+ nexight-devops admin computer list --connection online --query <name>
30
+ nexight-devops admin computer list --connection online --owner-query <username-or-email>
31
+ nexight-devops admin computer detail --computer-id <computer-id>
32
+ nexight-devops admin computer logs <computer-name-or-id> --range 1h
33
+ nexight-devops admin computer logs --owner-query <username-or-email> --range 1h
34
+ nexight-devops admin computer logs <computer-name-or-id> --from <timestamp> --to <timestamp>
35
+ nexight-devops admin computer log-recall list --computer-id <computer-id>
36
+ nexight-devops admin computer log-recall download --computer-id <computer-id> --task-id <task-id>
37
+ nexight-devops datafinder auth check
38
+ nexight-devops datafinder dashboard export --count 100
39
+ nexight-devops datafinder query shared-agent-summary --count 100
40
+ nexight-devops datafinder query p2p-health --count 100
41
+ nexight-devops datafinder query exec ./query.mjs -- arg1 arg2
42
+ nexight-devops diagnose shared-agent --room-id <room-id> --at '2026-08-12T12:00:00+08:00'
43
+ nexight-devops diagnose shared-agent --room-id <room-id> --at '2026-08-12T12:00:00+08:00' --json
44
+ nexight-devops ppe-lane deploy
45
+ nexight-devops ppe-lane destroy
46
+ nexight-devops ppe-lane status
47
+ nexight-devops ppe-lane status --all
48
+ nexight-devops release prepare
49
+ nexight-devops release hotfix
50
+ nexight-devops release approve
51
+ nexight-devops release rollback tutti-server
52
+ ```
53
+
54
+ ### Function overview
55
+
56
+ - `doctor` checks that the CLI can start.
57
+ - `onboard` installs or configures Homebrew, GitHub CLI authentication, AWS SSO, management backend login, DataFinder OpenAPI, and the CLI locale. Use `--set-mode <mode>` to configure only one integration.
58
+ - `update-version` checks npm for a newer CLI version and upgrades it with the detected package manager.
59
+ - `admin auth` logs into, logs out of, and inspects the management backend token.
60
+ - `admin system health` checks management backend health.
61
+ - `admin app list/detail` queries App Center applications and optionally their versions.
62
+ - `admin computer list/detail` finds Tutti Computers and reports their current connection state.
63
+ - `admin computer logs` resolves an online Computer and bundles recall, polling, and temporary download into one Agent-friendly workflow.
64
+ - `admin computer log-recall` exposes the lower-level task operations for troubleshooting and recovery.
65
+ - `datafinder` validates access, reads dashboards/reports, runs trusted local JavaScript queries, and exposes fixed reliability queries.
66
+ - `diagnose shared-agent` runs a bounded, read-only CloudWatch playbook that correlates room descriptor results, Owner lease observations, client version, and HTTP failures. It verifies the production AWS account before querying and supports stable `--json` output.
67
+ - `ppe-lane deploy` deploys selected backend repositories and the optional `zk-web/canvas` staging artifact to a PPE lane.
68
+ - `ppe-lane destroy` checks existing lane instances and triggers destroy workflows after a lane-name confirmation.
69
+ - `ppe-lane status` queries AWS Cloud Map for one lane, or all lanes with `--all`.
70
+ - `release prepare`, `release hotfix`, and `release approve` run the controlled release lifecycle through GitHub Actions and approval issues.
71
+ - `release rollback tutti-server` lists the current production image and recent successful Helm deployments (up to ten entries), then restores a selected image through GitHub Actions and waits for health checks. Use `--revision <number> --yes` for scripted selection and confirmation.
72
+
73
+ ## Controlled Release
74
+
75
+ ```bash
76
+ nexight-devops release prepare
77
+ nexight-devops release hotfix
78
+ nexight-devops release approve
79
+ ```
80
+
81
+ - `release prepare` starts a controlled release for a target repo and creates the approval issue.
82
+ - `release hotfix` starts a controlled hotfix flow and supports an explicit override when release-branch patches have not yet been absorbed by `main`.
83
+ - `release approve` posts the approval command to the pending release issue and advances the release.
84
+
85
+ ## Management Backend
86
+
87
+ `admin auth login` stores the verified token in the CLI config with `0600` permissions. The API origin defaults to `https://tutti.sh`; an `admin.tutti.sh` page URL is normalized automatically. For CI or temporary access, use `NEXIGHT_ADMIN_TOKEN` or `TUTTI_ADMIN_TOKEN`, and optionally `NEXIGHT_ADMIN_URL` or `TUTTI_ADMIN_URL`.
88
+
89
+ Read-only query commands accept `--json` for undecorated JSON output.
90
+
91
+ ### Tutti Computer runtime logs
92
+
93
+ The recommended command takes an exact Computer name or ID, or an owner username/email query, and an optional suspicious interval. An owner query must resolve to exactly one online Computer before recall starts. The command resolves the unique online Computer, selects the smallest backend range that covers the interval, creates the recall, waits for the device, downloads the result to a unique `/tmp` directory, and returns the artifact path:
94
+
95
+ ```bash
96
+ nexight-devops admin computer logs "liyingdeMacBook-Pro.local" \
97
+ --from "2026-09-01T10:30:00+08:00" \
98
+ --to "2026-09-01T11:00:00+08:00" \
99
+ --json
100
+ ```
101
+
102
+ For a user-owned Computer, use the server-supported owner directory query:
103
+
104
+ ```bash
105
+ nexight-devops admin computer logs \
106
+ --owner-query "rv4no" \
107
+ --from "2026-09-01T10:30:00+08:00" \
108
+ --to "2026-09-01T11:00:00+08:00" \
109
+ --json
110
+ ```
111
+
112
+ `--from` and `--to` require an explicit timezone offset or `Z`; `--to` defaults to now. The backend supports fixed trailing ranges (`1h`, `3h`, `1d`, `3d`, and `14d`), so the downloaded archive can include additional logs between the suspicious interval and the current time. When no interval is available, use `--range`, which defaults to `1h`:
113
+
114
+ ```bash
115
+ nexight-devops admin computer logs <computer-name-or-id> --range 3h
116
+ ```
117
+
118
+ The command writes elapsed-time progress lines to stderr while resolving the Computer, creating the task, waiting for device state changes, and downloading. `--json` keeps the final structured result on stdout, so Agents can observe progress without corrupting machine-readable output. The result never exposes the pre-signed storage URL or internal object key.
119
+
120
+ Use the lower-level task commands only when a recall needs to be created asynchronously, inspected, resumed, or downloaded to a specific path:
121
+
122
+ ```bash
123
+ nexight-devops admin computer log-recall create --computer-id <computer-id> --range 1h
124
+ nexight-devops admin computer log-recall list --computer-id <computer-id>
125
+ nexight-devops admin computer log-recall get --computer-id <computer-id> --task-id <task-id>
126
+ nexight-devops admin computer log-recall download --computer-id <computer-id> --task-id <task-id>
127
+ ```
128
+
129
+ ## Shared Agent diagnosis
130
+
131
+ ```bash
132
+ nexight-devops diagnose shared-agent \
133
+ --room-id <room-id> \
134
+ --at '2026-08-12T12:00:00+08:00' \
135
+ --shared-agent-id <shared-agent-id>
136
+ ```
137
+
138
+ The default query window is 30 minutes centered on `--at`, capped at the current time. Use `--window-minutes` to change it; the command rejects windows over 24 hours. When an issued descriptor exposes the Owner device, the playbook derives the same pseudonymous reference as `tsh-server` and joins sampled Owner lease evidence without requiring an Owner diagnostics bundle. `--owner-device-id` or `--authority-id` can provide the join key when it is already known.
139
+
140
+ The command is read-only. It returns partial results and explicit missing-evidence reasons when a secondary query fails or the Owner identity cannot be derived. Raw log lines are not included in the result.
141
+
142
+ ## Development
143
+
144
+ - Node.js 20+
145
+ - `pnpm install`
146
+ - `pnpm lint`
147
+ - `pnpm typecheck`
148
+ - `pnpm dev -- --help`
149
+ - `pnpm test`
150
+ - `pnpm build`
151
+
152
+ ## CLI publishing
153
+
154
+ The [Publish CLI](.github/workflows/publish-cli.yml) workflow checks pull requests and publishes `@tutti-os/nexight-devops` to npm after a successful push to `main` (including a merged pull request). It runs lint, type checking, tests, build, and CLI smoke checks before publishing. The publish job is serialized so two merges cannot choose the same npm version.
155
+
156
+ For the first publish, an npm user with write access to the `@tutti-os` scope must add a GitHub Actions repository secret named `NPM_TOKEN`. The token must allow direct publishing to that scope and unattended publishing when npm requires 2FA. The package is currently configured as public. Once the first version exists, the package owner can configure an npm trusted publisher for the `tutti-lab/nexight-devops` repository and `publish-cli.yml` workflow; the workflow already grants OIDC permission, so the token can then be removed.
157
+
158
+ `package.json` supplies the minimum release version. The first publish uses that version; later merges publish the next patch version above npm's current `latest`. To intentionally bump the minor or major version, raise `package.json` above the published version in the pull request. Re-running a workflow for a commit already published by this workflow skips publishing it again.
159
+
160
+ ## DataFinder OpenAPI
161
+
162
+ Run focused onboarding once. The CLI validates the credentials against the
163
+ selected dashboard before saving them to the existing CLI config file, which is
164
+ written with `0600` permissions.
165
+
166
+ ```bash
167
+ nexight-devops onboard --set-mode datafinder
168
+ nexight-devops datafinder auth check
169
+ ```
170
+
171
+ For temporary or CI use, these environment variables override stored values:
172
+ `DATAFINDER_AK`, `DATAFINDER_SK`, `DATAFINDER_PROJECT_ID`,
173
+ `DATAFINDER_APP_ID`, `DATAFINDER_DASHBOARD_ID`, `DATAFINDER_BASE_URL`, and
174
+ `DATAFINDER_TIMEZONE`. `DATAFINDER_PATH_MODE` accepts `project` or `app`.
175
+
176
+ The default `project` path mode targets SaaS cloud-native projects. Select
177
+ `app` during onboarding for legacy SaaS or private deployments that expose
178
+ app-ID paths. The API origin must be a plain HTTPS origin without credentials,
179
+ paths, query parameters, or fragments.
180
+
181
+ ### Dashboard and report queries
182
+
183
+ ```bash
184
+ nexight-devops datafinder dashboard get
185
+ nexight-devops datafinder dashboard export --count 100 --output dashboard.json
186
+ nexight-devops datafinder report list
187
+ nexight-devops datafinder report get <report-id> --count 100
188
+ ```
189
+
190
+ The two initial fixed internal queries resolve the default dashboard by stable
191
+ report ID, with exact-name fallback for copied dashboards, and return the saved
192
+ DataFinder query results:
193
+
194
+ ```bash
195
+ nexight-devops datafinder query shared-agent-summary --count 100
196
+ nexight-devops datafinder query p2p-health --count 100
197
+ ```
198
+
199
+ ### Generic JavaScript queries
200
+
201
+ `query exec` loads a local `.js`, `.mjs`, or `.cjs` module. The module must
202
+ default-export a function and receives `{ client, config, args }`. `config`
203
+ contains only non-secret connection metadata. The client exposes
204
+ `getDashboard`, `listDashboardReports`, `getReportData`, `exportDashboard`,
205
+ `analysis`, and the lower-level `request` method.
206
+
207
+ ```js
208
+ export default async function query({ args, client, config }) {
209
+ const [reportId, count = '1000'] = args;
210
+ return {
211
+ projectId: config.projectId,
212
+ data: await client.getReportData(reportId, Number(count)),
213
+ };
214
+ }
215
+ ```
216
+
217
+ ```bash
218
+ nexight-devops datafinder query exec ./query.mjs -- <report-id> 100
219
+ ```
220
+
221
+ Query modules execute as trusted local Node.js code; this command is not a
222
+ sandbox. Review generated modules before running them. Use `--output <path>` to
223
+ write JSON with `0600` permissions instead of printing it.
224
+
225
+ ### Development demo
226
+
227
+ The standalone development demo reuses the production DataFinder client and
228
+ exports the configured dashboard. Its defaults point to the `Shared Agent 可靠性`
229
+ dashboard.
230
+
231
+ ```bash
232
+ pnpm demo:datafinder -- --credentials /path/to/AccessKey.txt
233
+ ```
234
+
235
+ The credentials file must contain `AccessKeyId` and `SecretAccessKey`. You can
236
+ instead set `DATAFINDER_AK` and `DATAFINDER_SK`. Run the demo with `--help` to
237
+ override the project, app, dashboard, API origin, or per-report result limit.
@@ -0,0 +1,10 @@
1
+ # Third-party notices
2
+
3
+ This project uses `@datafinder/openapisdk` from
4
+ [`volcengine/datafinder-sdk-openapi-js`](https://github.com/volcengine/datafinder-sdk-openapi-js),
5
+ pinned to commit `1e8aef76cd1fc29d73bce99e1470253ed898ed0b`.
6
+
7
+ Copyright 2020 Beijing Volcano Engine Technology Co., Ltd.
8
+
9
+ Licensed under the Apache License, Version 2.0. A copy of the license is
10
+ available at <https://www.apache.org/licenses/LICENSE-2.0>.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+
3
+ declare const createProgram: () => Command;
4
+ declare const main: (argv?: string[]) => Promise<void>;
5
+
6
+ export { createProgram, main };