@model-go/cli 0.1.1 → 0.1.2

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  The official CLI for modelgo. Pairs with AI agent skills (Claude Code, Codex, Gemini CLI, etc.) so AI agents can operate modelgo on your behalf.
4
4
 
5
- > **v0 framework stage.** Business APIs are not wired up yet; the only command is `hello` (a demo to verify the install pipeline).
5
+ > **v0 framework stage.** The demo `hello` command and device-flow `auth` commands are available. API key, usage, and model gateway commands are not wired up yet.
6
6
 
7
7
  ## Install
8
8
 
@@ -12,23 +12,81 @@ npx @model-go/cli@latest install
12
12
 
13
13
  This runs an interactive wizard that:
14
14
 
15
- 1. Installs `@model-go/cli` globally via npm (which downloads the Go binary from GitHub Releases).
15
+ 1. Installs `@model-go/cli` globally via npm (which downloads the Go binary from GitHub Releases as `modelgo`).
16
16
  2. Distributes `modelgo-*` skills to every AI agent installed on your machine (Claude Code, Trae, Trae CN, and other agents in the [skills](https://www.npmjs.com/package/skills) ecosystem).
17
17
 
18
18
  After install, restart your AI agent (open a new chat / session) and try:
19
19
 
20
- > "Have modelgo-cli say hello to me."
20
+ > "Have modelgo say hello to me."
21
21
 
22
- Your AI should find the `modelgo-hello` skill and run `modelgo-cli hello`.
22
+ Your AI should find the `modelgo-hello` skill and run `modelgo hello`.
23
23
 
24
24
  ## Direct commands
25
25
 
26
26
  ```bash
27
- modelgo-cli --version
28
- modelgo-cli hello [--name NAME]
29
- modelgo-cli --help
27
+ modelgo --version
28
+ modelgo auth login
29
+ modelgo auth status
30
+ modelgo auth logout
31
+ modelgo hello [--name NAME]
32
+ modelgo --help
30
33
  ```
31
34
 
35
+ `modelgo auth login` without `--no-wait` is a blocking command: it prints the
36
+ authorization URL, then keeps polling until the browser approval completes or
37
+ the device code expires.
38
+
39
+ ### Environments
40
+
41
+ The CLI talks to a named environment. Two are built in:
42
+
43
+ | Env | Base URL |
44
+ | ------ | ---------------------------- |
45
+ | `cn` | `https://api.modelgo.com` |
46
+ | `intl` | `https://api.modelgo.global` |
47
+
48
+ The active environment defaults to `cn`. Switch it, or register your own:
49
+
50
+ ```bash
51
+ modelgo env list # show built-in + custom envs (active marked with *)
52
+ modelgo env current # print the active env
53
+ modelgo env use intl # switch the active env
54
+ modelgo env add <name> --base-url https://... # register or override an env URL
55
+ modelgo env remove <name> # remove a custom env or override
56
+ ```
57
+
58
+ Environment definitions and the active selection live in `~/.modelgo/config.json`.
59
+ Credentials are stored per-env in `~/.modelgo/auth.json`, so switching environments
60
+ preserves each login. There are no environment variables to set.
61
+
62
+ Auth commands operate on the active env; pass `--env <name>` to target a different one:
63
+
64
+ ```bash
65
+ modelgo auth login --env intl
66
+ modelgo auth status --env intl
67
+ modelgo auth logout --all # clear every env
68
+ ```
69
+
70
+ ### Non-streaming agent flows
71
+
72
+ For AI-agent harnesses that cannot stream intermediate output to the user, use:
73
+
74
+ ```bash
75
+ modelgo auth login --no-wait --json
76
+ modelgo auth login --device-code <DEVICE_CODE>
77
+ ```
78
+
79
+ Do not show the URL and then immediately block on `--device-code` in the same
80
+ turn. In final-message-only harnesses, that pattern prevents the user from ever
81
+ seeing the URL before the agent starts waiting.
82
+
83
+ > **`--json` emits newline-delimited JSON (NDJSON).** In the default waiting
84
+ > flow (`modelgo auth login --json` without `--no-wait`), stdout receives two
85
+ > JSON objects: first the device-code object (with `verification_url`), then
86
+ > the authenticated object once approved. Parse line by line — don't
87
+ > `JSON.parse` the whole stream. With `--no-wait`, only the device-code object
88
+ > is printed.
89
+
32
90
  ## Upgrade
33
91
 
34
92
  Re-run the installer; it detects an out-of-date install and upgrades in place:
package/checksums.txt CHANGED
@@ -1,6 +1,6 @@
1
- 769fac4456815aeabc8517827df7d174b650e2d6d127eb7805aec3477179cd23 modelgo-cli-0.1.1-darwin-amd64.tar.gz
2
- 5720ad47e70b7ad5a99688f47c7c345ee8a3e6306fbea7510276398011815801 modelgo-cli-0.1.1-darwin-arm64.tar.gz
3
- f4f46f11be9a485e8e12e26bb1c8f9b67c02d67466b46c96be32a4557c951ca4 modelgo-cli-0.1.1-linux-amd64.tar.gz
4
- 7482afffe11cf8bf3c8798d77166ce5a6c0b79acdd53c030712b9b4fc69a0521 modelgo-cli-0.1.1-linux-arm64.tar.gz
5
- c86b6da335e95354b0cfe2b8bc11cd4b2fbeff5a32231c9fdef0a55440659bf1 modelgo-cli-0.1.1-windows-amd64.zip
6
- 1f101449e834ff876ccc418d246e8b06b2a21031904d8c638066e0d6e1c52eb2 modelgo-cli-0.1.1-windows-arm64.zip
1
+ 818fc80cdbb471fe9abd2373c30795f4a138f4be4c812cdb3d25148b71a131ed modelgo-0.1.2-darwin-amd64.tar.gz
2
+ cb981e35d3652d2b0e3d50c0f0eadfd8ee1497887d1e529f7630581c8cfb29e5 modelgo-0.1.2-darwin-arm64.tar.gz
3
+ 974822455dd0b423e91a096b00fb6d28750f42ceb982185a434d14d6396974dd modelgo-0.1.2-linux-amd64.tar.gz
4
+ f388c0e1d23df86a24650b7bcbd2424b5a232b81a0a3f7bb426ad31781fa1217 modelgo-0.1.2-linux-arm64.tar.gz
5
+ 5d96a2409132650dd4a98dcc8d1d0f44d519fde5de816550e53db7aba6ae629a modelgo-0.1.2-windows-amd64.zip
6
+ ea37a1341c87afd2f3cddfe5027a3e8203532cf5432b329c6caa8b4ce506cc05 modelgo-0.1.2-windows-arm64.zip
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@model-go/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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
- "modelgo-cli": "scripts/run.js"
6
+ "modelgo": "scripts/run.js"
7
7
  },
8
8
  "scripts": {
9
9
  "postinstall": "node scripts/install.js",
@@ -7,6 +7,11 @@ const p = require("@clack/prompts");
7
7
  const { semverLessThan } = require("./install.js");
8
8
 
9
9
  const PKG = "@model-go/cli";
10
+ // PKG_VERSION is the version of the wizard CURRENTLY EXECUTING. The wizard
11
+ // pins step1's `npm install -g` to this exact version so that
12
+ // `npx @model-go/cli@rc install` installs the rc version globally,
13
+ // not whatever the @latest dist-tag happens to resolve to.
14
+ const PKG_VERSION = require("../package.json").version;
10
15
  const SKILLS_REPO = "modelgo/modelgo-cli";
11
16
  const isWindows = process.platform === "win32";
12
17
 
@@ -26,7 +31,7 @@ const messages = {
26
31
  step2Spinner: "正在安装 Skills...",
27
32
  step2Done: "Skills 已安装",
28
33
  step2Fail: "Skills 安装失败。运行以下命令重试: npx skills add %s -y -g",
29
- done: "安装完成!\n试试跟你的 AI 工具(Claude Code、Codex 等)说:\"用 modelgo-cli 跟我打个招呼\"",
34
+ done: "安装完成!\n试试跟你的 AI 工具(Claude Code、Codex 等)说:\"用 modelgo 跟我打个招呼\"",
30
35
  cancelled: "安装已取消",
31
36
  nonTtyHint: "非交互模式,已完成 npm 全局安装 + skills 安装。",
32
37
  },
@@ -41,7 +46,7 @@ const messages = {
41
46
  step2Spinner: "Installing skills...",
42
47
  step2Done: "Skills installed",
43
48
  step2Fail: "Failed to install skills. Run manually: npx skills add %s -y -g",
44
- done: "You are all set!\nTry asking your AI tool (Claude Code, Codex, etc.): \"Have modelgo-cli say hello to me\"",
49
+ done: "You are all set!\nTry asking your AI tool (Claude Code, Codex, etc.): \"Have modelgo say hello to me\"",
45
50
  cancelled: "Installation cancelled",
46
51
  nonTtyHint: "Non-interactive mode. Completed global install + skills install.",
47
52
  },
@@ -78,16 +83,6 @@ function fmt(template, ...values) {
78
83
  return template.replace(/%s/g, () => values[i++] ?? "");
79
84
  }
80
85
 
81
- function getLatestVersion() {
82
- try {
83
- const out = runSilent("npm", ["view", PKG, "version"], { timeout: 15000 });
84
- const ver = out.toString().trim();
85
- return /^\d+\.\d+\.\d+/.test(ver) ? ver : null;
86
- } catch (_) {
87
- return null;
88
- }
89
- }
90
-
91
86
  function getGloballyInstalledVersion() {
92
87
  try {
93
88
  const out = runSilent("npm", ["list", "-g", PKG], { timeout: 15000 });
@@ -162,8 +157,7 @@ function reportFail(isInteractive, spinner, message, err) {
162
157
 
163
158
  async function stepInstallGlobally(msg, isInteractive) {
164
159
  const installedVer = getGloballyInstalledVersion();
165
- const latestVer = getLatestVersion();
166
- const needsUpgrade = installedVer && latestVer && semverLessThan(installedVer, latestVer);
160
+ const needsUpgrade = installedVer && semverLessThan(installedVer, PKG_VERSION);
167
161
 
168
162
  if (installedVer && !needsUpgrade) {
169
163
  const skipMsg = fmt(msg.step1Skip, installedVer);
@@ -173,13 +167,16 @@ async function stepInstallGlobally(msg, isInteractive) {
173
167
  }
174
168
 
175
169
  const startMsg = needsUpgrade
176
- ? fmt(msg.step1Upgrade, PKG, installedVer, latestVer)
170
+ ? fmt(msg.step1Upgrade, PKG, installedVer, PKG_VERSION)
177
171
  : fmt(msg.step1, PKG);
178
- const doneMsg = needsUpgrade ? fmt(msg.step1Upgraded, latestVer) : msg.step1Done;
172
+ const doneMsg = needsUpgrade ? fmt(msg.step1Upgraded, PKG_VERSION) : msg.step1Done;
179
173
 
180
174
  const s = reportStart(isInteractive, startMsg);
181
175
  try {
182
- await runSilentAsync("npm", ["install", "-g", PKG], { timeout: 120000 });
176
+ // Pin to PKG_VERSION (the wizard's own version) so that
177
+ // `npx @model-go/cli@rc install` installs the rc version globally,
178
+ // not whatever the @latest dist-tag currently resolves to.
179
+ await runSilentAsync("npm", ["install", "-g", `${PKG}@${PKG_VERSION}`], { timeout: 120000 });
183
180
  reportStop(isInteractive, s, doneMsg);
184
181
  } catch (err) {
185
182
  reportFail(isInteractive, s, fmt(msg.step1Fail, PKG), err);
@@ -9,7 +9,7 @@ const crypto = require("crypto");
9
9
 
10
10
  const VERSION = require("../package.json").version;
11
11
  const REPO = "modelgo/modelgo-cli";
12
- const NAME = "modelgo-cli";
12
+ const NAME = "modelgo";
13
13
  const DEFAULT_MIRROR_HOST = "https://registry.npmmirror.com";
14
14
 
15
15
  // Allowlist gates the initial request host. curl --location follows redirects
@@ -224,7 +224,7 @@ function install() {
224
224
  const downloadUrls = [GITHUB_URL, ...mirrorUrls];
225
225
 
226
226
  fs.mkdirSync(binDir, { recursive: true });
227
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "modelgo-cli-"));
227
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "modelgo-"));
228
228
  const archivePath = path.join(tmpDir, archiveName);
229
229
 
230
230
  try {
package/scripts/run.js CHANGED
@@ -3,8 +3,8 @@
3
3
  // SPDX-License-Identifier: MIT
4
4
  //
5
5
  // npm bin entrypoint. Routes:
6
- // - `modelgo-cli install` → install-wizard.js (interactive setup)
7
- // - everything else → exec bin/modelgo-cli (the downloaded Go binary)
6
+ // - `modelgo install` → install-wizard.js (interactive setup)
7
+ // - everything else → exec bin/modelgo (the downloaded Go binary)
8
8
 
9
9
  const { execFileSync } = require("child_process");
10
10
  const path = require("path");
@@ -16,12 +16,12 @@ if (args[0] === "install") {
16
16
  require("./install-wizard.js");
17
17
  } else {
18
18
  const isWindows = process.platform === "win32";
19
- const binName = "modelgo-cli" + (isWindows ? ".exe" : "");
19
+ const binName = "modelgo" + (isWindows ? ".exe" : "");
20
20
  const binPath = path.join(__dirname, "..", "bin", binName);
21
21
 
22
22
  if (!fs.existsSync(binPath)) {
23
23
  console.error(
24
- `modelgo-cli binary not found at ${binPath}\n` +
24
+ `modelgo binary not found at ${binPath}\n` +
25
25
  `Please reinstall: npm install -g @model-go/cli`
26
26
  );
27
27
  process.exit(1);