@vatio-ai/cli 0.69.0 → 0.71.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 CHANGED
@@ -50,11 +50,11 @@ is no `--workspace` flag.
50
50
 
51
51
  ```
52
52
  init [SLUG] Create vatio.yml here, and the remote to match
53
- login | logout Authorize this machine in a browser, or forget it
53
+ login | logout Authorize this machine in a browser, or revoke and forget it
54
54
  doctor Node, config, workspace and token status
55
55
 
56
- push [--env NAME] Validate the workspace, then update a preview
57
- publish [--env NAME] Promote the latest push to live, or the named preview
56
+ push Validate the workspace, then update preview
57
+ publish Take preview live, once `vatio eval` has tested it
58
58
  diff [--env NAME] What this directory would change
59
59
  status Preview and live deployment state
60
60
  rollback Restore the previous live deployment
@@ -64,6 +64,10 @@ chat "message" [--env NAME] [--new]
64
64
  chat show [CHAT_ID] [--json]
65
65
  The chat you are in, or any chat in the workspace, with its tool calls
66
66
 
67
+ flags Every open report from the inbox, for your coding agent to fix
68
+ eval Test every report against preview; exits 1 if one fails
69
+ tools [--env NAME] How each tool's backend has been answering
70
+
67
71
  kb list|show|create|rm Knowledge bases
68
72
  kb write|cat|rm-entry Entries, from a file or stdin
69
73
 
@@ -78,8 +82,8 @@ docs [--save [PATH]] The whole developer contract
78
82
  config show|set|unset base_url and token, per developer
79
83
  ```
80
84
 
81
- `--env NAME` targets a deployment: `live`, `preview`, or a named preview like
82
- `pr-42`.
85
+ `--env NAME` targets an environment: `preview`, the next version, or `live`,
86
+ what visitors talk to.
83
87
 
84
88
  Run `npx @vatio-ai/cli help` for the whole surface, and see
