@animaapp/cli 0.2.0 → 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 +225 -68
- package/dist/index.js +615 -491
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,134 +1,291 @@
|
|
|
1
1
|
# @animaapp/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generate production-ready apps from prompts, URLs, or Figma designs — from the
|
|
4
|
+
command line.
|
|
4
5
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
npx @animaapp/cli auth --figma-token <figma-token>
|
|
41
|
+
npx @animaapp/cli login
|
|
42
|
+
```
|
|
13
43
|
|
|
14
|
-
|
|
15
|
-
|
|
44
|
+
In a terminal it also tries to open the verification page for you (disable with
|
|
45
|
+
`--no-open`).
|
|
16
46
|
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
50
|
+
|
|
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
|
+
```
|
|
19
58
|
|
|
20
|
-
|
|
21
|
-
|
|
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.
|
|
22
62
|
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
74
|
+
Resolution priority: `ANIMA_API_TOKEN` env var → stored credentials file → error.
|
|
75
|
+
|
|
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 |
|
|
28
84
|
|
|
29
|
-
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
30
88
|
|
|
31
89
|
```bash
|
|
32
|
-
#
|
|
33
|
-
npx @animaapp/cli
|
|
34
|
-
npx @animaapp/cli auth --figma-token <figma-token>
|
|
90
|
+
# 1. Connect (once)
|
|
91
|
+
npx @animaapp/cli login
|
|
35
92
|
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
97
|
+
|
|
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
|
-
|
|
104
|
+
---
|
|
42
105
|
|
|
43
106
|
## Commands
|
|
44
107
|
|
|
45
|
-
### `
|
|
108
|
+
### `login` — connect this machine
|
|
46
109
|
|
|
47
110
|
```bash
|
|
48
|
-
|
|
49
|
-
npx @animaapp/cli
|
|
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
|
-
|
|
52
|
-
|
|
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).
|
|
128
|
+
|
|
129
|
+
### `create` — generate a playground (3–7 min)
|
|
53
130
|
|
|
54
|
-
|
|
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
|
-
|
|
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)
|
|
59
155
|
|
|
60
|
-
|
|
156
|
+
```bash
|
|
157
|
+
npx @animaapp/cli codegen --file-key <key-or-url> --nodes 42:15 -o ./components
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
| Option | Values | Default |
|
|
161
|
+
|--------|--------|---------|
|
|
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)_ |
|
|
170
|
+
|
|
171
|
+
### `publish` — deploy a session (1–3 min)
|
|
61
172
|
|
|
62
173
|
```bash
|
|
63
174
|
npx @animaapp/cli publish <sessionId>
|
|
64
175
|
npx @animaapp/cli publish <sessionId> --mode designSystem --package-name my-ds
|
|
65
176
|
```
|
|
66
177
|
|
|
67
|
-
|
|
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
|
|
68
185
|
|
|
69
186
|
```bash
|
|
70
|
-
npx @animaapp/cli
|
|
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
|
|
71
198
|
```
|
|
72
199
|
|
|
73
|
-
|
|
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.
|
|
74
203
|
|
|
75
|
-
### `
|
|
204
|
+
### `logout` — disconnect this machine
|
|
76
205
|
|
|
77
206
|
```bash
|
|
78
|
-
npx @animaapp/cli
|
|
207
|
+
npx @animaapp/cli logout
|
|
79
208
|
```
|
|
80
209
|
|
|
81
|
-
|
|
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.
|
|
213
|
+
|
|
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.
|
|
82
219
|
|
|
83
220
|
```bash
|
|
84
|
-
npx @animaapp/cli
|
|
85
|
-
npx @animaapp/cli
|
|
86
|
-
npx @animaapp/cli
|
|
87
|
-
npx @animaapp/cli
|
|
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
|
|
88
225
|
```
|
|
89
226
|
|
|
90
|
-
|
|
227
|
+
The API URL resolves in this order: **`--api-url` flag → `ANIMA_API_URL` env →
|
|
228
|
+
`config.json` → default (`https://public-api.animaapp.com`).**
|
|
91
229
|
|
|
92
|
-
|
|
93
|
-
- **Piped (AI tools):** Single JSON object to stdout
|
|
230
|
+
### `auth` — inspect or manage credentials
|
|
94
231
|
|
|
95
232
|
```bash
|
|
96
|
-
|
|
97
|
-
npx @animaapp/cli
|
|
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`
|
|
98
236
|
```
|
|
99
237
|
|
|
100
|
-
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Global flags
|
|
101
241
|
|
|
102
|
-
|
|
242
|
+
Available on the network commands (`login`, `create`, `codegen`, `publish`,
|
|
243
|
+
`get-git-token`):
|
|
103
244
|
|
|
104
|
-
|
|
|
105
|
-
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
|
|
|
109
|
-
|
|
|
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) |
|
|
110
252
|
|
|
111
|
-
|
|
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.
|
|
112
258
|
|
|
113
|
-
|
|
259
|
+
---
|
|
114
260
|
|
|
115
|
-
|
|
116
|
-
|------|---------|
|
|
117
|
-
| 0 | Success |
|
|
118
|
-
| 1 | API error |
|
|
119
|
-
| 2 | Auth error |
|
|
120
|
-
| 3 | Validation error |
|
|
121
|
-
| 4 | Timeout |
|
|
261
|
+
## Output modes
|
|
122
262
|
|
|
123
|
-
|
|
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.
|
|
124
267
|
|
|
125
268
|
```bash
|
|
126
|
-
|
|
127
|
-
npm run build # tsup → dist/index.js
|
|
128
|
-
npm test # vitest (35 tests)
|
|
129
|
-
npm run typecheck # tsc --noEmit
|
|
269
|
+
npx @animaapp/cli create -t p2c -p "dashboard" --json 2>/dev/null | jq .playgroundUrl
|
|
130
270
|
```
|
|
131
271
|
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Debugging
|
|
275
|
+
|
|
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.
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
npx @animaapp/cli login --log-file ./anima-debug.log
|
|
282
|
+
```
|
|
283
|
+
|
|
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`.
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
132
289
|
## License
|
|
133
290
|
|
|
134
291
|
MIT
|