@wevion/cli 1.0.2 → 1.0.3

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,46 +1,119 @@
1
- # @wevion/cli — Wevion CLI
1
+ # @wevion/cli
2
2
 
3
- Generic, spec-driven command-line interface for the Wevion API. Every command
4
- is derived at runtime from the public OpenAPI spec no generated code. CI
5
- refreshes the bundled `openapi.json` snapshot on every production release.
6
- The CLI exposes operations that the public spec marks as `apiKeyAuth`.
3
+ Command-line access to the [Wevion](https://wevion.ai) API. Manage ad accounts,
4
+ campaigns, insights, creatives and everything else the API exposesstraight
5
+ from your terminal or a script. Every API-key-auth endpoint in the public spec is
6
+ a command, and successful responses come back as JSON on stdout, so it's easy to
7
+ pipe into `jq` or a script.
8
+
9
+ Requires **Node.js 22+**.
7
10
 
8
11
  ## Install
9
12
 
10
13
  ```bash
11
- npm i -g @wevion/cli # or: npx @wevion/cli list
14
+ npm install -g @wevion/cli
15
+ # or run without installing:
16
+ npx @wevion/cli list
17
+ ```
18
+
19
+ ## Authenticate
20
+
21
+ You need a Wevion **API key** (create one in the Wevion app under
22
+ Settings → API keys). Then log in once:
23
+
24
+ ```bash
25
+ wevion login # prompts for the key and stores it securely
26
+ ```
27
+
28
+ The key is saved under `$XDG_CONFIG_HOME/wevion/config.json` or
29
+ `~/.config/wevion/config.json` (on Windows: `%APPDATA%\Wevion\config.json`;
30
+ readable only by you). In CI or scripts, skip the prompt with an env var instead:
31
+
32
+ ```bash
33
+ export WEVION_API_KEY=sk_live_xxx
34
+ ```
35
+
36
+ Log out (delete the stored key) with `wevion logout`.
37
+
38
+ ## Usage
39
+
40
+ ```bash
41
+ wevion <command> [--flag value ...]
42
+ ```
43
+
44
+ Discover what's available:
45
+
46
+ ```bash
47
+ wevion list # all commands, grouped by area (ad-accounts, campaigns, …)
48
+ wevion help <command> # flags, required params and the underlying endpoint
12
49
  ```
13
50
 
14
- ## Use
51
+ Examples:
15
52
 
16
53
  ```bash
17
- wevion login # prompts for the API key, saves it
18
- printf '%s' "$WEVION_API_KEY" | wevion login # non-interactive; avoids shell history
19
- wevion logout # forget the saved key
20
- wevion list # list all commands, grouped by tag
21
- wevion help <command> # show a command's flags
54
+ # List your ad accounts (paginated), filtered by name
22
55
  wevion get-api-v1-ad-accounts --limit 10 --search brand
56
+
57
+ # Send a request body with individual flags…
23
58
  wevion post-api-v1-ad-accounts-assign-all --connected true
59
+
60
+ # …or pass the whole JSON body at once
24
61
  wevion post-api-v1-ad-accounts-assign-all --json '{"connected":true}'
62
+
63
+ # Pipe JSON output into jq
64
+ wevion get-api-v1-ad-accounts --limit 50 | jq '.data[].name'
65
+ ```
66
+
67
+ Each command mirrors one API endpoint: path, query and supported header
68
+ parameters become `--flags` using their exact OpenAPI names, and request-body
69
+ fields are `--flags` too (use `--json '<raw>'` to send a body verbatim).
70
+ `wevion help <command>` shows exactly which are required.
71
+
72
+ ## For LLMs & agents
73
+
74
+ Driving the CLI from an agent (e.g. Claude Code) with no prior Wevion knowledge?
75
+ Start with one command — a self-contained primer covering auth, how commands map
76
+ to endpoints, parameter rules, and the output/exit-code contract:
77
+
78
+ ```bash
79
+ wevion agent
25
80
  ```
26
81
 
27
- Credentials & base URL are resolved in this order:
82
+ Then discover and inspect commands as structured JSON:
28
83
 
29
- - API key: `WEVION_API_KEY` env → `wevion login` config (`~/.config/wevion/config.json`).
30
- - Base URL: `--base-url` `WEVION_BASE_URL` env config → default `https://api.wevion.ai`
31
- (stage: `https://api-stage.wevion.ai`).
84
+ ```bash
85
+ wevion list --json # every command: command, method, path, params, body
86
+ wevion help <command> --json # one command's exact parameter/body schema
87
+ ```
88
+
89
+ ## Configuration
90
+
91
+ Resolved in this order (first wins):
92
+
93
+ | Setting | Sources |
94
+ | -------- | --------------------------------------------------------------------- |
95
+ | API key | `WEVION_API_KEY` env → stored login (`wevion login`) |
96
+ | Base URL | `--base-url` → `WEVION_BASE_URL` env → stored login config → default `https://api.wevion.ai` |
97
+
98
+ To target staging, point the base URL at `https://api-stage.wevion.ai`:
99
+
100
+ ```bash
101
+ wevion --base-url https://api-stage.wevion.ai get-api-v1-ad-accounts
102
+ # or: export WEVION_BASE_URL=https://api-stage.wevion.ai
103
+ ```
32
104
 
33
- ## Release
105
+ ## Exit codes
34
106
 
35
- The `publish-cli` job in `.github/workflows/deploy.yml` runs on every push to
36
- `main` that touches `apps/backend/**` or `packages/cli/**`. It regenerates the
37
- snapshot from the released source (`dump:openapi`), so the published CLI always
38
- matches the API at that commit, then `npm publish`es.
107
+ `0` on success, `1` on an API/network/runtime error (HTTP errors print the
108
+ request line and response body to stderr),
109
+ `2` on a usage error (unknown command, missing required flag, no API key),
110
+ `3` when the CLI is too old for the API — run `npm i -g @wevion/cli@latest`.
39
111
 
40
- Version: `MAJOR.MINOR` comes from this `package.json` (human-owned); the patch
41
- is the GitHub Actions run number, so every release is unique and monotonic
42
- (e.g. `1.0.523`). Bump the minor here when there's a meaningful change.
112
+ ---
43
113
 
44
- Requires the `NPM_TOKEN` repository secret (automation token with publish
45
- rights for the `@wevion` scope). If the bundled snapshot is ever absent the CLI
46
- falls back to fetching `${baseUrl}/docs/json`.
114
+ The command set is derived from the Wevion API's **live** OpenAPI spec and
115
+ cached briefly. Offline or non-OK spec fetches fall back to the last valid cache
116
+ or bundled snapshot, so commands normally track the current API while still
117
+ working without the network. The CLI checks npm for a newer version and prints an
118
+ upgrade hint when one exists — set `NO_UPDATE_NOTIFIER=1` to silence it. Full
119
+ endpoint details: [api.wevion.ai/docs](https://api.wevion.ai/docs).