@tailglow/cli 0.2.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,104 @@
1
+ # @tailglow/cli
2
+
3
+ `tglow` is the Tailglow command line. Every command is generated from the API's own routes and
4
+ validations, so the CLI, the docs site, `llms.txt` and the in-product AI assistant all describe the
5
+ same API by construction.
6
+
7
+ ```bash
8
+ npm install -g @tailglow/cli
9
+ tglow config set api_key tg_api_...
10
+ tglow projects list
11
+ ```
12
+
13
+ Node 18.3 or newer. `bun add -g` and `pnpm add -g` work the same way.
14
+
15
+ Prefer a shorter name? Alias it rather than installing over one:
16
+
17
+ ```bash
18
+ alias tg=tglow
19
+ ```
20
+
21
+ ## Shape
22
+
23
+ ```
24
+ tglow <resource> <command> [flags]
25
+ ```
26
+
27
+ Run `tglow` for the resources, `tglow <resource>` for its commands, and
28
+ `tglow <resource> <command> --help` for the flags, their types, allowed values and requiredness.
29
+
30
+ ```bash
31
+ tglow metrics list --project prj_x
32
+ tglow metrics create --project prj_x --name "API Latency" --view-id view_x
33
+ tglow metrics delete --project prj_x --metric-id met_x
34
+ ```
35
+
36
+ Field names are snake_case on the wire and kebab-case on the command line: `time_window_minutes`
37
+ becomes `--time-window-minutes`. Object and array fields take JSON:
38
+
39
+ ```bash
40
+ tglow views create-join --project prj_x --joins '[{"view_id":"view_b","on":"user_id"}]'
41
+ ```
42
+
43
+ ## Credentials
44
+
45
+ Authentication is an API key, created in the dashboard under Team settings. Precedence is flag, then
46
+ environment, then stored config:
47
+
48
+ ```bash
49
+ tglow projects list --api-key tg_api_... # this call only
50
+ TAILGLOW_API_KEY=tg_api_... tglow projects list
51
+ tglow config set api_key tg_api_... # ~/.tailglow/config.json, mode 0600
52
+ ```
53
+
54
+ A stored key is never printed back, by `config get` or anything else.
55
+
56
+ `tglow config` also stores a default `project` and `team`, which is what lets
57
+ `tglow metrics list` work without repeating the project on every call. Those two are the only
58
+ defaults: every other id has to be named on the command line, so nothing in your environment can
59
+ quietly become the target of a delete.
60
+
61
+ ## Output
62
+
63
+ Human-readable tables in a terminal, JSON everywhere else. `--json` forces JSON; a pipe implies it,
64
+ so `tglow projects list | jq` needs no flag. Failures go to stderr and follow the same mode, so a
65
+ pipeline reading stdout never has to tell a result apart from an explanation of why there is none.
66
+
67
+ JSON is the API's response verbatim, envelope included, so the cursors and the message travel with
68
+ the rows: read `.data` for the results and `.pagination.next_cursor` to continue.
69
+
70
+ ```bash
71
+ tglow projects list --json | jq '.data[].name'
72
+ ```
73
+
74
+ ## Lists
75
+
76
+ List commands paginate. `--all` follows the cursor, up to `--max` results (10,000 by default):
77
+
78
+ ```bash
79
+ tglow metrics list --project prj_x --all --max 500
80
+ ```
81
+
82
+ The cap is a guardrail, not a ceiling: records and collection documents are unbounded, so an
83
+ uncapped follow would pull millions of rows into a terminal. A run that stops early always reports
84
+ the cursor to resume from, printed as the whole command you typed plus `--after`. Under `--json`,
85
+ `--all` returns `{ data, truncated, next_cursor }` so a caller can continue on its own.
86
+
87
+ `--all` owns paging, so it does not combine with `--limit` or `--before`. Use `--max` for the total,
88
+ and `--limit` on its own when you want a single page.
89
+
90
+ ## Deletes
91
+
92
+ A delete asks for confirmation in a terminal. `--yes` skips the prompt, and a non-interactive run
93
+ proceeds without one, so scripts and agents are not blocked on a question they cannot answer.
94
+
95
+ ## Development
96
+
97
+ ```bash
98
+ bun run tglow <resource> <command> # run from source, without installing
99
+ bun run test:cli # unit tests, no network
100
+ bun run build:llms # regenerate src/commands.generated.js
101
+ ```
102
+
103
+ `src/commands.generated.js` is written by `scripts/build/llms.build.js` and is never edited by hand.
104
+ Adding a route to the API adds its command here with no change to this package.
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@tailglow/cli",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "description": "The Tailglow command line. Every command is generated from the Tailglow API reference, so the CLI and the documentation can never describe different APIs.",
6
+ "bin": {
7
+ "tglow": "./src/index.js"
8
+ },
9
+ "main": "src/index.js",
10
+ "exports": {
11
+ ".": "./src/index.js",
12
+ "./commands": "./src/commands.generated.js"
13
+ },
14
+ "files": [
15
+ "src"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18.3.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/tailglow-dev/monorepo.git",
23
+ "directory": "packages/cli"
24
+ },
25
+ "keywords": [
26
+ "tailglow",
27
+ "cli",
28
+ "analytics",
29
+ "observability"
30
+ ],
31
+ "license": "ISC",
32
+ "scripts": {
33
+ "test": "bun test"
34
+ },
35
+ "dependencies": {
36
+ "@clack/prompts": "^1.2.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/bun": "^1.3.6"
40
+ }
41
+ }