@tsuga/cli 1.38.0 → 1.40.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 (3) hide show
  1. package/README.md +68 -32
  2. package/dist/cli.js +287 -171
  3. package/package.json +10 -5
package/README.md CHANGED
@@ -30,10 +30,10 @@ For `bash` and `zsh`, add the matching line to your shell startup file:
30
30
 
31
31
  ```bash
32
32
  # ~/.bashrc
33
- eval "$(tsuga completion bash)"
33
+ eval "$(tsuga --completions bash)"
34
34
 
35
35
  # ~/.zshrc
36
- eval "$(tsuga completion zsh)"
36
+ eval "$(tsuga --completions zsh)"
37
37
  ```
38
38
 
39
39
  Then open a new shell (or `source` the file).
@@ -41,7 +41,7 @@ Then open a new shell (or `source` the file).
41
41
  For `fish`, write the script to your completions directory:
42
42
 
43
43
  ```fish
44
- tsuga completion fish > ~/.config/fish/completions/tsuga.fish
44
+ tsuga --completions fish > ~/.config/fish/completions/tsuga.fish
45
45
  ```
46
46
 
47
47
  Fish loads it automatically in new shells.
@@ -80,7 +80,7 @@ tsuga auth logout
80
80
 
81
81
  After `tsuga auth login`, commands work without an Operation API key.
82
82
 
83
- Sessions renew themselves: the login also saves a refresh token, and the CLI exchanges it for a new access token when the current one is within five minutes of expiry. You log in again when the refresh token expires, when it is revoked, or when the session predates refresh support.
83
+ Sessions renew themselves: the login also saves a refresh token, and the CLI exchanges it for a new access token when the current one is within five minutes of expiry. You log in again when the refresh token expires, when it is revoked, or when the session has no refresh token.
84
84
 
85
85
  ### Operation API key
86
86
 
@@ -117,11 +117,11 @@ Commands have built-in defaults so you can omit common flags:
117
117
  | `--query` | `*` |
118
118
  | `--max-results` | `100` |
119
119
 
120
- Override defaults persistently:
120
+ Override defaults persistently. The value is given with `--value`:
121
121
 
122
122
  ```bash
123
- tsuga config set default from -1h
124
- tsuga config set default query 'level:ERROR'
123
+ tsuga config set default from --value=-1h
124
+ tsuga config set default query --value 'level:ERROR'
125
125
  ```
126
126
 
127
127
  Current defaults are listed by `tsuga config` (custom overrides marked with `*`).
@@ -135,7 +135,7 @@ tsuga config reset defaults
135
135
  Clear a single default by setting it to an empty value:
136
136
 
137
137
  ```bash
138
- tsuga config set default cluster ''
138
+ tsuga config set default cluster --value ''
139
139
  ```
140
140
 
141
141
  ## Clusters
@@ -149,7 +149,7 @@ tsuga clusters list
149
149
  Pick the cluster you want to use by default via the defaults mechanism:
150
150
 
151
151
  ```bash
152
- tsuga config set default cluster <CLUSTER_ID>
152
+ tsuga config set default cluster --value <CLUSTER_ID>
153
153
  ```
154
154
 
155
155
  Override per-command without persisting:
@@ -209,15 +209,17 @@ For resources with server-side filters, narrowing the query beats paging through
209
209
 
210
210
  ### Explaining a call with `--rationale`
211
211
 
212
- API-calling commands accept an optional `--rationale` flag to record why they are being run.
213
- It does not change the result; the text is sent as a request header and recorded in the
214
- backend request log, which is useful for understanding agent behavior. `feedback` is excluded
215
- since its message already explains why it's being sent.
212
+ Every command accepts an optional `--rationale` flag to record why it is being run. It does not
213
+ change the result; the text is sent as a request header on any API call the command makes, and
214
+ recorded in the backend request log, which is useful for understanding agent behavior.
216
215
 
217
216
  ```bash
218
217
  tsuga logs patterns --rationale "exploring telemetry to investigate prod outage"
219
218
  ```
220
219
 
220
+ `--rationale`, `--cluster` and `--operation-api-key` are shared flags: they may be given before
221
+ or after the subcommand, and are inherited by every subcommand.
222
+
221
223
  ### Available resources
