@vibiz/cli 0.3.23 → 0.3.25
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/dist/vibiz.js
CHANGED
|
@@ -11,17 +11,18 @@ import {
|
|
|
11
11
|
formatUsd,
|
|
12
12
|
mergeEnvFile,
|
|
13
13
|
oneKeyMessage
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XGUYBK6U.js";
|
|
15
15
|
|
|
16
16
|
// packages/cli/src/main.ts
|
|
17
17
|
import { spawn } from "node:child_process";
|
|
18
|
+
import { randomUUID } from "node:crypto";
|
|
18
19
|
import { chmod, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
19
|
-
import { dirname as
|
|
20
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
20
21
|
import { format } from "node:util";
|
|
21
22
|
|
|
22
23
|
// packages/cli/src/commands.ts
|
|
23
24
|
import { homedir as homedir2 } from "node:os";
|
|
24
|
-
import { dirname as
|
|
25
|
+
import { dirname as dirname7, join as join7, resolve as resolve3 } from "node:path";
|
|
25
26
|
import { parseArgs } from "node:util";
|
|
26
27
|
|
|
27
28
|
// packages/app/src/index.ts
|
|
@@ -39,6 +40,20 @@ var VibizAppError = class extends Error {
|
|
|
39
40
|
this.details = details;
|
|
40
41
|
}
|
|
41
42
|
};
|
|
43
|
+
function attribution() {
|
|
44
|
+
const w = globalThis.window;
|
|
45
|
+
try {
|
|
46
|
+
const got = w?.vibiz?.attribution?.();
|
|
47
|
+
if (got && typeof got === "object") return got;
|
|
48
|
+
const raw = globalThis.sessionStorage?.getItem("_vz_a");
|
|
49
|
+
if (!w || !raw) return null;
|
|
50
|
+
const a = JSON.parse(raw);
|
|
51
|
+
const page = globalThis.location?.pathname;
|
|
52
|
+
return { ...a, checkout_page: page ?? a.checkout_page ?? null };
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
42
57
|
var WEBHOOK_TOLERANCE_S = 300;
|
|
43
58
|
var K = new Uint32Array([
|
|
44
59
|
1116352408,
|
|
@@ -617,6 +632,11 @@ var VibizApp = class _VibizApp {
|
|
|
617
632
|
}
|
|
618
633
|
}
|
|
619
634
|
};
|
|
635
|
+
/**
|
|
636
|
+
* Analytics helpers. `attribution()` runs in the browser (no key, no
|
|
637
|
+
* request): the tab's first-touch attribution, to send with a checkout.
|
|
638
|
+
*/
|
|
639
|
+
analytics = { attribution };
|
|
620
640
|
/**
|
|
621
641
|
* A server-side event in the project's analytics, next to the browser's.
|
|
622
642
|
* Never throws: analytics must not break the request that tracks it.
|
|
@@ -789,8 +809,8 @@ async function diffCommand(io, positionals, flags) {
|
|
|
789
809
|
if (!d.files.length) io.log(" No files changed.");
|
|
790
810
|
const mark = { added: "A", updated: "M", deleted: "D" };
|
|
791
811
|
for (const f of d.files) {
|
|
792
|
-
const
|
|
793
|
-
io.log(`${mark[f.change]} ${f.path}${
|
|
812
|
+
const size2 = f.binary ? ` (binary, ${bytesLabel(f.size_before ?? 0)} \u2192 ${bytesLabel(f.size_after ?? 0)})` : "";
|
|
813
|
+
io.log(`${mark[f.change]} ${f.path}${size2}`);
|
|
794
814
|
if (f.diff) io.out(f.diff);
|
|
795
815
|
if (f.note && !f.binary) io.log(` ${f.note}`);
|
|
796
816
|
}
|
|
@@ -2209,6 +2229,225 @@ async function inboxCommand(io, vibiz2, flags, positionals) {
|
|
|
2209
2229
|
throw new Error(`usage: vibiz email [${INBOX_SUBCOMMANDS.join(" | ")}]`);
|
|
2210
2230
|
}
|
|
2211
2231
|
|
|
2232
|
+
// packages/cli/src/library.ts
|
|
2233
|
+
import { lstat, readdir as readdir3 } from "node:fs/promises";
|
|
2234
|
+
import { basename as basename2, dirname as dirname4, isAbsolute, relative, resolve as resolve2, sep as sep2 } from "node:path";
|
|
2235
|
+
var PUT_LIMITS = {
|
|
2236
|
+
fileBytes: 1024 * 1024,
|
|
2237
|
+
batchFiles: 1e3,
|
|
2238
|
+
batchBytes: 20 * 1024 * 1024
|
|
2239
|
+
};
|
|
2240
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store"]);
|
|
2241
|
+
var size = (n) => n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
2242
|
+
var day = (iso) => iso.slice(0, 16).replace("T", " ");
|
|
2243
|
+
function textOf(bytes) {
|
|
2244
|
+
if (bytes.length > PUT_LIMITS.fileBytes) return { skip: `${size(bytes.length)}, over 1 MB` };
|
|
2245
|
+
if (bytes.includes(0)) return { skip: "binary (has NUL bytes)" };
|
|
2246
|
+
try {
|
|
2247
|
+
return { text: new TextDecoder("utf-8", { fatal: true }).decode(bytes) };
|
|
2248
|
+
} catch {
|
|
2249
|
+
return { skip: "not UTF-8 text" };
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
async function walk(root) {
|
|
2253
|
+
const files = [];
|
|
2254
|
+
const folders = [];
|
|
2255
|
+
const visit = async (dir) => {
|
|
2256
|
+
const entries = await readdir3(dir, { withFileTypes: true });
|
|
2257
|
+
for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
2258
|
+
if (SKIP_DIRS.has(e.name)) continue;
|
|
2259
|
+
const full = resolve2(dir, e.name);
|
|
2260
|
+
const rel = relative(root, full).split(sep2).join("/");
|
|
2261
|
+
if (e.isSymbolicLink()) continue;
|
|
2262
|
+
if (e.isDirectory()) {
|
|
2263
|
+
folders.push(rel);
|
|
2264
|
+
await visit(full);
|
|
2265
|
+
} else if (e.isFile()) files.push(rel);
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
await visit(root);
|
|
2269
|
+
return { files, folders };
|
|
2270
|
+
}
|
|
2271
|
+
function entryLine(e, indent = false) {
|
|
2272
|
+
const name = e.kind === "folder" ? `${indent ? e.path : e.name}/` : indent ? e.path : e.name;
|
|
2273
|
+
const items = e.kind === "folder" ? `${e.items ?? 0} item${e.items === 1 ? "" : "s"}` : "";
|
|
2274
|
+
return ` ${name.padEnd(40)} ${size(e.size_bytes).padStart(9)} ${items.padEnd(9)} ${day(e.updated_at)}`;
|
|
2275
|
+
}
|
|
2276
|
+
async function libraryCommand(io, positionals, f) {
|
|
2277
|
+
const vibiz2 = await io.client();
|
|
2278
|
+
const scope = f.project ? { project_id: f.project } : {};
|
|
2279
|
+
const where = f.project ? `project ${f.project}'s Library` : "the Library";
|
|
2280
|
+
const out = (value) => io.log(JSON.stringify(value, null, 2));
|
|
2281
|
+
const [sub, a, b] = positionals;
|
|
2282
|
+
switch (sub ?? "ls") {
|
|
2283
|
+
case "ls":
|
|
2284
|
+
case "list": {
|
|
2285
|
+
const list2 = await vibiz2.library.list({
|
|
2286
|
+
...scope,
|
|
2287
|
+
...a ? { path: a } : {},
|
|
2288
|
+
...f.recursive ? { recursive: true } : {}
|
|
2289
|
+
});
|
|
2290
|
+
if (f.json) return out(list2);
|
|
2291
|
+
if (!list2.data.length) {
|
|
2292
|
+
io.log(
|
|
2293
|
+
list2.path ? `${list2.path}/ is empty.` : `Nothing in ${where} yet. Keep your scripts and agent skills here: vibiz library put <file-or-folder>. Nothing here runs; it's stored so you don't lose it.`
|
|
2294
|
+
);
|
|
2295
|
+
} else {
|
|
2296
|
+
for (const e of list2.data) io.log(entryLine(e, !!f.recursive));
|
|
2297
|
+
}
|
|
2298
|
+
io.log(
|
|
2299
|
+
`
|
|
2300
|
+
${list2.usage.entries} item${list2.usage.entries === 1 ? "" : "s"} in ${where}, ${size(list2.usage.bytes)}`
|
|
2301
|
+
);
|
|
2302
|
+
io.log(` ${list2.console_url}`);
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
case "cat":
|
|
2306
|
+
case "read": {
|
|
2307
|
+
if (!a) throw new Error("usage: vibiz library cat <path>");
|
|
2308
|
+
const file = await vibiz2.library.read(a, scope);
|
|
2309
|
+
if (f.json) return out(file);
|
|
2310
|
+
io.log(file.content ?? "");
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
case "put":
|
|
2314
|
+
case "push": {
|
|
2315
|
+
if (!a) throw new Error("usage: vibiz library put <local-file-or-folder> [remote-path]");
|
|
2316
|
+
const local = io.local();
|
|
2317
|
+
const source = isAbsolute(a) ? a : resolve2(local.cwd(), a);
|
|
2318
|
+
const info = await lstat(source).catch(() => null);
|
|
2319
|
+
if (!info) throw new Error(`${a}: no such file or folder here.`);
|
|
2320
|
+
const name = basename2(source);
|
|
2321
|
+
if (info.isFile()) {
|
|
2322
|
+
const got = textOf(new Uint8Array(await local.readFile(source)));
|
|
2323
|
+
if ("skip" in got)
|
|
2324
|
+
throw new Error(
|
|
2325
|
+
`${a}: ${got.skip}. The Library keeps text files only (scripts, skills, notes); put images and other binaries in a project's Files (vibiz files upload).`
|
|
2326
|
+
);
|
|
2327
|
+
const remote2 = !b ? name : b.endsWith("/") ? `${b}${name}` : b;
|
|
2328
|
+
const saved = await vibiz2.library.write({ path: remote2, content: got.text, ...scope });
|
|
2329
|
+
if (f.json) return out(saved);
|
|
2330
|
+
io.log(`${saved.created ? "Saved" : "Updated"} ${saved.path} (${size(saved.size_bytes)}).`);
|
|
2331
|
+
io.log(` ${saved.console_url}`);
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
if (!info.isDirectory()) throw new Error(`${a}: not a file or a folder.`);
|
|
2335
|
+
const remote = (b ?? name).replace(/^\/+|\/+$/g, "");
|
|
2336
|
+
const tree = await walk(source);
|
|
2337
|
+
const batches = [[]];
|
|
2338
|
+
let bytes = 0;
|
|
2339
|
+
const skipped2 = [];
|
|
2340
|
+
for (const rel of tree.files) {
|
|
2341
|
+
const got = textOf(new Uint8Array(await local.readFile(resolve2(source, rel))));
|
|
2342
|
+
if ("skip" in got) {
|
|
2343
|
+
skipped2.push(`${rel} (${got.skip})`);
|
|
2344
|
+
continue;
|
|
2345
|
+
}
|
|
2346
|
+
const n = Buffer.byteLength(got.text);
|
|
2347
|
+
let batch = batches[batches.length - 1];
|
|
2348
|
+
if (batch.length >= PUT_LIMITS.batchFiles || bytes + n > PUT_LIMITS.batchBytes) {
|
|
2349
|
+
batch = [];
|
|
2350
|
+
batches.push(batch);
|
|
2351
|
+
bytes = 0;
|
|
2352
|
+
}
|
|
2353
|
+
batch.push({ path: rel, content: got.text });
|
|
2354
|
+
bytes += n;
|
|
2355
|
+
}
|
|
2356
|
+
let created = 0;
|
|
2357
|
+
let updated = 0;
|
|
2358
|
+
let consoleUrl = "";
|
|
2359
|
+
const results = [];
|
|
2360
|
+
for (const [i, files] of batches.entries()) {
|
|
2361
|
+
if (!files.length && i > 0) continue;
|
|
2362
|
+
const res = await vibiz2.library.import({
|
|
2363
|
+
path: remote,
|
|
2364
|
+
files,
|
|
2365
|
+
...i === 0 && tree.folders.length ? { folders: tree.folders } : {},
|
|
2366
|
+
...scope
|
|
2367
|
+
});
|
|
2368
|
+
created += res.created;
|
|
2369
|
+
updated += res.updated;
|
|
2370
|
+
consoleUrl = res.console_url;
|
|
2371
|
+
results.push(res);
|
|
2372
|
+
}
|
|
2373
|
+
if (f.json) return out({ path: remote, created, updated, skipped: skipped2, imports: results });
|
|
2374
|
+
for (const s of skipped2) io.log(` skipped ${s}`);
|
|
2375
|
+
io.log(
|
|
2376
|
+
`Saved ${remote || "the top"}/ to ${where}: ${created} new, ${updated} updated${skipped2.length ? `, ${skipped2.length} skipped` : ""}.`
|
|
2377
|
+
);
|
|
2378
|
+
if (consoleUrl) io.log(` ${consoleUrl}`);
|
|
2379
|
+
return;
|
|
2380
|
+
}
|
|
2381
|
+
case "get":
|
|
2382
|
+
case "pull": {
|
|
2383
|
+
if (a === void 0) throw new Error("usage: vibiz library get <remote-path> [local-dir]");
|
|
2384
|
+
const local = io.local();
|
|
2385
|
+
const exp = await vibiz2.library.export(a, scope);
|
|
2386
|
+
const base = resolve2(local.cwd(), b ?? ".");
|
|
2387
|
+
const root = exp.kind === "file" ? base : resolve2(base, exp.path ? basename2(exp.path) : "library");
|
|
2388
|
+
const inside = (rel) => {
|
|
2389
|
+
const target = resolve2(root, rel);
|
|
2390
|
+
if (target !== root && !target.startsWith(root + sep2)) {
|
|
2391
|
+
throw new Error(`Refusing to write ${rel}: it would land outside ${root}.`);
|
|
2392
|
+
}
|
|
2393
|
+
return target;
|
|
2394
|
+
};
|
|
2395
|
+
await local.mkdir(root, { recursive: true });
|
|
2396
|
+
for (const folder of exp.folders) await local.mkdir(inside(folder), { recursive: true });
|
|
2397
|
+
for (const file of exp.files) {
|
|
2398
|
+
const target = inside(file.path);
|
|
2399
|
+
await local.mkdir(dirname4(target), { recursive: true });
|
|
2400
|
+
await local.writeFile(target, file.content, "utf8");
|
|
2401
|
+
}
|
|
2402
|
+
if (f.json)
|
|
2403
|
+
return out({ ...exp, files: exp.files.map(({ content: _, ...r }) => r), to: root });
|
|
2404
|
+
io.log(
|
|
2405
|
+
exp.kind === "file" ? `Saved ${resolve2(root, exp.files[0]?.path ?? "")}.` : `Saved ${exp.files.length} file${exp.files.length === 1 ? "" : "s"} to ${root}.`
|
|
2406
|
+
);
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
case "mkdir": {
|
|
2410
|
+
if (!a) throw new Error("usage: vibiz library mkdir <path>");
|
|
2411
|
+
const made = await vibiz2.library.mkdir(a, scope);
|
|
2412
|
+
if (f.json) return out(made);
|
|
2413
|
+
io.log(`${made.created ? "Made" : "Already there:"} ${made.path}/`);
|
|
2414
|
+
io.log(` ${made.console_url}`);
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
case "mv":
|
|
2418
|
+
case "move": {
|
|
2419
|
+
if (!a || !b) throw new Error("usage: vibiz library mv <from> <to> [--force]");
|
|
2420
|
+
const moved = await vibiz2.library.move({
|
|
2421
|
+
from: a,
|
|
2422
|
+
to: b,
|
|
2423
|
+
...scope,
|
|
2424
|
+
...f.force ? { overwrite: true } : {}
|
|
2425
|
+
});
|
|
2426
|
+
if (f.json) return out(moved);
|
|
2427
|
+
io.log(`Moved ${a} to ${moved.path}${moved.moved > 1 ? ` (${moved.moved} items)` : ""}.`);
|
|
2428
|
+
io.log(` ${moved.console_url}`);
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
case "rm":
|
|
2432
|
+
case "delete": {
|
|
2433
|
+
if (!a) throw new Error("usage: vibiz library rm <path> [-r]");
|
|
2434
|
+
const gone = await vibiz2.library.delete(a, {
|
|
2435
|
+
...scope,
|
|
2436
|
+
...f.recursive ? { recursive: true } : {}
|
|
2437
|
+
});
|
|
2438
|
+
if (f.json) return out(gone);
|
|
2439
|
+
io.log(
|
|
2440
|
+
`Deleted ${gone.path}${gone.kind === "folder" ? `/ (${gone.deleted_count} item${gone.deleted_count === 1 ? "" : "s"})` : ""}.`
|
|
2441
|
+
);
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
default:
|
|
2445
|
+
throw new Error(
|
|
2446
|
+
`vibiz library ${sub}: not a command. Use ls, cat, put, get, mkdir, mv or rm (vibiz help library).`
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2212
2451
|
// packages/cli/src/login.ts
|
|
2213
2452
|
import { hostname, platform, release } from "node:os";
|
|
2214
2453
|
import { join as join4 } from "node:path";
|
|
@@ -2798,8 +3037,8 @@ function formatProfile(p) {
|
|
|
2798
3037
|
|
|
2799
3038
|
// packages/cli/src/scaffold.ts
|
|
2800
3039
|
import { existsSync } from "node:fs";
|
|
2801
|
-
import { cp, readdir as
|
|
2802
|
-
import { dirname as
|
|
3040
|
+
import { cp, readdir as readdir4, readFile, rename, writeFile } from "node:fs/promises";
|
|
3041
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
2803
3042
|
import { fileURLToPath } from "node:url";
|
|
2804
3043
|
var TEMPLATES = ["nextjs-saas"];
|
|
2805
3044
|
var SKIP = /* @__PURE__ */ new Set([
|
|
@@ -2820,7 +3059,7 @@ var packedName = (dotfile) => `_${dotfile.slice(1)}`;
|
|
|
2820
3059
|
function templatesDir() {
|
|
2821
3060
|
const fromEnv = process.env.VIBIZ_TEMPLATES_DIR?.trim();
|
|
2822
3061
|
if (fromEnv) return fromEnv;
|
|
2823
|
-
const here =
|
|
3062
|
+
const here = dirname5(fileURLToPath(import.meta.url));
|
|
2824
3063
|
const packaged = join5(here, "..", "templates");
|
|
2825
3064
|
if (existsSync(packaged)) return packaged;
|
|
2826
3065
|
return join5(here, "..", "..", "..", "templates");
|
|
@@ -2834,7 +3073,7 @@ function packageName(name) {
|
|
|
2834
3073
|
}
|
|
2835
3074
|
async function isEffectivelyEmpty(dir) {
|
|
2836
3075
|
try {
|
|
2837
|
-
return (await
|
|
3076
|
+
return (await readdir4(dir)).every((e) => HARMLESS.has(e));
|
|
2838
3077
|
} catch (err) {
|
|
2839
3078
|
if (err.code === "ENOENT") return true;
|
|
2840
3079
|
throw err;
|
|
@@ -2854,7 +3093,7 @@ async function scaffold(opts) {
|
|
|
2854
3093
|
}
|
|
2855
3094
|
}).catch((err) => {
|
|
2856
3095
|
if (err.code === "ENOENT") {
|
|
2857
|
-
throw new Error(`Template "${opts.template}" not found in ${
|
|
3096
|
+
throw new Error(`Template "${opts.template}" not found in ${dirname5(source)}`);
|
|
2858
3097
|
}
|
|
2859
3098
|
throw err;
|
|
2860
3099
|
});
|
|
@@ -2893,7 +3132,7 @@ async function setAppName(dir, name) {
|
|
|
2893
3132
|
// packages/cli/src/setup.ts
|
|
2894
3133
|
import { accessSync, constants } from "node:fs";
|
|
2895
3134
|
import { homedir, platform as platform2 } from "node:os";
|
|
2896
|
-
import { delimiter, dirname as
|
|
3135
|
+
import { delimiter, dirname as dirname6, join as join6 } from "node:path";
|
|
2897
3136
|
var CLIENT_NAMES = {
|
|
2898
3137
|
"claude code": "claude",
|
|
2899
3138
|
claude: "claude",
|
|
@@ -3016,7 +3255,7 @@ async function mergeJsonServer(io, path, key, entry) {
|
|
|
3016
3255
|
if (before && JSON.stringify(before) === JSON.stringify(entry)) return "unchanged";
|
|
3017
3256
|
doc[key] = { ...servers, vibiz: entry };
|
|
3018
3257
|
const local = io.local();
|
|
3019
|
-
await local.mkdir(
|
|
3258
|
+
await local.mkdir(dirname6(path), { recursive: true });
|
|
3020
3259
|
await local.writeFile(path, `${JSON.stringify(doc, null, 2)}
|
|
3021
3260
|
`);
|
|
3022
3261
|
return before ? "updated" : "added";
|
|
@@ -3025,9 +3264,9 @@ async function mergeCodexToml(io, path, url) {
|
|
|
3025
3264
|
const text2 = await readText2(io, path) ?? "";
|
|
3026
3265
|
if (/^\s*\[mcp_servers\.vibiz\]\s*$/m.test(text2)) return "unchanged";
|
|
3027
3266
|
const local = io.local();
|
|
3028
|
-
await local.mkdir(
|
|
3029
|
-
const
|
|
3030
|
-
await local.writeFile(path, `${text2}${
|
|
3267
|
+
await local.mkdir(dirname6(path), { recursive: true });
|
|
3268
|
+
const sep3 = text2 && !text2.endsWith("\n") ? "\n\n" : text2 ? "\n" : "";
|
|
3269
|
+
await local.writeFile(path, `${text2}${sep3}[mcp_servers.vibiz]
|
|
3031
3270
|
url = "${url}"
|
|
3032
3271
|
`);
|
|
3033
3272
|
return "added";
|
|
@@ -3177,7 +3416,7 @@ async function skillsAdd(io, api, names, opts) {
|
|
|
3177
3416
|
const res = await f(url);
|
|
3178
3417
|
if (!res.ok) throw new Error(`Could not download ${url} (${res.status})`);
|
|
3179
3418
|
const target = join6(dir, rel);
|
|
3180
|
-
await local.mkdir(
|
|
3419
|
+
await local.mkdir(dirname6(target), { recursive: true });
|
|
3181
3420
|
await local.writeFile(target, await res.text());
|
|
3182
3421
|
}
|
|
3183
3422
|
}
|
|
@@ -3731,6 +3970,9 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3731
3970
|
vibiz whoami the account and key this machine uses
|
|
3732
3971
|
vibiz logout forget this machine's key (a browser login's key is
|
|
3733
3972
|
revoked too)
|
|
3973
|
+
vibiz feedback "<what happened>" [--kind bug|missing|confusing_error|docs|other]
|
|
3974
|
+
[--tool <command>] [--project <id>] tell the thelastapi team: something it can't do yet,
|
|
3975
|
+
an unclear error, wrong docs. The team reads every one
|
|
3734
3976
|
vibiz init <name> [--resources a,b|none] create a project here (default: hosting, database,
|
|
3735
3977
|
auth, analytics). Any one alone works for an app on
|
|
3736
3978
|
another host: --resources email, auth, ai, analytics\u2026
|
|
@@ -3942,6 +4184,11 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3942
4184
|
vibiz add <hosting|database|auth|email|analytics|replay|ai> add a resource to this project
|
|
3943
4185
|
vibiz analytics [--period 24h|7d|30d] [--json] visitors, pages, sources, events
|
|
3944
4186
|
vibiz analytics snippet the tag for a site hosted anywhere, and the domains it counts
|
|
4187
|
+
vibiz analytics visitors [--converted] [--source google.com|direct] [--landing /p] [--country ES]
|
|
4188
|
+
[--period 24h|7d|30d] [--goals Signup,Purchase] [--limit n] [--cursor c] [--json]
|
|
4189
|
+
visitor journeys: where each visitor (or buyer) came from, their path
|
|
4190
|
+
vibiz analytics visitor <visitor_id> [--day YYYY-MM-DD] [--json]
|
|
4191
|
+
one visitor's day: every page and event, replays, sales
|
|
3945
4192
|
vibiz replays [--errors] [--rage] [--dead] [--path /x] [--period 7d] [--json]
|
|
3946
4193
|
what went wrong for visitors, then sessions to watch
|
|
3947
4194
|
vibiz replay <id> [--json] one session's signals and a link to watch it
|
|
@@ -4147,6 +4394,16 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
4147
4394
|
vibiz files get <id> [--json] one file: its link, size, and the prompt if AI made it
|
|
4148
4395
|
vibiz files download <id> [-o path] save its bytes here (private files too)
|
|
4149
4396
|
vibiz files rm <id> delete it: its link stops working
|
|
4397
|
+
vibiz library ls [path] [-r] [--project id] [--json]
|
|
4398
|
+
the Library: folders of scripts, agent skills and notes,
|
|
4399
|
+
the account's (or a project's with --project). Stored
|
|
4400
|
+
only: nothing in it runs or is public
|
|
4401
|
+
vibiz library cat <path> print one file
|
|
4402
|
+
vibiz library put <local-file-or-folder> [remote-path]
|
|
4403
|
+
save a file, or a whole folder (a skill) recursively;
|
|
4404
|
+
files already there are replaced (text only, 1 MB each)
|
|
4405
|
+
vibiz library get <remote-path> [local-dir] download a file, or a folder recursively
|
|
4406
|
+
vibiz library mkdir <path> | mv <from> <to> [--force] | rm <path> [-r]
|
|
4150
4407
|
vibiz image "<prompt>" -o out.png [--size 1024x1024] [--model m] [--from-image <https url>] generate an image, or edit a photo
|
|
4151
4408
|
vibiz video "<prompt>" -o out.mp4 [--from-image <https url>] [--aspect 16:9|9:16] [--model m] [--params '<json>'] a short video (or animate an image)
|
|
4152
4409
|
vibiz media-models [words] [--category image-to-video] every image/video model you can run by id (Kling, face swap\u2026), with its live price
|
|
@@ -4409,13 +4666,13 @@ async function linkedProject(io) {
|
|
|
4409
4666
|
} catch {
|
|
4410
4667
|
return void 0;
|
|
4411
4668
|
}
|
|
4412
|
-
for (let dir = local.cwd(); ; dir =
|
|
4669
|
+
for (let dir = local.cwd(); ; dir = dirname7(dir)) {
|
|
4413
4670
|
try {
|
|
4414
4671
|
const linked = JSON.parse(await local.readFile(join7(dir, PROJECT_FILE), "utf8"));
|
|
4415
4672
|
if (linked.project_id) return linked.project_id;
|
|
4416
4673
|
} catch {
|
|
4417
4674
|
}
|
|
4418
|
-
if (
|
|
4675
|
+
if (dirname7(dir) === dir) return void 0;
|
|
4419
4676
|
}
|
|
4420
4677
|
}
|
|
4421
4678
|
async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
|
|
@@ -4705,7 +4962,7 @@ async function framesCommand(io, id, values) {
|
|
|
4705
4962
|
const saved = /* @__PURE__ */ new Map();
|
|
4706
4963
|
if (values.out) {
|
|
4707
4964
|
const local = io.local();
|
|
4708
|
-
const dir =
|
|
4965
|
+
const dir = resolve3(local.cwd(), values.out);
|
|
4709
4966
|
await local.mkdir(dir, { recursive: true });
|
|
4710
4967
|
const vibiz2 = await io.client();
|
|
4711
4968
|
for (const f of out.frames) {
|
|
@@ -4743,9 +5000,9 @@ async function framesCommand(io, id, values) {
|
|
|
4743
5000
|
if (!out.frames.length) io.log(" none");
|
|
4744
5001
|
for (const f of out.frames) {
|
|
4745
5002
|
const where = `${clock(f.offset_ms).padStart(6)} ${f.kind.padEnd(14)} ${f.page}`;
|
|
4746
|
-
const
|
|
5003
|
+
const size2 = f.viewport ? ` ${f.viewport.width}x${f.viewport.height}` : "";
|
|
4747
5004
|
const label = f.label === f.page ? "" : ` ${f.label}`;
|
|
4748
|
-
io.log(` ${dot(f.status === "ready" ? "ready" : "failed")} ${where}${
|
|
5005
|
+
io.log(` ${dot(f.status === "ready" ? "ready" : "failed")} ${where}${size2}${label}`);
|
|
4749
5006
|
if (f.id && saved.has(f.id)) io.log(` saved ${saved.get(f.id)}`);
|
|
4750
5007
|
else if (f.image) io.log(` ${f.image.url}`);
|
|
4751
5008
|
if (f.error) io.log(` ${f.error.message} ${f.error.next_step}`);
|
|
@@ -5078,6 +5335,50 @@ function printAnalytics(io, r) {
|
|
|
5078
5335
|
r.events.map((e) => [e.name, e.count])
|
|
5079
5336
|
);
|
|
5080
5337
|
}
|
|
5338
|
+
var fromLabel = (source) => source ?? "direct";
|
|
5339
|
+
function printJourneys(io, r) {
|
|
5340
|
+
const f = r.filters;
|
|
5341
|
+
const only = [
|
|
5342
|
+
f.converted && "converted",
|
|
5343
|
+
f.source && `from ${f.source}`,
|
|
5344
|
+
f.landing && `landing ${f.landing}`,
|
|
5345
|
+
f.country
|
|
5346
|
+
].filter(Boolean);
|
|
5347
|
+
io.log(`Visitors, last ${r.period}${only.length ? ` (${only.join(", ")})` : ""}, newest first`);
|
|
5348
|
+
if (!r.data.length) io.log(" none");
|
|
5349
|
+
for (const j of r.data) {
|
|
5350
|
+
const sale = j.sales.length ? ` bought ${j.sales.map((p) => formatMinor(p.amount_cents, p.currency)).join(" + ")}` : j.converted ? " converted" : "";
|
|
5351
|
+
io.log(
|
|
5352
|
+
`
|
|
5353
|
+
${j.started_at.slice(0, 16).replace("T", " ")} from ${fromLabel(j.source)} ${[j.country, j.device].filter(Boolean).join(" ")} ${clock(j.duration_ms)}${sale}`
|
|
5354
|
+
);
|
|
5355
|
+
io.log(` ${j.pages.map((p) => p.path).join(" \u2192 ")}`);
|
|
5356
|
+
if (j.custom_events.length)
|
|
5357
|
+
io.log(` events: ${j.custom_events.map((e) => e.name).join(", ")}`);
|
|
5358
|
+
io.log(` vibiz analytics visitor ${j.visitor_id} --day ${j.day}`);
|
|
5359
|
+
}
|
|
5360
|
+
if (r.next_cursor) io.log(`
|
|
5361
|
+
more: --cursor ${r.next_cursor}`);
|
|
5362
|
+
if (r.console_url) io.log(`
|
|
5363
|
+
${r.console_url}`);
|
|
5364
|
+
}
|
|
5365
|
+
function printJourney(io, j) {
|
|
5366
|
+
io.log(
|
|
5367
|
+
`Visitor ${j.visitor_id} on ${j.day}: from ${fromLabel(j.source)}, landed on ${j.landing_page ?? "?"}`
|
|
5368
|
+
);
|
|
5369
|
+
io.log(
|
|
5370
|
+
` ${[j.country, j.device].filter(Boolean).join(" \xB7 ")} ${j.pageviews} pages \xB7 ${j.events} events \xB7 ${clock(j.duration_ms)}${j.converted ? " \xB7 converted" : ""}`
|
|
5371
|
+
);
|
|
5372
|
+
for (const t of j.timeline) {
|
|
5373
|
+
const what = t.type === "pageview" ? t.path : `${t.name} (${t.path})`;
|
|
5374
|
+
const src = t.source ? ` \u2190 ${t.source}` : "";
|
|
5375
|
+
io.log(` ${t.at.slice(11, 19)} ${t.type === "pageview" ? " " : " \u2022 "}${what}${src}`);
|
|
5376
|
+
}
|
|
5377
|
+
for (const p of j.sales)
|
|
5378
|
+
io.log(` sale ${p.id}: ${formatMinor(p.amount_cents, p.currency)} (${p.environment})`);
|
|
5379
|
+
for (const r of j.replays) io.log(` replay ${r.id}: vibiz replay ${r.id}`);
|
|
5380
|
+
if (j.console_url) io.log(` ${j.console_url}`);
|
|
5381
|
+
}
|
|
5081
5382
|
var clock = (ms2) => {
|
|
5082
5383
|
const sec = Math.round(ms2 / 1e3);
|
|
5083
5384
|
return `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, "0")}`;
|
|
@@ -5170,6 +5471,17 @@ function bytesLabel(n) {
|
|
|
5170
5471
|
if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
|
5171
5472
|
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
5172
5473
|
}
|
|
5474
|
+
var subcommands;
|
|
5475
|
+
function commandName(argv2) {
|
|
5476
|
+
const [command, sub] = argv2;
|
|
5477
|
+
if (!command || !/^[a-z][a-z-]{0,30}$/.test(command)) return null;
|
|
5478
|
+
subcommands ??= new Set(
|
|
5479
|
+
[...HELP.matchAll(/^ {2}vibiz ([a-z][a-z-]*) ([a-z][a-z-]*)(?=[\s|]|$)/gm)].map(
|
|
5480
|
+
(m) => `${m[1]} ${m[2]}`
|
|
5481
|
+
)
|
|
5482
|
+
);
|
|
5483
|
+
return sub && subcommands.has(`${command} ${sub}`) ? `${command} ${sub}` : command;
|
|
5484
|
+
}
|
|
5173
5485
|
function commandHelp(command) {
|
|
5174
5486
|
const lines = HELP.split("\n");
|
|
5175
5487
|
const out = [];
|
|
@@ -5300,6 +5612,8 @@ async function runCli(argv2, io) {
|
|
|
5300
5612
|
bucket: { type: "string" },
|
|
5301
5613
|
level: { type: "string" },
|
|
5302
5614
|
product: { type: "string" },
|
|
5615
|
+
// vibiz library ls -r, rm -r (docs: library)
|
|
5616
|
+
recursive: { type: "boolean", short: "r", default: false },
|
|
5303
5617
|
// vibiz search pages (docs: Search)
|
|
5304
5618
|
"not-indexed": { type: "boolean", default: false },
|
|
5305
5619
|
"owner-email": { type: "string" },
|
|
@@ -5435,6 +5749,11 @@ async function runCli(argv2, io) {
|
|
|
5435
5749
|
"max-pages": { type: "string" },
|
|
5436
5750
|
action: { type: "string" },
|
|
5437
5751
|
cursor: { type: "string" },
|
|
5752
|
+
// visitor journeys (vibiz analytics visitors | visitor <id>)
|
|
5753
|
+
day: { type: "string" },
|
|
5754
|
+
landing: { type: "string" },
|
|
5755
|
+
converted: { type: "boolean", default: false },
|
|
5756
|
+
goals: { type: "string" },
|
|
5438
5757
|
page: { type: "boolean", default: false },
|
|
5439
5758
|
code: { type: "boolean", default: false },
|
|
5440
5759
|
db: { type: "boolean", default: false },
|
|
@@ -5527,6 +5846,29 @@ async function runCli(argv2, io) {
|
|
|
5527
5846
|
io.log(` api ${io.env.VIBIZ_API_URL || saved.apiUrl || DEFAULT_API_URL}`);
|
|
5528
5847
|
return;
|
|
5529
5848
|
}
|
|
5849
|
+
case "feedback": {
|
|
5850
|
+
const summary = positionals.join(" ").trim();
|
|
5851
|
+
const kinds = ["bug", "missing", "confusing_error", "docs", "other"];
|
|
5852
|
+
const kind = values.kind ?? "other";
|
|
5853
|
+
if (!summary) {
|
|
5854
|
+
throw new Error(
|
|
5855
|
+
'Say what happened: vibiz feedback "<what you needed or what went wrong>" [--kind bug|missing|confusing_error|docs|other]'
|
|
5856
|
+
);
|
|
5857
|
+
}
|
|
5858
|
+
if (!kinds.includes(kind)) throw new Error(`--kind is ${kinds.join(", ")}`);
|
|
5859
|
+
const out = await (await io.client()).feedback({
|
|
5860
|
+
kind,
|
|
5861
|
+
summary,
|
|
5862
|
+
...values.tool ? { tool: values.tool } : {},
|
|
5863
|
+
...values.project ? { project_id: values.project } : {}
|
|
5864
|
+
});
|
|
5865
|
+
if (values.json) {
|
|
5866
|
+
io.log(JSON.stringify(out, null, 2));
|
|
5867
|
+
return;
|
|
5868
|
+
}
|
|
5869
|
+
io.log(out.message);
|
|
5870
|
+
return;
|
|
5871
|
+
}
|
|
5530
5872
|
case "logout": {
|
|
5531
5873
|
const dir = io.configDir ?? CONFIG_DIR;
|
|
5532
5874
|
const saved = await readLogin(io, dir);
|
|
@@ -5624,7 +5966,7 @@ ${await oneKeyLines(vibiz2, project.id)}`);
|
|
|
5624
5966
|
const local = io.local();
|
|
5625
5967
|
const vibiz2 = await io.client();
|
|
5626
5968
|
const id = values.project ?? await io.project();
|
|
5627
|
-
const dir =
|
|
5969
|
+
const dir = resolve3(local.cwd(), positionals[0] ?? ".");
|
|
5628
5970
|
const { deployment, uploaded, total } = await deployDirectory(vibiz2, id, dir, {
|
|
5629
5971
|
target: values.preview ? "preview" : "production",
|
|
5630
5972
|
...values.message ? { message: values.message } : {},
|
|
@@ -6981,6 +7323,35 @@ ${await oneKeyLines(vibiz2, id)}`);
|
|
|
6981
7323
|
}
|
|
6982
7324
|
const period = values.period ?? "7d";
|
|
6983
7325
|
if (!["24h", "7d", "30d"].includes(period)) throw new Error("--period is 24h, 7d or 30d");
|
|
7326
|
+
if (positionals[0] === "visitors" || positionals[0] === "journeys") {
|
|
7327
|
+
const goals = values.goals?.split(",").map((g) => g.trim()).filter(Boolean);
|
|
7328
|
+
const list2 = await (await io.client()).analytics.visitors(await io.project(), {
|
|
7329
|
+
period,
|
|
7330
|
+
...values.source ? { source: values.source } : {},
|
|
7331
|
+
...values.landing ? { landing: values.landing } : {},
|
|
7332
|
+
...values.country ? { country: values.country } : {},
|
|
7333
|
+
...values.converted ? { converted: true } : {},
|
|
7334
|
+
...goals?.length ? { goals } : {},
|
|
7335
|
+
...values.limit ? { limit: Number(values.limit) } : {},
|
|
7336
|
+
...values.cursor ? { cursor: values.cursor } : {}
|
|
7337
|
+
});
|
|
7338
|
+
if (values.json) io.log(JSON.stringify(list2, null, 2));
|
|
7339
|
+
else printJourneys(io, list2);
|
|
7340
|
+
return;
|
|
7341
|
+
}
|
|
7342
|
+
if (positionals[0] === "visitor") {
|
|
7343
|
+
const id = positionals[1];
|
|
7344
|
+
if (!id)
|
|
7345
|
+
throw new Error(
|
|
7346
|
+
"Which visitor? vibiz analytics visitor <visitor_id> --day YYYY-MM-DD (ids are in vibiz analytics visitors)"
|
|
7347
|
+
);
|
|
7348
|
+
const j = await (await io.client()).analytics.visitor(await io.project(), id, {
|
|
7349
|
+
...values.day ? { day: values.day } : {}
|
|
7350
|
+
});
|
|
7351
|
+
if (values.json) io.log(JSON.stringify(j, null, 2));
|
|
7352
|
+
else printJourney(io, j);
|
|
7353
|
+
return;
|
|
7354
|
+
}
|
|
6984
7355
|
const report = await (await io.client()).analytics.get(await io.project(), { period });
|
|
6985
7356
|
if (values.json) io.log(JSON.stringify(report, null, 2));
|
|
6986
7357
|
else printAnalytics(io, report);
|
|
@@ -6995,6 +7366,11 @@ ${await oneKeyLines(vibiz2, id)}`);
|
|
|
6995
7366
|
await dashboardsCommand(io, positionals, values);
|
|
6996
7367
|
return;
|
|
6997
7368
|
}
|
|
7369
|
+
case "library":
|
|
7370
|
+
case "lib": {
|
|
7371
|
+
await libraryCommand(io, positionals, values);
|
|
7372
|
+
return;
|
|
7373
|
+
}
|
|
6998
7374
|
case "replays": {
|
|
6999
7375
|
if (positionals[0] === "frames") {
|
|
7000
7376
|
await framesCommand(io, positionals[1], values);
|
|
@@ -7714,7 +8090,7 @@ Store the key now: it is not shown again.`
|
|
|
7714
8090
|
return;
|
|
7715
8091
|
}
|
|
7716
8092
|
case "docs": {
|
|
7717
|
-
const { DOC_TOPICS, DOCS } = await import("./src-
|
|
8093
|
+
const { DOC_TOPICS, DOCS } = await import("./src-FCM467GZ.js");
|
|
7718
8094
|
const topic = positionals[0];
|
|
7719
8095
|
if (!topic || !DOC_TOPICS.includes(topic)) {
|
|
7720
8096
|
for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
|
|
@@ -7739,7 +8115,7 @@ ${DOCS[topic].body}`);
|
|
|
7739
8115
|
if (positionals[0])
|
|
7740
8116
|
throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
|
|
7741
8117
|
io.local();
|
|
7742
|
-
const { serveStdio } = await import("./src-
|
|
8118
|
+
const { serveStdio } = await import("./src-FCM467GZ.js");
|
|
7743
8119
|
await serveStdio({ version: cliVersion() });
|
|
7744
8120
|
return;
|
|
7745
8121
|
}
|
|
@@ -8174,19 +8550,27 @@ function openUrl(url) {
|
|
|
8174
8550
|
} catch {
|
|
8175
8551
|
}
|
|
8176
8552
|
}
|
|
8553
|
+
var runCommand = commandName(process.argv.slice(2));
|
|
8554
|
+
var agentHeaders = {
|
|
8555
|
+
"x-vibiz-session": `cli_${randomUUID()}`,
|
|
8556
|
+
...runCommand ? { "x-vibiz-tool": runCommand } : {}
|
|
8557
|
+
};
|
|
8558
|
+
var CLIENT = `vibiz-cli/${cliVersion()}`;
|
|
8177
8559
|
var terminal = {
|
|
8178
8560
|
log: (...parts) => console.log(format(...parts)),
|
|
8179
8561
|
error: (...parts) => console.error(format(...parts)),
|
|
8180
8562
|
out: (text2) => void process.stdout.write(text2),
|
|
8181
8563
|
err: (text2) => void process.stderr.write(text2),
|
|
8182
8564
|
env: process.env,
|
|
8183
|
-
client: async () => new Vibiz({ ...await login(), client:
|
|
8565
|
+
client: async () => new Vibiz({ ...await login(), client: CLIENT, headers: agentHeaders }),
|
|
8184
8566
|
aiClient: async (project) => {
|
|
8185
8567
|
const { apiKey, baseUrl } = await login();
|
|
8186
8568
|
const headers = project ? { "x-vibiz-project": project } : void 0;
|
|
8187
8569
|
return new Vibiz({
|
|
8188
8570
|
apiKey,
|
|
8189
8571
|
baseUrl,
|
|
8572
|
+
client: CLIENT,
|
|
8573
|
+
headers: agentHeaders,
|
|
8190
8574
|
...headers ? {
|
|
8191
8575
|
fetch: ((url, init) => fetch(url, {
|
|
8192
8576
|
...init,
|
|
@@ -8196,12 +8580,16 @@ var terminal = {
|
|
|
8196
8580
|
});
|
|
8197
8581
|
},
|
|
8198
8582
|
project: async () => {
|
|
8199
|
-
for (let dir = process.cwd(); ; dir =
|
|
8583
|
+
for (let dir = process.cwd(); ; dir = dirname8(dir)) {
|
|
8200
8584
|
const linked = await readJson2(join9(dir, PROJECT_FILE));
|
|
8201
8585
|
if (linked?.project_id) return linked.project_id;
|
|
8202
|
-
if (
|
|
8586
|
+
if (dirname8(dir) === dir) break;
|
|
8203
8587
|
}
|
|
8204
|
-
const list2 = await new Vibiz(
|
|
8588
|
+
const list2 = await new Vibiz({
|
|
8589
|
+
...await login(),
|
|
8590
|
+
client: CLIENT,
|
|
8591
|
+
headers: agentHeaders
|
|
8592
|
+
}).projects.list();
|
|
8205
8593
|
const wanted = process.env.VIBIZ_PROJECT?.trim().toLowerCase();
|
|
8206
8594
|
if (wanted) {
|
|
8207
8595
|
const p = list2.find((x) => [x.id, x.slug, x.name.toLowerCase()].includes(wanted));
|