@vocoder/cli 0.1.6 → 0.1.7
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 +192 -13
- package/dist/bin.mjs +1717 -778
- package/dist/bin.mjs.map +1 -1
- package/dist/chunk-OC5N5C5X.mjs +546 -0
- package/dist/chunk-OC5N5C5X.mjs.map +1 -0
- package/dist/lib.d.mts +175 -0
- package/dist/lib.mjs +15 -0
- package/dist/lib.mjs.map +1 -0
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vocoder/cli
|
|
2
2
|
|
|
3
|
-
Command-line tool for Vocoder. Handles project setup
|
|
3
|
+
Command-line tool for Vocoder. Handles project setup, string extraction, and translation sync.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -18,22 +18,169 @@ npx vocoder <command>
|
|
|
18
18
|
|
|
19
19
|
### `vocoder init`
|
|
20
20
|
|
|
21
|
-
Connect your repository to Vocoder.
|
|
21
|
+
Connect your repository to Vocoder. Runs a full TUI-based onboarding flow — authentication, workspace selection, GitHub connection, and project configuration all happen in the terminal. A browser is opened only for steps that require OAuth (sign-in, GitHub App install).
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
vocoder init
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
**Fast path:** If the current repository's remote is already linked to a Vocoder project, `init` detects it and prints the scaffold instructions immediately — no prompts, no browser.
|
|
28
|
+
|
|
29
|
+
**Full flow:**
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
◆ Vocoder Setup
|
|
33
|
+
|
|
34
|
+
● Open the link below to sign in or create your account:
|
|
35
|
+
◇ Authentication URL ──────────────────────────────────────╮
|
|
36
|
+
│ │
|
|
37
|
+
│ https://vocoder.app/auth/cli?session=<token> │
|
|
38
|
+
│ │
|
|
39
|
+
├────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
◆ Open in your browser? › Yes
|
|
42
|
+
|
|
43
|
+
◒ Waiting for authentication...
|
|
44
|
+
◇ Authenticated as eric@example.com
|
|
45
|
+
|
|
46
|
+
◒ Loading workspaces...
|
|
47
|
+
◆ Select workspace
|
|
48
|
+
│ ● My Workspace (2 projects)
|
|
49
|
+
│ ○ Create new workspace
|
|
50
|
+
└
|
|
51
|
+
|
|
52
|
+
◇ Workspace: My Workspace
|
|
53
|
+
|
|
54
|
+
◆ Project name › my-app
|
|
55
|
+
◆ Source language (type to search) › en → English — en
|
|
56
|
+
◆ Target languages (type to search) › es → Spanish — es
|
|
57
|
+
◆ Target branches (comma-separated) › main
|
|
58
|
+
|
|
59
|
+
◒ Creating project...
|
|
60
|
+
|
|
61
|
+
◆ Step 1: Add the plugin to vite.config.ts
|
|
62
|
+
│ ...
|
|
63
|
+
◆ Step 2: Add the provider to App.tsx
|
|
64
|
+
│ ...
|
|
65
|
+
◆ Step 3: Wrap translatable strings
|
|
66
|
+
|
|
67
|
+
◆ Use Vocoder with Claude Code
|
|
68
|
+
│ claude mcp add --scope project --transport stdio \
|
|
69
|
+
│ --env VOCODER_API_KEY=vc_xxxx \
|
|
70
|
+
│ vocoder -- npx -y @vocoder/mcp
|
|
71
|
+
|
|
72
|
+
◆ You're all set.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Returning user (stored token, existing workspace):**
|
|
76
|
+
|
|
77
|
+
No browser opens. The stored auth token is verified, workspaces are listed, and the flow continues directly in the terminal.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
◆ Vocoder Setup
|
|
81
|
+
|
|
82
|
+
◒ Checking authentication...
|
|
83
|
+
◇ Authenticated as eric@example.com
|
|
84
|
+
|
|
85
|
+
◒ Loading workspaces...
|
|
86
|
+
◆ Select workspace
|
|
87
|
+
│ ● My Workspace (2 projects)
|
|
88
|
+
│ ○ Create new workspace
|
|
89
|
+
└
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**New workspace (GitHub App install):**
|
|
93
|
+
|
|
94
|
+
If creating a new workspace, a second browser step installs the GitHub App. The CLI opens the install URL and waits for the browser to redirect back to a local callback server.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
◆ Connect your new workspace to GitHub
|
|
98
|
+
│ ● Install the Vocoder GitHub App
|
|
99
|
+
│ ○ Link an existing installation
|
|
100
|
+
└
|
|
101
|
+
|
|
102
|
+
○ Opening GitHub to install the Vocoder App...
|
|
103
|
+
Complete the installation in your browser.
|
|
104
|
+
|
|
105
|
+
◇ Connected to GitHub as itsmoops
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Options:**
|
|
109
|
+
|
|
110
|
+
| Flag | Description |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `--yes` | Skip "Open in your browser?" confirmation |
|
|
113
|
+
| `--ci` | Non-interactive mode. Prints the auth URL as `VOCODER_AUTH_URL: <url>` on its own line to stdout — no browser opens, no interactive prompts, no local callback server. The CLI polls `GET /api/cli/auth/session` every 2 seconds until the browser completes authentication. Intended for automated test harnesses that drive the browser step externally. |
|
|
114
|
+
|
|
115
|
+
**Auth storage:**
|
|
116
|
+
|
|
117
|
+
After sign-in, the CLI stores a persistent auth token at `~/.config/vocoder/auth.json` (mode `0600`). The file contains:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"token": "vcu_...",
|
|
122
|
+
"apiUrl": "https://vocoder.app",
|
|
123
|
+
"userId": "...",
|
|
124
|
+
"email": "user@example.com",
|
|
125
|
+
"name": "User Name",
|
|
126
|
+
"createdAt": "2026-04-25T12:00:00.000Z"
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Tokens never expire. Use `vocoder logout` to revoke.
|
|
131
|
+
|
|
132
|
+
**Token priority:**
|
|
133
|
+
|
|
134
|
+
| Command | Token source |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `vocoder init` | `VOCODER_AUTH_TOKEN` env var → `~/.config/vocoder/auth.json` |
|
|
137
|
+
| `vocoder sync` | `VOCODER_API_KEY` env var → `.env` file |
|
|
138
|
+
| MCP tools | `VOCODER_API_KEY` env var |
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### `vocoder sync`
|
|
143
|
+
|
|
144
|
+
Submit extracted strings for translation and retrieve results.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
vocoder sync
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Reads `VOCODER_API_KEY` from environment or `.env`. Extracts `<T>` and `t()` usages from source files, submits them to Vocoder, and polls until translations are returned. Writes locale JSON files to the configured output path.
|
|
28
151
|
|
|
29
152
|
**Options:**
|
|
30
153
|
|
|
31
154
|
| Flag | Description |
|
|
32
155
|
|---|---|
|
|
33
|
-
| `--
|
|
34
|
-
| `--
|
|
35
|
-
| `--
|
|
36
|
-
|
|
156
|
+
| `--locale <code>` | Sync only this target locale |
|
|
157
|
+
| `--dry-run` | Show what would be synced without submitting |
|
|
158
|
+
| `--verbose` | Show extraction and sync details |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### `vocoder logout`
|
|
163
|
+
|
|
164
|
+
Revoke the stored auth token and clear `~/.config/vocoder/auth.json`.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
vocoder logout
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Also revokes the token server-side so it can no longer be used for API calls.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### `vocoder whoami`
|
|
175
|
+
|
|
176
|
+
Print the currently authenticated user.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
vocoder whoami
|
|
180
|
+
# Authenticated as eric@example.com (My Workspace)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
37
184
|
|
|
38
185
|
### `vocoder wrap`
|
|
39
186
|
|
|
@@ -43,7 +190,7 @@ Automatically wrap string literals in your source code with `<T>` and `t()`.
|
|
|
43
190
|
vocoder wrap
|
|
44
191
|
```
|
|
45
192
|
|
|
46
|
-
Scans
|
|
193
|
+
Scans JSX/TSX files for user-facing string literals and wraps them with the appropriate translation markers. Uses AST analysis to detect strings that are likely user-facing (not keys, classnames, or internal identifiers).
|
|
47
194
|
|
|
48
195
|
**Options:**
|
|
49
196
|
|
|
@@ -56,15 +203,35 @@ Scans your JSX/TSX files for user-facing string literals and wraps them with the
|
|
|
56
203
|
| `--confidence <level>` | Minimum confidence: `high`, `medium`, `low` (default: `high`) |
|
|
57
204
|
| `--verbose` | Detailed output |
|
|
58
205
|
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## How `init` interacts with the browser
|
|
209
|
+
|
|
210
|
+
The CLI never redirects the terminal to a URL or relies on the browser to complete setup. Instead:
|
|
211
|
+
|
|
212
|
+
1. The CLI starts a local HTTP server on a random available port.
|
|
213
|
+
2. It requests an auth session from Vocoder, passing the local port as the callback destination.
|
|
214
|
+
3. The terminal displays the verification URL and (optionally) opens it in the system browser.
|
|
215
|
+
4. After the user signs in, `vocoder.app/auth/cli` silently pings `localhost:<port>/callback?token=...` in the background.
|
|
216
|
+
5. The CLI's local server receives the token instantly and the TUI continues — no polling delay.
|
|
217
|
+
|
|
218
|
+
If the local server fails to bind (port conflict, firewall), the CLI falls back to polling `GET /api/cli/auth/session` every 2 seconds until the token is available.
|
|
219
|
+
|
|
220
|
+
The same local server pattern is used for the GitHub App install callback.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
59
224
|
## String Extraction
|
|
60
225
|
|
|
61
|
-
The `wrap` command uses Babel to parse JSX/TSX files and detect strings that are likely user-facing
|
|
226
|
+
The `wrap` command uses Babel to parse JSX/TSX files and detect strings that are likely user-facing:
|
|
227
|
+
|
|
228
|
+
- JSX text content is wrapped with `<T>`
|
|
229
|
+
- String props like `placeholder`, `title`, `aria-label` are wrapped with `t()`
|
|
230
|
+
- Non-translatable strings (class names, keys, URLs) are left alone
|
|
62
231
|
|
|
63
|
-
-
|
|
64
|
-
- String props like `placeholder`, `title`, `aria-label` (wrapped with `t()`)
|
|
65
|
-
- Non-translatable strings like class names, keys, and URLs (left alone)
|
|
232
|
+
It tracks imports from `@vocoder/react` to avoid double-wrapping strings already marked for translation.
|
|
66
233
|
|
|
67
|
-
|
|
234
|
+
---
|
|
68
235
|
|
|
69
236
|
## Git Integration
|
|
70
237
|
|
|
@@ -74,6 +241,18 @@ The CLI auto-detects the repository and branch:
|
|
|
74
241
|
- **Branch:** Checks CI environment variables first (GitHub Actions, Vercel, Netlify, etc.), then falls back to reading `.git/HEAD`
|
|
75
242
|
- **Scope path:** For monorepos, computes the relative path from the git root to the working directory
|
|
76
243
|
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Environment Variables
|
|
247
|
+
|
|
248
|
+
| Variable | Used by | Purpose |
|
|
249
|
+
|---|---|---|
|
|
250
|
+
| `VOCODER_API_KEY` | `sync`, MCP | Project API key (`vc_` prefix) |
|
|
251
|
+
| `VOCODER_AUTH_TOKEN` | `init` | Override stored user auth token (`vcu_` prefix) |
|
|
252
|
+
| `VOCODER_API_URL` | All commands | Override API base URL (default: `https://vocoder.app`) |
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
77
256
|
## License
|
|
78
257
|
|
|
79
258
|
MIT
|