You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(cli): add first-run onboarding for missing api_url
Any command resolving an unconfigured API URL now triggers an inline TTY
prompt that persists to config.json; non-TTY contexts return a structured
JSON error with code config.missing.api_url so CI / AI agents fail cleanly.
When any command resolves the API URL and finds none from flag, env, or `~/.config/mxs/config.json`, the CLI enters an inline onboarding prompt:
110
+
111
+
```
112
+
$ mxs post list
113
+
👋 mx-space CLI — first run
114
+
115
+
? API URL of your mx-core server: https://blog.example.com
116
+
🔍 probing… API v2 (prefix /api/v2)
117
+
✅ saved to ~/.config/mxs/config.json
118
+
119
+
You are not logged in yet. Run `mxs auth login` to authenticate.
120
+
```
121
+
122
+
Rules:
123
+
124
+
- The prompt only runs when stdin is a TTY. In non-TTY contexts (CI, piped input, `--json` mode in scripts), the CLI exits with code 5 and the JSON error:
125
+
126
+
```json
127
+
{
128
+
"ok": false,
129
+
"code": "config.missing.api_url",
130
+
"message": "API URL is not configured",
131
+
"hint": "set MXS_API_URL or pass --api-url <url>, or run `mxs auth login` in an interactive shell"
132
+
}
133
+
```
134
+
135
+
- The URL is normalised: trailing slash stripped, scheme required (`https://` assumed if absent and host is not `localhost`).
136
+
- After capture, the CLI immediately runs the prefix-detection probe (§8.3) and persists `api_url` / `api_base` / `auth_base` / `api_version` to `config.json`.
137
+
- If the user then needs auth, they are reminded to run `mxs auth login`; the original command is **not** auto-continued (we don't surprise the user by running their command against an unauthenticated server in onboarding).
138
+
-`mxs auth login` itself follows the same onboarding when missing api_url — it asks once, persists, then proceeds with the device flow.
106
139
107
140
### 4.2 Auth
108
141
@@ -505,7 +538,7 @@ The route resolves to:
505
538
506
539
```
507
540
$ mxs auth login
508
-
? API URL: https://blog.example.com
541
+
? API URL: https://blog.example.com # only asked if not yet configured (§4.1.1)
0 commit comments