85
89
  [vatio.ai/docs](https://vatio.ai/docs) for the platform.
package/bin/vatio.mjs CHANGED
@@ -21,7 +21,6 @@ import { business } from "../lib/commands/business.mjs";
21
21
  import { instagram, whatsapp } from "../lib/commands/channels.mjs";
22
22
  import { docs, feedback, shareSession } from "../lib/commands/support-commands.mjs";
23
23
  import { evalCommand, flags, tools } from "../lib/commands/improve.mjs";
24
- import { propose } from "../lib/commands/propose.mjs";
25
24
  import { printUpdateNotice, startUpdateCheck } from "../lib/update-notice.mjs";
26
25
  import { beginRun, isCodingAgent, reportRun, telemetryEnabled } from "../lib/telemetry.mjs";
27
26
 
@@ -37,7 +36,8 @@ const RETIRED = {
37
36
  "the console's Widget page.",
38
37
  mcp: "was removed. Point your coding agent at `vatio docs --save` and let it run the CLI.",
39
38
  update: "is npm's job now: `npx @vatio-ai/cli@latest` always runs the current release, and\n" +
40
- "`npm install -g @vatio-ai/cli@latest` updates a global install."
39
+ "`npm install -g @vatio-ai/cli@latest` updates a global install.",
40
+ propose: "was removed in 0.71.0. Test with `vatio eval` and publish with `vatio publish`."
41
41
  };
42
42
 
43
43
  const config = new Config({ startDir: process.cwd() });
@@ -64,7 +64,7 @@ async function run(command, args) {
64
64
  case "login":
65
65
  return await login(config, args);
66
66
  case "logout":
67
- return logout(config);
67
+ return await logout(config);
68
68
  case "config":
69
69
  return configCommand(config, args);
70
70
  case "init":
@@ -109,8 +109,6 @@ async function run(command, args) {
109
109
  return await evalCommand(config, args);
110
110
  case "tools":
111
111
  return await tools(config, args);
112
- case "propose":
113
- return await propose(config, args);
114
112
  case "docs":
115
113
  return await docs(config, args);
116
114
  case "feedback":
@@ -29,19 +29,21 @@ export class ApiClient extends HttpClient {
29
29
  return this.post("/check", body);
30
30
  }
31
31
 
32
- pushPreview({ manifest, gitSha = null, gitBranch = null, createdBy = null, environment = null }) {
32
+ pushPreview({ manifest, gitSha = null, gitBranch = null, createdBy = null, environment = null, force = false }) {
33
33
  const body = { manifest };
34
34
  if (gitSha) body.git_sha = gitSha;
35
35
  if (gitBranch) body.git_branch = gitBranch;
36
36
  if (createdBy) body.created_by = createdBy;
37
37
  if (environment) body.environment = environment;
38
+ if (force) body.force = true;
38
39
  return this.put("/push", body);
39
40
  }
40
41
 
41
- publish({ createdBy = null, environment = null } = {}) {
42
+ publish({ createdBy = null, environment = null, force = false } = {}) {
42
43
  const body = {};
43
44
  if (createdBy) body.created_by = createdBy;
44
45
  if (environment) body.environment = environment;
46
+ if (force) body.force = true;
45
47
  return this.post("/publish", body);
46
48
  }
47
49
 
@@ -61,23 +63,6 @@ export class ApiClient extends HttpClient {
61
63
  return this.get(`/env/${encode(name)}`);
62
64
  }
63
65
 
64
- deleteEnvironment(name) {
65
- return this.delete(`/env/${encode(name)}`);
66
- }
67
-
68
- // --- proposals ------------------------------------------------------
69
-
70
- proposals() {
71
- return this.get("/proposals");
72
- }
73
-
74
- propose({ environment, title, summary }) {
75
- const body = { environment };
76
- if (title) body.title = title;
77
- if (summary != null) body.summary = summary;
78
- return this.post("/proposals", body);
79
- }
80
-
81
66
  // The project "Connect Supabase" picked in the console, if any.
82
67
  supabase() {
83
68
  return this.get("/supabase");
@@ -106,9 +91,9 @@ export class ApiClient extends HttpClient {
106
91
 
107
92
  // --- knowledge bases ------------------------------------------------
108
93
  //
109
- // Every read and write below is as one environment sees the base: a
110
- // branch's, which keeps its changes on top of live, or `live` itself.
111
- // Without one the platform means `preview`.
94
+ // Every read and write below is as one environment sees the base: preview,
95
+ // which keeps its changes on top of live, or `live` itself. Without one the
96
+ // platform means `preview`.
112
97
 
113
98
  knowledgeBases({ environment = null } = {}) {
114
99
  return this.get("/knowledge_bases", { environment });
@@ -3,6 +3,9 @@
3
3
  import { DeniedError, DeviceAuthClient, ExpiredError, PendingError } from "../device-auth.mjs";
4
4
  import { DEFAULT_BASE_URL } from "../config.mjs";
5
5
  import { fail, openBrowser, sleep, takeValue } from "../support.mjs";
6
+ import { clientHeaders } from "../telemetry.mjs";
7
+
8
+ const LOGOUT_TIMEOUT_MS = 10_000;
6
9
 
7
10
  // A token is minted by a human signing in on the page this opens -- email,
8
11
  // Google or GitHub -- never by the CLI alone, which is why it asks nothing
@@ -85,7 +88,27 @@ export async function login(config, args) {
85
88
  console.log(`Token saved to ${config.configPath}`);
86
89
  }
87
90
 
88
- export function logout(config) {
91
+ // Revokes the saved token on the server before forgetting it, so a copy of
92
+ // the config file stops working too. Offline or already revoked, the local
93
+ // copy is still removed. A token in VATIO_TOKEN is left alone: it was never
94
+ // this file's to forget.
95
+ export async function logout(config) {
96
+ const token = config.load().token;
97
+ let revoked = false;
98
+ if (token) {
99
+ try {
100
+ const response = await fetch(`${config.resolveBaseUrl()}/api/developer/v1/session`, {
101
+ method: "DELETE",
102
+ headers: { ...clientHeaders(), Accept: "application/json", Authorization: `Bearer ${token}` },
103
+ signal: AbortSignal.timeout(LOGOUT_TIMEOUT_MS)
104
+ });
105
+ revoked = response.ok;
106
+ } catch {
107
+ revoked = false;
108
+ }
109
+ }
110
+
89
111
  config.clearToken();
90
112
  console.log(`Removed the token from ${config.configPath}`);
113
+ if (token && !revoked) console.log("Could not reach Vatio to revoke it; it expires 90 days after its last use.");
91
114
  }
@@ -36,7 +36,7 @@ export async function chat(config, args) {
36
36
  }
37
37
  }
38
38
 
39
- const environment = takeEnv(args, { fallback: "preview", cwd: config.workspaceRoot });
39
+ const environment = takeEnv(args, { fallback: "preview" });
40
40
  const timeout = Number(takeValue(args, "--timeout") ?? 120);
41
41
  const lastValue = takeValue(args, "--last");
42
42
  const last = Number(lastValue ?? 10);
@@ -16,10 +16,9 @@ import { stringify as stringifyYaml } from "yaml";
16
16
 
17
17
  import { buildBundle, BundleError } from "../bundle.mjs";
18
18
  import { ApiClient, CliClient } from "../api-client.mjs";
19
- import { NotFoundError } from "../http.mjs";
19
+ import { NotFoundError, UnprocessableError } from "../http.mjs";
20
20
  import { deviceLogin } from "./auth.mjs";
21
- import { branchEnvironment } from "../branch.mjs";
22
- import { detectGitSha, fail, paint, takeEnv, takeFlag, takeValue } from "../support.mjs";
21
+ import { detectGitBranch, detectGitSha, fail, paint, takeEnv, takeFlag, takeValue } from "../support.mjs";
23
22
 
24
23
  // The first command that makes something exist on a server, so the first one
25
24
  // that needs to know whose it is.
@@ -85,9 +84,11 @@ function diagnosticLine(row) {
85
84
  export async function push(config, args) {
86
85
  // Null, not "preview": the platform owns that default, and sending it
87
86
  // explicitly would make a bare `vatio push` and `vatio push --env preview`
88
- // two different requests that only happen to agree today. On a branch, the
89
- // branch's own environment.
90
- const environment = takeEnv(args, { fallback: null, cwd: config.workspaceRoot });
87
+ // two different requests that only happen to agree today.
88
+ const environment = takeEnv(args, { fallback: null });
89
+ // Replaces an unpublished push from another branch, which the platform
90
+ // otherwise refuses (preview_has_unpublished_push).
91
+ const force = takeFlag(args, "--force");
91
92
  const workspace = config.resolveWorkspaceRequired();
92
93
 
93
94
  await ensureAuthorized(config, { workspace });
@@ -110,9 +111,10 @@ export async function push(config, args) {
110
111
  const payload = await client.pushPreview({
111
112
  manifest: check.manifest,
112
113
  gitSha: detectGitSha(config.workspaceRootRequired()),
113
- gitBranch: branchEnvironment(config.workspaceRootRequired())?.branch ?? null,
114
+ gitBranch: detectGitBranch(config.workspaceRootRequired()),
114
115
  createdBy: process.env.USER ?? null,
115
- environment
116
+ environment,
117
+ force
116
118
  });
117
119
 
118
120
  const landedOn = payload.environment ?? "preview";
@@ -142,15 +144,25 @@ function printNotices(payload) {
142
144
 
143
145
  export async function publish(config, args) {
144
146
  // Here `--env` names the environment being promoted, not a destination: the
145
- // destination of a publish is always live. On a branch it is the branch's;
146
- // otherwise the platform promotes the most recent push, whichever preview it
147
- // landed on. Its knowledge changes go live with it.
148
- const environment = takeEnv(args, { fallback: null, cwd: config.workspaceRoot });
147
+ // destination of a publish is always live, and what goes there is preview,
148
+ // with its knowledge changes.
149
+ const environment = takeEnv(args, { fallback: null });
150
+ // Publishes even when preview fails a report that live passes.
151
+ const force = takeFlag(args, "--force");
149
152
  const workspace = config.resolveWorkspaceRequired();
150
- const payload = await deployClient(config, workspace).publish({
151
- createdBy: process.env.USER ?? null,
152
- environment
153
- });
153
+ let payload;
154
+ try {
155
+ payload = await deployClient(config, workspace).publish({
156
+ createdBy: process.env.USER ?? null,
157
+ environment,
158
+ force
159
+ });
160
+ } catch (error) {
161
+ // evals_missing and evals_running already say what to run next; a
162
+ // regression also needs to say which reports.
163
+ if (error instanceof UnprocessableError && error.errorKey === "evals_regressed") fail(regressionsMessage(error));
164
+ throw error;
165
+ }
154
166
  const from = asArray(payload.published_from);
155
167
  const source = from.length > 0 ? ` from ${from.join(", ")}` : "";
156
168
  console.log(`Published live deployment #${payload.deployment_id}${source} (git_sha=${JSON.stringify(payload.git_sha ?? null)})`);
@@ -159,6 +171,17 @@ export async function publish(config, args) {
159
171
  printNotices(payload);
160
172
  }
161
173
 
174
+ function regressionsMessage(error) {
175
+ const lines = [error.message];
176
+ for (const row of asArray(error.body.regressions)) lines.push(` ${row.id} — ${row.title}`);
177
+ lines.push(
178
+ "",
179
+ "Fix them, then `vatio push` and `vatio eval` again before publishing.",
180
+ "`vatio publish --force` publishes anyway: only if you know what you're doing."
181
+ );
182
+ return lines.join("\n");
183
+ }
184
+
162
185
  export async function rollback(config) {
163
186
  const workspace = config.resolveWorkspaceRequired();
164
187
  const payload = await deployClient(config, workspace).rollback({ createdBy: process.env.USER ?? null });
@@ -183,7 +206,7 @@ export async function status(config) {
183
206
  }
184
207
 
185
208
  export async function diff(config, args) {
186
- const environment = takeEnv(args, { fallback: "preview", cwd: config.workspaceRoot });
209
+ const environment = takeEnv(args, { fallback: "preview" });
187
210
  const full = takeFlag(args, "--full");
188
211
  const stat = takeFlag(args, "--stat");
189
212
  const nameOnly = takeFlag(args, "--name-only");
@@ -1,26 +1,29 @@
1
- // `vatio env` — where you are working, and how to point things at it.
1
+ // `vatio env` — an environment, and how to point things at it.
2
2
  //
3
- // On a branch other than the default one, every command works in the branch's
4
- // own environment (see branch.mjs): its agent, its knowledge changes on top of
5
- // live, its secret values. This is the command that says which one that is and
6
- // hands over what an app needs to talk to it -- the publishable token and the
7
- // widget snippet -- and the link to try it in the console.
3
+ // There are two: preview, the next version, which `vatio push` updates and
4
+ // where its knowledge changes and secret values sit on top of live; and live,
5
+ // what visitors talk to. This hands over what an app needs to talk to one --
6
+ // the publishable token and the widget snippet -- and the link to try it in
7
+ // the console.
8
8
 
9
9
  import { deployClient } from "./deploy.mjs";
10
10
  import { fail, takeEnv } from "../support.mjs";
11
11
 
12
12
  export async function env(config, args) {
13
+ if (args[0] === "rm") {
14
+ fail("`vatio env rm` was removed in 0.71.0, with named environments: there are only preview and live.");
15
+ }
16
+
13
17
  const workspace = config.resolveWorkspaceRequired();
14
18
  const client = deployClient(config, workspace);
15
- const sub = ["list", "show", "rm"].includes(args[0]) ? args.shift() : "show";
19
+ const sub = ["list", "show"].includes(args[0]) ? args.shift() : "show";
16
20
 
17
21
  if (sub === "list") return await list(client, workspace);
18
22
 
19
23
  const named = args.find((arg) => !arg.startsWith("-"));
20
24
  if (named) args.splice(args.indexOf(named), 1);
21
- const name = named ?? takeEnv(args, { fallback: "preview", cwd: config.workspaceRoot });
25
+ const name = named ?? takeEnv(args, { fallback: "preview" });
22
26
 
23
- if (sub === "rm") return await remove(client, workspace, name);
24
27
  return await show(client, workspace, name);
25
28
  }
26
29
 
@@ -42,7 +45,8 @@ async function show(client, workspace, name) {
42
45
  row = await client.environment(name);
43
46
  } catch (error) {
44
47
  if (error?.status !== 404) throw error;
45
- console.log(`${name} on workspace ${workspace} does not exist yet — \`vatio push\` creates it.`);
48
+ const creates = name === "live" ? "vatio publish" : "vatio push";
49
+ console.log(`${name} on workspace ${workspace} does not exist yet — \`${creates}\` creates it.`);
46
50
  return;
47
51
  }
48
52
 
@@ -76,14 +80,6 @@ async function show(client, workspace, name) {
76
80
  if (secrets.length > 0) console.log(`\n secrets with their own value here: ${secrets.join(", ")}`);
77
81
  }
78
82
 
79
- async function remove(client, workspace, name) {
80
- if (!name || name === "live") fail("usage: vatio env rm NAME (live cannot be removed)");
81
-
82
- const result = await client.deleteEnvironment(name);
83
- console.log(`Removed ${name} from workspace ${workspace} (${result.agents ?? 0} agents, ${result.chats ?? 0} chats)`);
84
- console.log("Its unpublished knowledge changes and secret values went with it.");
85
- }
86
-
87
83
  function asArray(value) {
88
84
  return Array.isArray(value) ? value : [];
89
85
  }
@@ -1,10 +1,11 @@
1
- // flags / eval / tools -- what supervisors flagged, proving a fix for it, and
1
+ // flags / eval / tools -- what supervisors reported, proving a fix for it, and
2
2
  // how the tools' backend has been answering.
3
3
  //
4
4
  // All print markdown, because the reader is usually a coding agent: `vatio
5
5
  // flags` is the document it fixes the agent from, `vatio eval` is the
6
- // evidence that the fix worked on a branch before anyone merges it, and
7
- // `vatio tools` is the console's Tools page for the failures nobody flagged.
6
+ // evidence that the fix worked on preview before `vatio publish` takes it
7
+ // live, and `vatio tools` is the console's Tools page for the failures nobody
8
+ // reported.
8
9
 
9
10
  import { mkdirSync, writeFileSync } from "node:fs";
10
11
  import { dirname, resolve } from "node:path";
@@ -68,7 +69,7 @@ export async function flags(config, args) {
68
69
  // then the calls that failed with what your backend answered: the console's
69
70
  // Tools page.
70
71
  export async function tools(config, args) {
71
- const environment = takeEnv(args, { fallback: "live", cwd: config.workspaceRoot });
72
+ const environment = takeEnv(args, { fallback: "live" });
72
73
  const period = takeValue(args, "--period");
73
74
  const json = takeFlag(args, "--json");
74
75
  if (args.length > 0) fail("Usage: vatio tools [--env NAME] [--period 1h|1d|7d|30d] [--json]");
@@ -84,13 +85,13 @@ export async function tools(config, args) {
84
85
  process.stdout.write(await fetchMarkdown(config, `/tools.md?${query}`, "the tools"));
85
86
  }
86
87
 
87
- // Replays every eval case -- each flag is one -- against an environment and
88
- // waits for the judge. Exits 1 when a case fails, so it can gate CI.
88
+ // Replays every report with a note against an environment and waits for the
89
+ // judge. Exits 1 when a case fails, so it can gate CI.
89
90
  export async function evalCommand(config, args) {
90
91
  const show = takeValue(args, "--show");
91
92
  if (show) return await evalShow(config, show);
92
93
 
93
- const environment = takeEnv(args, { fallback: "preview", cwd: config.workspaceRoot });
94
+ const environment = takeEnv(args, { fallback: "preview" });
94
95
  const agent = takeValue(args, "--agent");
95
96
  const noWait = takeFlag(args, "--no-wait");
96
97
  const timeoutS = Number(takeValue(args, "--timeout") ?? DEFAULT_TIMEOUT_S);
@@ -104,7 +105,7 @@ export async function evalCommand(config, args) {
104
105
  }
105
106
  const runs = started.runs ?? [];
106
107
  if (runs.length === 0) {
107
- console.log("No eval cases to run. Flag a reply in the inbox, or add a case in the console.");
108
+ console.log("No reports to test yet. Report a reply in the inbox and write what it should have said.");
108
109
  return;
109
110
  }
110
111
 
@@ -5,12 +5,11 @@
5
5
  // That is why this is a command and not part of the manifest.
6
6
  //
7
7
  // The entries are live. Reads and writes here are as one environment sees
8
- // them: on a branch, the branch's own (see branch.mjs), which keeps the
9
- // entries it changed on top of live and answers from them in its preview;
10
- // otherwise `preview`; `--env live` writes live directly, the way a supervisor
11
- // in the inbox does. `vatio publish`, or merging the branch's pull request,
12
- // takes the changes live with the agent -- `vatio kb publish` takes them alone.
13
- // So: write, try it on the branch's preview, publish.
8
+ // them: `preview` by default, which keeps the entries it changed on top of
9
+ // live and answers from them; `--env live` writes live directly, the way a
10
+ // supervisor in the inbox does. `vatio publish` takes the changes live with
11
+ // the agent -- `vatio kb publish` takes them alone. So: write, try it on
12
+ // preview, publish.
14
13
  //
15
14
  // A base holds entries, and an entry is markdown you wrote.
16
15
 
@@ -27,7 +26,7 @@ export async function kb(config, args) {
27
26
  const workspace = config.resolveWorkspaceRequired();
28
27
  const client = deployClient(config, workspace);
29
28
  const sub = args.shift() ?? "list";
30
- const env = ENVIRONMENT_SCOPED.has(sub) ? takeEnv(args, { fallback: null, cwd: config.workspaceRoot }) : null;
29
+ const env = ENVIRONMENT_SCOPED.has(sub) ? takeEnv(args, { fallback: null }) : null;
31
30
  const ctx = { client, workspace, env };
32
31
 
33
32
  switch (sub) {
@@ -73,8 +72,8 @@ function usage() {
73
72
  vatio kb publish BASE Take this environment's changes live, without the agent
74
73
  vatio kb history BASE What reached live, newest first
75
74
 
76
- Entry commands, status and publish take --env NAME; on a branch they default
77
- to the branch's environment, otherwise to preview. --env live writes live.`;
75
+ Entry commands, status and publish take --env preview|live; the default is
76
+ preview. --env live writes live.`;
78
77
  }
79
78
 
80
79
  async function list({ client, workspace, env }) {
@@ -137,9 +137,10 @@ const AGENTS_NOTE = [
137
137
  "contract for the manifest, tools, knowledge and the CLI; read it before",
138
138
  "changing anything here.",
139
139
  "",
140
- "To improve the agent from what supervisors flagged in the inbox, run",
141
- "`vatio flags` and follow the instructions at the top of its output. Prove",
142
- "each fix with `vatio eval` on a branch before opening a pull request.",
140
+ "To fix what supervisors reported in the inbox, take every open report in",
141
+ "one session: `vatio flags` (follow the instructions at the top of its",
142
+ "output), fix, `vatio push`, `vatio eval` until the reports pass, then",
143
+ "`vatio publish`. The `vatio-improve` skill walks through it.",
143
144
  "`vatio tools --env live` shows how each tool's backend has been answering:",
144
145
  "error rate, timeouts, latency and the calls that failed.",
145
146
  ""
@@ -26,7 +26,7 @@ export async function templates(config, args) {
26
26
  args.shift();
27
27
  return createTemplate(config, args, json);
28
28
  }
29
- const environment = takeEnv(args, { fallback: "live", cwd: config.workspaceRoot });
29
+ const environment = takeEnv(args, { fallback: "live" });
30
30
  const workspace = config.resolveWorkspaceRequired();
31
31
  const client = deployClient(config, workspace);
32
32
  const sub = args.shift() ?? "list";
@@ -102,7 +102,7 @@ async function createTemplate(config, args, json) {
102
102
  }
103
103
 
104
104
  export async function webhooks(config, args) {
105
- const environment = takeEnv(args, { fallback: "live", cwd: config.workspaceRoot });
105
+ const environment = takeEnv(args, { fallback: "live" });
106
106
  const label = takeValue(args, "--label");
107
107
  const events = takeAll(args, "--event");
108
108
  const workspace = config.resolveWorkspaceRequired();
@@ -4,16 +4,15 @@
4
4
  // them is in vatio.yml.
5
5
 
6
6
  import { deployClient } from "./deploy.mjs";
7
- import { branchEnvironment } from "../branch.mjs";
8
- import { askSecret, branchDefault, fail, paint, takeFlag, takeValue } from "../support.mjs";
7
+ import { askSecret, fail, paint, takeFlag, takeValue } from "../support.mjs";
9
8
 
10
- // live, preview, or a branch's own like fix-pagos.
9
+ // The platform says which names exist (preview and live); this only keeps
10
+ // something that cannot be a name out of a URL.
11
11
  const ENVIRONMENT_NAME = /^[a-z0-9]+(?:[-_][a-z0-9]+)*$/;
12
12
  const ENVIRONMENT_MAX = 40;
13
13
 
14
- // On a branch, its environment unless told otherwise (see branch.mjs).
15
- function environmentOption(args, fallback, cwd) {
16
- return checkEnvironment(givenEnvironment(args) ?? branchDefault(cwd, fallback));
14
+ function environmentOption(args, fallback) {
15
+ return checkEnvironment(givenEnvironment(args) ?? fallback);
17
16
  }
18
17
 
19
18
  function givenEnvironment(args) {
@@ -23,20 +22,18 @@ function givenEnvironment(args) {
23
22
  function checkEnvironment(value) {
24
23
  if (value === null) return null;
25
24
  if (String(value).length > ENVIRONMENT_MAX || !ENVIRONMENT_NAME.test(String(value))) {
26
- fail(`Unknown environment "${value}" (use live, preview, or a branch's environment like fix-pagos)`);
25
+ fail(`Unknown environment "${value}" (use preview or live)`);
27
26
  }
28
27
  return String(value);
29
28
  }
30
29
 
31
- // Without an environment a secret is the value everywhere. On a branch, or
32
- // with --env, it is the value only that environment uses -- a preview pointing
33
- // its tools at staging while live keeps production. With --tests, the value
34
- // every environment but live and every eval replay uses, branches included,
35
- // so it never takes the branch's environment.
30
+ // Without an environment a secret is the value everywhere. With --env, it is
31
+ // the value only that environment uses -- preview pointing its tools at
32
+ // staging while live keeps production. With --tests, the value preview and
33
+ // every eval replay use.
36
34
  //
37
35
  // `list` shows every row, every environment's included, unless --env asks for
38
- // one: a value set from a branch was otherwise somewhere `list` did not look.
39
- // Every line names the row's scope, and `set` and `rm` say which one they
36
+ // one. Every line names the row's scope, and `set` and `rm` say which one they
40
37
  // touched.
41
38
  export async function secrets(config, args) {
42
39
  const workspace = config.resolveWorkspaceRequired();
@@ -46,9 +43,9 @@ export async function secrets(config, args) {
46
43
  if (tests && given) fail("--tests is the value for every environment but live; drop --env");
47
44
  const sub = args.shift() ?? "list";
48
45
 
49
- if (sub === "list") return listSecrets(client, workspace, checkEnvironment(given), config.workspaceRoot);
46
+ if (sub === "list") return listSecrets(client, workspace, checkEnvironment(given));
50
47
 
51
- const environment = tests ? null : checkEnvironment(given ?? branchDefault(config.workspaceRoot, null));
48
+ const environment = tests ? null : checkEnvironment(given);
52
49
  const scope = secretScope({ environment, tests });
53
50
 
54
51
  if (sub === "set") {
@@ -73,7 +70,7 @@ export async function secrets(config, args) {
73
70
  fail("Usage: vatio secrets list|set KEY [VALUE]|rm KEY [--env NAME | --tests]");
74
71
  }
75
72
 
76
- async function listSecrets(client, workspace, environment, cwd) {
73
+ async function listSecrets(client, workspace, environment) {
77
74
  const payload = await client.listSecrets({ environment });
78
75
  const keys = asArray(payload.secrets);
79
76
  const title = environment ? `secrets ${environment} reads on workspace ${workspace}` : `secrets on workspace ${workspace}`;
@@ -90,10 +87,6 @@ async function listSecrets(client, workspace, environment, cwd) {
90
87
  for (const secret of keys) {
91
88
  console.log(` ${String(secret.key ?? secret).padEnd(width)} ${secretScope(secret)}`);
92
89
  }
93
- const branch = environment || !cwd ? null : branchEnvironment(cwd);
94
- if (branch) {
95
- console.log(`On branch ${branch.branch}, \`vatio secrets set\` sets the value only ${branch.environment} uses; --env NAME picks another.`);
96
- }
97
90
  }
98
91
 
99
92
  function secretScope({ environment, tests }) {
@@ -111,7 +104,7 @@ function takeOrigins(args) {
111
104
  }
112
105
 
113
106
  export async function tokens(config, args) {
114
- const environment = environmentOption(args, "live", config.workspaceRoot);
107
+ const environment = environmentOption(args, "live");
115
108
  const label = takeValue(args, "--label") ?? takeValue(args, "-l");
116
109
  const origins = takeOrigins(args);
117
110
  const workspace = config.resolveWorkspaceRequired();
@@ -163,7 +156,7 @@ export async function tokens(config, args) {
163
156
  }
164
157
 
165
158
  fail(
166
- "Usage: vatio tokens list|create [--env live|preview|NAME] [--label NAME] [--origin URL]...|" +
159
+ "Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]...|" +
167
160
  "origins PREFIX URL...|revoke PREFIX"
168
161
  );
169
162
  }
@@ -173,7 +166,7 @@ export async function tokens(config, args) {
173
166
  // token it is a secret, and unlike the CLI's own token it belongs to the
174
167
  // workspace, so it outlives whoever created it.
175
168
  export async function keys(config, args) {
176
- const environment = environmentOption(args, "live", config.workspaceRoot);
169
+ const environment = environmentOption(args, "live");
177
170
  const label = takeValue(args, "--label") ?? takeValue(args, "-l");
178
171
  const workspace = config.resolveWorkspaceRequired();
179
172
  const client = deployClient(config, workspace);
@@ -221,7 +214,7 @@ export async function keys(config, args) {
221
214
  return;
222
215
  }
223
216
 
224
- fail("Usage: vatio keys list|create [--env live|preview|NAME] [--label NAME]|revoke PREFIX");
217
+ fail("Usage: vatio keys list|create [--env live|preview] [--label NAME]|revoke PREFIX");
225
218
  }
226
219
 
227
220
  // An empty list is not "anywhere": only Vatio's own pages can use the token.
package/lib/help.mjs CHANGED
@@ -4,7 +4,7 @@ export function helpText() {
4
4
  return `Vatio CLI ${VERSION}
5
5
 
6
6
  npx @vatio-ai/cli init my-agent Start a workspace here
7
- npx @vatio-ai/cli push Deploy it to a preview
7
+ npx @vatio-ai/cli push Deploy it to preview
8
8
 
9
9
  (installed globally with \`npm i -g @vatio-ai/cli\`, the command is just \`vatio\`)
10
10
 
@@ -12,16 +12,15 @@ A workspace is any directory with a vatio.yml. Every command except init reads
12
12
  \`workspace:\` from the vatio.yml at or above the cwd — there is no --workspace
13
13
  flag, the directory decides.
14
14
 
15
- --env NAME targets an environment: live, preview, or a branch's own. On a git
16
- branch other than the default one, the branch's environment is the default
17
- (fix/pagos -> fix-pagos): its own agent, knowledge changes and secret values,
18
- and the one its pull request deploys to. Elsewhere commands default as listed.
15
+ --env NAME targets an environment, and there are two: preview (the next
16
+ version, what \`vatio push\` updates) and live (what visitors talk to).
17
+ Commands default as listed.
19
18
 
20
19
  Getting started:
21
20
  init [SLUG] [--name NAME] Create vatio.yml here, and the remote to match
22
21
  login [--base-url URL] Sign this machine in from the browser: email link,
23
22
  Google or GitHub. Creates the account if needed
24
- logout Forget the token
23
+ logout Revoke and forget the token
25
24
  doctor Node, config, workspace and token status
26
25
  version What this CLI is
27
26
  docs [--save [PATH]] The whole developer contract, live from Vatio
@@ -35,17 +34,19 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
35
34
  share-session --never Stop coding agents from offering
36
35
 
37
36
  Deploy:
38
- push [--env NAME] Validate the workspace, then update a preview
39
- (the first one signs in like \`login\`)
40
- publish [--env NAME] Promote an environment to live, with its knowledge
41
- changes. Without --env or a branch, the latest
42
- push. Refused when GitHub is connected: merge
43
- the branch's pull request instead
37
+ push [--force] Validate the workspace, then update preview; runs
38
+ no tests (the first push signs in like \`login\`).
39
+ --force replaces an unpublished push from
40
+ another git branch
41
+ publish [--force] Take preview live, with its knowledge changes.
42
+ Once published, refused until \`vatio eval\` has
43
+ tested preview's version, and while it fails a
44
+ report live passes; --force publishes anyway
44
45
  rollback Put live back to the previous snapshot: config and knowledge
45
46
  status Preview and live deployment state
46
- env [NAME] This environment: token, widget snippet, link,
47
- knowledge changes and conflicts
48
- env list | rm NAME Every environment / remove one and what it holds
47
+ env [preview|live] An environment: token, widget snippet, link,
48
+ knowledge changes and conflicts (default: preview)
49
+ env list Both environments and what each runs
49
50
  diff [--env NAME] What this directory would change (default: preview)
50
51
  --env live answers "what would publishing change?"
51
52
  diff --stat|--name-only|--format json|--full
@@ -58,26 +59,22 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
58
59
  The chat you are in, or any chat in the workspace
59
60
  (web, WhatsApp, ...): messages, tool calls, channel
60
61
 
61
- Improve it from what supervisors flagged and how its tools answered:
62
+ Improve it from what supervisors reported and how its tools answered
63
+ (flags, fix, push, eval, publish):
62
64
  flags [--save [PATH]|--json]
63
- Every open flag: the conversation, what each tool
65
+ Every open report: the conversation, what each tool
64
66
  answered, and what should have happened
65
67
  tools [--env NAME] [--period 1h|1d|7d|30d] [--json]
66
68
  The console's Tools page: each tool's calls, error
67
69
  rate, timeouts and p50/p95, then the calls that
68
70
  failed with what your backend answered. Default:
69
- the branch's environment, else live; 7d
70
- eval [--env NAME] [--agent SLUG] [--no-wait]
71
- Replay every eval case (each flag is one) and
72
- judge it; exits 1 if one fails. Default: the
73
- branch's environment, else preview
71
+ live, 7d
72
+ eval [--env NAME] [--agent SLUG] [--no-wait] [--timeout N]
73
+ Test every report with a note against preview
74
+ (default) and judge it; exits 1 if one fails.
75
+ Can take minutes: in Claude Code, run it in the
76
+ background
74
77
  eval --show RUN_ID One run's report
75
- propose [--env NAME] --title TEXT [--summary TEXT|--summary-file PATH]
76
- Without a GitHub repo: put the branch's
77
- environment in front of the owner, who accepts
78
- (publishes) or discards it in the inbox. Replays
79
- every eval case there first
80
- propose --list Every proposal and where it stands
81
78
 
82
79
  Knowledge:
83
80
  kb [list] Bases, and whether a deployed agent reads each
@@ -105,10 +102,9 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
105
102
  Credentials:
106
103
  secrets list|set KEY [VALUE]|rm KEY [--env NAME | --tests]
107
104
  Without VALUE, set asks for it with the input hidden.
108
- On a branch or with --env, the value only that
109
- environment uses; otherwise the value everywhere.
110
- With --tests, the value every environment but live
111
- and every eval uses, like a staging URL
105
+ With --env, the value only that environment uses;
106
+ otherwise the value everywhere. With --tests, the
107
+ value preview and every eval use, like a staging URL
112
108
  tokens list|create [--env NAME] [--label NAME] [--origin URL]...|revoke PREFIX
113
109
  tokens origins PREFIX URL...
114
110
  The origins a token is accepted from (replaces the list)
package/lib/support.mjs CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  import { execFileSync } from "node:child_process";
5
5
 
6
- import { branchEnvironment } from "./branch.mjs";
7
-
8
6
  export class UserError extends Error {
9
7
  constructor(message) {
10
8
  super(message);
@@ -19,15 +17,13 @@ export function fail(message) {
19
17
  }
20
18
 
21
19
  // `--env NAME` is the one way to say which environment a command is about:
22
- // live, preview, or a branch's own like fix-pagos.
20
+ // preview or live. The platform validates the name.
23
21
  //
24
- // Without it, a workspace checked out on a branch other than the default one
25
- // means that branch's environment (see branch.mjs), said once on stderr so it
26
- // is never a surprise. Otherwise the default is the command's own and is passed
27
- // in, because the sensible answer differs: push writes a preview, tokens are
28
- // for live. `--as` was the spelling on push and publish and stays as an alias
29
- // -- it is sitting in CI jobs, and there is nothing wrong with what it does.
30
- export function takeEnv(args, { fallback = null, cwd = null } = {}) {
22
+ // Without it, the default is the command's own and is passed in, because the
23
+ // sensible answer differs: push writes preview, tokens are for live. `--as`
24
+ // was the spelling on push and publish and stays as an alias -- it is sitting
25
+ // in CI jobs, and there is nothing wrong with what it does.
26
+ export function takeEnv(args, { fallback = null } = {}) {
31
27
  let environment;
32
28
  const rest = [];
33
29
 
@@ -43,22 +39,13 @@ export function takeEnv(args, { fallback = null, cwd = null } = {}) {
43
39
  continue;
44
40
  }
45
41
  i += 1;
46
- if (i >= args.length) fail(`${match[0]} needs an environment name (live, preview, or a branch's)`);
42
+ if (i >= args.length) fail(`${match[0]} needs an environment name (preview or live)`);
47
43
  environment = args[i];
48
44
  }
49
45
 
50
46
  args.length = 0;
51
47
  args.push(...rest);
52
- return environment !== undefined ? environment : branchDefault(cwd, fallback);
53
- }
54
-
55
- // The branch's environment when the workspace is on one, else `fallback`.
56
- export function branchDefault(cwd, fallback) {
57
- const fromBranch = cwd ? branchEnvironment(cwd) : null;
58
- if (!fromBranch) return fallback;
59
-
60
- process.stderr.write(paint("cyan", `vatio: environment ${fromBranch.environment} (branch ${fromBranch.branch})`) + "\n");
61
- return fromBranch.environment;
48
+ return environment !== undefined ? environment : fallback;
62
49
  }
63
50
 
64
51
  export function takeFlag(args, name) {
@@ -89,12 +76,19 @@ export function takeValue(args, name) {
89
76
  // Stamped on a deployment so a revision can be traced back to a commit. Absent
90
77
  // outside a repository, which is fine -- a workspace does not have to be in one.
91
78
  export function detectGitSha(cwd) {
79
+ return git(cwd, ["rev-parse", "HEAD"]);
80
+ }
81
+
82
+ // Sent with a push so the platform can refuse one that would replace an
83
+ // unpublished push from another branch. Null outside a repository or with
84
+ // HEAD detached.
85
+ export function detectGitBranch(cwd) {
86
+ return git(cwd, ["symbolic-ref", "--short", "-q", "HEAD"]);
87
+ }
88
+
89
+ function git(cwd, args) {
92
90
  try {
93
- return execFileSync("git", ["rev-parse", "HEAD"], {
94
- cwd,
95
- encoding: "utf8",
96
- stdio: ["ignore", "pipe", "ignore"]
97
- }).trim() || null;
91
+ return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
98
92
  } catch {
99
93
  return null;
100
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.69.0",
3
+ "version": "0.71.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",
package/lib/branch.mjs DELETED
@@ -1,51 +0,0 @@
1
- // The environment a git branch gets, so that working on a branch is working in
2
- // its own environment without saying so: `vatio push` from `fix/pagos` lands on
3
- // `fix-pagos`, and so do `vatio kb write`, `vatio secrets set` and `vatio chat`.
4
- // The pull request opened from that branch deploys to the same one.
5
- //
6
- // The default branch is not a branch environment: there, and outside a
7
- // repository, every command keeps the default it always had.
8
- //
9
- // The name is derived exactly as the platform derives it for a pull request
10
- // (Vatio::Environment.for_branch, backend/app/vatio/environment.rb). Kept in
11
- // step by hand; both are short.
12
-
13
- import { execFileSync } from "node:child_process";
14
- import { createHash } from "node:crypto";
15
-
16
- const RESERVED = new Set(["live", "preview", "staging", "sandbox", "main"]);
17
- const MAX_LENGTH = 40;
18
-
19
- export function environmentForBranch(ref) {
20
- const raw = String(ref ?? "").replace(/^refs\/heads\//, "");
21
- let slug = raw.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
22
- if (slug === "") return null;
23
-
24
- if (RESERVED.has(slug)) slug = `branch-${slug}`;
25
- if (slug.length <= MAX_LENGTH) return slug;
26
-
27
- const hash = createHash("sha1").update(String(ref)).digest("hex").slice(0, 6);
28
- return `${slug.slice(0, 33).replace(/-+$/, "")}-${hash}`;
29
- }
30
-
31
- // { branch, environment } on a branch other than the default one; null on the
32
- // default branch, outside a repository, or with HEAD detached.
33
- export function branchEnvironment(cwd) {
34
- const branch = git(cwd, ["symbolic-ref", "--short", "-q", "HEAD"]);
35
- if (!branch) return null;
36
-
37
- const remoteHead = git(cwd, ["symbolic-ref", "--short", "-q", "refs/remotes/origin/HEAD"]);
38
- const defaultBranch = remoteHead ? remoteHead.replace(/^[^/]+\//, "") : null;
39
- if (branch === defaultBranch || (!defaultBranch && (branch === "main" || branch === "master"))) return null;
40
-
41
- const environment = environmentForBranch(branch);
42
- return environment ? { branch, environment } : null;
43
- }
44
-
45
- function git(cwd, args) {
46
- try {
47
- return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim() || null;
48
- } catch {
49
- return null;
50
- }
51
- }
@@ -1,51 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { deployClient } from "./deploy.mjs";
3
- import { fail, takeEnv, takeFlag, takeValue } from "../support.mjs";
4
-
5
- // `vatio propose`: put a branch's environment in front of the workspace's
6
- // owner as a change to accept from the inbox, for a workspace with no
7
- // repository connected -- there, the pull request is the proposal. Vatio
8
- // replays every eval case on it and mails the owner once they finish; the
9
- // owner accepts (which publishes it) or discards it. Proposing the same
10
- // environment again, after another push, updates it and replays the evals.
11
- export async function propose(config, args) {
12
- const workspace = config.resolveWorkspaceRequired();
13
- const client = deployClient(config, workspace);
14
- if (takeFlag(args, "--list")) return await list(client, workspace);
15
-
16
- const title = takeValue(args, "--title");
17
- const summaryFile = takeValue(args, "--summary-file");
18
- let summary = takeValue(args, "--summary");
19
- if (summaryFile) {
20
- try {
21
- summary = readFileSync(summaryFile, "utf8");
22
- } catch (error) {
23
- fail(`Could not read ${summaryFile}: ${error.message}`);
24
- }
25
- }
26
- const environment = takeEnv(args, { fallback: null, cwd: config.workspaceRoot });
27
- if (!environment) {
28
- fail('usage: vatio propose --env NAME --title "What it fixes" [--summary TEXT | --summary-file PATH]');
29
- }
30
-
31
- const payload = await client.propose({ environment, title, summary });
32
- console.log(`${payload.created ? "Proposed" : "Updated"} ${payload.environment} as ${payload.id}: ${payload.title}`);
33
- const runs = Array.isArray(payload.runs) ? payload.runs : [];
34
- const cases = runs.reduce((sum, run) => sum + (run.cases ?? 0), 0);
35
- if (cases > 0) {
36
- console.log(`Replaying ${cases} eval case${cases === 1 ? "" : "s"} there; the owner gets a mail when they finish.`);
37
- } else {
38
- console.log("No eval cases to replay: the owner decides on the change alone.");
39
- }
40
- console.log(`Accept or discard it in the inbox: ${payload.url}`);
41
- }
42
-
43
- async function list(client, workspace) {
44
- const payload = await client.proposals();
45
- const rows = Array.isArray(payload.data) ? payload.data : [];
46
- console.log(`Proposals on workspace ${workspace} (${rows.length}):`);
47
- for (const row of rows) {
48
- console.log(` ${row.id} ${row.status.padEnd(9)} ${row.environment} ${row.title}`);
49
- console.log(` ${row.url}`);
50
- }
51
- }