@vatio-ai/cli 0.87.0 → 0.89.0
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 +2 -3
- package/bin/vatio.mjs +8 -49
- package/lib/api-client.mjs +14 -1
- package/lib/commands/chat.mjs +6 -12
- package/lib/commands/deploy.mjs +165 -80
- package/lib/commands/misc.mjs +1 -15
- package/lib/config.mjs +36 -42
- package/lib/help.mjs +9 -5
- package/lib/http.mjs +7 -10
- package/lib/pull.mjs +605 -0
- package/lib/support.mjs +17 -0
- package/lib/workspace.mjs +1 -17
- package/package.json +1 -1
- package/lib/trial.mjs +0 -135
package/README.md
CHANGED
|
@@ -27,9 +27,7 @@ npx @vatio-ai/cli init my-agent
|
|
|
27
27
|
npx @vatio-ai/cli push
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
No runtime to install first: if you have Node 20 or newer, you have this.
|
|
31
|
-
account either: with none on the machine, `push` deploys a 7-day trial and
|
|
32
|
-
prints a link to try it and one to keep it, which is where you sign in.
|
|
30
|
+
No runtime to install first: if you have Node 20 or newer, you have this.
|
|
33
31
|
|
|
34
32
|
The package is `@vatio-ai/cli`; the command it installs is `vatio`. So
|
|
35
33
|
`npm install -g @vatio-ai/cli` gives you `vatio push`, and `npx @vatio-ai/cli push`
|
|
@@ -73,6 +71,7 @@ login | logout Authorize this machine in a browser, or revoke and f
|
|
|
73
71
|
doctor Node, config, workspace and token status
|
|
74
72
|
|
|
75
73
|
push Validate the workspace, then update preview
|
|
74
|
+
pull [--env NAME] Write the deployed agent back into vatio.yml and tools/
|
|
76
75
|
publish Take preview live, once `vatio test` has tested it
|
|
77
76
|
diff [--env NAME] What this directory would change
|
|
78
77
|
status Preview and live deployment state
|
package/bin/vatio.mjs
CHANGED
|
@@ -5,21 +5,12 @@
|
|
|
5
5
|
// terminal; the credential lives in ~/.vatio/config.json.
|
|
6
6
|
|
|
7
7
|
import { Config, ConfigError } from "../lib/config.mjs";
|
|
8
|
-
import {
|
|
9
|
-
CliOutdatedError,
|
|
10
|
-
HttpError,
|
|
11
|
-
UnauthorizedError,
|
|
12
|
-
ForbiddenError,
|
|
13
|
-
NotFoundError,
|
|
14
|
-
TrialClaimedError,
|
|
15
|
-
TrialGoneError
|
|
16
|
-
} from "../lib/http.mjs";
|
|
17
|
-
import { keepClaimedTrial } from "../lib/trial.mjs";
|
|
8
|
+
import { CliOutdatedError, HttpError, UnauthorizedError, ForbiddenError, NotFoundError } from "../lib/http.mjs";
|
|
18
9
|
import { UserError, fail } from "../lib/support.mjs";
|
|
19
10
|
import { helpText } from "../lib/help.mjs";
|
|
20
11
|
import { login, logout } from "../lib/commands/auth.mjs";
|
|
21
12
|
import { configCommand, doctor, init, version, whoami } from "../lib/commands/misc.mjs";
|
|
22
|
-
import { diff, publish, push, rollback, status } from "../lib/commands/deploy.mjs";
|
|
13
|
+
import { diff, publish, pull, push, rollback, status } from "../lib/commands/deploy.mjs";
|
|
23
14
|
import { env } from "../lib/commands/env.mjs";
|
|
24
15
|
import { keys, secrets, tokens } from "../lib/commands/workspace-admin.mjs";
|
|
25
16
|
import { templates, webhooks } from "../lib/commands/webhooks.mjs";
|
|
@@ -38,9 +29,6 @@ import { beginRun, isCodingAgent, reportRun, telemetryEnabled } from "../lib/tel
|
|
|
38
29
|
// Commands that existed and are gone, answered by name rather than as
|
|
39
30
|
// unknown: removed from the product, or what npm does now.
|
|
40
31
|
const RETIRED = {
|
|
41
|
-
pull: "was removed: a deployed manifest only ever comes from a push, so it could never\n" +
|
|
42
|
-
"hand back anything your repository did not already have. Use `vatio diff --env live`,\n" +
|
|
43
|
-
"or read the manifest at GET /api/developer/v1/:slug/manifest.",
|
|
44
32
|
issue: "was removed: report a problem on the public repository it belongs to --\n" +
|
|
45
33
|
"https://github.com/vatio-ai/cli/issues (or sdk, ios, ruby under github.com/vatio-ai).",
|
|
46
34
|
widget: "was removed: `vatio env` prints the snippet and its token, and the look is edited in\n" +
|
|
@@ -58,25 +46,11 @@ async function main(argv) {
|
|
|
58
46
|
const command = args.shift();
|
|
59
47
|
beginRun(command, args);
|
|
60
48
|
const updateCheck = startUpdateCheck(command);
|
|
61
|
-
await
|
|
49
|
+
await run(command, args);
|
|
62
50
|
await reportRun(config, { exitCode: process.exitCode ?? 0 });
|
|
63
51
|
await printUpdateNotice(updateCheck);
|
|
64
52
|
}
|
|
65
53
|
|
|
66
|
-
// The trial this directory pushed to was kept in the browser since the last
|
|
67
|
-
// command (lib/trial.mjs): the refused call did nothing, so this terminal signs
|
|
68
|
-
// in to the account that kept it and the command runs again, as that account.
|
|
69
|
-
async function runKeepingTrial(command, args) {
|
|
70
|
-
const again = [...args];
|
|
71
|
-
try {
|
|
72
|
-
await run(command, args);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (!(error instanceof TrialClaimedError) || !error.workspace) throw error;
|
|
75
|
-
await keepClaimedTrial(config, error);
|
|
76
|
-
await run(command, again);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
54
|
async function run(command, args) {
|
|
81
55
|
// `--help` after a command asks about it. Left to the command, it reads as a
|
|
82
56
|
// message to send, an argument, or nothing at all: `vatio chat --help` said
|
|
@@ -104,6 +78,8 @@ async function run(command, args) {
|
|
|
104
78
|
return await init(config, args);
|
|
105
79
|
case "push":
|
|
106
80
|
return await push(config, args);
|
|
81
|
+
case "pull":
|
|
82
|
+
return await pull(config, args);
|
|
107
83
|
case "publish":
|
|
108
84
|
return await publish(config, args);
|
|
109
85
|
case "rollback":
|
|
@@ -180,23 +156,10 @@ function printError(error) {
|
|
|
180
156
|
console.error(error.message);
|
|
181
157
|
return suggestFeedback();
|
|
182
158
|
}
|
|
183
|
-
if (error instanceof TrialGoneError) {
|
|
184
|
-
config.clearTrial();
|
|
185
|
-
// The platform's hint says what to run next.
|
|
186
|
-
console.error("This trial no longer exists: nobody kept it in time, so it was deleted.");
|
|
187
|
-
return printTrailer(error);
|
|
188
|
-
}
|
|
189
159
|
if (error instanceof UnauthorizedError) {
|
|
190
160
|
console.error("Authentication failed (401). Run `vatio login`.");
|
|
191
161
|
return printTrailer(error);
|
|
192
162
|
}
|
|
193
|
-
if (error instanceof ForbiddenError && errorCode(error) === "trial_unclaimed") {
|
|
194
|
-
// The platform says what needs an account; the link to keep it is only here.
|
|
195
|
-
const trial = config.trial();
|
|
196
|
-
const link = trial?.claim_url ?? 'the link `vatio push` printed after "Keep it"';
|
|
197
|
-
console.error(`${error.message} Keep it first: ${link}, then run vatio ${process.argv[2]} again (it signs this terminal in).`);
|
|
198
|
-
return printTrailer(error, { hint: false });
|
|
199
|
-
}
|
|
200
163
|
if (error instanceof ForbiddenError) {
|
|
201
164
|
console.error("Access denied (403). Your token cannot access this workspace.");
|
|
202
165
|
return printTrailer(error);
|
|
@@ -219,20 +182,16 @@ function printError(error) {
|
|
|
219
182
|
|
|
220
183
|
// What the platform said to do next, and the ids that find this request in
|
|
221
184
|
// its logs.
|
|
222
|
-
function printTrailer(error
|
|
185
|
+
function printTrailer(error) {
|
|
223
186
|
const hint = error.body?.hint;
|
|
224
|
-
if (
|
|
187
|
+
if (hint && !(error instanceof UnauthorizedError)) console.error(`Next: ${hint}`);
|
|
225
188
|
|
|
226
|
-
const code =
|
|
189
|
+
const code = error.body?.error_key ?? (typeof error.body?.error === "string" ? error.body.error : error.body?.error?.code);
|
|
227
190
|
const ids = [code && `error=${code}`, error.requestId && `request_id=${error.requestId}`].filter(Boolean);
|
|
228
191
|
if (ids.length > 0) console.error(ids.join(" "));
|
|
229
192
|
suggestFeedback();
|
|
230
193
|
}
|
|
231
194
|
|
|
232
|
-
function errorCode(error) {
|
|
233
|
-
return error.body?.error_key ?? (typeof error.body?.error === "string" ? error.body.error : error.body?.error?.code);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
195
|
// Said to coding agents only: a person at a terminal has better ways to
|
|
237
196
|
// complain, and does not need the line on every typo.
|
|
238
197
|
function suggestFeedback() {
|
package/lib/api-client.mjs
CHANGED
|
@@ -39,13 +39,26 @@ export class ApiClient extends HttpClient {
|
|
|
39
39
|
return this.post("/check", body);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
// `baseDeploymentId`: the deployment the files were last made to match. The
|
|
43
|
+
// platform refuses the push (409 preview_edited_outside) while preview holds
|
|
44
|
+
// edits made outside the files since then, or any at all without one,
|
|
45
|
+
// unless `force`.
|
|
46
|
+
pushPreview({
|
|
47
|
+
manifest,
|
|
48
|
+
gitSha = null,
|
|
49
|
+
gitBranch = null,
|
|
50
|
+
createdBy = null,
|
|
51
|
+
environment = null,
|
|
52
|
+
force = false,
|
|
53
|
+
baseDeploymentId = null
|
|
54
|
+
}) {
|
|
43
55
|
const body = { manifest };
|
|
44
56
|
if (gitSha) body.git_sha = gitSha;
|
|
45
57
|
if (gitBranch) body.git_branch = gitBranch;
|
|
46
58
|
if (createdBy) body.created_by = createdBy;
|
|
47
59
|
if (environment) body.environment = environment;
|
|
48
60
|
if (force) body.force = true;
|
|
61
|
+
if (Number.isInteger(baseDeploymentId)) body.base_deployment_id = baseDeploymentId;
|
|
49
62
|
return this.put("/push", body);
|
|
50
63
|
}
|
|
51
64
|
|
package/lib/commands/chat.mjs
CHANGED
|
@@ -138,24 +138,18 @@ async function exportChats(config, args) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
// With no account on this machine, the trial this directory pushed to, with
|
|
142
|
-
// its key (lib/trial.mjs): a chat there is the trial's developer, like any.
|
|
143
141
|
function client(config, options) {
|
|
144
|
-
const apiUrl =
|
|
145
|
-
const token = options.token ?? config.resolveToken()
|
|
142
|
+
const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
|
|
143
|
+
const token = options.token ?? config.resolveToken();
|
|
146
144
|
if (!apiUrl) {
|
|
147
145
|
// Says which: no vatio.yml here (and where one is), or one without `workspace:`.
|
|
148
146
|
config.resolveWorkspaceRequired();
|
|
149
147
|
fail("A workspace API url is required (--api-url, or base_url + a vatio.yml with `workspace:`)");
|
|
150
148
|
}
|
|
151
|
-
if (!token) fail("VATIO_TOKEN is required (env or `vatio login`)
|
|
149
|
+
if (!token) fail("VATIO_TOKEN is required (env or `vatio login`)");
|
|
152
150
|
return new ApiClient({ baseUrl: apiUrl, token });
|
|
153
151
|
}
|
|
154
152
|
|
|
155
|
-
function apiUrlFor(config, options) {
|
|
156
|
-
return config.resolveApiUrl({ explicit: options.apiUrl, token: options.token });
|
|
157
|
-
}
|
|
158
|
-
|
|
159
153
|
function statePath(config) {
|
|
160
154
|
return join(config.workspaceRootRequired(), STATE_FILE);
|
|
161
155
|
}
|
|
@@ -187,7 +181,7 @@ function rememberChat(config, { apiUrl, environment, chatId }) {
|
|
|
187
181
|
}
|
|
188
182
|
|
|
189
183
|
async function ensureChat(config, options) {
|
|
190
|
-
const apiUrl =
|
|
184
|
+
const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
|
|
191
185
|
const existing = chatsFor(config, apiUrl)[options.environment];
|
|
192
186
|
if (existing) return Number(existing);
|
|
193
187
|
|
|
@@ -273,7 +267,7 @@ async function showChat(config, options, args) {
|
|
|
273
267
|
let chatId = args.shift();
|
|
274
268
|
if (chatId !== undefined && !/^\d+$/.test(chatId)) fail("Usage: vatio chat show [CHAT_ID] [--last N] [--json]");
|
|
275
269
|
if (chatId === undefined) {
|
|
276
|
-
const apiUrl =
|
|
270
|
+
const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
|
|
277
271
|
chatId = chatsFor(config, apiUrl)[options.environment];
|
|
278
272
|
if (!chatId) fail(`No ${options.environment} chat yet: run \`vatio chat "hello"\` first, or pass a CHAT_ID.`);
|
|
279
273
|
chatId = String(chatId);
|
|
@@ -388,7 +382,7 @@ function truncate(text, max) {
|
|
|
388
382
|
}
|
|
389
383
|
|
|
390
384
|
async function startOver(config, options) {
|
|
391
|
-
const apiUrl =
|
|
385
|
+
const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
|
|
392
386
|
const payload = await openChat(config, options, {
|
|
393
387
|
apiUrl,
|
|
394
388
|
chatId: chatsFor(config, apiUrl)[options.environment] ?? null
|
package/lib/commands/deploy.mjs
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
// push / publish / rollback / status / diff.
|
|
1
|
+
// push / pull / publish / rollback / status / diff.
|
|
2
2
|
//
|
|
3
3
|
// Every one of them is HTTP. The workspace is parsed by the platform
|
|
4
4
|
// (POST /deploy/check), so what is left here is: read the directory, send it,
|
|
5
5
|
// print what came back.
|
|
6
6
|
//
|
|
7
|
-
// `pull` is
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
7
|
+
// `pull` is the exception, the one command that writes over the developer's
|
|
8
|
+
// own files. It is back because the files stopped being the only writer: from
|
|
9
|
+
// the Vatio MCP, in Claude or ChatGPT, people edit the agent itself, and each
|
|
10
|
+
// edit lands in preview as a deployment of its own. What it writes is narrow
|
|
11
|
+
// on purpose (lib/pull.mjs): each tools/KEY.yml exactly as the platform holds
|
|
12
|
+
// it, and only the `agent:` block of the vatio.yml already on disk, key by
|
|
13
|
+
// key, because a revision keeps neither that file's comments nor `auth:` the
|
|
14
|
+
// way the file spells it. And it wants a clean git tree, so that git, not this
|
|
15
|
+
// CLI, is what gives back whatever it replaced.
|
|
16
|
+
//
|
|
17
|
+
// The two directions meet in the base deployment: the one the files were last
|
|
18
|
+
// made to match, by a push or a pull, kept in the config file. A push sends
|
|
19
|
+
// it, so the platform can refuse to overwrite edits the files have never seen.
|
|
20
|
+
|
|
21
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
22
|
+
import { dirname, join } from "node:path";
|
|
14
23
|
|
|
15
24
|
import { stringify as stringifyYaml } from "yaml";
|
|
16
25
|
|
|
17
26
|
import { buildBundle, BundleError } from "../bundle.mjs";
|
|
18
27
|
import { ApiClient, CliClient } from "../api-client.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
28
|
+
import { ConflictError, NotFoundError, UnprocessableError } from "../http.mjs";
|
|
29
|
+
import { MANIFEST_FILE } from "../workspace.mjs";
|
|
30
|
+
import { PullError, planPull } from "../pull.mjs";
|
|
21
31
|
import { deviceLogin } from "./auth.mjs";
|
|
22
|
-
import { detectGitBranch, detectGitSha, fail, paint, takeEnv, takeFlag, takeValue } from "../support.mjs";
|
|
32
|
+
import { detectGitBranch, detectGitSha, fail, gitChanges, paint, takeEnv, takeFlag, takeValue } from "../support.mjs";
|
|
23
33
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
export async function ensureAuthorized(config, { workspace = null, message = "Before I can
|
|
34
|
+
// The first command that makes something exist on a server, so the first one
|
|
35
|
+
// that needs to know whose it is.
|
|
36
|
+
export async function ensureAuthorized(config, { workspace = null, message = "Before I can push this, I need to know whose it is." } = {}) {
|
|
27
37
|
if (config.resolveToken()) return;
|
|
28
38
|
|
|
29
39
|
const auth = await deviceLogin({ config, workspace, message });
|
|
@@ -33,18 +43,13 @@ export async function ensureAuthorized(config, { workspace = null, message = "Be
|
|
|
33
43
|
console.log("");
|
|
34
44
|
}
|
|
35
45
|
|
|
36
|
-
// With no account on this machine, the trial `vatio push` made from this
|
|
37
|
-
// directory (lib/trial.mjs), on its own slug and key: the platform answers
|
|
38
|
-
// what a trial may do and refuses the rest with `trial_unclaimed`.
|
|
39
46
|
export function deployClient(config, workspace) {
|
|
40
47
|
const base = config.resolveBaseUrl();
|
|
41
48
|
if (!base) fail("VATIO_BASE_URL is required (env or `vatio config set base_url …`)");
|
|
42
49
|
const token = config.resolveToken();
|
|
43
|
-
if (token)
|
|
50
|
+
if (!token) fail("VATIO_TOKEN is required (env or `vatio login`)");
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
if (trial) return new ApiClient({ baseUrl: `${base}/api/developer/v1/${trial.workspace}`, token: trial.key });
|
|
47
|
-
fail("VATIO_TOKEN is required (env or `vatio login`). `vatio push` deploys a trial with no account.");
|
|
52
|
+
return new ApiClient({ baseUrl: `${base}/api/developer/v1/${workspace}`, token });
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export function workspacesClient(config) {
|
|
@@ -93,14 +98,13 @@ export async function push(config, args) {
|
|
|
93
98
|
// explicitly would make a bare `vatio push` and `vatio push --env preview`
|
|
94
99
|
// two different requests that only happen to agree today.
|
|
95
100
|
const environment = takeEnv(args, { fallback: null });
|
|
96
|
-
// Replaces an unpublished push from another branch,
|
|
97
|
-
// otherwise refuses
|
|
101
|
+
// Replaces an unpublished push from another branch, or edits made outside
|
|
102
|
+
// the files, which the platform otherwise refuses
|
|
103
|
+
// (preview_has_unpublished_push, preview_edited_outside).
|
|
98
104
|
const force = takeFlag(args, "--force");
|
|
99
105
|
const workspace = config.resolveWorkspaceRequired();
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
if (!config.resolveToken()) return await pushTrial(config, { workspace, environment, force });
|
|
103
|
-
noticeLeftoverTrial(config);
|
|
107
|
+
await ensureAuthorized(config, { workspace });
|
|
104
108
|
|
|
105
109
|
// The remote has to exist before the workspace can be checked: the slug is in
|
|
106
110
|
// the URL of the call that checks it. It is created unnamed; the display name
|
|
@@ -113,7 +117,29 @@ export async function push(config, args) {
|
|
|
113
117
|
console.log(`Created remote workspace ${workspace}`);
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
const
|
|
120
|
+
const check = await checkWorkspace(config, workspace, { environment });
|
|
121
|
+
printDiagnostics(check);
|
|
122
|
+
if (!check.ok) fail(`push aborted: check failed (${asArray(check.errors).length} error(s))`);
|
|
123
|
+
|
|
124
|
+
const client = deployClient(config, workspace);
|
|
125
|
+
const baseUrl = config.resolveBaseUrl();
|
|
126
|
+
let payload;
|
|
127
|
+
try {
|
|
128
|
+
payload = await client.pushPreview({
|
|
129
|
+
manifest: check.manifest,
|
|
130
|
+
gitSha: detectGitSha(config.workspaceRootRequired()),
|
|
131
|
+
gitBranch: detectGitBranch(config.workspaceRootRequired()),
|
|
132
|
+
createdBy: process.env.USER ?? null,
|
|
133
|
+
environment,
|
|
134
|
+
force,
|
|
135
|
+
baseDeploymentId: config.baseDeploymentFor({ baseUrl, workspace })
|
|
136
|
+
});
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof ConflictError && error.errorKey === "preview_edited_outside") fail(editedOutsideMessage(error));
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
// What the files match now, so the next push is built on it.
|
|
142
|
+
config.rememberBaseDeployment({ baseUrl, workspace, deploymentId: payload.deployment_id });
|
|
117
143
|
|
|
118
144
|
const landedOn = payload.environment ?? "preview";
|
|
119
145
|
console.log(`Pushed deployment #${payload.deployment_id} to ${landedOn} (git_sha=${JSON.stringify(payload.git_sha ?? null)})`);
|
|
@@ -131,72 +157,120 @@ export async function push(config, args) {
|
|
|
131
157
|
printNotices(payload);
|
|
132
158
|
}
|
|
133
159
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
160
|
+
// Something the platform wants the developer to know about the command they
|
|
161
|
+
// just ran -- a deprecation, usually. On stderr so scripts reading stdout keep
|
|
162
|
+
// working.
|
|
163
|
+
function printNotices(payload) {
|
|
164
|
+
for (const notice of asArray(payload.notices)) {
|
|
165
|
+
process.stderr.write(`\n${paint("yellow", `Notice: ${notice}`)}\n`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
138
168
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
169
|
+
// Refused because preview holds edits the files have never seen: which, and
|
|
170
|
+
// the two ways forward. The platform's message says all of it in one line,
|
|
171
|
+
// for releases that print only that; with the list to go by, this one says
|
|
172
|
+
// it a line per edit instead of repeating it.
|
|
173
|
+
function editedOutsideMessage(error) {
|
|
174
|
+
const edits = asArray(error.body.edits);
|
|
175
|
+
const count = edits.length === 1 ? "a change" : `${edits.length} changes`;
|
|
176
|
+
const lines = edits.length === 0 ? [error.message] : [`Preview has ${count} made outside your files that this push would overwrite:`];
|
|
177
|
+
for (const edit of edits) lines.push(` ${editLine(edit)}`);
|
|
178
|
+
const them = edits.length === 1 ? "it" : "them";
|
|
179
|
+
lines.push(
|
|
180
|
+
"",
|
|
181
|
+
`Run \`vatio pull\` to bring ${them} into your files, review with \`git diff\`, and push again.`,
|
|
182
|
+
`\`vatio push --force\` overwrites ${them} instead.`
|
|
183
|
+
);
|
|
184
|
+
return lines.join("\n");
|
|
147
185
|
}
|
|
148
186
|
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
// `#42 by ivan@x.cl via Claude, 2026-10-16T12:00:00Z: instructions, tool my_orders`
|
|
188
|
+
function editLine(edit) {
|
|
189
|
+
const who = edit?.created_by ? ` by ${edit.created_by}` : "";
|
|
190
|
+
const when = edit?.created_at ? `, ${edit.created_at}` : "";
|
|
191
|
+
const what = edit?.summary ? `: ${edit.summary}` : "";
|
|
192
|
+
return `#${edit?.deployment_id ?? "?"}${who}${when}${what}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// The deployed agent, back in the files: what an edit made from the Vatio MCP
|
|
196
|
+
// changed, so the next push carries it rather than undoing it. Preview by
|
|
197
|
+
// default, since that is where those edits land.
|
|
198
|
+
export async function pull(config, args) {
|
|
199
|
+
const environment = takeEnv(args, { fallback: "preview" });
|
|
200
|
+
// Writes even over uncommitted changes, or outside git.
|
|
201
|
+
const force = takeFlag(args, "--force");
|
|
202
|
+
if (args.length > 0) fail(`vatio pull: unexpected ${JSON.stringify(args[0])} (it takes --env NAME and --force)`);
|
|
203
|
+
|
|
204
|
+
const workspace = config.resolveWorkspaceRequired();
|
|
205
|
+
const root = config.workspaceRootRequired();
|
|
206
|
+
const client = deployClient(config, workspace);
|
|
207
|
+
if (!force) refuseUnkeptChanges(root);
|
|
158
208
|
|
|
159
209
|
let payload;
|
|
160
210
|
try {
|
|
161
|
-
payload = await
|
|
211
|
+
payload = await client.deployedManifest({ environment });
|
|
162
212
|
} catch (error) {
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
started = true;
|
|
168
|
-
payload = await checkAndPush(config, workspace, { environment, force });
|
|
213
|
+
if (error instanceof NotFoundError) {
|
|
214
|
+
fail(`Nothing to pull: ${workspace} has no ${environment} deployment yet. \`vatio push\` makes one from your files.`);
|
|
215
|
+
}
|
|
216
|
+
throw error;
|
|
169
217
|
}
|
|
170
218
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
219
|
+
let changes;
|
|
220
|
+
try {
|
|
221
|
+
changes = planPull(root, payload.manifest);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
if (error instanceof PullError) fail(`vatio pull: ${error.message}`);
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
178
226
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
227
|
+
const deployment = `deployment #${payload.deployment_id} (${payload.environment ?? environment})`;
|
|
228
|
+
const edits = asArray(payload.edited_outside_push);
|
|
229
|
+
if (edits.length > 0) {
|
|
230
|
+
console.log(`Edits made outside your files, in ${deployment}:`);
|
|
231
|
+
for (const edit of edits) console.log(` ${editLine(edit)}`);
|
|
232
|
+
console.log("");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
for (const change of changes) {
|
|
236
|
+
const path = join(root, change.path);
|
|
237
|
+
if (change.action === "deleted") {
|
|
238
|
+
rmSync(path, { force: true });
|
|
239
|
+
} else {
|
|
240
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
241
|
+
writeFileSync(path, change.content);
|
|
242
|
+
}
|
|
243
|
+
console.log(`${change.action} ${change.path}`);
|
|
244
|
+
}
|
|
245
|
+
config.rememberBaseDeployment({ baseUrl: config.resolveBaseUrl(), workspace, deploymentId: payload.deployment_id });
|
|
246
|
+
|
|
247
|
+
if (changes.length === 0) {
|
|
248
|
+
console.log(`Your files already match ${deployment}.`);
|
|
249
|
+
} else {
|
|
250
|
+
console.log(`Your files now match ${deployment}. Review with \`git diff\`, then \`vatio push\`.`);
|
|
188
251
|
}
|
|
189
|
-
process.stderr.write(
|
|
190
|
-
`${paint("yellow", `This directory had a trial (${trial.workspace}): keep it with ${trial.claim_url} or this push goes to your account`)}\n\n`
|
|
191
|
-
);
|
|
192
252
|
}
|
|
193
253
|
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
254
|
+
// Pull writes over vatio.yml and tools/, so what they hold now has to be
|
|
255
|
+
// somewhere it can come back from: committed to git.
|
|
256
|
+
function refuseUnkeptChanges(root) {
|
|
257
|
+
const changed = gitChanges(root, [MANIFEST_FILE, "tools"]);
|
|
258
|
+
if (changed === null) {
|
|
259
|
+
fail(
|
|
260
|
+
`vatio pull writes over ${MANIFEST_FILE} and tools/, and this workspace is not in a git repository,\n` +
|
|
261
|
+
"so nothing could give you back what they hold now. Commit them to git first, or run\n" +
|
|
262
|
+
"`vatio pull --force` to overwrite them anyway."
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (changed.length > 0) {
|
|
266
|
+
fail(
|
|
267
|
+
[
|
|
268
|
+
`vatio pull writes over ${MANIFEST_FILE} and tools/, and they have changes git has not kept:`,
|
|
269
|
+
...changed.map((line) => ` ${line}`),
|
|
270
|
+
"",
|
|
271
|
+
"Commit or stash them first, so git keeps what you had, or run `vatio pull --force` to overwrite them."
|
|
272
|
+
].join("\n")
|
|
273
|
+
);
|
|
200
274
|
}
|
|
201
275
|
}
|
|
202
276
|
|
|
@@ -268,6 +342,17 @@ export async function status(config) {
|
|
|
268
342
|
`reads it — add \`knowledge: [${base.name}]\` to vatio.yml and push.`
|
|
269
343
|
);
|
|
270
344
|
}
|
|
345
|
+
// Edits from the Vatio MCP that preview carries, no push has written over
|
|
346
|
+
// and these files have not pulled: the next push is refused until they are.
|
|
347
|
+
const base = config.baseDeploymentFor({ baseUrl: config.resolveBaseUrl(), workspace });
|
|
348
|
+
const edits = asArray(payload.preview_edited_outside_push).filter(
|
|
349
|
+
(edit) => base == null || Number(edit.deployment_id) > base
|
|
350
|
+
);
|
|
351
|
+
if (edits.length > 0) {
|
|
352
|
+
console.error(`Preview has ${edits.length === 1 ? "a change" : `${edits.length} changes`} made outside your files:`);
|
|
353
|
+
for (const edit of edits) console.error(` ${editLine(edit)}`);
|
|
354
|
+
console.error(" `vatio pull` brings them into your files before your next push.");
|
|
355
|
+
}
|
|
271
356
|
printVatioSide(payload.vatio);
|
|
272
357
|
}
|
|
273
358
|
|
package/lib/commands/misc.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import { KEYS, SLUG_FORMAT } from "../config.mjs";
|
|
|
7
7
|
import { MANIFEST_FILE, manifestPath } from "../workspace.mjs";
|
|
8
8
|
import { VERSION } from "../version.mjs";
|
|
9
9
|
import { fail, takeValue } from "../support.mjs";
|
|
10
|
-
import { formatUtc } from "../trial.mjs";
|
|
11
10
|
import { workspacesClient } from "./deploy.mjs";
|
|
12
11
|
|
|
13
12
|
export const DOCS_URL = "https://vatio.ai/docs";
|
|
@@ -40,14 +39,6 @@ export async function doctor(config) {
|
|
|
40
39
|
const token = config.resolveToken();
|
|
41
40
|
console.log(`Token: ${token ? "configured" : "missing — run `vatio login`"}`);
|
|
42
41
|
if (token) console.log(`Account: ${await accountLine(config)}`);
|
|
43
|
-
// Where this directory pushes with no account. The link to keep it is not
|
|
44
|
-
// printed: whoever holds it can take the trial, and this output is the one
|
|
45
|
-
// that gets pasted into issues.
|
|
46
|
-
const trial = config.trial();
|
|
47
|
-
if (trial) {
|
|
48
|
-
const used = token ? " (not used: this machine has an account)" : "";
|
|
49
|
-
console.log(`Trial: ${trial.workspace}${used}, deleted ${formatUtc(trial.expires_at)} unless kept`);
|
|
50
|
-
}
|
|
51
42
|
console.log(`Docs: ${DOCS_URL}`);
|
|
52
43
|
}
|
|
53
44
|
|
|
@@ -160,12 +151,7 @@ export async function init(config, args) {
|
|
|
160
151
|
console.log(`Wrote ${manifest}`);
|
|
161
152
|
const agentsNote = writeAgentsNote(target);
|
|
162
153
|
if (agentsNote) console.log(agentsNote);
|
|
163
|
-
if (!authorized) {
|
|
164
|
-
console.log(
|
|
165
|
-
"Local only for now — `vatio push` deploys it with no account, as a trial, and prints a link to try it " +
|
|
166
|
-
`and one to keep it as ${slug}.`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
154
|
+
if (!authorized) console.log(`Local only for now — \`vatio push\` is what creates ${slug} on the platform.`);
|
|
169
155
|
if (!authorized && String(name ?? "").trim() !== "") {
|
|
170
156
|
console.log("Set the display name once it exists: `vatio business set --name NAME`, or the inbox's Business page.");
|
|
171
157
|
}
|