@migoo-ai/cli 0.0.0-stage → 1.0.1

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,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # @migoo-ai/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Migoo CLI — create images and videos with [Migoo](https://migoo.ai) from the terminal and from coding agents such as Claude Code, Codex CLI and Cursor.
4
+
5
+ - One command starts a task; local files are uploaded for you, and `--output` downloads the results into your project.
6
+ - `--wait` blocks until the task finishes or needs you, so an agent does not spend turns polling.
7
+ - Videos are quoted before generation: the CLI prints the credits and exits with code `11`, and never approves on its own. Image tasks start generating, and consume credits, right away.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install -g @migoo-ai/cli
13
+ ```
14
+
15
+ `pnpm add -g`, `yarn global add` and `bun add -g` work as well.
16
+
17
+ Postinstall downloads the prebuilt `migoo` binary for your platform from the Migoo CDN. It verifies the archive's SHA-256 against checksums bundled in this npm package before extracting the binary. Installation fails if the checksum is missing or does not match.
18
+
19
+ Supported platforms: macOS, Linux, Windows (x64, arm64). Requires Node.js 18 or later.
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ # Sign in to Migoo in the browser
25
+ migoo auth login
26
+
27
+ # Image: starts generating (and consumes credits) right away; local reference images are uploaded automatically and results are saved to ./assets
28
+ migoo image create "Restyle this image with a summer look" --image ./product.png --count 4 --wait --output ./assets
29
+
30
+ # Video: a plan and quote come first
31
+ migoo video create "Turn this image into a 15-second vertical ad" --image ./product.png --duration 15 --ratio 9:16 --wait
32
+ # Exit code 11: the credits and an approval ID are printed; once you agree, approve and keep waiting
33
+ migoo task approve <task_id> <approval_id> --wait --output ./assets
34
+
35
+ # Plan and credits
36
+ migoo account
37
+ ```
38
+
39
+ ### Use with a coding agent
40
+
41
+ ```bash
42
+ migoo skills install
43
+ ```
44
+
45
+ Installs the Migoo skill into Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf on this machine, so the agent knows when and how to call `migoo`. The skill is updated together with the CLI.
46
+
47
+ Or paste this into your agent:
48
+
49
+ ```text
50
+ Set up Migoo for me so I can create images and videos from here.
51
+
52
+ 1. Install the CLI: run `npm i -g @migoo-ai/cli`.
53
+ 2. Authenticate: run `migoo auth login` and complete the sign-in in the browser it opens.
54
+ 3. Install the companion skill: run `migoo skills install`.
55
+ Once that's done, let me know when it's ready.
56
+ ```
57
+
58
+ ### Commands
59
+
60
+ | Command | What it does |
61
+ | --- | --- |
62
+ | `migoo image create "<request>"` | Start an image task (consumes credits) |
63
+ | `migoo video create "<request>"` | Start a video task: a plan and quote come first |
64
+ | `migoo task list` | List your tasks from the last 7 days (`--status`, `--type`) |
65
+ | `migoo task get <task_id>` | Check a task |
66
+ | `migoo task reply <task_id> "<answer>"` | Answer a task's question or request changes; on a completed task it makes a new version and charges credits again |
67
+ | `migoo task approve <task_id> <approval_id>` | Approve or reject (`--reject`) a quote |
68
+ | `migoo task stop <task_id>` | Stop a task |
69
+ | `migoo upload <file>...` | Upload local files and print their `media_id`s |
70
+ | `migoo media list` / `migoo media get <media_id>` | Browse your Migoo Library and download files |
71
+ | `migoo models <image\|video>` | List the models you can pass with `--model`, with their ratios and resolutions |
72
+ | `migoo account` | Show your plan and credits |
73
+ | `migoo feedback "<message>"` | Send feedback to the Migoo team (`--task <task_id>` for a specific task) |
74
+ | `migoo auth login` / `logout` / `status` | Manage your session |
75
+ | `migoo skills install` / `uninstall` | Add or remove the Migoo skill for coding agents |
76
+ | `migoo update` / `migoo version` | Upgrade the CLI, print the version |
77
+
78
+ Commands that start, check, answer or approve a task accept `--wait` and `--output <dir>`. Every command accepts `--json` for machine-readable output. Run `migoo <command> --help` for all flags.
79
+
80
+ ### Exit codes
81
+
82
+ | Code | Meaning | What to do |
83
+ | --- | --- | --- |
84
+ | `0` | Done, or the task was submitted | — |
85
+ | `1` | Task failed or was stopped, or a business error such as insufficient credits | Read the message |
86
+ | `2` | Invalid arguments or media | Fix the command or the files |
87
+ | `3` | Not signed in, or the session expired | `migoo auth login` |
88
+ | `4` | This version is no longer supported | `migoo update` |
89
+ | `5` | Network or service error, or `--wait` timed out | `migoo task get <task_id> --wait`; do not start the task again |
90
+ | `10` | The task has a question | `migoo task reply` |
91
+ | `11` | The task is waiting for approval, such as a video quote | Check the credits, then `migoo task approve` |
92
+
93
+ ## Update
94
+
95
+ `migoo update` upgrades with the package manager you installed with. You can also run `npm install -g @migoo-ai/cli@latest`.
96
+
97
+ ## Uninstall
98
+
99
+ ```bash
100
+ migoo auth logout # revoke the session and delete local credentials
101
+ migoo skills uninstall # remove the skill from coding agents
102
+ npm uninstall -g @migoo-ai/cli
103
+ ```
104
+
105
+ ## Links
106
+
107
+ - Migoo: https://migoo.ai
package/bin/migoo.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ // Launch the migoo binary downloaded by postinstall, passing through args, stdio and exit code.
3
+ 'use strict';
4
+
5
+ const { spawn } = require('child_process');
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ const bin = path.join(__dirname, '..', 'vendor', process.platform === 'win32' ? 'migoo.exe' : 'migoo');
10
+ if (!fs.existsSync(bin)) {
11
+ console.error('migoo binary not found. postinstall may have been skipped (e.g. --ignore-scripts); reinstall with: npm install -g @migoo-ai/cli');
12
+ process.exit(1);
13
+ }
14
+
15
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
16
+ for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
17
+ process.on(sig, () => child.kill(sig));
18
+ }
19
+ child.on('error', (err) => {
20
+ console.error(`failed to start migoo: ${err.message}`);
21
+ process.exit(1);
22
+ });
23
+ child.on('exit', (code, signal) => {
24
+ if (signal) {
25
+ process.kill(process.pid, signal);
26
+ return;
27
+ }
28
+ process.exit(code === null ? 1 : code);
29
+ });
package/checksums.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "migoo_1.0.1_darwin_amd64.tar.gz": "e6c526beaba86c052d0540492ceef487d8717cd2e78fa87152a1614698292df2",
3
+ "migoo_1.0.1_darwin_arm64.tar.gz": "d42b25b5a2255041a4e903dc8e9a3f00ad048c446c37fd7b0e34074e1bab9dd2",
4
+ "migoo_1.0.1_linux_amd64.tar.gz": "db78ac62361dd6b0610047bf4500f57a8c70da2a0fa7bb0e578f31a9ed548845",
5
+ "migoo_1.0.1_linux_arm64.tar.gz": "f97db2b2e06087faae776bc54ca95984255577e5dfbd0f385f6b2cb425ac2b3f",
6
+ "migoo_1.0.1_windows_amd64.zip": "4c5f81e755f1efb93dd8b3005da42229d2d58db5eee02066e146f3a52d2b1950",
7
+ "migoo_1.0.1_windows_arm64.zip": "c373548ac1bb4fa9344982f714a4ea0dd3c153d7610bdc18af34f5f8647b36e1"
8
+ }
package/install.js ADDED
@@ -0,0 +1,198 @@
1
+ #!/usr/bin/env node
2
+ // postinstall: download the migoo binary for the current platform, verify its SHA-256 against checksums.json,
3
+ // extract in-process, and keep only the regular file named migoo.
4
+ 'use strict';
5
+
6
+ const crypto = require('crypto');
7
+ const fs = require('fs');
8
+ const http = require('http');
9
+ const https = require('https');
10
+ const path = require('path');
11
+ const zlib = require('zlib');
12
+
13
+ const OS_MAP = { darwin: 'darwin', linux: 'linux', win32: 'windows' };
14
+ const ARCH_MAP = { x64: 'amd64', arm64: 'arm64' };
15
+ const PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun'];
16
+ const MAX_REDIRECTS = 5;
17
+
18
+ function target(platform, arch) {
19
+ const os = OS_MAP[platform];
20
+ const goarch = ARCH_MAP[arch];
21
+ if (!os || !goarch) {
22
+ throw new Error(`migoo does not support platform ${platform}/${arch}`);
23
+ }
24
+ const windows = os === 'windows';
25
+ return { os, arch: goarch, ext: windows ? 'zip' : 'tar.gz', bin: windows ? 'migoo.exe' : 'migoo' };
26
+ }
27
+
28
+ function assetName(version, t) {
29
+ return `migoo_${version}_${t.os}_${t.arch}.${t.ext}`;
30
+ }
31
+
32
+ function downloadUrl(base, version, asset) {
33
+ return `${base.replace(/\/+$/, '')}/v${version}/${asset}`;
34
+ }
35
+
36
+ function download(url, redirects = 0) {
37
+ return new Promise((resolve, reject) => {
38
+ const client = url.startsWith('https:') ? https : http;
39
+ const req = client.get(url, { headers: { 'User-Agent': 'migoo-cli-npm-installer' } }, (res) => {
40
+ if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
41
+ res.resume();
42
+ if (redirects >= MAX_REDIRECTS) {
43
+ reject(new Error(`download ${url}: too many redirects`));
44
+ return;
45
+ }
46
+ resolve(download(new URL(res.headers.location, url).toString(), redirects + 1));
47
+ return;
48
+ }
49
+ if (res.statusCode !== 200) {
50
+ res.resume();
51
+ reject(new Error(`download ${url} failed: HTTP ${res.statusCode}`));
52
+ return;
53
+ }
54
+ const chunks = [];
55
+ res.on('data', (c) => chunks.push(c));
56
+ res.on('end', () => resolve(Buffer.concat(chunks)));
57
+ res.on('error', reject);
58
+ });
59
+ req.setTimeout(120000, () => req.destroy(new Error(`download ${url} timed out`)));
60
+ req.on('error', reject);
61
+ });
62
+ }
63
+
64
+ function sha256(buf) {
65
+ return crypto.createHash('sha256').update(buf).digest('hex');
66
+ }
67
+
68
+ function verify(buf, asset, checksums) {
69
+ const want = checksums[asset];
70
+ if (!want) {
71
+ throw new Error(`${asset} not found in checksums.json; aborting install`);
72
+ }
73
+ const got = sha256(buf);
74
+ if (got !== want.toLowerCase()) {
75
+ throw new Error(`SHA-256 mismatch for ${asset} (expected ${want}, got ${got}); aborting install`);
76
+ }
77
+ }
78
+
79
+ function hasSeparator(name) {
80
+ return name.includes('/') || name.includes('\\');
81
+ }
82
+
83
+ function cString(buf, start, len) {
84
+ const end = buf.indexOf(0, start);
85
+ return buf.toString('utf8', start, end === -1 || end > start + len ? start + len : end);
86
+ }
87
+
88
+ // extractTar parses a tar (ustar) archive and returns the content of the regular file named binName.
89
+ function extractTar(tar, binName) {
90
+ let off = 0;
91
+ let found = null;
92
+ while (off + 512 <= tar.length) {
93
+ const header = tar.subarray(off, off + 512);
94
+ if (header.every((b) => b === 0)) break;
95
+ const name = cString(header, 345, 155) ? `${cString(header, 345, 155)}/${cString(header, 0, 100)}` : cString(header, 0, 100);
96
+ const size = parseInt(cString(header, 124, 12).trim() || '0', 8);
97
+ const type = String.fromCharCode(header[156] || 0x30);
98
+ if (Number.isNaN(size)) throw new Error('invalid archive format');
99
+ if (hasSeparator(name)) {
100
+ throw new Error(`archive contains entry with path separator ${name}; aborting install`);
101
+ }
102
+ const dataStart = off + 512;
103
+ if (name === binName && (type === '0' || type === '\0')) {
104
+ if (found) throw new Error(`archive contains multiple ${binName}; aborting install`);
105
+ found = Buffer.from(tar.subarray(dataStart, dataStart + size));
106
+ }
107
+ off = dataStart + Math.ceil(size / 512) * 512;
108
+ }
109
+ if (!found) throw new Error(`no ${binName} found in archive`);
110
+ return found;
111
+ }
112
+
113
+ function extractTarGz(buf, binName) {
114
+ return extractTar(zlib.gunzipSync(buf), binName);
115
+ }
116
+
117
+ // extractZip parses a zip via its central directory and returns the content of the file named binName.
118
+ function extractZip(buf, binName) {
119
+ let eocd = -1;
120
+ for (let i = buf.length - 22; i >= Math.max(0, buf.length - 65557); i--) {
121
+ if (buf.readUInt32LE(i) === 0x06054b50) {
122
+ eocd = i;
123
+ break;
124
+ }
125
+ }
126
+ if (eocd < 0) throw new Error('invalid archive format: zip directory not found');
127
+ const count = buf.readUInt16LE(eocd + 10);
128
+ let p = buf.readUInt32LE(eocd + 16);
129
+ let found = null;
130
+ for (let i = 0; i < count; i++) {
131
+ if (buf.readUInt32LE(p) !== 0x02014b50) throw new Error('invalid archive format: corrupt zip directory');
132
+ const method = buf.readUInt16LE(p + 10);
133
+ const compSize = buf.readUInt32LE(p + 20);
134
+ const nameLen = buf.readUInt16LE(p + 28);
135
+ const extraLen = buf.readUInt16LE(p + 30);
136
+ const commentLen = buf.readUInt16LE(p + 32);
137
+ const localOff = buf.readUInt32LE(p + 42);
138
+ const name = buf.toString('utf8', p + 46, p + 46 + nameLen);
139
+ p += 46 + nameLen + extraLen + commentLen;
140
+ if (hasSeparator(name)) {
141
+ throw new Error(`archive contains entry with path separator ${name}; aborting install`);
142
+ }
143
+ if (name !== binName) continue;
144
+ if (found) throw new Error(`archive contains multiple ${binName}; aborting install`);
145
+ if (buf.readUInt32LE(localOff) !== 0x04034b50) throw new Error('invalid archive format: corrupt zip entry');
146
+ const start = localOff + 30 + buf.readUInt16LE(localOff + 26) + buf.readUInt16LE(localOff + 28);
147
+ const data = buf.subarray(start, start + compSize);
148
+ if (method === 0) found = Buffer.from(data);
149
+ else if (method === 8) found = zlib.inflateRawSync(data);
150
+ else throw new Error(`unsupported zip compression method ${method}`);
151
+ }
152
+ if (!found) throw new Error(`no ${binName} found in archive`);
153
+ return found;
154
+ }
155
+
156
+ function packageManager(userAgent) {
157
+ const name = (userAgent || '').split('/')[0];
158
+ return PACKAGE_MANAGERS.includes(name) ? name : 'npm';
159
+ }
160
+
161
+ async function install(opts = {}) {
162
+ const pkgDir = opts.pkgDir || __dirname;
163
+ const pkg = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8'));
164
+ const checksums = JSON.parse(fs.readFileSync(path.join(pkgDir, 'checksums.json'), 'utf8'));
165
+ const t = target(opts.platform || process.platform, opts.arch || process.arch);
166
+ const asset = assetName(pkg.version, t);
167
+ const url = downloadUrl(pkg.migoo.downloadBaseUrl, pkg.version, asset);
168
+
169
+ const archive = await download(url);
170
+ verify(archive, asset, checksums);
171
+ const bin = t.ext === 'zip' ? extractZip(archive, t.bin) : extractTarGz(archive, t.bin);
172
+
173
+ const vendor = path.join(pkgDir, 'vendor');
174
+ fs.mkdirSync(vendor, { recursive: true });
175
+ const binPath = path.join(vendor, t.bin);
176
+ const tmp = `${binPath}.tmp-${process.pid}`;
177
+ fs.writeFileSync(tmp, bin, { mode: 0o755 });
178
+ fs.renameSync(tmp, binPath);
179
+ const info = {
180
+ method: packageManager(opts.userAgent !== undefined ? opts.userAgent : process.env.npm_config_user_agent),
181
+ package: pkg.name,
182
+ version: pkg.version,
183
+ };
184
+ fs.writeFileSync(path.join(vendor, 'install.json'), `${JSON.stringify(info, null, 2)}\n`);
185
+ return binPath;
186
+ }
187
+
188
+ module.exports = { target, assetName, downloadUrl, download, sha256, verify, extractTar, extractTarGz, extractZip, packageManager, install };
189
+
190
+ if (require.main === module) {
191
+ install().then(
192
+ (p) => console.log(`migoo installed: ${p}`),
193
+ (err) => {
194
+ console.error(`migoo install failed: ${err.message}`);
195
+ process.exit(1);
196
+ },
197
+ );
198
+ }
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@migoo-ai/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Migoo CLI: create images and videos from your terminal and coding agents",
5
+ "bin": {
6
+ "migoo": "bin/migoo.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js",
10
+ "test": "node --test test/*.test.js"
11
+ },
12
+ "files": [
13
+ "install.js",
14
+ "checksums.json",
15
+ "bin/"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "migoo": {
21
+ "downloadBaseUrl": "https://cache-media-sg.migoo.ai/api/v4/50095895/beeai-budee-live-sg/migoo-cli"
22
+ },
23
+ "license": "UNLICENSED"
24
+ }