@letterapp/cli 0.1.0 → 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 CHANGED
@@ -1,11 +1,46 @@
1
1
  # @letterapp/cli
2
2
 
3
- Connect your app to [Letter](https://letter.app) in one command. The CLI runs an
4
- interactive, secure device login: the API key is provisioned by a browser
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
+ [![npm version](https://img.shields.io/npm/v/@letterapp/cli)](https://www.npmjs.com/package/@letterapp/cli)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
7
5
 
8
- ## Usage
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,157 @@ 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 a project API key and sends it to the CLI over a secure back
22
- channel. The CLI writes `LETTER_API_KEY` to `.env.local` and stores a copy in
23
- `~/.letter/credentials.json` for tooling (such as `@letterapp/mcp`).
55
+ 3. Letter mints a project API key and sends it to the CLI over a secure back channel. The CLI writes `LETTER_API_KEY` to `.env.local` and stores a copy in `~/.letter/credentials.json` for tooling (such as `@letterapp/mcp`).
24
56
  4. It detects your package manager and installs `@letterapp/node`.
25
57
 
26
- ## Options
58
+ The API key is never printed to the terminal or chat.
59
+
60
+ ---
61
+
62
+ ## Commands
63
+
64
+ ### Login
65
+
66
+ ```bash
67
+ # Interactive device login (default command). `letter` and `letter login`
68
+ # and `letter init` are equivalent.
69
+ letter
70
+ letter login
71
+ letter init
72
+ ```
27
73
 
28
74
  | Flag | Description |
29
75
  | --- | --- |
30
76
  | `--no-open` | Don't auto-open the browser; print the URL to open manually (headless/remote). |
31
- | `--yes`, `-y` | Non-interactive: don't wait for Enter. Useful when an agent runs the command. |
77
+ | `-y`, `--yes` | Non-interactive: don't wait for Enter. Useful when an agent runs the command. |
32
78
  | `--no-install` | Skip installing `@letterapp/node`. |
33
79
  | `--base-url <url>` | Target a self-hosted or local Letter instance. |
34
80
  | `--api-key <key>` | CI only. Writes the key without the device flow. Do not use interactively or in chat. |
35
81
 
82
+ ### Status
83
+
84
+ ```bash
85
+ # Check whether your project has received any contacts or events yet.
86
+ letter status
87
+ ```
88
+
89
+ ### Auth
90
+
91
+ ```bash
92
+ # Show whether this machine is connected, and to which project.
93
+ letter auth status
94
+
95
+ # Remove the stored credential (~/.letter/credentials.json).
96
+ letter auth logout
97
+ ```
98
+
99
+ ### Config
100
+
101
+ ```bash
102
+ # Point the CLI at a self-hosted / local Letter instance.
103
+ letter config set base-url http://localhost:3001
104
+
105
+ # Show current configuration.
106
+ letter config get
107
+
108
+ # Reset to defaults.
109
+ letter config reset
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Output Modes
115
+
116
+ - **Default** — human-friendly colored output.
117
+ - `--json` — raw JSON, for scripting and agents:
118
+
119
+ ```bash
120
+ letter --json auth status
121
+ letter --json status | jq '.events'
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Environment Variables
127
+
128
+ | Variable | Default | Purpose |
129
+ | --- | --- | --- |
130
+ | `LETTER_API_KEY` | (from credential store) | Overrides the stored key (CI). |
131
+ | `LETTER_BASE_URL` | `https://api.letter.app` | API origin for self-host / local dev. |
132
+
133
+ ---
134
+
36
135
  ## Security
37
136
 
38
- The interactive flow follows the OAuth 2.0 Device Authorization Grant pattern
39
- (`gh auth login` / `vercel login` style). The key is minted server-side only
40
- after a human approves in the browser, then delivered to the CLI out of band. The
41
- CLI confirms success without ever echoing the secret. Treat `.env.local` and
42
- `~/.letter/credentials.json` as secrets and keep them out of source control.
137
+ 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.
138
+
139
+ ---
140
+
141
+ ## Project Structure
142
+
143
+ ```
144
+ src/
145
+ ├── index.ts # CLI entry point — Commander program + global flags
146
+ ├── client.ts # Device-auth flow + authenticated API client
147
+ ├── config.ts # base-url config (conf) + secret credential store
148
+ ├── output.ts # Colors, spinners, JSON mode, prompts
149
+ ├── browser.ts # Open the confirmation URL
150
+ ├── env-file.ts # Upsert keys into .env.local
151
+ ├── pm.ts # Detect package manager / framework, install the SDK
152
+ └── commands/
153
+ ├── login.ts # login / init — the device flow (default command)
154
+ ├── auth.ts # auth status / logout
155
+ ├── status.ts # status — has data landed?
156
+ └── config.ts # config set / get / reset
157
+ package.json
158
+ tsconfig.json
159
+ tsup.config.ts
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Development
165
+
166
+ ```bash
167
+ npm install # install dependencies
168
+ npm run build # bundle to dist/ with tsup
169
+ npm run dev # watch mode
170
+ npm run typecheck
171
+
172
+ node dist/index.js --help
173
+ ```
174
+
175
+ ---
43
176
 
44
177
  ## Roadmap
45
178
 
46
- v1 ships the setup/login flow. The command registry and credential store are
47
- built to extend: future versions add authenticated subcommands that reuse the
48
- same stored credential, for example:
179
+ v1 ships the secure setup/login flow plus connection helpers. The command
180
+ structure is built to extend: future authenticated areas register the same way
181
+ and reuse the credential store + API client, for example:
182
+
183
+ - `letter sequences` — list / create / configure automation sequences
184
+ - `letter broadcast` — create and send broadcasts
185
+ - `letter contacts`, `letter events`, `letter keys`
186
+
187
+ ---
188
+
189
+ ## See Also
190
+
191
+ - [`@letterapp/mcp`](https://www.npmjs.com/package/@letterapp/mcp) — MCP server for AI agents.
192
+ - [`@letterapp/node`](https://www.npmjs.com/package/@letterapp/node) — Node.js SDK.
193
+
194
+ ---
195
+
196
+ ## Links
197
+
198
+ - **Website:** [letter.app](https://letter.app)
199
+ - **npm:** [@letterapp/cli](https://www.npmjs.com/package/@letterapp/cli)
200
+ - **GitHub:** [vincenzor/letter-cli](https://github.com/vincenzor/letter-cli)
201
+ - **Issues:** [Report a bug](https://github.com/vincenzor/letter-cli/issues)
49
202
 
50
- - `letter sequences` - list / create / configure automation sequences
51
- - `letter broadcast` - create and send broadcasts
52
- - `letter contacts`, `letter events`, `letter keys`, `letter status`
203
+ ---
53
204
 
54
205
  ## License
55
206