@model-go/cli 0.1.2-rc.1 → 0.1.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 +76 -7
- package/checksums.txt +6 -6
- package/package.json +6 -3
- package/scripts/install-wizard.js +2 -2
- package/scripts/install.js +2 -2
- package/scripts/run.js +4 -4
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.**
|
|
5
|
+
> **v0 framework stage.** Device-flow `auth` commands are available. `modelgo pay request` supports anonymous x402 pay-per-call calls to model gateway APIs; API key management is not wired up yet.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -12,23 +12,92 @@ 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
|
-
> "
|
|
20
|
+
> "Check my modelgo login status."
|
|
21
21
|
|
|
22
|
-
Your AI should find the `modelgo-
|
|
22
|
+
Your AI should find the `modelgo-shared` skill and run `modelgo auth status`.
|
|
23
23
|
|
|
24
24
|
## Direct commands
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
modelgo
|
|
28
|
-
modelgo
|
|
29
|
-
modelgo
|
|
27
|
+
modelgo --version
|
|
28
|
+
modelgo auth login
|
|
29
|
+
modelgo auth status
|
|
30
|
+
modelgo auth logout
|
|
31
|
+
modelgo pay methods
|
|
32
|
+
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[]}' --json
|
|
33
|
+
modelgo --help
|
|
30
34
|
```
|
|
31
35
|
|
|
36
|
+
`modelgo auth login` without `--no-wait` is a blocking command: it prints the
|
|
37
|
+
authorization URL, then keeps polling until the browser approval completes or
|
|
38
|
+
the device code expires.
|
|
39
|
+
|
|
40
|
+
### Environments
|
|
41
|
+
|
|
42
|
+
The CLI talks to a named environment. Two are built in:
|
|
43
|
+
|
|
44
|
+
| Env | Base URL |
|
|
45
|
+
| ------ | ---------------------------- |
|
|
46
|
+
| `cn` | `https://api.modelgo.com` |
|
|
47
|
+
| `intl` | `https://api.modelgo.global` |
|
|
48
|
+
|
|
49
|
+
The active environment defaults to `cn`. Switch it, or register your own:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
modelgo env list # show built-in + custom envs (active marked with *)
|
|
53
|
+
modelgo env current # print the active env
|
|
54
|
+
modelgo env use intl # switch the active env
|
|
55
|
+
modelgo env add <name> --base-url https://... # register or override an env URL
|
|
56
|
+
modelgo env remove <name> # remove a custom env or override
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Environment definitions and the active selection live in `~/.modelgo/config.json`.
|
|
60
|
+
Credentials are stored per-env in `~/.modelgo/auth.json`, so switching environments
|
|
61
|
+
preserves each login. There are no environment variables to set.
|
|
62
|
+
|
|
63
|
+
Auth commands operate on the active env; pass `--env <name>` to target a different one:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
modelgo auth login --env intl
|
|
67
|
+
modelgo auth status --env intl
|
|
68
|
+
modelgo auth logout --all # clear every env
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Non-streaming agent flows
|
|
72
|
+
|
|
73
|
+
For AI-agent harnesses that cannot stream intermediate output to the user, use:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
modelgo auth login --no-wait --json
|
|
77
|
+
modelgo auth login --device-code <DEVICE_CODE>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Do not show the URL and then immediately block on `--device-code` in the same
|
|
81
|
+
turn. In final-message-only harnesses, that pattern prevents the user from ever
|
|
82
|
+
seeing the URL before the agent starts waiting.
|
|
83
|
+
|
|
84
|
+
> **`--json` emits newline-delimited JSON (NDJSON).** In the default waiting
|
|
85
|
+
> flow (`modelgo auth login --json` without `--no-wait`), stdout receives two
|
|
86
|
+
> JSON objects: first the device-code object (with `verification_url`), then
|
|
87
|
+
> the authenticated object once approved. Parse line by line — don't
|
|
88
|
+
> `JSON.parse` the whole stream. With `--no-wait`, only the device-code object
|
|
89
|
+
> is printed.
|
|
90
|
+
|
|
91
|
+
### x402 pay-per-call model APIs
|
|
92
|
+
|
|
93
|
+
Use `modelgo pay request` when the user wants to call a model API without logging in to ModelGo first. The CLI opts into the gateway x402 path with `X-Payment-Protocol: x402`.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[{"role":"user","content":"hello"}]}' --intent "调用 gpt-4o 完成聊天补全" --json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
In the `cn` environment, if the gateway returns a 402 that advertises `alipay:*`, the CLI writes the `PAYMENT-REQUIRED` payload to a local file and returns a structured handoff for `alipay-payment-skill`. In `intl`, the CLI does not route to Alipay; it returns the advertised x402 options for a future non-Alipay rail.
|
|
100
|
+
|
|
32
101
|
## Upgrade
|
|
33
102
|
|
|
34
103
|
Re-run the installer; it detects an out-of-date install and upgrades in place:
|
package/checksums.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
d2301f86bdccb4225e959062382d20108eaac2ce023456f306485b8addcacacc modelgo-0.1.2-rc.1-SNAPSHOT-7701312-darwin-amd64.tar.gz
|
|
2
|
+
88480f50f971139c72866d73a69a67368a08a260c96b71e04add4eb7d6676ecf modelgo-0.1.2-rc.1-SNAPSHOT-7701312-darwin-arm64.tar.gz
|
|
3
|
+
9bc1719a182e3b996a793491775fd501da419a6c526d2b8a7cb2e72479cd9e1c modelgo-0.1.2-rc.1-SNAPSHOT-7701312-linux-amd64.tar.gz
|
|
4
|
+
534554cb7b7fff278260b4e030fcbe30a0029c146d46980493a1d902e65c7669 modelgo-0.1.2-rc.1-SNAPSHOT-7701312-linux-arm64.tar.gz
|
|
5
|
+
13cfa7761480b595fab0e1c3400c299013d29eaca3643282f2817b872b7d89d1 modelgo-0.1.2-rc.1-SNAPSHOT-7701312-windows-amd64.zip
|
|
6
|
+
3d57522bf6cfaeaded3ea3b6db4cf4afd8ddd4f0fbf0bcea71241531898a939c modelgo-0.1.2-rc.1-SNAPSHOT-7701312-windows-arm64.zip
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@model-go/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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
|
|
6
|
+
"modelgo": "scripts/run.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"postinstall": "node scripts/install.js",
|
|
10
10
|
"test": "node --test scripts/__tests__/*.test.mjs",
|
|
11
|
-
"lint:skills": "node scripts/lint-skills.mjs"
|
|
11
|
+
"lint:skills": "node scripts/lint-skills.mjs",
|
|
12
|
+
"sync:skills": "node scripts/sync-skill-version.mjs",
|
|
13
|
+
"generate:reference": "node scripts/generate-reference.mjs",
|
|
14
|
+
"sync:skill-assets": "node scripts/generate-reference.mjs && node scripts/sync-skill-version.mjs"
|
|
12
15
|
},
|
|
13
16
|
"files": [
|
|
14
17
|
"scripts/install.js",
|
|
@@ -31,7 +31,7 @@ const messages = {
|
|
|
31
31
|
step2Spinner: "正在安装 Skills...",
|
|
32
32
|
step2Done: "Skills 已安装",
|
|
33
33
|
step2Fail: "Skills 安装失败。运行以下命令重试: npx skills add %s -y -g",
|
|
34
|
-
done: "安装完成!\n试试跟你的 AI 工具(Claude Code、Codex 等)说:\"用 modelgo
|
|
34
|
+
done: "安装完成!\n试试跟你的 AI 工具(Claude Code、Codex 等)说:\"用 modelgo 跟我打个招呼\"",
|
|
35
35
|
cancelled: "安装已取消",
|
|
36
36
|
nonTtyHint: "非交互模式,已完成 npm 全局安装 + skills 安装。",
|
|
37
37
|
},
|
|
@@ -46,7 +46,7 @@ const messages = {
|
|
|
46
46
|
step2Spinner: "Installing skills...",
|
|
47
47
|
step2Done: "Skills installed",
|
|
48
48
|
step2Fail: "Failed to install skills. Run manually: npx skills add %s -y -g",
|
|
49
|
-
done: "You are all set!\nTry asking your AI tool (Claude Code, Codex, etc.): \"Have modelgo
|
|
49
|
+
done: "You are all set!\nTry asking your AI tool (Claude Code, Codex, etc.): \"Have modelgo say hello to me\"",
|
|
50
50
|
cancelled: "Installation cancelled",
|
|
51
51
|
nonTtyHint: "Non-interactive mode. Completed global install + skills install.",
|
|
52
52
|
},
|
package/scripts/install.js
CHANGED
|
@@ -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
|
|
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-
|
|
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
|
|
7
|
-
// - everything else
|
|
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
|
|
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
|
|
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);
|