@go-labs-sg/gosh 0.1.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,149 @@
1
+ # GOSH CLI
2
+
3
+ `@go-labs-sg/gosh` provides the `gosh` binary for permission-aware GOSH organizer operations and agent automation. It calls the same tRPC procedures as the web app using the authorizing user's global, organization, and event permissions.
4
+
5
+ ## Runtime and installation
6
+
7
+ The CLI requires [Bun](https://bun.com/docs/installation) 1.4.0 or newer. npm remains the package distribution channel, while the installed `gosh` command runs under Bun.
8
+
9
+ Check whether a compatible Bun version is already available:
10
+
11
+ ```bash
12
+ bun --version
13
+ ```
14
+
15
+ If Bun is missing, install it for the current operating system:
16
+
17
+ **macOS (Homebrew)**
18
+
19
+ ```bash
20
+ brew install oven-sh/bun/bun
21
+ ```
22
+
23
+ **Windows (PowerShell)**
24
+
25
+ ```powershell
26
+ powershell -c "irm bun.sh/install.ps1|iex"
27
+ ```
28
+
29
+ **Linux**
30
+
31
+ ```bash
32
+ curl -fsSL https://bun.com/install | bash
33
+ ```
34
+
35
+ If Bun is installed but older than 1.4.0, run `bun upgrade`. Open a new terminal if the installer changes `PATH`, then verify `bun --version` again. Installation agents should skip the platform installer when Bun 1.4.0 or newer is already available.
36
+
37
+ Install and verify the CLI:
38
+
39
+ ```bash
40
+ bun add --global @go-labs-sg/gosh
41
+ gosh version
42
+ ```
43
+
44
+ ## Authentication
45
+
46
+ ```bash
47
+ gosh auth login
48
+ gosh auth status
49
+ gosh auth whoami
50
+ ```
51
+
52
+ `gosh auth login` opens GOSH in your browser. Sign in through the normal web flow if needed, confirm that the displayed device and code match your terminal, and click **Authorize CLI**. The CLI polls automatically, then stores the product-issued credentials exclusively through `Bun.secrets` in the operating system credential store. No Google credentials are stored by the CLI.
53
+
54
+ GOSH CLI access is limited to global administrators. The server rechecks the account's current global role and ban state when issuing, refreshing, and authenticating CLI credentials, so removing the admin role immediately blocks further CLI access.
55
+
56
+ Use `gosh auth logout` to revoke the remote CLI session and remove the local credential. Use `GOSH_API_URL` or `--api-url` to target another HTTPS deployment; plain HTTP is accepted only for localhost development. Pass `--no-browser` when working over SSH or in a container and open the printed URL on another device.
57
+
58
+ ## Commands and JSON input
59
+
60
+ Discover the current command surface instead of guessing payloads:
61
+
62
+ ```bash
63
+ gosh commands
64
+ gosh help event list
65
+ gosh health status
66
+ gosh organization list
67
+ gosh event list --input '{"organizationId":"acme"}'
68
+ gosh event get --input '{"organizationId":"acme","eventId":"event-id"}'
69
+ ```
70
+
71
+ Commands use `--input '<json>'` for the exact validated tRPC input object. This preserves the GOSH API's typed validation without maintaining a second set of lossy CLI flags. See [command-reference.md](./command-reference.md) or import `@go-labs-sg/gosh/command-manifest` for the generated catalogue.
72
+
73
+ The command registry covers every callable GOSH tRPC procedure: organizer and global-admin operations, organization invitations and membership, player workflows, public results/login procedures, uploads, and realtime subscriptions. The compile-time registry test fails whenever a new API procedure is added without a CLI command.
74
+
75
+ ### Local file uploads
76
+
77
+ Upload commands add the local file metadata to the supplied API input, request a permission-scoped signed URL, and upload the bytes directly to storage without sending the GOSH CLI access token to storage:
78
+
79
+ ```bash
80
+ gosh upload branding \
81
+ --file ./logo.png \
82
+ --input '{"eventId":"event-id","assetType":"logo"}' \
83
+ --target event-id \
84
+ --allow-state-change \
85
+ --allow-external-write
86
+
87
+ gosh player mission upload \
88
+ --file ./proof.mp4 \
89
+ --input '{"eventId":"event-id","missionId":"mission-id"}' \
90
+ --target mission-id \
91
+ --allow-state-change \
92
+ --allow-external-write
93
+ ```
94
+
95
+ Mission videos use GOSH's multipart upload protocol automatically. Failed multipart uploads are aborted best-effort, and signed URLs are never included in the final JSON envelope or debug output.
96
+
97
+ ### Submission media exports
98
+
99
+ Queue all original photo and video submissions as a ZIP organized by event and
100
+ then by team or individual participant. GOSH emails the requester when the
101
+ archive is ready and keeps it available for 30 days.
102
+
103
+ ```bash
104
+ gosh event submissions request-image-export \
105
+ --input '{"organizationId":"acme","eventId":"event-id"}' \
106
+ --target event-id \
107
+ --allow-state-change \
108
+ --allow-email \
109
+ --allow-external-write
110
+
111
+ gosh event submissions image-exports \
112
+ --input '{"organizationId":"acme","eventId":"event-id"}'
113
+ ```
114
+
115
+ ### Realtime watches
116
+
117
+ `gosh player watch` and `gosh submission watch` keep an authenticated SSE connection open and emit one JSON envelope per line. Press Ctrl-C to close the stream cleanly:
118
+
119
+ ```bash
120
+ gosh submission watch --input '{"organizationId":"acme","eventId":"event-id"}'
121
+ ```
122
+
123
+ ### Global administration
124
+
125
+ Global admins can list users, change global roles, and ban or unban accounts under `gosh admin users …`. Banning an account atomically revokes its active browser and CLI sessions.
126
+
127
+ ## Mutation safety
128
+
129
+ Mutations require `--target` to exactly match an identifier in `--input` (such as an `eventId`, `stationId`, slug, or name), binding the confirmation to the payload. In non-interactive automation, every applicable effect flag is also required:
130
+
131
+ - `--allow-state-change`
132
+ - `--allow-email`
133
+ - `--allow-external-write`
134
+ - `--allow-delete`
135
+
136
+ Example after reviewing the event and obtaining explicit approval:
137
+
138
+ ```bash
139
+ gosh event update-status \
140
+ --input '{"organizationId":"acme","eventId":"event-id","status":"LIVE"}' \
141
+ --target 'event-id' \
142
+ --allow-state-change
143
+ ```
144
+
145
+ Without the allow flags, an interactive terminal prints a workflow preview and requires the exact response `CONFIRM`. Read-only commands never prompt.
146
+
147
+ ## Output
148
+
149
+ One-shot commands write one JSON envelope to stdout. Watch commands write newline-delimited JSON envelopes. Failures and opt-in `--debug` diagnostics go to stderr, and known secrets, payloads, join codes, share tokens, and signed URLs are redacted. `--quiet` or `-q` suppresses diagnostics.