222
224
 
223
225
  `cloud-resources`, `dashboard-folders`, `dashboards`, `ingestion-api-keys`, `investigations`, `monitors`, `notification-integrations`, `notification-rules`, `notification-silences`, `public-tokens`, `quality-reports`, `retention-policies`, `log-routes`, `services`, `slos`, `tag-policies`, `teams`
@@ -285,6 +287,8 @@ tsuga retention-policies delete abc-123
285
287
 
286
288
  ### Time formats
287
289
 
290
+ Use an equals sign for negative offsets, such as `--from=-1h`.
291
+
288
292
  `--from` and `--to` accept any of:
289
293
 
290
294
  | Format | Example |
@@ -297,7 +301,7 @@ tsuga retention-policies delete abc-123
297
301
  ### Search logs
298
302
 
299
303
  ```bash
300
- tsuga logs search --from -1h --query 'level:ERROR'
304
+ tsuga logs search --from=-1h --query 'level:ERROR'
301
305
  tsuga logs search --from 1704067200 --to 1704153600 --query 'service:api'
302
306
  ```
303
307
 
@@ -306,49 +310,70 @@ dot-paths from each log, and `-o tsv|csv` for tabular output:
306
310
 
307
311
  ```bash
308
312
  # JSON projected to selected fields (preserves the {logs: [...]} envelope and nesting)
309
- tsuga logs search --from -10m \
313
+ tsuga logs search --from=-10m \
310
314
  --fields timestamp,level,message,context.k8s.pod.name
311
315
 
312
316
  # TSV with default columns: timestamp, level, message
313
- tsuga logs search --from -10m --query 'level:ERROR' -o tsv
317
+ tsuga logs search --from=-10m --query 'level:ERROR' -o tsv
314
318
 
315
319
  # CSV with custom columns
316
- tsuga logs search --from -10m -o csv \
320
+ tsuga logs search --from=-10m -o csv \
317
321
  --fields timestamp,level,message,context.k8s.pod.name
318
322
  ```
319
323
 
320
324
  ### Log attributes
321
325
 
322
326
  ```bash
323
- tsuga logs attributes --from -1h
327
+ tsuga logs attributes --from=-1h
324
328
  ```
325
329
 
326
330
  ### Log patterns
327
331
 
328
332
  ```bash
329
333
  # Group recent logs into patterns
330
- tsuga logs patterns --from -1h --query 'level:ERROR'
334
+ tsuga logs patterns --from=-1h --query 'level:ERROR'
331
335
 
332
336
  # List new error patterns observed in the time range
333
- tsuga logs new-error-patterns --from -24h --team my-team --service api --env prod
337
+ tsuga logs new-error-patterns --from=-24h --team my-team --service api --env prod
334
338
 
335
339
  # List error patterns whose volume increased for a team
336
- tsuga logs error-pattern-increases --from -24h --team my-team --env prod
340
+ tsuga logs error-pattern-increases --from=-24h --team my-team --env prod
337
341
  ```
338
342
 
339
343
  ### Search traces
340
344
 
341
345
  ```bash
342
- tsuga traces search --from -30m --query 'span_name:GET'
346
+ tsuga traces search --from=-30m --query 'span_name:GET'
347
+ ```
348
+
349
+ ### Search RUM events
350
+
351
+ Prefix query fields with the stream they belong to (`measurements.`, `events.`, or
352
+ `exceptions.`), and filter on one stream per query. A query without a prefixed field, including
353
+ the default `*`, searches the `events` stream:
354
+
355
+ ```bash
356
+ tsuga rum search --from=-1h --query 'events.view.name:/checkout'
357
+ tsuga rum search --from=-1h --query 'exceptions.exception.type:*' --max-results 20
358
+ ```
359
+
360
+ ### RUM attributes
361
+
362
+ Lists every RUM attribute you can query:
363
+
364
+ ```bash
365
+ tsuga rum attributes
343
366
  ```
344
367
 
368
+ Both RUM commands require an operation API key with the **RUM events** (`rum`) read permission.
369
+
345
370
  ### Summarize a trace
346
371
 
