@animaapp/cli 0.2.1 → 0.3.1

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,132 +1,290 @@
1
1
  # @animaapp/cli
2
2
 
3
- CLI for generating production-ready apps from prompts, URLs, or Figma designs.
3
+ Generate production-ready apps from prompts, URLs, or Figma designs — from the
4
+ command line.
4
5
 
5
- Works with any AI coding tool that can run shell commands — no MCP setup, no plugins, just `npx`.
6
+ Built for **agents**: any AI tool that can run a shell command can use it. No MCP
7
+ server to configure, no plugins — just `npx`. (Under the hood every command talks
8
+ to Anima over MCP; you don't have to set any of that up.)
6
9
 
7
- ## Quick Start
10
+ ```bash
11
+ npx @animaapp/cli login
12
+ npx @animaapp/cli create -t p2c -p "SaaS dashboard with sidebar and analytics"
13
+ ```
14
+
15
+ > Examples use `npx @animaapp/cli <command>`. If you install the package globally
16
+ > (`npm i -g @animaapp/cli`), the same commands are available as `anima <command>` —
17
+ > the shorthand used in prose below.
18
+
19
+ ---
20
+
21
+ ## Connecting an agent
22
+
23
+ Every command runs as a **scoped agent identity**: it acts only within the
24
+ workspaces and capabilities a human approved, your team can see and **revoke** it
25
+ at any time, and it expires after ~7 days. You get that identity one of two ways.
26
+
27
+ ### 1. Device login — `anima login`
28
+
29
+ The machine running the CLI needs **no browser and no human sitting at it**. The
30
+ command prints a short code and a verification URL; a human opens that URL on
31
+ _any_ device, picks the workspaces/capabilities, names the agent, and approves.
32
+ The CLI polls until approval lands, then stores the token at
33
+ `~/.config/anima/credentials.json`.
34
+
35
+ Re-running `anima login` with the **same agent name** reconnects to the same
36
+ identity (renewal is just logging in again).
37
+
38
+ **Interactive agent (Claude Code, Cursor, a dev at a terminal):**
8
39
 
9
40
  ```bash
10
- # One-time: save your tokens
11
- npx @animaapp/cli auth --token <anima-token>
12
- npx @animaapp/cli auth --figma-token <figma-token>
41
+ npx @animaapp/cli login
42
+ ```
13
43
 
14
- # Create an app from a prompt
15
- npx @animaapp/cli create -t p2c -p "SaaS dashboard with sidebar and analytics"
44
+ In a terminal it also tries to open the verification page for you (disable with
45
+ `--no-open`).
16
46
 
17
- # Clone a website
18
- npx @animaapp/cli create -t l2c -u https://stripe.com
47
+ **Headless agent with a human it can reach (chat, PR, logs):** run in JSON mode
48
+ and relay the verification step. The CLI emits a `verification_required` event to
49
+ **stderr** so your agent can surface it to its human while stdout stays clean:
19
50
 
20
- # Convert Figma to code
21
- npx @animaapp/cli codegen --file-key <figma-url> -o ./components
51
+ ```bash
52
+ npx @animaapp/cli login --json
53
+ # stderr:
54
+ # {"event":"verification_required","verificationUri":"https://.../device",
55
+ # "verificationUriComplete":"https://.../device?user_code=ABCD-1234",
56
+ # "userCode":"ABCD-1234","expiresIn":900}
57
+ ```
22
58
 
23
- # Publish to a live URL
24
- npx @animaapp/cli publish <sessionId>
59
+ The agent shows the human the URL + code, the human approves, and the same
60
+ process resolves with the final `{ "success": true, "tokenType": "agent", ... }`
61
+ on stdout.
62
+
63
+ ### 2. Pre-issued token — `ANIMA_API_TOKEN`
64
+
65
+ For CI or a fully headless agent with **no human in the loop**, skip login and
66
+ provide a token directly:
67
+
68
+ ```bash
69
+ export ANIMA_API_TOKEN=<agent-or-personal-token>
70
+ export ANIMA_TEAM_ID=<team-id> # optional
71
+ export FIGMA_TOKEN=<token> # only for codegen / f2c
25
72
  ```
26
73
 
27
- ## Authentication
74
+ Resolution priority: `ANIMA_API_TOKEN` env var → stored credentials file → error.
28
75
 
29
- Get your Anima API token at [dev.animaapp.com](https://dev.animaapp.com) > Settings > API Keys.
76
+ ### Which do I use?
77
+
78
+ | Situation | How to connect |
79
+ |-----------|----------------|
80
+ | Human at a dev machine | `anima login` (browser opens) |
81
+ | Interactive agent, human nearby | `anima login` — show the URL + code, human approves on any device |
82
+ | Headless agent, human reachable | `anima login --json` — relay the `verification_required` event, polling finishes automatically |
83
+ | Fully headless / CI, no human | set `ANIMA_API_TOKEN` — no login step |
84
+
85
+ ---
86
+
87
+ ## Quick start
30
88
 
31
89
  ```bash
32
- # Store tokens (persisted to ~/.config/anima/credentials.json)
33
- npx @animaapp/cli auth --token <anima-token>
34
- npx @animaapp/cli auth --figma-token <figma-token>
90
+ # 1. Connect (once)
91
+ npx @animaapp/cli login
92
+
93
+ # 2. Create from a prompt / URL / Figma
94
+ npx @animaapp/cli create -t p2c -p "E-commerce product page with cart"
95
+ npx @animaapp/cli create -t l2c -u https://linear.app
96
+ npx @animaapp/cli create -t f2c --file-key <key> --nodes 42:15
35
97
 
36
- # Or use environment variables
37
- export ANIMA_API_TOKEN=<token>
38
- export FIGMA_TOKEN=<token>
98
+ # 3. Publish, edit over git, or generate raw files
99
+ npx @animaapp/cli publish <sessionId>
100
+ npx @animaapp/cli get-git-token https://dev.animaapp.com/chat/<sessionId> # then: git clone <url>
101
+ npx @animaapp/cli codegen --file-key <key> --nodes 42:15 -o ./components
39
102
  ```
40
103
 
41
- Priority: env var > stored credentials file.
104
+ ---
42
105
 
43
106
  ## Commands
44
107
 
45
- ### `create` — Generate a playground (3-7 min)
108
+ ### `login` — connect this machine
46
109
 
47
110
  ```bash
48
- # Prompt to Code
49
- npx @animaapp/cli create -t p2c -p "E-commerce product page with cart"
111
+ npx @animaapp/cli login
112
+ npx @animaapp/cli login --client-name "My CI Agent" # label on the consent screen
113
+ npx @animaapp/cli login --no-open # don't auto-open the browser
114
+ npx @animaapp/cli login --print-mcp-config # also emit an MCP server config
115
+ ```
50
116
 
51
- # Link to Code (clone a website)
52
- npx @animaapp/cli create -t l2c -u https://linear.app
117
+ | Option | Description | Default |
118
+ |--------|-------------|---------|
119
+ | `--client-name <name>` | How the CLI appears on the consent screen | `Anima CLI` |
120
+ | `--no-open` | Don't try to open the verification page in a browser | — |
121
+ | `--print-mcp-config` | After login, print an MCP server config (with the token) to paste into an MCP-capable agent | off |
122
+
123
+ **MCP-capable agents:** use `login` only to obtain the token, then `--print-mcp-config`
124
+ gives you a ready-to-paste remote MCP server entry (points at `/v1/mcp` with a bearer
125
+ header). Configure that and use native MCP tools directly — no CLI in the loop. The token
126
+ is scoped and expires in ~7 days; re-run `login` to refresh it. The token is only printed
127
+ with this flag (never in plain `--json` output).
53
128
 
54
- # Figma to Code
129
+ ### `create` — generate a playground (3–7 min)
130
+
131
+ ```bash
132
+ npx @animaapp/cli create -t p2c -p "Analytics dashboard with a sidebar"
133
+ npx @animaapp/cli create -t l2c -u https://stripe.com
55
134
  npx @animaapp/cli create -t f2c --file-key <key> --nodes 42:15
56
135
  ```
57
136
 
58
- **Options** (all optional with sensible defaults):
137
+ | Option | Values | Default |
138
+ |--------|--------|---------|
139
+ | `-t, --type` | `p2c` (prompt), `l2c` (URL), `f2c` (Figma) | _required_ |
140
+ | `-p, --prompt` | free text | _(p2c)_ |
141
+ | `-u, --url` | website URL | _(l2c)_ |
142
+ | `--file-key` | Figma file key or URL | _(f2c)_ |
143
+ | `--nodes` | Figma node IDs, comma-separated | _(f2c)_ |
144
+ | `--figma-token` | Figma PAT (or `FIGMA_TOKEN` env) | _(f2c)_ |
145
+ | `--framework` | `react`, `html` | `react` |
146
+ | `--styling` | `tailwind`, `css`, `plain_css`, `css_modules`, `inline_styles`¹ | `tailwind` |
147
+ | `--language` | `typescript`, `javascript` | `typescript` (react) |
148
+ | `--ui-library` | `shadcn`, `mui`, `antd`, `clean_react` | _(none)_ |
149
+ | `--guidelines` | free text | _(p2c only)_ |
150
+
151
+ ¹ The valid styling / UI-library set depends on `--type`; the server validates and
152
+ returns a clear error for unsupported combinations.
153
+
154
+ ### `codegen` — Figma to local files (no playground)
155
+
156
+ ```bash
157
+ npx @animaapp/cli codegen --file-key <key-or-url> --nodes 42:15 -o ./components
158
+ ```
59
159
 
60
160
  | Option | Values | Default |
61
161
  |--------|--------|---------|
62
- | `--framework` | react, html | react |
63
- | `--styling` | tailwind, css, plain_css, css_modules, inline_styles | tailwind |
64
- | `--language` | typescript, javascript | typescript (when react) |
65
- | `--ui-library` | shadcn, mui, antd, clean_react | _(none)_ |
66
- | `--guidelines` | free text | _(none, p2c only)_ |
162
+ | `--file-key` | Figma file key or URL | _required_ |
163
+ | `--nodes` | Figma node IDs, comma-separated | _(or node id in the URL)_ |
164
+ | `--figma-token` | Figma PAT (or `FIGMA_TOKEN` env) | _required_ |
165
+ | `-o, --output` | output directory | `./generated` |
166
+ | `--framework` | `react`, `html` | `react` |
167
+ | `--styling` | `tailwind`, `plain_css` | `tailwind` |
168
+ | `--language` | `typescript`, `javascript` | `typescript` (react) |
169
+ | `--ui-library` | `shadcn`, `mui`, `antd`, `clean_react` | _(none)_ |
67
170
 
68
- ### `publish` — Deploy to live URL (1-3 min)
171
+ ### `publish` — deploy a session (1–3 min)
69
172
 
70
173
  ```bash
71
174
  npx @animaapp/cli publish <sessionId>
72
175
  npx @animaapp/cli publish <sessionId> --mode designSystem --package-name my-ds
73
176
  ```
74
177
 
75
- ### `codegen` — Figma to local files
178
+ | Option | Values | Default |
179
+ |--------|--------|---------|
180
+ | `--mode` | `webapp`, `designSystem` | `webapp` |
181
+ | `--package-name` | npm package name | _(designSystem)_ |
182
+ | `--package-version` | npm package version | _(designSystem)_ |
183
+
184
+ ### `get-git-token` — read/edit a playground's code over git
76
185
 
77
186
  ```bash
78
- npx @animaapp/cli codegen --file-key <key-or-url> --nodes 42:15 -o ./components
187
+ npx @animaapp/cli get-git-token https://dev.animaapp.com/chat/<sessionId>
188
+ ```
189
+
190
+ A playground **is** a git repository, and git is the only way to read or edit
191
+ its code. This command mints a short-lived access token scoped to that one
192
+ playground and prints a ready-to-use remote URL — you run git yourself:
193
+
194
+ ```bash
195
+ git clone <gitRemoteUrl> # read (and edit locally)
196
+ git push # read-write access: updates the live playground
197
+ git remote set-url origin <new url> # after expiry: re-run get-git-token, re-point the clone
198
+ ```
199
+
200
+ In `--json` mode the output is `{ gitRemoteUrl, access: "ro"|"rw", expiresAt }`.
201
+ The token expires within an hour and cannot be renewed — treat the URL as a
202
+ secret, and re-mint rather than store it.
203
+
204
+ ### `logout` — disconnect this machine
205
+
206
+ ```bash
207
+ npx @animaapp/cli logout
79
208
  ```
80
209
 
81
- Requires a Figma personal access token (stored via `auth --figma-token` or `FIGMA_TOKEN` env var).
210
+ Clears **all** stored credentials (Anima token, Figma token, agent metadata) and
211
+ removes the config directory. This only forgets the token locally — to actually
212
+ disable an agent, revoke it from your team settings.
82
213
 
83
- ### `download` — Download playground project
214
+ ### `config` — store CLI preferences
215
+
216
+ Persist non-secret settings to `~/.config/anima/config.json` so you don't have to
217
+ pass flags every time — handy for pointing at a local API during development.
218
+ Kept separate from credentials, so `logout` never touches it.
84
219
 
85
220
  ```bash
86
- npx @animaapp/cli download https://dev.animaapp.com/chat/<sessionId> -o ./my-project
221
+ npx @animaapp/cli config set api-url http://localhost:3789
222
+ npx @animaapp/cli config get api-url
223
+ npx @animaapp/cli config list
224
+ npx @animaapp/cli config unset api-url
87
225
  ```
88
226
 
89
- ### `auth` — Manage credentials
227
+ The API URL resolves in this order: **`--api-url` flag → `ANIMA_API_URL` env →
228
+ `config.json` → default (`https://public-api.animaapp.com`).**
229
+
230
+ ### `auth` — inspect or manage credentials
90
231
 
91
232
  ```bash
92
- npx @animaapp/cli auth --token <T> # Save Anima token
93
- npx @animaapp/cli auth --figma-token <T> # Save Figma token
94
- npx @animaapp/cli auth --status # Check what's configured
95
- npx @animaapp/cli auth --logout # Clear all credentials
233
+ npx @animaapp/cli auth --status # token type + expiry
234
+ npx @animaapp/cli auth --figma-token <T> # save a Figma token for codegen / f2c
235
+ npx @animaapp/cli auth --logout # alias for `anima logout`
96
236
  ```
97
237
 
98
- ## Output Modes
238
+ ---
99
239
 
100
- - **Terminal (TTY):** Colored text with spinner and progress
101
- - **Piped (AI tools):** Single JSON object to stdout
240
+ ## Global flags
241
+
242
+ Available on the network commands (`login`, `create`, `codegen`, `publish`,
243
+ `get-git-token`):
244
+
245
+ | Flag | Description | Default |
246
+ |------|-------------|---------|
247
+ | `--json` | Emit a single JSON object to stdout (for agents) | off (pretty in a TTY) |
248
+ | `--verbose` | Stream progress to stderr in JSON mode¹ | off |
249
+ | `--api-url <url>` | API base URL (point at local/staging)³ | `https://public-api.animaapp.com` |
250
+ | `--log-file <path>` | Append a JSON debug log of each step to a file | off |
251
+ | `--timeout <ms>` | Request timeout² | `600000` (10 min) |
252
+
253
+ ¹ `--verbose` applies to `create` / `codegen` / `publish` / `get-git-token`.
254
+ ² `--timeout` applies to `create` / `codegen`. Don't lower it — generation takes
255
+ minutes.
256
+ ³ Falls back to `ANIMA_API_URL`, then `anima config set api-url`, then the
257
+ default. Set it once with `config` instead of passing `--api-url` every time.
258
+
259
+ ---
260
+
261
+ ## Output modes
262
+
263
+ - **Terminal (TTY):** colored text, spinner, elapsed time.
264
+ - **Piped / `--json`:** a single JSON object on **stdout**; progress and the
265
+ device-flow `verification_required` event go to **stderr**, so stdout is always
266
+ a clean, parseable result.
102
267
 
103
268
  ```bash
104
- # AI tool usage — parse JSON output
105
269
  npx @animaapp/cli create -t p2c -p "dashboard" --json 2>/dev/null | jq .playgroundUrl
106
270
  ```
107
271
 
108
- Progress is streamed to stderr with `--verbose`.
272
+ ---
109
273
 
110
- ## Timing
274
+ ## Debugging
111
275
 
112
- | Command | Duration |
113
- |---------|----------|
114
- | `create` | 3-7 minutes |
115
- | `publish` | 1-3 minutes |
116
- | `codegen` | 2-5 minutes |
117
- | `download` | seconds |
276
+ **`--log-file`** (or the `ANIMA_LOG_FILE` env var) writes one JSON line per step —
277
+ HTTP requests/responses, MCP connect and tool calls, and errors — to a file you
278
+ can inspect or share. Tokens and auth headers are redacted.
118
279
 
119
- The `--timeout` default is 600,000ms (10 min). Do not reduce it.
280
+ ```bash
281
+ npx @animaapp/cli login --log-file ./anima-debug.log
282
+ ```
120
283
 
121
- ## Exit Codes
284
+ **`HTTP 404` on `login`** means the API at `--api-url` doesn't have the device
285
+ grant deployed. Point at an API that does (`--api-url`) or use `ANIMA_API_TOKEN`.
122
286
 
123
- | Code | Meaning |
124
- |------|---------|
125
- | 0 | Success |
126
- | 1 | API error |
127
- | 2 | Auth error |
128
- | 3 | Validation error |
129
- | 4 | Timeout |
287
+ ---
130
288
 
131
289
  ## License
132
290