@vatio-ai/cli 0.73.0 → 0.75.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.
@@ -48,6 +48,15 @@ const SECRET_PATTERNS = [
48
48
  ]
49
49
  ];
50
50
 
51
+ // The people a session is about rather than the one who sends it: customers
52
+ // that came up in a query or a log. The team never needs who they were. A
53
+ // phone counts only in international form; a bare run of digits is as likely
54
+ // an id.
55
+ const PERSONAL_PATTERNS = [
56
+ [/(?<![\w.%+/-])(?!git@|no-?reply@)[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g, "[EMAIL]"],
57
+ [/(?<![\w+])\+\d(?:[ .-]?\d){7,14}\b/g, "[PHONE]"]
58
+ ];
59
+
51
60
  export function claudeHome() {
52
61
  return process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude");
53
62
  }
@@ -120,10 +129,11 @@ export function describe(session) {
120
129
  }
121
130
 
122
131
  // The session as it is sent: only what was said and done, without images,
123
- // with anything that looks like a secret replaced and the home directory as ~.
132
+ // with anything that looks like a secret, an email or a phone replaced and the
133
+ // home directory as ~.
124
134
  export function clean(session) {
125
135
  const lines = [];
126
- const counts = { messages: 0, images: 0, redactions: 0 };
136
+ const counts = { messages: 0, images: 0, redactions: 0, personal: 0 };
127
137
  let startedAt = null;
128
138
  let endedAt = null;
129
139
  let gitBranch = null;
@@ -197,6 +207,12 @@ function redact(text, counts) {
197
207
  return replacement.replace(/\$(\d)/g, (_, index) => match[Number(index)] ?? "");
198
208
  });
199
209
  }
210
+ for (const [pattern, replacement] of PERSONAL_PATTERNS) {
211
+ result = result.replace(pattern, () => {
212
+ counts.personal += 1;
213
+ return replacement;
214
+ });
215
+ }
200
216
  return HOME.length > 1 ? result.replaceAll(HOME, "~") : result;
201
217
  }
202
218
 
@@ -80,7 +80,11 @@ workspace has never met.`;
80
80
  function client(config, options) {
81
81
  const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
82
82
  const token = options.token ?? config.resolveToken();
83
- if (!apiUrl) fail("A workspace API url is required (--api-url, or base_url + a vatio.yml with `workspace:`)");
83
+ if (!apiUrl) {
84
+ // Says which: no vatio.yml here (and where one is), or one without `workspace:`.
85
+ config.resolveWorkspaceRequired();
86
+ fail("A workspace API url is required (--api-url, or base_url + a vatio.yml with `workspace:`)");
87
+ }
84
88
  if (!token) fail("VATIO_TOKEN is required (env or `vatio login`)");
85
89
  return new ApiClient({ baseUrl: apiUrl, token });
86
90
  }
@@ -97,7 +97,8 @@ export async function shareSession(config, args) {
97
97
  console.log(` ${size(Buffer.byteLength(transcript.jsonl))}, ${size(gzipped.length)} compressed`);
98
98
  console.log(
99
99
  ` Left out: ${transcript.images > 0 ? `${transcript.images} image(s) and ` : ""}Claude Code's own bookkeeping.` +
100
- (transcript.redactions > 0 ? ` ${transcript.redactions} thing(s) that looked like a key, token or password are [REDACTED].` : "")
100
+ (transcript.redactions > 0 ? ` ${transcript.redactions} thing(s) that looked like a key, token or password are [REDACTED].` : "") +
101
+ (transcript.personal > 0 ? ` ${transcript.personal} email address(es) and phone number(s) are [EMAIL] and [PHONE].` : "")
101
102
  );
102
103
 
