maritime-cli 1.4.0 → 1.5.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/AGENTS.md +44 -0
- package/dist/commands/blueprint.js +3 -4
- package/dist/commands/create.js +129 -2
- package/dist/commands/deploy.js +4 -3
- package/dist/commands/guide.js +1 -0
- package/dist/commands/login.js +3 -3
- package/dist/commands/signup.js +2 -2
- package/dist/commands/sleep.js +2 -3
- package/dist/output.d.ts +2 -0
- package/dist/output.js +20 -1
- package/dist/version-check.js +18 -2
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -152,6 +152,50 @@ auto-sleeps the agent for the rest of the billing period when hit).
|
|
|
152
152
|
`status <agent> --json` echoes `memMb`, `vcpus`, `idleTtlSeconds`
|
|
153
153
|
(`0` = always-on, `null` = inherits tier), `diskMb`, and `computeMinutesLimit`.
|
|
154
154
|
|
|
155
|
+
## Fleets — `create --count`
|
|
156
|
+
|
|
157
|
+
`maritime create <name> --count <n>` (n = 2–50) spins up **n identical agents**
|
|
158
|
+
in a single call. `<name>` becomes the prefix — agents are named
|
|
159
|
+
`<name>-1` … `<name>-n`. `--count 1` (the default) is the classic single-agent
|
|
160
|
+
path, unchanged.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
maritime create swarm --template openclaw --count 5 --idle 3600 --json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Flags supported alongside `--count > 1`: `--template`, `--tier`,
|
|
167
|
+
`--idle`/`--always-on`, `--repo`, and `-e/--env` (applied to every agent).
|
|
168
|
+
In the fleet path `--idle 0` means always-on (same as `--always-on`).
|
|
169
|
+
Any other `create` flag (`--branch`, `--public`, `--port`, `--framework`,
|
|
170
|
+
`--ram`, `--cpu`, `--disk`, `--max-compute`) combined with `--count > 1` is a
|
|
171
|
+
usage error (exit `4`) — nothing is silently dropped. `--count` above 50 is
|
|
172
|
+
also exit `4`; the 50-agent cap is enforced server-side too.
|
|
173
|
+
|
|
174
|
+
Success shape (`--json`, the backend response verbatim):
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"created": [{ "id": "…", "name": "swarm-1", "status": "deploying" }],
|
|
179
|
+
"failed": [{ "name": "swarm-3", "error": "…" }],
|
|
180
|
+
"requested": 5,
|
|
181
|
+
"monthlyCostCents": 500
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Exit codes: `0` = **all** requested agents created (`failed` empty);
|
|
186
|
+
`1` = partial or none — inspect `created`/`failed` on stdout. Billing/limit
|
|
187
|
+
rejections surface as the standard error object on stderr with exit `1`:
|
|
188
|
+
`402` → `error.code = "insufficient_balance"` (each agent bills $1/mo from the
|
|
189
|
+
wallet; n agents need n×$1 available), `403` → `error.code =
|
|
190
|
+
"fleet_cap_exceeded"`.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Recipe: spin up a 5-agent fleet, then fan a message out to every member
|
|
194
|
+
maritime create swarm --template openclaw --count 5 --idle 3600 --json \
|
|
195
|
+
| jq -r '.created[].name' \
|
|
196
|
+
| xargs -I{} maritime chat {} "introduce yourself" --json
|
|
197
|
+
```
|
|
198
|
+
|
|
155
199
|
## Environment variables
|
|
156
200
|
|
|
157
201
|
Values are secret (encrypted) by default. Env changes apply on the next
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
3
|
import { authGet, authPost } from '../api.js';
|
|
5
4
|
import { resolveAgent } from '../resolve.js';
|
|
6
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
5
|
+
import { isJsonMode, outputJson, handleError, makeSpinner } from '../output.js';
|
|
7
6
|
const blueprintListCmd = new Command('list')
|
|
8
7
|
.description('List your blueprints')
|
|
9
8
|
.action(async () => {
|
|
@@ -44,7 +43,7 @@ const blueprintCreateCmd = new Command('create')
|
|
|
44
43
|
.action(async (agentArg, opts) => {
|
|
45
44
|
try {
|
|
46
45
|
const agent = await resolveAgent(agentArg);
|
|
47
|
-
const spinner =
|
|
46
|
+
const spinner = await makeSpinner('Creating blueprint...');
|
|
48
47
|
const blueprint = await authPost('/api/blueprints', {
|
|
49
48
|
agentId: agent.id,
|
|
50
49
|
name: opts.name || agent.name,
|
|
@@ -68,7 +67,7 @@ const blueprintDeployCmd = new Command('deploy')
|
|
|
68
67
|
.option('--name <name>', 'Name for the new agent')
|
|
69
68
|
.action(async (slug, opts) => {
|
|
70
69
|
try {
|
|
71
|
-
const spinner =
|
|
70
|
+
const spinner = await makeSpinner('Deploying from blueprint...');
|
|
72
71
|
const body = {};
|
|
73
72
|
if (opts.name)
|
|
74
73
|
body.name = opts.name;
|
package/dist/commands/create.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { authGet, authPost } from '../api.js';
|
|
3
|
+
import { authGet, authPost, CliHttpError } from '../api.js';
|
|
4
4
|
import { promptForValue } from '../prompt.js';
|
|
5
5
|
import { isJsonMode, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
6
|
+
const FLEET_CAP = 50;
|
|
7
|
+
/** Format integer cents as a dollar string ($5 or $7.50). */
|
|
8
|
+
function formatDollars(cents) {
|
|
9
|
+
return cents % 100 === 0 ? `$${cents / 100}` : `$${(cents / 100).toFixed(2)}`;
|
|
10
|
+
}
|
|
6
11
|
function parseEnvPairs(pairs) {
|
|
7
12
|
return pairs.map((pair) => {
|
|
8
13
|
const eqIdx = pair.indexOf('=');
|
|
@@ -24,6 +29,7 @@ export const createCommand = new Command('create')
|
|
|
24
29
|
.argument('[name]', 'Agent name')
|
|
25
30
|
.option('-t, --template <template>', 'Template to base the agent on (see `maritime templates`)')
|
|
26
31
|
.option('-e, --env <pairs...>', 'Environment variables (KEY=value)')
|
|
32
|
+
.option('--count <n>', 'Spin up N identical agents in one call (fleet) — names become <name>-1..<name>-N')
|
|
27
33
|
.option('-r, --repo <url>', 'Deploy from a GitHub repo (must contain a Dockerfile)')
|
|
28
34
|
.option('-b, --branch <branch>', 'Git branch to deploy (with --repo)')
|
|
29
35
|
.option('--public', 'Serve a public, no-login web URL for this agent (web apps)')
|
|
@@ -46,11 +52,27 @@ Examples:
|
|
|
46
52
|
maritime create researcher
|
|
47
53
|
maritime create acme-bot --template openclaw --json
|
|
48
54
|
maritime create my-app --repo https://github.com/you/app --public # public web agent
|
|
49
|
-
maritime create client-x -e OPENAI_API_KEY=sk
|
|
55
|
+
maritime create client-x -e OPENAI_API_KEY=sk-...
|
|
56
|
+
maritime create swarm --template openclaw --count 5 # fleet: swarm-1..swarm-5`)
|
|
50
57
|
.action(async (nameArg, opts) => {
|
|
51
58
|
try {
|
|
52
59
|
let name = nameArg || opts.name;
|
|
53
60
|
let templateId = opts.template;
|
|
61
|
+
// --count: fleet spin-up. 1 (default) = the classic single-agent path.
|
|
62
|
+
let count = 1;
|
|
63
|
+
if (opts.count !== undefined) {
|
|
64
|
+
const n = Number(opts.count);
|
|
65
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
66
|
+
fail('--count must be an integer between 1 and 50.', {
|
|
67
|
+
code: 'usage',
|
|
68
|
+
exitCode: EXIT.USAGE,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (n > FLEET_CAP) {
|
|
72
|
+
fail('Fleet spin-ups are capped at 50 agents. Contact us if you need more — we keep the cap to protect shared server capacity.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
73
|
+
}
|
|
74
|
+
count = n;
|
|
75
|
+
}
|
|
54
76
|
const interactive = !isJsonMode() && process.stdin.isTTY;
|
|
55
77
|
// Interactive mode if no name given
|
|
56
78
|
if (!name) {
|
|
@@ -86,6 +108,111 @@ Examples:
|
|
|
86
108
|
// Templates fetch failed; continue without template
|
|
87
109
|
}
|
|
88
110
|
}
|
|
111
|
+
// ── Fleet path (--count > 1): one POST /api/fleet/batch call ──
|
|
112
|
+
if (count > 1) {
|
|
113
|
+
// The batch endpoint only understands a subset of create's flags.
|
|
114
|
+
// Anything it can't honor is a hard usage error — never silently dropped.
|
|
115
|
+
const unsupported = [];
|
|
116
|
+
if (opts.branch !== undefined)
|
|
117
|
+
unsupported.push('--branch');
|
|
118
|
+
if (opts.public)
|
|
119
|
+
unsupported.push('--public');
|
|
120
|
+
if (opts.port !== undefined)
|
|
121
|
+
unsupported.push('--port');
|
|
122
|
+
if (opts.framework !== undefined)
|
|
123
|
+
unsupported.push('--framework');
|
|
124
|
+
if (opts.ram !== undefined)
|
|
125
|
+
unsupported.push('--ram');
|
|
126
|
+
if (opts.cpu !== undefined)
|
|
127
|
+
unsupported.push('--cpu');
|
|
128
|
+
if (opts.disk !== undefined)
|
|
129
|
+
unsupported.push('--disk');
|
|
130
|
+
if (opts.maxCompute !== undefined)
|
|
131
|
+
unsupported.push('--max-compute');
|
|
132
|
+
if (unsupported.length > 0) {
|
|
133
|
+
fail(`${unsupported.join(', ')} cannot be combined with --count > 1. ` +
|
|
134
|
+
'Fleet spin-ups support --template, --tier, --idle/--always-on, --repo, and -e/--env.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
135
|
+
}
|
|
136
|
+
if (opts.alwaysOn && opts.idle !== undefined) {
|
|
137
|
+
fail('--always-on and --idle are mutually exclusive.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
138
|
+
}
|
|
139
|
+
const batchBody = { namePrefix: name, count };
|
|
140
|
+
if (templateId)
|
|
141
|
+
batchBody.templateId = templateId;
|
|
142
|
+
if (opts.tier)
|
|
143
|
+
batchBody.tier = opts.tier;
|
|
144
|
+
if (opts.repo)
|
|
145
|
+
batchBody.githubRepo = opts.repo;
|
|
146
|
+
if (opts.env)
|
|
147
|
+
batchBody.envVars = parseEnvPairs(opts.env);
|
|
148
|
+
if (opts.alwaysOn) {
|
|
149
|
+
batchBody.idleTtlSeconds = 0; // 0 = always-on (never auto-sleep)
|
|
150
|
+
}
|
|
151
|
+
else if (opts.idle !== undefined) {
|
|
152
|
+
const secs = Number(opts.idle);
|
|
153
|
+
if (!Number.isInteger(secs) || secs < 0) {
|
|
154
|
+
fail('--idle must be an integer number of seconds (0 = always-on).', {
|
|
155
|
+
code: 'usage',
|
|
156
|
+
exitCode: EXIT.USAGE,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
batchBody.idleTtlSeconds = secs; // 0 = always-on
|
|
160
|
+
}
|
|
161
|
+
const spinner = await makeSpinner(`Creating fleet ${chalk.bold(name)} × ${count}...`);
|
|
162
|
+
let result;
|
|
163
|
+
try {
|
|
164
|
+
result = await authPost('/api/fleet/batch', batchBody);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
spinner.fail('Failed to create fleet');
|
|
168
|
+
if (error instanceof CliHttpError && (error.status === 402 || error.status === 403)) {
|
|
169
|
+
// 402 = wallet can't cover count × $1/mo; 403 = server-enforced cap.
|
|
170
|
+
// Both are request failures, not auth failures → exit 1.
|
|
171
|
+
fail(error.detail, {
|
|
172
|
+
status: error.status,
|
|
173
|
+
code: error.status === 402 ? 'insufficient_balance' : 'fleet_cap_exceeded',
|
|
174
|
+
exitCode: EXIT.ERROR,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
const allCreated = result.failed.length === 0 && result.created.length > 0;
|
|
180
|
+
if (allCreated) {
|
|
181
|
+
spinner.succeed(chalk.green('Created ') + chalk.bold(`${result.created.length} agents`));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
spinner.stop();
|
|
185
|
+
}
|
|
186
|
+
// --json → the backend response verbatim on stdout.
|
|
187
|
+
outputResult(result, () => {
|
|
188
|
+
if (result.created.length > 0) {
|
|
189
|
+
console.log('\n ' +
|
|
190
|
+
chalk.dim('NAME'.padEnd(24)) +
|
|
191
|
+
chalk.dim('ID'.padEnd(28)) +
|
|
192
|
+
chalk.dim('STATUS'));
|
|
193
|
+
console.log(chalk.dim(' ' + '─'.repeat(62)));
|
|
194
|
+
for (const a of result.created) {
|
|
195
|
+
const shortName = a.name.length > 22 ? a.name.slice(0, 21) + '…' : a.name;
|
|
196
|
+
console.log(' ' + chalk.bold(shortName.padEnd(24)) + chalk.dim(a.id.padEnd(28)) + a.status);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (result.failed.length > 0) {
|
|
200
|
+
console.log('\n ' + chalk.red(`Failed (${result.failed.length}):`));
|
|
201
|
+
for (const f of result.failed) {
|
|
202
|
+
console.log(' ' + chalk.bold(f.name.padEnd(24)) + chalk.red(f.error));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
console.log('\n ' +
|
|
206
|
+
`${result.created.length}/${result.requested} created` +
|
|
207
|
+
chalk.dim(' · ') +
|
|
208
|
+
`${formatDollars(result.monthlyCostCents)}/mo`);
|
|
209
|
+
console.log();
|
|
210
|
+
});
|
|
211
|
+
// Exit contract: 0 = all created, 1 = partial or none.
|
|
212
|
+
if (!allCreated)
|
|
213
|
+
process.exit(EXIT.ERROR);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
89
216
|
const body = { name };
|
|
90
217
|
if (templateId)
|
|
91
218
|
body.templateId = templateId;
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
3
|
import { authPost, authPut } from '../api.js';
|
|
5
4
|
import { resolveAgent } from '../resolve.js';
|
|
6
5
|
import { getConfig, getLinkedAgentId, writeLink } from '../context.js';
|
|
7
|
-
import { isJsonMode, outputJson, fail, handleError, EXIT } from '../output.js';
|
|
6
|
+
import { isJsonMode, outputJson, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
8
7
|
import { connectWs } from '../websocket.js';
|
|
9
8
|
export const deployCommand = new Command('deploy')
|
|
10
9
|
.description('Deploy this directory: reconcile the agent to maritime.json, then ship it')
|
|
@@ -59,7 +58,9 @@ Explicit sources still work: \`maritime deploy --source github --repo <url>\`.`)
|
|
|
59
58
|
body.imageName = opts.image;
|
|
60
59
|
if (opts.branch)
|
|
61
60
|
body.branch = opts.branch;
|
|
62
|
-
|
|
61
|
+
// makeSpinner (not raw ora): degrades to static lines on 0-width PTYs —
|
|
62
|
+
// raw ora write-storms there (the create/chat bug fixed in 1.5.0).
|
|
63
|
+
const spinner = isJsonMode() ? null : await makeSpinner(`Deploying ${chalk.bold(agent.name)}...`);
|
|
63
64
|
try {
|
|
64
65
|
const deployment = await authPost('/api/deploy', body);
|
|
65
66
|
if (!opts.wait) {
|
package/dist/commands/guide.js
CHANGED
|
@@ -15,6 +15,7 @@ const CONTRACT = {
|
|
|
15
15
|
exitCodes: { '0': 'ok', '1': 'error', '2': 'auth', '3': 'not_found', '4': 'usage' },
|
|
16
16
|
interaction: 'Talk to a deployed agent with `maritime chat <agent> <message>` (or pipe the message via stdin). Returns the reply text (or {response} under --json). Sleeping serverless agents auto-wake.',
|
|
17
17
|
resources: 'create accepts per-agent overrides: --ram <mb>, --cpu <cores>, --idle <seconds> | --always-on, --disk <gb>, --max-compute <minutes>. Omitted = inherit the tier/plan.',
|
|
18
|
+
fleet: 'create --count <n> (2–50) spins up n identical agents named <name>-1..<name>-n in one call. Supported alongside --count: --template, --tier, --idle/--always-on, --repo, -e/--env; other create flags exit 4. --json returns {created:[{id,name,status}],failed:[{name,error}],requested,monthlyCostCents}. Exit 0 = all created, 1 = partial/none (402 insufficient wallet balance, 403 over the 50-agent cap → exit 1).',
|
|
18
19
|
project: 'A directory can be linked to an agent (like vercel/railway). `maritime init <name>` scaffolds maritime.json + AGENTS.md and links it; `maritime link <agent>` links an existing one; `maritime deploy` reconciles the agent to maritime.json. Once linked, the <agent> argument is optional on every command (resolved from .maritime/project.json, walking up from cwd).',
|
|
19
20
|
apiBase: 'Override the API base with MARITIME_API_URL (default https://api.maritime.sh).',
|
|
20
21
|
};
|
package/dist/commands/login.js
CHANGED
|
@@ -2,10 +2,10 @@ import http from 'node:http';
|
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import ora from 'ora';
|
|
6
5
|
import open from 'open';
|
|
7
6
|
import { config } from '../config.js';
|
|
8
7
|
import { CliHttpError, getApiUrl, postJson } from '../api.js';
|
|
8
|
+
import { makeSpinner } from '../output.js';
|
|
9
9
|
import { promptForPassword, promptForValue } from '../prompt.js';
|
|
10
10
|
const APP_URL = process.env.MARITIME_APP_URL || 'https://maritime.sh';
|
|
11
11
|
const TIMEOUT_MS = 120_000;
|
|
@@ -115,7 +115,7 @@ export const loginCommand = new Command('login')
|
|
|
115
115
|
console.log(chalk.red('Error:') + ' email and password are required');
|
|
116
116
|
process.exit(1);
|
|
117
117
|
}
|
|
118
|
-
const spinner =
|
|
118
|
+
const spinner = await makeSpinner('Authenticating...');
|
|
119
119
|
try {
|
|
120
120
|
const auth = await postJson('/api/auth/cli-login', {
|
|
121
121
|
email,
|
|
@@ -152,7 +152,7 @@ export const loginCommand = new Command('login')
|
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
// 3. Default: browser-based login.
|
|
155
|
-
const spinner =
|
|
155
|
+
const spinner = await makeSpinner('Opening browser for authentication...');
|
|
156
156
|
try {
|
|
157
157
|
const token = await browserLogin();
|
|
158
158
|
const payload = decodeJwt(token);
|
package/dist/commands/signup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
3
|
import { config } from '../config.js';
|
|
5
4
|
import { CliHttpError, postJson } from '../api.js';
|
|
5
|
+
import { makeSpinner } from '../output.js';
|
|
6
6
|
import { promptForPassword, promptForValue } from '../prompt.js';
|
|
7
7
|
export const signupCommand = new Command('signup')
|
|
8
8
|
.description('Create a Maritime account with email and password')
|
|
@@ -17,7 +17,7 @@ export const signupCommand = new Command('signup')
|
|
|
17
17
|
console.log(chalk.red('Error:') + ' email and password are required');
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
|
-
const spinner =
|
|
20
|
+
const spinner = await makeSpinner('Creating account...');
|
|
21
21
|
try {
|
|
22
22
|
const auth = await postJson('/api/auth/cli-signup', {
|
|
23
23
|
email,
|
package/dist/commands/sleep.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import ora from 'ora';
|
|
4
3
|
import { authPost } from '../api.js';
|
|
5
4
|
import { resolveAgent } from '../resolve.js';
|
|
6
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
5
|
+
import { isJsonMode, outputJson, handleError, makeSpinner } from '../output.js';
|
|
7
6
|
export const sleepCommand = new Command('sleep')
|
|
8
7
|
.description('Put an agent to sleep')
|
|
9
8
|
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
10
9
|
.action(async (agentArg) => {
|
|
11
10
|
try {
|
|
12
11
|
const agent = await resolveAgent(agentArg);
|
|
13
|
-
const spinner =
|
|
12
|
+
const spinner = await makeSpinner(`Sleeping ${chalk.bold(agent.name)}...`);
|
|
14
13
|
const result = await authPost(`/api/agents/${agent.id}/sleep`);
|
|
15
14
|
spinner.succeed(chalk.green('Agent is now sleeping: ') + chalk.bold(agent.name));
|
|
16
15
|
if (isJsonMode()) {
|
package/dist/output.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export declare function handleError(error: unknown): never;
|
|
|
53
53
|
* corrupt machine output. Lazily loads `ora` only when actually needed.
|
|
54
54
|
*/
|
|
55
55
|
export interface Spinner {
|
|
56
|
+
/** Live status line (mirrors ora's `.text`); ignored in degraded modes. */
|
|
57
|
+
text?: string;
|
|
56
58
|
succeed(text?: string): void;
|
|
57
59
|
fail(text?: string): void;
|
|
58
60
|
stop(): void;
|
package/dist/output.js
CHANGED
|
@@ -113,9 +113,28 @@ export async function makeSpinner(text) {
|
|
|
113
113
|
if (isJsonMode() || !process.stderr.isTTY) {
|
|
114
114
|
return { succeed() { }, fail() { }, stop() { } };
|
|
115
115
|
}
|
|
116
|
+
// Degenerate PTYs — script(1), some CI wrappers — report a 0×0 winsize.
|
|
117
|
+
// ora's line-wrap math then clears "text ÷ 0" lines per frame: a multi-MB/s
|
|
118
|
+
// ANSI write storm whose backpressure starves the event loop, so the await
|
|
119
|
+
// the spinner is covering never resolves. Degrade to static lines instead.
|
|
120
|
+
const cols = process.stderr.columns;
|
|
121
|
+
if (!cols || cols < 20) {
|
|
122
|
+
process.stderr.write(`${text}\n`);
|
|
123
|
+
return {
|
|
124
|
+
succeed: (t) => process.stderr.write(`✔ ${t ?? 'done'}\n`),
|
|
125
|
+
fail: (t) => process.stderr.write(`✖ ${t ?? 'failed'}\n`),
|
|
126
|
+
stop() { },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
116
129
|
const { default: ora } = await import('ora');
|
|
117
|
-
|
|
130
|
+
// discardStdin grabs stdin in raw mode; in wrapped PTYs that can keep the
|
|
131
|
+
// process alive after the command finishes. We never need it.
|
|
132
|
+
const spinner = ora({ text, stream: process.stderr, discardStdin: false }).start();
|
|
118
133
|
return {
|
|
134
|
+
set text(t) {
|
|
135
|
+
if (t !== undefined)
|
|
136
|
+
spinner.text = t;
|
|
137
|
+
},
|
|
119
138
|
succeed: (t) => spinner.succeed(t),
|
|
120
139
|
fail: (t) => spinner.fail(t),
|
|
121
140
|
stop: () => spinner.stop(),
|
package/dist/version-check.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { config } from './config.js';
|
|
3
3
|
const ONE_DAY = 24 * 60 * 60 * 1000;
|
|
4
|
+
/** True when `a` is a strictly newer semver than `b` (numeric x.y.z compare). */
|
|
5
|
+
function isNewer(a, b) {
|
|
6
|
+
const pa = a.split('.').map((n) => parseInt(n, 10) || 0);
|
|
7
|
+
const pb = b.split('.').map((n) => parseInt(n, 10) || 0);
|
|
8
|
+
for (let i = 0; i < 3; i++) {
|
|
9
|
+
if ((pa[i] || 0) !== (pb[i] || 0))
|
|
10
|
+
return (pa[i] || 0) > (pb[i] || 0);
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* Non-blocking daily check against npm registry.
|
|
6
16
|
* Prints a one-line update notice after command output if a newer version exists.
|
|
@@ -17,9 +27,15 @@ export function checkForUpdates(currentVersion) {
|
|
|
17
27
|
.then((data) => {
|
|
18
28
|
config.set('lastVersionCheck', Date.now());
|
|
19
29
|
const latest = data.version;
|
|
20
|
-
|
|
30
|
+
// Store only genuinely-newer versions, and clear anything stale —
|
|
31
|
+
// otherwise an old cached value survives upgrades forever and the
|
|
32
|
+
// banner suggests a "downgrade" (the 1.x → 0.2.1 bug).
|
|
33
|
+
if (latest && isNewer(latest, currentVersion)) {
|
|
21
34
|
config.set('latestVersion', latest);
|
|
22
35
|
}
|
|
36
|
+
else {
|
|
37
|
+
config.delete('latestVersion');
|
|
38
|
+
}
|
|
23
39
|
})
|
|
24
40
|
.catch(() => {
|
|
25
41
|
// Silently ignore — this is a non-blocking check
|
|
@@ -34,7 +50,7 @@ export function printUpdateNotice(currentVersion) {
|
|
|
34
50
|
if (process.argv.includes('--json'))
|
|
35
51
|
return;
|
|
36
52
|
const latest = config.get('latestVersion');
|
|
37
|
-
if (latest && latest
|
|
53
|
+
if (latest && isNewer(latest, currentVersion)) {
|
|
38
54
|
console.log(chalk.dim(`\n Update available: ${currentVersion} → ${chalk.bold(latest)}`) +
|
|
39
55
|
chalk.dim(' Run ') +
|
|
40
56
|
chalk.bold('npm i -g maritime-cli') +
|