@model-go/cli 0.1.4 → 0.1.5

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
@@ -44,7 +44,7 @@ The CLI talks to a named environment. Two are built in:
44
44
  | Env | Base URL |
45
45
  | ------ | ---------------------------- |
46
46
  | `cn` | `https://api.modelgo.com` |
47
- | `intl` | `https://api.modelgo.global` |
47
+ | `intl` | `https://api.modelgo.ai` |
48
48
 
49
49
  The active environment defaults to `cn`. Switch it, or register your own:
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@model-go/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The official CLI for modelgo. Pairs with AI agent skills so AI agents can operate modelgo on your behalf.",
5
5
  "bin": {
6
6
  "modelgo": "scripts/run.js"
@@ -34,6 +34,15 @@ const messages = {
34
34
  done: "安装完成!\n试试跟你的 AI 工具(Claude Code、Codex 等)说:\"用 modelgo 跟我打个招呼\"",
35
35
  cancelled: "安装已取消",
36
36
  nonTtyHint: "非交互模式,已完成 npm 全局安装 + skills 安装。",
37
+ envPrompt: "请选择环境 / Select environment",
38
+ envCN: "国内(api.modelgo.com)",
39
+ envIntl: "国际(api.modelgo.ai)",
40
+ envDone: "已切换到 %s 环境",
41
+ envFail: "环境切换失败,可稍后运行: modelgo env use %s",
42
+ authPrompt: "现在登录 modelgo 吗?(将通过浏览器授权,也可稍后再登录)",
43
+ authDone: "登录成功",
44
+ authSkip: "已跳过登录。稍后运行: modelgo auth login",
45
+ authFail: "登录失败,可稍后运行: modelgo auth login",
37
46
  },
38
47
  en: {
39
48
  setup: "Setting up modelgo CLI...",
@@ -49,6 +58,15 @@ const messages = {
49
58
  done: "You are all set!\nTry asking your AI tool (Claude Code, Codex, etc.): \"Have modelgo say hello to me\"",
50
59
  cancelled: "Installation cancelled",
51
60
  nonTtyHint: "Non-interactive mode. Completed global install + skills install.",
61
+ envPrompt: "Select environment",
62
+ envCN: "China (api.modelgo.com)",
63
+ envIntl: "International (api.modelgo.ai)",
64
+ envDone: "Switched to %s environment",
65
+ envFail: "Failed to switch env. Run later: modelgo env use %s",
66
+ authPrompt: "Log in to modelgo now? (browser authorization; you can also log in later)",
67
+ authDone: "Logged in",
68
+ authSkip: "Skipped login. Run later: modelgo auth login",
69
+ authFail: "Login failed. Run later: modelgo auth login",
52
70
  },
53
71
  };
54
72
 
@@ -200,6 +218,42 @@ async function stepInstallSkills(msg, isInteractive) {
200
218
  }
201
219
  }
202
220
 
221
+ async function stepSelectEnv(msg) {
222
+ const env = handleCancel(
223
+ await p.select({
224
+ message: msg.envPrompt,
225
+ options: [
226
+ { value: "cn", label: msg.envCN },
227
+ { value: "intl", label: msg.envIntl },
228
+ ],
229
+ }),
230
+ msg
231
+ );
232
+ try {
233
+ // `modelgo` is on PATH after the global install in stepInstallGlobally.
234
+ runSilent("modelgo", ["env", "use", env], { timeout: 15000 });
235
+ p.log.success(fmt(msg.envDone, env));
236
+ } catch (_) {
237
+ p.log.warn(fmt(msg.envFail, env));
238
+ }
239
+ }
240
+
241
+ async function stepAuthLogin(msg) {
242
+ const wantLogin = handleCancel(await p.confirm({ message: msg.authPrompt }), msg);
243
+ if (!wantLogin) {
244
+ p.log.info(msg.authSkip);
245
+ return;
246
+ }
247
+ try {
248
+ // `auth login` prints a verification URL and blocks polling until the user
249
+ // approves in the browser — inherit stdio so the URL and progress show.
250
+ execCmd("modelgo", ["auth", "login"], { stdio: "inherit" });
251
+ p.log.success(msg.authDone);
252
+ } catch (_) {
253
+ p.log.warn(msg.authFail);
254
+ }
255
+ }
256
+
203
257
  // ---------------------------------------------------------------------------
204
258
  // Main
205
259
  // ---------------------------------------------------------------------------
@@ -213,6 +267,8 @@ async function main() {
213
267
  p.intro(msg.setup);
214
268
  await stepInstallGlobally(msg, isInteractive);
215
269
  await stepInstallSkills(msg, isInteractive);
270
+ await stepSelectEnv(msg);
271
+ await stepAuthLogin(msg);
216
272
  p.outro(msg.done);
217
273
  } else {
218
274
  console.log(msg.setup);