347
372
  Aggregates groups of similar spans into synthetic summary spans (marked with
348
373
  `spanAttributes.aggregation.is_summary`) for a compact view of large traces:
349
374
 
350
375
  ```bash
351
- tsuga traces summarize --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from -30m
376
+ tsuga traces summarize --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from=-30m
352
377
  ```
353
378
 
354
379
  ### Trace latency summary
@@ -357,13 +382,13 @@ Summarizes where wall-clock time is spent in a trace: each slice of the timeline
357
382
  is attributed to the services with active leaf spans, with per-service totals:
358
383
 
359
384
  ```bash
360
- tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from -30m
385
+ tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from=-30m
361
386
 
362
387
  # Per-service totals only, without the range timeline
363
- tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from -30m --no-ranges
388
+ tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from=-30m --no-ranges
364
389
 
365
390
  # Collapse timeline ranges shorter than 50ms (0 disables collapsing)
366
- tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from -30m --min-range-duration-ms 50
391
+ tsuga traces latency-summary --trace-id 78c99c5bb1e4a30297fa134b9dbec64f --from=-30m --min-range-duration-ms 50
367
392
  ```
368
393
 
369
394
  ### Contrast sets
@@ -431,10 +456,10 @@ with `topK`, `minLift`, and `minSupport`; restrict the attributes tested with
431
456
 
432
457
  ```bash
433
458
  # List all metrics
434
- tsuga metrics list --from -1h
459
+ tsuga metrics list --from=-1h
435
460
 
436
461
  # Get a specific metric
437
- tsuga metrics get my.metric.name --from -1h
462
+ tsuga metrics get my.metric.name --from=-1h
438
463
 
439
464
  # List dashboards and monitors that use a metric
440
465
  tsuga metrics assets-usage my.metric.name
@@ -460,7 +485,7 @@ tsuga aggregation scalar --generate-skeleton > query.json
460
485
  Inspect service dependency graphs:
461
486
 
462
487
  ```bash
463
- tsuga service-graph get <SERVICE_ID> --from -1h --query 'env:prod'
488
+ tsuga service-graph get <SERVICE_ID> --from=-1h --query 'env:prod'
464
489
  ```
465
490
 
466
491
  ## Kubernetes
@@ -513,11 +538,11 @@ Commands under `tsuga experimental` may change or be removed without notice.
513
538
 
514
539
  ```bash
515
540
  # Rank functions by self (flat) and inclusive (cum) sample value, like `go tool pprof -top`
516
- tsuga experimental profiles top --service api --type cpu --from -1h
517
- tsuga experimental profiles top --service api --type alloc_space --from -1h --limit 10 -o tsv
541
+ tsuga experimental profiles top --service api --type cpu --from=-1h
542
+ tsuga experimental profiles top --service api --type alloc_space --from=-1h --limit 10 -o tsv
518
543
 
519
544
  # Download the merged profile as raw pprof protobuf and open it with pprof
520
- tsuga experimental profiles pprof --service api --type cpu --from -1h -O cpu.pb
545
+ tsuga experimental profiles pprof --service api --type cpu --from=-1h -O cpu.pb
521
546
  go tool pprof -http=: cpu.pb
522
547
 
523
548
  # Raw folded stacks (`root;...;leaf` with a value), with the usual -f / -d / --generate-skeleton
@@ -578,3 +603,14 @@ Read from stdin with `-f -`:
578
603
  ```bash
579
604
  echo '{"name": "My Team"}' | tsuga teams create -f -
580
605
  ```
606
+
607
+ ## Implementation
608
+
609
+ The CLI uses Effect v4 services for HTTP, configuration, filesystem access, subprocesses, and
610
+ command parsing. Command folders mirror tadmin: each group has a composition `index.ts` and one
611
+ file per action, with nearby tests. Cross-directory application imports use `@cli/*`. `packages/common-cli` shares OAuth token exchange, browser callbacks, macOS
612
+ keychain access, output, and closed-pipe handling with tadmin. The CLIs retain separate credential
613
+ namespaces and authentication policies. Generic field projection lives in `common`.
614
+
615
+ Run `yarn lint`, `yarn typecheck`, `yarn test`, and `yarn build` from `packages/cli` to verify
616
+ changes. Lint includes Effect language-service diagnostics.