@letterapp/cli 0.1.0 → 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.
- package/README.md +203 -24
- package/dist/index.js +1533 -54
- package/dist/index.js.map +1 -0
- package/package.json +14 -5
- package/dist/commands/login.js +0 -151
- package/dist/commands/registry.js +0 -21
- package/dist/lib/api.js +0 -29
- package/dist/lib/args.js +0 -49
- package/dist/lib/browser.js +0 -33
- package/dist/lib/config.js +0 -35
- package/dist/lib/env-file.js +0 -45
- package/dist/lib/pm.js +0 -72
- package/dist/lib/ui.js +0 -57
package/README.md
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
# @letterapp/cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
confirmation and written straight to your project's env file. **The key never
|
|
6
|
-
appears in your shell history, terminal output, or an agent's chat transcript.**
|
|
3
|
+
[](https://www.npmjs.com/package/@letterapp/cli)
|
|
4
|
+
[](./LICENSE)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
**Letter CLI** — connect your app to [Letter](https://letter.app) in one command, then manage the connection from the terminal.
|
|
7
|
+
|
|
8
|
+
Built for AI coding agents (Claude Code, Cursor, Codex, Windsurf, Cline, OpenClaw) and developers alike. The setup flow uses an interactive, secure device login: the API key is provisioned by a browser confirmation and written straight to your project's env file. **The key never appears in your shell history, terminal output, or an agent's chat transcript.**
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
No install needed - run it straight from your project root:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx @letterapp/cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install globally:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @letterapp/cli
|
|
24
|
+
letter --version
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### For AI Agents
|
|
28
|
+
|
|
29
|
+
Add the Letter MCP server so your agent can set up and verify the integration with tools instead of shell parsing:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"letter": { "command": "npx", "args": ["-y", "@letterapp/mcp"] }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
See [`@letterapp/mcp`](https://www.npmjs.com/package/@letterapp/mcp).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Setup
|
|
9
44
|
|
|
10
45
|
From your project root:
|
|
11
46
|
|
|
@@ -15,41 +50,185 @@ npx @letterapp/cli
|
|
|
15
50
|
|
|
16
51
|
What happens:
|
|
17
52
|
|
|
18
|
-
1. The CLI prints a short confirmation code and (after you press Enter) opens
|
|
19
|
-
your browser to the Letter dashboard.
|
|
53
|
+
1. The CLI prints a short confirmation code and (after you press Enter) opens your browser to the Letter dashboard.
|
|
20
54
|
2. You confirm the code matches and pick the project to connect.
|
|
21
|
-
3. Letter mints
|
|
22
|
-
|
|
23
|
-
`~/.letter/credentials.json` for
|
|
55
|
+
3. Letter mints **two** credentials and sends them to the CLI over a secure back channel:
|
|
56
|
+
- a project **ingestion key** (`lt_live_*`) written to `.env.local` as `LETTER_API_KEY` for the SDK / ingestion API, and
|
|
57
|
+
- a workspace **Personal Access Token** (`lt_pat_*`) stored in `~/.letter/credentials.json` for the CLI's management commands and `@letterapp/mcp`.
|
|
24
58
|
4. It detects your package manager and installs `@letterapp/node`.
|
|
25
59
|
|
|
26
|
-
|
|
60
|
+
Neither secret is printed to the terminal or chat. You never pass a token by hand: each command picks the right credential automatically.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
### Login
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Interactive device login (default command). `letter` and `letter login`
|
|
70
|
+
# and `letter init` are equivalent.
|
|
71
|
+
letter
|
|
72
|
+
letter login
|
|
73
|
+
letter init
|
|
74
|
+
```
|
|
27
75
|
|
|
28
76
|
| Flag | Description |
|
|
29
77
|
| --- | --- |
|
|
30
78
|
| `--no-open` | Don't auto-open the browser; print the URL to open manually (headless/remote). |
|
|
31
|
-
| `--yes
|
|
79
|
+
| `-y`, `--yes` | Non-interactive: don't wait for Enter. Useful when an agent runs the command. |
|
|
32
80
|
| `--no-install` | Skip installing `@letterapp/node`. |
|
|
33
81
|
| `--base-url <url>` | Target a self-hosted or local Letter instance. |
|
|
34
82
|
| `--api-key <key>` | CI only. Writes the key without the device flow. Do not use interactively or in chat. |
|
|
35
83
|
|
|
84
|
+
### Status
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Check whether your project has received any contacts or events yet.
|
|
88
|
+
letter status
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Auth
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Show whether this machine is connected, and to which project.
|
|
95
|
+
letter auth status
|
|
96
|
+
|
|
97
|
+
# Remove the stored credential (~/.letter/credentials.json).
|
|
98
|
+
letter auth logout
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Config
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Set the API origin (defaults to https://api.letter.app).
|
|
105
|
+
letter config set base-url https://api.letter.app
|
|
106
|
+
|
|
107
|
+
# Show current configuration.
|
|
108
|
+
letter config get
|
|
109
|
+
|
|
110
|
+
# Reset to defaults.
|
|
111
|
+
letter config reset
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Manage your workspace
|
|
115
|
+
|
|
116
|
+
The same things the dashboard does are available as resource commands, backed by
|
|
117
|
+
the workspace PAT from `letter login`. Each group has `list` / `get` / `create` /
|
|
118
|
+
`update` / `delete` plus verb subcommands; run `letter <group> --help` for the
|
|
119
|
+
exact flags. Project-scoped groups default to the connected project and accept
|
|
120
|
+
`--project <slug>`.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
letter me # identity, workspace, role
|
|
124
|
+
letter projects list --json
|
|
125
|
+
letter contacts list --limit 20
|
|
126
|
+
letter segments preview --filter @paid.json
|
|
127
|
+
letter sequences draft seq_123 --graph @graph.json --trigger @trigger.json --expected-revision 7
|
|
128
|
+
letter sequences publish seq_123
|
|
129
|
+
letter broadcasts preflight bc_42
|
|
130
|
+
letter broadcasts schedule bc_42 --scheduled-at 2026-06-01T09:00:00Z
|
|
131
|
+
letter domains create --domain mail.acme.com
|
|
132
|
+
letter sender-identity --from-email hi@mail.acme.com --from-name "Acme"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Groups: `projects`, `members`, `invitations`, `api-keys`, `contacts`,
|
|
136
|
+
`accounts`, `events`, `suppressions`, `segments`, `sequences`, `broadcasts`,
|
|
137
|
+
`templates`, `domains`, `project-tokens`, `sender-identity`, `sending-mode`,
|
|
138
|
+
`me`. Full reference: [letter.app/docs/cli](https://letter.app/docs/cli) and the
|
|
139
|
+
[Management API](https://letter.app/docs/management-api).
|
|
140
|
+
|
|
141
|
+
### Two credentials, one login
|
|
142
|
+
|
|
143
|
+
| Purpose | Format | Dashboard | CLI group | Stored as |
|
|
144
|
+
| --- | --- | --- | --- | --- |
|
|
145
|
+
| Send events (SDK / ingestion) | `lt_live_*` | Project tokens | `project-tokens` | `LETTER_API_KEY` in `.env.local` |
|
|
146
|
+
| Run the CLI / Management API | `lt_pat_*` | API keys | `api-keys` | `~/.letter/credentials.json` |
|
|
147
|
+
|
|
148
|
+
(The older group names `keys` and `tokens` still work as aliases.)
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Output Modes
|
|
153
|
+
|
|
154
|
+
- **Default** — human-friendly colored output.
|
|
155
|
+
- `--json` — raw JSON, for scripting and agents:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
letter --json auth status
|
|
159
|
+
letter --json status | jq '.events'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Environment Variables
|
|
165
|
+
|
|
166
|
+
| Variable | Default | Purpose |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `LETTER_API_KEY` | (from credential store) | Project ingestion key (`lt_live_*`) for the SDK / `letter status`. Overrides the stored key (CI). |
|
|
169
|
+
| `LETTER_PAT` | (from credential store) | Workspace PAT (`lt_pat_*`) for management commands. Set it to run them without `letter login` (CI). |
|
|
170
|
+
| `LETTER_PROJECT` | (connected project) | Default project slug for project-scoped management commands. |
|
|
171
|
+
| `LETTER_BASE_URL` | `https://api.letter.app` | API origin for self-host / local dev. |
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
36
175
|
## Security
|
|
37
176
|
|
|
38
|
-
The interactive flow follows the OAuth 2.0 Device Authorization Grant pattern
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
177
|
+
The interactive flow follows the OAuth 2.0 Device Authorization Grant pattern (`gh auth login` / `vercel login` style). The key is minted server-side only after a human approves in the browser, then delivered to the CLI out of band. The CLI confirms success without ever echoing the secret. Treat `.env.local` and `~/.letter/credentials.json` as secrets and keep them out of source control.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Project Structure
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
src/
|
|
185
|
+
├── index.ts # CLI entry point — Commander program + global flags
|
|
186
|
+
├── client.ts # Device-auth flow + authenticated API client
|
|
187
|
+
├── config.ts # base-url config (conf) + secret credential store
|
|
188
|
+
├── output.ts # Colors, spinners, JSON mode, prompts
|
|
189
|
+
├── browser.ts # Open the confirmation URL
|
|
190
|
+
├── env-file.ts # Upsert keys into .env.local
|
|
191
|
+
├── pm.ts # Detect package manager / framework, install the SDK
|
|
192
|
+
└── commands/
|
|
193
|
+
├── login.ts # login / init — the device flow (default command)
|
|
194
|
+
├── auth.ts # auth status / logout
|
|
195
|
+
├── status.ts # status — has data landed?
|
|
196
|
+
└── config.ts # config set / get / reset
|
|
197
|
+
package.json
|
|
198
|
+
tsconfig.json
|
|
199
|
+
tsup.config.ts
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Development
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm install # install dependencies
|
|
208
|
+
npm run build # bundle to dist/ with tsup
|
|
209
|
+
npm run dev # watch mode
|
|
210
|
+
npm run typecheck
|
|
211
|
+
|
|
212
|
+
node dist/index.js --help
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## See Also
|
|
218
|
+
|
|
219
|
+
- [`@letterapp/mcp`](https://www.npmjs.com/package/@letterapp/mcp) — MCP server for AI agents.
|
|
220
|
+
- [`@letterapp/node`](https://www.npmjs.com/package/@letterapp/node) — Node.js SDK.
|
|
221
|
+
|
|
222
|
+
---
|
|
43
223
|
|
|
44
|
-
##
|
|
224
|
+
## Links
|
|
45
225
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
226
|
+
- **Website:** [letter.app](https://letter.app)
|
|
227
|
+
- **npm:** [@letterapp/cli](https://www.npmjs.com/package/@letterapp/cli)
|
|
228
|
+
- **GitHub:** [vincenzor/letter-cli](https://github.com/vincenzor/letter-cli)
|
|
229
|
+
- **Issues:** [Report a bug](https://github.com/vincenzor/letter-cli/issues)
|
|
49
230
|
|
|
50
|
-
|
|
51
|
-
- `letter broadcast` - create and send broadcasts
|
|
52
|
-
- `letter contacts`, `letter events`, `letter keys`, `letter status`
|
|
231
|
+
---
|
|
53
232
|
|
|
54
233
|
## License
|
|
55
234
|
|