103
104
  if (savePath) {
@@ -108,7 +109,10 @@ export async function shareSession(config, args) {
108
109
  return;
109
110
  }
110
111
 
111
- console.log("\nOnly the Vatio team reads it, to see where you and your coding agent got stuck.");
112
+ console.log(
113
+ "\nOnly the Vatio team reads it, to see where you and your coding agent got stuck. Every read is logged,\n" +
114
+ "and it is deleted 30 days after it arrives."
115
+ );
112
116
  if (!yes) {
113
117
  if (!process.stdin.isTTY) {
114
118
  fail(
@@ -153,7 +157,8 @@ export async function shareSession(config, args) {
153
157
  if (response.status === 401) fail("Your sign-in has expired. Run `vatio login`, then this again.");
154
158
  if (!response.ok) fail(`Could not send it: ${body.error_description ?? `HTTP ${response.status}`}`);
155
159
 
156
- console.log(`Sent to the Vatio team (#${body.id}). Thank you.`);
160
+ console.log(`Sent to the Vatio team (#${body.id}).${body.expires_at ? ` It is deleted on ${when(body.expires_at)}.` : ""} Thank you.`);
161
+ rememberSent(session.id, body.id);
157
162
  rememberOffer(session.id);
158
163
  }
159
164
 
@@ -201,6 +206,26 @@ function rememberOffer(sessionId) {
201
206
  }
202
207
  }
203
208
 
209
+ // Which sessions went, so `--list` can say so: when a permission check stops
210
+ // the coding agent and the developer sends it from a terminal, this is how the
211
+ // agent learns it arrived.
212
+ const SENT_KEPT = 20;
213
+
214
+ function rememberSent(sessionId, transcriptId) {
215
+ try {
216
+ const state = readOfferState();
217
+ const { [sessionId]: _previous, ...others } = sentSessions(state);
218
+ const sent = Object.entries({ ...others, [sessionId]: { id: transcriptId, at: new Date().toISOString() } });
219
+ writeOfferState({ ...state, sent: Object.fromEntries(sent.slice(-SENT_KEPT)) });
220
+ } catch {
221
+ // Not remembering only means `--list` does not mark it.
222
+ }
223
+ }
224
+
225
+ function sentSessions(state = readOfferState()) {
226
+ return state.sent && typeof state.sent === "object" && !Array.isArray(state.sent) ? state.sent : {};
227
+ }
228
+
204
229
  function offerStatePath() {
205
230
  return join(configHome(), "share-session.json");
206
231
  }
@@ -243,11 +268,13 @@ function listSessions() {
243
268
  if (sessions.length === 0) fail("No Claude Code sessions for this directory.");
244
269
 
245
270
  const current = process.env.CLAUDE_CODE_SESSION_ID;
271
+ const sent = sentSessions();
246
272
  for (const session of sessions) {
247
273
  const mark = session.id === current ? "*" : " ";
248
274
  const title = session.title ? truncate(session.title, 60) : "";
249
275
  const modified = when(new Date(session.modifiedAt).toISOString());
250
- console.log(`${mark} ${short(session.id)} ${modified} ${String(session.messages).padStart(5)} msgs ${title}`);
276
+ const shared = sent[session.id] ? ` (sent #${sent[session.id].id}, ${when(sent[session.id].at)})` : "";
277
+ console.log(`${mark} ${short(session.id)} ${modified} ${String(session.messages).padStart(5)} msgs ${title}${shared}`);
251
278
  }
252
279
  console.log("\nSend one with `vatio share-session --id ID`.");
253
280
  }
package/lib/config.mjs CHANGED
@@ -15,7 +15,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "n
15
15
  import { homedir } from "node:os";
16
16
  import { dirname, join, resolve } from "node:path";
17
17
 
18
- import { MANIFEST_FILE, SLUG_FORMAT, findWorkspaceRoot, manifestPath, workspaceSlug } from "./workspace.mjs";
18
+ import { MANIFEST_FILE, SLUG_FORMAT, findWorkspaceRoot, manifestPath, workspaceSlug, workspacesBelow } from "./workspace.mjs";
19
19
 
20
20
  export const KEYS = ["base_url", "token"];
21
21
  export const DEFAULT_BASE_URL = "https://vatio.ai";
@@ -122,9 +122,12 @@ export class Config {
122
122
 
123
123
  workspaceRootRequired() {
124
124
  if (this.workspaceRoot) return this.workspaceRoot;
125
+ const below = workspacesBelow(this.startDir);
125
126
  throw new ConfigError(
126
127
  `Not inside a Vatio workspace (no ${MANIFEST_FILE} found walking up from ${this.startDir}).\n` +
127
- "Run `vatio init SLUG` here to create one."
128
+ (below.length > 0
129
+ ? `There is one in ${below.map((dir) => `./${dir}`).join(", ")}: run it from there (\`cd ${below[0]}\`).`
130
+ : "Run `vatio init SLUG` here to create one.")
128
131
  );
129
132
  }
130
133
 
package/lib/workspace.mjs CHANGED
@@ -7,8 +7,8 @@
7
7
  // thing a client cannot ask the platform for is the address of that call: the
8
8
  // slug is in its URL. So this reads `workspace:` and stops.
9
9
 
10
- import { existsSync, readFileSync, statSync } from "node:fs";
11
- import { dirname, join, parse as parsePath, resolve } from "node:path";
10
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
11
+ import { dirname, join, parse as parsePath, relative, resolve } from "node:path";
12
12
  import { parse as parseYaml } from "yaml";
13
13
 
14
14
  export const MANIFEST_FILE = "vatio.yml";
@@ -42,6 +42,34 @@ export function findWorkspaceRoot(startDir) {
42
42
  }
43
43
  }
44
44
 
45
+ // The workspaces just below a directory that is not in one, for the error that
46
+ // says so: a coding agent started at the top of a repository is usually one
47
+ // `cd` away from its vatio.yml.
48
+ const SKIPPED_DIRS = new Set(["node_modules", "vendor", "dist", "build"]);
49
+
50
+ export function workspacesBelow(startDir, { depth = 2, limit = 3 } = {}) {
51
+ const root = resolve(startDir);
52
+ const found = [];
53
+ const visit = (dir, level) => {
54
+ if (level > depth || found.length >= limit) return;
55
+ let names;
56
+ try {
57
+ names = readdirSync(dir, { withFileTypes: true });
58
+ } catch {
59
+ return;
60
+ }
61
+ for (const entry of names) {
62
+ if (!entry.isDirectory() || entry.name.startsWith(".") || SKIPPED_DIRS.has(entry.name)) continue;
63
+ const child = join(dir, entry.name);
64
+ if (manifestPath(child)) found.push(relative(root, child));
65
+ else visit(child, level + 1);
66
+ if (found.length >= limit) return;
67
+ }
68
+ };
69
+ visit(root, 1);
70
+ return found;
71
+ }
72
+
45
73
  // Which workspace this directory deploys to. Addressing, not content: it names
46
74
  // the remote, so it never rides along in the deployed manifest. Null when the
47
75
  // file does not declare one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.73.0",
3
+ "version": "0.75.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",