@vibiz/cli 0.2.1 → 0.2.3

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
@@ -1,22 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ APP_SDK_VERSION,
3
4
  Vibiz,
4
5
  VibizApiError,
6
+ connectHostMessage,
5
7
  deployDirectory,
8
+ deployPathProblem,
6
9
  formatUnits,
7
10
  formatUsd,
8
- mergeEnvFile
9
- } from "./chunk-J4RTAA72.js";
11
+ mergeEnvFile,
12
+ oneKeyMessage
13
+ } from "./chunk-RXH3L5IW.js";
10
14
 
11
15
  // packages/cli/src/main.ts
12
16
  import { spawn } from "node:child_process";
13
17
  import { chmod, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
14
- import { dirname as dirname5, join as join8 } from "node:path";
18
+ import { dirname as dirname7, join as join9 } from "node:path";
15
19
  import { format } from "node:util";
16
20
 
17
21
  // packages/cli/src/commands.ts
18
22
  import { homedir as homedir2 } from "node:os";
19
- import { join as join6, resolve } from "node:path";
23
+ import { dirname as dirname6, join as join7, resolve as resolve2 } from "node:path";
20
24
  import { parseArgs } from "node:util";
21
25
 
22
26
  // packages/app/src/index.ts
@@ -565,8 +569,86 @@ function formatBilling(b, history) {
565
569
  return lines.join("\n");
566
570
  }
567
571
 
572
+ // packages/cli/src/code.ts
573
+ import { readdir } from "node:fs/promises";
574
+ import { dirname, join, resolve, sep } from "node:path";
575
+ async function deploymentOf(vibiz2, projectId, wanted) {
576
+ if (wanted) return wanted;
577
+ const project = await vibiz2.projects.get(projectId);
578
+ if (project.production_deployment_id) return project.production_deployment_id;
579
+ const latest = (await vibiz2.deployments.list(projectId))[0];
580
+ if (!latest)
581
+ throw new Error(
582
+ `${projectId} has no deployment yet, so there is no code to read. Deploy it first: vibiz deploy`
583
+ );
584
+ return latest.id;
585
+ }
586
+ async function manifest(vibiz2, projectId, wanted) {
587
+ const id = await deploymentOf(vibiz2, projectId, wanted);
588
+ const listed = await vibiz2.deployments.files(id);
589
+ if (listed.project_id !== projectId)
590
+ throw new Error(`${id} is a deployment of ${listed.project_id}, not of ${projectId}.`);
591
+ return { id, files: listed.data };
592
+ }
593
+ async function codeCommand(io, positionals, flags) {
594
+ const [sub = "ls", path] = positionals;
595
+ const vibiz2 = await io.client();
596
+ const projectId = await io.project();
597
+ if (sub === "ls" || sub === "list") {
598
+ const { id, files } = await manifest(vibiz2, projectId, flags.deployment);
599
+ if (flags.json) {
600
+ io.log(JSON.stringify({ deployment_id: id, files }, null, 2));
601
+ return;
602
+ }
603
+ io.log(`${id}: ${files.length} file${files.length === 1 ? "" : "s"}`);
604
+ for (const f of files) io.log(` ${bytesLabel(f.size).padStart(9)} ${f.path}`);
605
+ return;
606
+ }
607
+ if (sub === "cat" || sub === "read") {
608
+ if (!path) throw new Error("usage: vibiz code cat <path> [--deployment <id>]");
609
+ const id = await deploymentOf(vibiz2, projectId, flags.deployment);
610
+ const bytes = await vibiz2.deployments.readFile(id, path);
611
+ io.out(new TextDecoder().decode(bytes));
612
+ return;
613
+ }
614
+ throw new Error("usage: vibiz code [ls | cat <path>] [--deployment <id>]");
615
+ }
616
+ async function pullCommand(io, positionals, flags) {
617
+ const local = io.local();
618
+ const vibiz2 = await io.client();
619
+ const projectId = await io.project();
620
+ const dir = resolve(local.cwd(), positionals[0] ?? ".");
621
+ const existing = await readdir(dir).catch((e) => {
622
+ if (e.code === "ENOENT") return [];
623
+ throw e;
624
+ });
625
+ if (existing.some((n) => n !== "vibiz.json") && !flags.force)
626
+ throw new Error(
627
+ `${dir} is not empty, and pulling would overwrite files there. Pull into a new folder (vibiz pull my-site), or add --force to overwrite.`
628
+ );
629
+ const { id, files } = await manifest(vibiz2, projectId, flags.deployment);
630
+ let bytesTotal = 0;
631
+ for (const f of files) {
632
+ const problem = deployPathProblem(f.path);
633
+ if (problem) throw new Error(`Refusing to write ${JSON.stringify(f.path)}: it ${problem}.`);
634
+ const target = join(dir, ...f.path.split("/"));
635
+ if (!target.startsWith(`${dir}${sep}`))
636
+ throw new Error(`Refusing to write ${f.path}: it is outside ${dir}.`);
637
+ const bytes = await vibiz2.deployments.readFile(id, f.path);
638
+ await local.mkdir(dirname(target), { recursive: true });
639
+ await local.writeFile(target, bytes);
640
+ bytesTotal += bytes.byteLength;
641
+ }
642
+ if (flags.json) {
643
+ io.log(JSON.stringify({ deployment_id: id, dir, files: files.length }, null, 2));
644
+ return;
645
+ }
646
+ io.log(`Pulled ${files.length} files (${bytesLabel(bytesTotal)}) of ${id} into ${dir}`);
647
+ io.log(" Change what you need, then deploy it: vibiz deploy");
648
+ }
649
+
568
650
  // packages/cli/src/design.ts
569
- import { dirname, join } from "node:path";
651
+ import { dirname as dirname2, join as join2 } from "node:path";
570
652
  var usd = (micro) => micro === null || micro === void 0 ? "" : `$${(micro / 1e6).toFixed(micro < 1e4 ? 4 : 2)}`;
571
653
  var DESIGN_USAGE = "vibiz design <url> [--out design.md] [--tailwind] [--shadcn] [--css] [--own] [--pages /pricing,/about] [--fresh] [--json]";
572
654
  async function designCommand(io, args, flags) {
@@ -594,8 +676,8 @@ async function designCommand(io, args, flags) {
594
676
  const local = io.local();
595
677
  const out = flags.out ?? "design.md";
596
678
  const write = async (name, text) => {
597
- const path = join(local.cwd(), name);
598
- await local.mkdir(dirname(path), { recursive: true });
679
+ const path = join2(local.cwd(), name);
680
+ await local.mkdir(dirname2(path), { recursive: true });
599
681
  await local.writeFile(path, text);
600
682
  return name;
601
683
  };
@@ -637,7 +719,7 @@ ${tail}
637
719
  }
638
720
 
639
721
  // packages/cli/src/detect.ts
640
- import { readdir } from "node:fs/promises";
722
+ import { readdir as readdir2 } from "node:fs/promises";
641
723
  var SIGNS = [
642
724
  { kind: "vercel", label: "Vercel", files: /^(vercel\.json|\.vercel)$/, push: true },
643
725
  { kind: "netlify", label: "Netlify", files: /^(netlify\.toml|\.netlify)$/, push: true },
@@ -679,7 +761,7 @@ var SIGNS = [
679
761
  { kind: "digitalocean", label: "DigitalOcean App Platform", files: /^\.do$/, push: false }
680
762
  ];
681
763
  async function detectHosts(dir) {
682
- const names = await readdir(dir).catch(() => []);
764
+ const names = await readdir2(dir).catch(() => []);
683
765
  const out = [];
684
766
  for (const sign of SIGNS) {
685
767
  const file = names.find((n) => sign.files.test(n));
@@ -689,8 +771,10 @@ async function detectHosts(dir) {
689
771
  }
690
772
  return out;
691
773
  }
692
- var ONE_KEY_PATHS = ` Put ONE secret in the host: VIBIZ_APP_KEY (an owner copies it from the console:
693
- project \u25B8 Settings \u25B8 Production environment \u25B8 Show values). Then, at start:
774
+ function hostName(h) {
775
+ return h.label.replace(/\s*\(.*\)$/, "");
776
+ }
777
+ var ONE_KEY_PATHS = ` Then the app loads the rest at start:
694
778
 
695
779
  Node, Bun, Deno import { vibiz } from '@vibiz/app'; await vibiz.loadEnv();
696
780
  any language npx @vibiz/cli run -- <your start command>
@@ -1192,7 +1276,7 @@ ${EMAIL_MARKETING_HELP}`);
1192
1276
  }
1193
1277
 
1194
1278
  // packages/cli/src/export.ts
1195
- import { dirname as dirname2, join as join2 } from "node:path";
1279
+ import { dirname as dirname3, join as join3 } from "node:path";
1196
1280
  import { Readable } from "node:stream";
1197
1281
  var STEP = {
1198
1282
  starting: "starting",
@@ -1252,7 +1336,7 @@ async function exportCommand(io, flags) {
1252
1336
  }
1253
1337
  const out = local;
1254
1338
  const zipKind = done.files.find((f) => f.kind === "code" || f.kind === "guide");
1255
- const dir = flags.output ? dirname2(flags.output) : ".";
1339
+ const dir = flags.output ? dirname3(flags.output) : ".";
1256
1340
  const saved = [];
1257
1341
  for (const f of done.files) {
1258
1342
  if (!f.url) {
@@ -1260,7 +1344,7 @@ async function exportCommand(io, flags) {
1260
1344
  `);
1261
1345
  continue;
1262
1346
  }
1263
- const path = f === zipKind && flags.output ? flags.output : join2(dir, f.name);
1347
+ const path = f === zipKind && flags.output ? flags.output : join3(dir, f.name);
1264
1348
  const res = await vibiz2.exports.download(f.url);
1265
1349
  if (!res.body) throw new Error(`${f.name} came back empty`);
1266
1350
  await out.writeFile(path, Readable.fromWeb(res.body));
@@ -1269,7 +1353,7 @@ async function exportCommand(io, flags) {
1269
1353
  let envPath = null;
1270
1354
  if (flags.secrets) {
1271
1355
  const project = await vibiz2.projects.get(projectId);
1272
- envPath = join2(dir, `${project.slug}.env.${done.environment}`);
1356
+ envPath = join3(dir, `${project.slug}.env.${done.environment}`);
1273
1357
  if (!flags.yes) {
1274
1358
  const answer = await io.promptLine(
1275
1359
  `Write the ${done.environment} secret values to ${envPath}? They are live credentials: never commit or share that file. Type yes: `
@@ -1505,7 +1589,7 @@ async function inboxCommand(io, vibiz2, flags, positionals) {
1505
1589
 
1506
1590
  // packages/cli/src/login.ts
1507
1591
  import { hostname, platform, release } from "node:os";
1508
- import { join as join3 } from "node:path";
1592
+ import { join as join4 } from "node:path";
1509
1593
 
1510
1594
  // packages/cli/src/version.ts
1511
1595
  import { readFileSync } from "node:fs";
@@ -1520,8 +1604,8 @@ function cliVersion() {
1520
1604
 
1521
1605
  // packages/cli/src/login.ts
1522
1606
  var DEFAULT_API_URL = "https://app.vibiz.app";
1523
- var pendingFile = (dir) => join3(dir, "pending-login.json");
1524
- var configFile = (dir) => join3(dir, "config.json");
1607
+ var pendingFile = (dir) => join4(dir, "pending-login.json");
1608
+ var configFile = (dir) => join4(dir, "config.json");
1525
1609
  async function readJson(io, path) {
1526
1610
  try {
1527
1611
  return JSON.parse(String(await io.local().readFile(path, "utf8")));
@@ -1667,8 +1751,8 @@ async function browserLogin(io, api, deps) {
1667
1751
 
1668
1752
  // packages/cli/src/scaffold.ts
1669
1753
  import { existsSync } from "node:fs";
1670
- import { cp, readdir as readdir2, readFile, rename, writeFile } from "node:fs/promises";
1671
- import { dirname as dirname3, join as join4 } from "node:path";
1754
+ import { cp, readdir as readdir3, readFile, rename, writeFile } from "node:fs/promises";
1755
+ import { dirname as dirname4, join as join5 } from "node:path";
1672
1756
  import { fileURLToPath } from "node:url";
1673
1757
  var TEMPLATES = ["nextjs-saas"];
1674
1758
  var SKIP = /* @__PURE__ */ new Set([
@@ -1689,10 +1773,10 @@ var packedName = (dotfile) => `_${dotfile.slice(1)}`;
1689
1773
  function templatesDir() {
1690
1774
  const fromEnv = process.env.VIBIZ_TEMPLATES_DIR?.trim();
1691
1775
  if (fromEnv) return fromEnv;
1692
- const here = dirname3(fileURLToPath(import.meta.url));
1693
- const packaged = join4(here, "..", "templates");
1776
+ const here = dirname4(fileURLToPath(import.meta.url));
1777
+ const packaged = join5(here, "..", "templates");
1694
1778
  if (existsSync(packaged)) return packaged;
1695
- return join4(here, "..", "..", "..", "templates");
1779
+ return join5(here, "..", "..", "..", "templates");
1696
1780
  }
1697
1781
  function isTemplate(name) {
1698
1782
  return TEMPLATES.includes(name);
@@ -1703,7 +1787,7 @@ function packageName(name) {
1703
1787
  }
1704
1788
  async function isEffectivelyEmpty(dir) {
1705
1789
  try {
1706
- return (await readdir2(dir)).every((e) => HARMLESS.has(e));
1790
+ return (await readdir3(dir)).every((e) => HARMLESS.has(e));
1707
1791
  } catch (err) {
1708
1792
  if (err.code === "ENOENT") return true;
1709
1793
  throw err;
@@ -1713,7 +1797,7 @@ async function scaffold(opts) {
1713
1797
  if (!opts.force && !await isEffectivelyEmpty(opts.dir)) {
1714
1798
  throw new Error(`${opts.dir} is not empty. Use an empty folder, or pass --force.`);
1715
1799
  }
1716
- const source = join4(opts.templatesRoot ?? templatesDir(), opts.template);
1800
+ const source = join5(opts.templatesRoot ?? templatesDir(), opts.template);
1717
1801
  await cp(source, opts.dir, {
1718
1802
  recursive: true,
1719
1803
  force: true,
@@ -1723,24 +1807,24 @@ async function scaffold(opts) {
1723
1807
  }
1724
1808
  }).catch((err) => {
1725
1809
  if (err.code === "ENOENT") {
1726
- throw new Error(`Template "${opts.template}" not found in ${dirname3(source)}`);
1810
+ throw new Error(`Template "${opts.template}" not found in ${dirname4(source)}`);
1727
1811
  }
1728
1812
  throw err;
1729
1813
  });
1730
1814
  for (const dotfile of PACKED_DOTFILES) {
1731
- await rename(join4(opts.dir, packedName(dotfile)), join4(opts.dir, dotfile)).catch((err) => {
1815
+ await rename(join5(opts.dir, packedName(dotfile)), join5(opts.dir, dotfile)).catch((err) => {
1732
1816
  if (err.code !== "ENOENT") throw err;
1733
1817
  });
1734
1818
  }
1735
1819
  await setAppName(opts.dir, opts.name);
1736
1820
  }
1737
1821
  async function setAppName(dir, name) {
1738
- const pkgPath = join4(dir, "package.json");
1822
+ const pkgPath = join5(dir, "package.json");
1739
1823
  const pkg = JSON.parse(await readFile(pkgPath, "utf8"));
1740
1824
  pkg.name = packageName(name);
1741
1825
  await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}
1742
1826
  `);
1743
- const lockPath = join4(dir, "package-lock.json");
1827
+ const lockPath = join5(dir, "package-lock.json");
1744
1828
  const lockText = await readFile(lockPath, "utf8").catch(() => null);
1745
1829
  if (lockText !== null) {
1746
1830
  const lock = JSON.parse(lockText);
@@ -1750,7 +1834,7 @@ async function setAppName(dir, name) {
1750
1834
  await writeFile(lockPath, `${JSON.stringify(lock, null, 2)}
1751
1835
  `);
1752
1836
  }
1753
- const configPath = join4(dir, "app.config.ts");
1837
+ const configPath = join5(dir, "app.config.ts");
1754
1838
  const config = await readFile(configPath, "utf8").catch(() => null);
1755
1839
  if (config === null) return;
1756
1840
  const literal = `'${name.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
@@ -1762,7 +1846,7 @@ async function setAppName(dir, name) {
1762
1846
  // packages/cli/src/setup.ts
1763
1847
  import { accessSync, constants } from "node:fs";
1764
1848
  import { homedir, platform as platform2 } from "node:os";
1765
- import { delimiter, dirname as dirname4, join as join5 } from "node:path";
1849
+ import { delimiter, dirname as dirname5, join as join6 } from "node:path";
1766
1850
  var CLIENT_NAMES = {
1767
1851
  "claude code": "claude",
1768
1852
  claude: "claude",
@@ -1792,7 +1876,7 @@ function onPath(cmd, env) {
1792
1876
  for (const dir of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
1793
1877
  for (const ext of exts) {
1794
1878
  try {
1795
- accessSync(join5(dir, cmd + ext), constants.X_OK);
1879
+ accessSync(join6(dir, cmd + ext), constants.X_OK);
1796
1880
  return true;
1797
1881
  } catch {
1798
1882
  }
@@ -1820,24 +1904,24 @@ function parseClients(raw) {
1820
1904
  function mcpConfigPath(client, home) {
1821
1905
  switch (client) {
1822
1906
  case "cursor":
1823
- return join5(home, ".cursor", "mcp.json");
1907
+ return join6(home, ".cursor", "mcp.json");
1824
1908
  case "windsurf":
1825
- return join5(home, ".codeium", "windsurf", "mcp_config.json");
1909
+ return join6(home, ".codeium", "windsurf", "mcp_config.json");
1826
1910
  case "gemini":
1827
- return join5(home, ".gemini", "settings.json");
1911
+ return join6(home, ".gemini", "settings.json");
1828
1912
  case "opencode":
1829
- return join5(home, ".config", "opencode", "opencode.json");
1913
+ return join6(home, ".config", "opencode", "opencode.json");
1830
1914
  case "vscode":
1831
1915
  if (platform2() === "darwin")
1832
- return join5(home, "Library", "Application Support", "Code", "User", "mcp.json");
1916
+ return join6(home, "Library", "Application Support", "Code", "User", "mcp.json");
1833
1917
  if (platform2() === "win32")
1834
- return join5(
1835
- process.env.APPDATA ?? join5(home, "AppData", "Roaming"),
1918
+ return join6(
1919
+ process.env.APPDATA ?? join6(home, "AppData", "Roaming"),
1836
1920
  "Code",
1837
1921
  "User",
1838
1922
  "mcp.json"
1839
1923
  );
1840
- return join5(home, ".config", "Code", "User", "mcp.json");
1924
+ return join6(home, ".config", "Code", "User", "mcp.json");
1841
1925
  }
1842
1926
  }
1843
1927
  function jsonEntry(client, url) {
@@ -1885,7 +1969,7 @@ async function mergeJsonServer(io, path, key, entry) {
1885
1969
  if (before && JSON.stringify(before) === JSON.stringify(entry)) return "unchanged";
1886
1970
  doc[key] = { ...servers, vibiz: entry };
1887
1971
  const local = io.local();
1888
- await local.mkdir(dirname4(path), { recursive: true });
1972
+ await local.mkdir(dirname5(path), { recursive: true });
1889
1973
  await local.writeFile(path, `${JSON.stringify(doc, null, 2)}
1890
1974
  `);
1891
1975
  return before ? "updated" : "added";
@@ -1894,9 +1978,9 @@ async function mergeCodexToml(io, path, url) {
1894
1978
  const text = await readText2(io, path) ?? "";
1895
1979
  if (/^\s*\[mcp_servers\.vibiz\]\s*$/m.test(text)) return "unchanged";
1896
1980
  const local = io.local();
1897
- await local.mkdir(dirname4(path), { recursive: true });
1898
- const sep = text && !text.endsWith("\n") ? "\n\n" : text ? "\n" : "";
1899
- await local.writeFile(path, `${text}${sep}[mcp_servers.vibiz]
1981
+ await local.mkdir(dirname5(path), { recursive: true });
1982
+ const sep2 = text && !text.endsWith("\n") ? "\n\n" : text ? "\n" : "";
1983
+ await local.writeFile(path, `${text}${sep2}[mcp_servers.vibiz]
1900
1984
  url = "${url}"
1901
1985
  `);
1902
1986
  return "added";
@@ -1930,7 +2014,7 @@ async function mcpAdd(io, api, rawClients) {
1930
2014
  continue;
1931
2015
  }
1932
2016
  if (client === "claude") {
1933
- const path2 = join5(home, ".claude.json");
2017
+ const path2 = join6(home, ".claude.json");
1934
2018
  const out2 = await mergeJsonServer(io, path2, "mcpServers", { type: "http", url });
1935
2019
  io.log(`\u25CF ${name}: ${out2} in ${path2}`);
1936
2020
  io.log(" To sign in: open /mcp in Claude Code, select vibiz, choose Authenticate.");
@@ -1948,7 +2032,7 @@ async function mcpAdd(io, api, rawClients) {
1948
2032
  continue;
1949
2033
  }
1950
2034
  if (client === "codex") {
1951
- const path2 = join5(io.env.CODEX_HOME || join5(home, ".codex"), "config.toml");
2035
+ const path2 = join6(io.env.CODEX_HOME || join6(home, ".codex"), "config.toml");
1952
2036
  const out2 = await mergeCodexToml(io, path2, url);
1953
2037
  io.log(`\u25CF ${name}: ${out2} in ${path2}`);
1954
2038
  io.log(" To sign in: codex mcp login vibiz");
@@ -1986,7 +2070,7 @@ function detectAgent(env) {
1986
2070
  return "claude";
1987
2071
  }
1988
2072
  function skillsDir(io, agent, global) {
1989
- return join5(global ? homeOf(io) : io.local().cwd(), AGENT_DIR[agent]);
2073
+ return join6(global ? homeOf(io) : io.local().cwd(), AGENT_DIR[agent]);
1990
2074
  }
1991
2075
  async function skillIndex(io, api) {
1992
2076
  const f = io.fetch ?? fetch;
@@ -2002,7 +2086,7 @@ function parseAgent(raw, env) {
2002
2086
  return a;
2003
2087
  }
2004
2088
  async function installed(io, dir, name) {
2005
- return await readText2(io, join5(dir, name, "SKILL.md")) !== null;
2089
+ return await readText2(io, join6(dir, name, "SKILL.md")) !== null;
2006
2090
  }
2007
2091
  async function skillsList(io, api, opts) {
2008
2092
  const agent = parseAgent(opts.agent, io.env);
@@ -2045,8 +2129,8 @@ async function skillsAdd(io, api, names, opts) {
2045
2129
  }
2046
2130
  const res = await f(url);
2047
2131
  if (!res.ok) throw new Error(`Could not download ${url} (${res.status})`);
2048
- const target = join5(dir, rel);
2049
- await local.mkdir(dirname4(target), { recursive: true });
2132
+ const target = join6(dir, rel);
2133
+ await local.mkdir(dirname5(target), { recursive: true });
2050
2134
  await local.writeFile(target, await res.text());
2051
2135
  }
2052
2136
  }
@@ -2419,8 +2503,8 @@ function printAction(io, a) {
2419
2503
  }
2420
2504
 
2421
2505
  // packages/cli/src/commands.ts
2422
- var CONFIG_DIR = join6(homedir2(), ".vibiz");
2423
- var CONFIG_FILE = join6(CONFIG_DIR, "config.json");
2506
+ var CONFIG_DIR = join7(homedir2(), ".vibiz");
2507
+ var CONFIG_FILE = join7(CONFIG_DIR, "config.json");
2424
2508
  var PROJECT_FILE = "vibiz.json";
2425
2509
  var HELP = `vibiz \u2014 website, database and sign-in for a new business, in one command
2426
2510
 
@@ -2444,6 +2528,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
2444
2528
  vibiz status this project, its resources and deployments
2445
2529
  vibiz deploy [dir] [--preview] [--project <id>]
2446
2530
  upload and deploy live (or a preview with --preview)
2531
+ vibiz code [ls|cat <path>] [--deployment <id>]
2532
+ the project's code: the live deployment's files (ls),
2533
+ or one file's content (cat)
2534
+ vibiz pull [dir] [--deployment <id>] [--force]
2535
+ write the live deployment's files into a folder to edit
2536
+ them (refuses a non-empty folder unless --force)
2447
2537
  vibiz promote <deployment-id> make a deployment the live site
2448
2538
  vibiz rollback go back to the previous production deployment
2449
2539
  vibiz dev [--write <file>] [--reset] the development env (own database branch with your
@@ -2452,6 +2542,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
2452
2542
  vibiz dev -- <command\u2026> run a command with the development env, no file
2453
2543
  vibiz env [--write <file>] the PRODUCTION env (full-access keys only), to paste into
2454
2544
  a host outside Vibiz; agents use \`vibiz dev\`
2545
+ vibiz env set <NAME> [--dev] the app's own variable (a third-party key\u2026): from $NAME
2546
+ or a hidden prompt; write-only, never printed. The app
2547
+ reads it from its env; connected hosts get it too
2548
+ vibiz env vars the app's own variables: names only, never values
2549
+ vibiz env unset <NAME> [--dev] remove one
2550
+ vibiz env link <NAME> [--dev] a console link where a person pastes it instead
2455
2551
  vibiz export [--code] [--db] [--csv] [--env production|development] [-o file.zip]
2456
2552
  take the app elsewhere, or keep a backup: its source
2457
2553
  with a guide (VIBIZ-EXPORT.md, .env.example), the
@@ -2472,7 +2568,16 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
2472
2568
  buy it from your credits for this project (full-access keys,
2473
2569
  or Limited keys up to the owner's per-domain limit;
2474
2570
  registered to the saved domain owner details)
2475
- vibiz domains owned [--json] domains this account bought: expiry, auto-renew
2571
+ vibiz domains owned [--json] domains this account bought: expiry, auto-renew, the
2572
+ projects and names using each
2573
+ vibiz domains use <domain> [--project <id|slug>] [--name app.example.com] [--elsewhere]
2574
+ [--points-to <host or IP>] put a bought domain (or any name under it) on any of
2575
+ your projects: no DNS to set, HTTPS by itself; an app
2576
+ elsewhere: --points-to and we write the record
2577
+ vibiz domains move <domain> --to <id|slug> [--name app] [--from <id|slug>]
2578
+ move a bought name to another project (full-access keys)
2579
+ vibiz domains point <name> <host or IP|none>
2580
+ a bought name used by an app elsewhere: we point it there
2476
2581
  vibiz domains renew <domain> [--years 1] renew now from credits (full-access keys)
2477
2582
  vibiz domains auto-renew <domain> on|off renew from credits 30 days before expiry (default on)
2478
2583
  vibiz domains transfer-code <domain> the code to move it to another registrar (full-access keys)
@@ -2564,7 +2669,9 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
2564
2669
  variable (VERCEL_TOKEN, FLY_API_TOKEN\u2026) or a hidden
2565
2670
  prompt. Any other host: vibiz connect
2566
2671
  vibiz hosts sync | rm <id> [--keep-values] push again now, or disconnect
2567
- vibiz app-key [rotate [--dev] [--grace <s>]] the app's one key (VIBIZ_APP_KEY); never printed
2672
+ vibiz app-key [rotate [--dev] [--grace <s>]] the app's one key (VIBIZ_APP_KEY): it gives the
2673
+ app everything; prints the link to copy it (the
2674
+ key itself is never printed)
2568
2675
  vibiz add <hosting|database|auth|email|analytics|replay|ai> add a resource to this project
2569
2676
  vibiz analytics [--period 24h|7d|30d] [--json] visitors, pages, sources, events
2570
2677
  vibiz analytics snippet the tag for a site hosted anywhere, and the domains it counts
@@ -2769,7 +2876,10 @@ var BUY_DOMAIN_COMMANDS = /* @__PURE__ */ new Set([
2769
2876
  "renew",
2770
2877
  "auto-renew",
2771
2878
  "transfer-code",
2772
- "owner"
2879
+ "owner",
2880
+ "use",
2881
+ "move",
2882
+ "point"
2773
2883
  ]);
2774
2884
  var dollarsOf = (cents2) => cents2 === null || cents2 === void 0 ? "\u2014" : `$${(cents2 / 100).toFixed(2)}`;
2775
2885
  function printOwned(io, d) {
@@ -2777,9 +2887,59 @@ function printOwned(io, d) {
2777
2887
  io.log(
2778
2888
  `${d.domain} ${d.status} ${expires} auto-renew ${d.auto_renew ? "on" : "off"} (${dollarsOf(d.renewal_price_cents)}/year)`
2779
2889
  );
2780
- io.log(` registered to ${d.registered_to}${d.project_id ? ` \xB7 serves ${d.project_id}` : ""}`);
2890
+ io.log(` registered to ${d.registered_to}`);
2891
+ if (d.status === "active" || d.status === "expired") {
2892
+ if (!d.used_on?.length) {
2893
+ io.log(` not used on a project yet: vibiz domains use ${d.domain} --project <id|slug>`);
2894
+ }
2895
+ for (const u of d.used_on ?? []) {
2896
+ io.log(
2897
+ ` on ${u.project_name} (${u.project_slug}): ${u.name}${u.www_redirect ? ` (+ ${u.www_redirect})` : ""}${u.hosting === "elsewhere" ? " runs elsewhere" : ""}`
2898
+ );
2899
+ }
2900
+ }
2781
2901
  if (d.next_step) io.log(` ${d.next_step}`);
2782
2902
  }
2903
+ function printUse(io, u) {
2904
+ const p = u.project_domain;
2905
+ const project = u.owned.used_on.find((x) => x.name === u.name)?.project_name ?? u.project_id;
2906
+ io.log(
2907
+ u.moved_from ? `${u.name} moved from ${u.moved_from.project_name} to ${project}.` : `${u.name} is on ${project}.`
2908
+ );
2909
+ if (p) {
2910
+ io.log(
2911
+ ` ${p.status}${p.https ? ", HTTPS" : ""}${p.trusted_for_sign_in ? ", trusted for sign-in" : ""}${p.www_redirect ? ` \xB7 ${p.www_redirect} redirects here` : ""}${p.points_to ? ` \xB7 points to ${p.points_to}` : ""}`
2912
+ );
2913
+ }
2914
+ io.log(` ${u.next_step}`);
2915
+ }
2916
+ async function zoneFor(vibiz2, name) {
2917
+ const host = name.trim().toLowerCase().replace(/\.$/, "");
2918
+ const owned = (await vibiz2.domains.list()).data.filter((d) => d.status !== "failed");
2919
+ const zone = owned.map((d) => d.domain).filter((z) => host === z || host.endsWith(`.${z}`)).sort((a, b) => b.length - a.length)[0];
2920
+ if (!zone) {
2921
+ throw new Error(
2922
+ `${host} is not under a domain this account bought (vibiz domains owned lists them). A domain bought elsewhere connects with vibiz domains add ${host}.`
2923
+ );
2924
+ }
2925
+ return zone;
2926
+ }
2927
+ async function linkedProject(io) {
2928
+ let local;
2929
+ try {
2930
+ local = io.local();
2931
+ } catch {
2932
+ return void 0;
2933
+ }
2934
+ for (let dir = local.cwd(); ; dir = dirname6(dir)) {
2935
+ try {
2936
+ const linked = JSON.parse(await local.readFile(join7(dir, PROJECT_FILE), "utf8"));
2937
+ if (linked.project_id) return linked.project_id;
2938
+ } catch {
2939
+ }
2940
+ if (dirname6(dir) === dir) return void 0;
2941
+ }
2942
+ }
2783
2943
  async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
2784
2944
  const d = vibiz2.domains;
2785
2945
  const json = (v) => io.log(JSON.stringify(v, null, 2));
@@ -2796,7 +2956,7 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
2796
2956
  };
2797
2957
  if (sub === "search") {
2798
2958
  if (!arg) throw new Error("usage: vibiz domains search <name>");
2799
- const project = await io.project().catch(() => void 0);
2959
+ const project = await linkedProject(io);
2800
2960
  const found = await d.search(positionalsAfter(arg, third), { projectId: project });
2801
2961
  if (values.json) return json(found);
2802
2962
  for (const x of found.data) {
@@ -2809,8 +2969,8 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
2809
2969
  }
2810
2970
  if (sub === "buy") {
2811
2971
  const domain = need();
2812
- const project = await io.project();
2813
- const q = await d.quote(domain, { years, projectId: project });
2972
+ const project = values.project ?? await linkedProject(io);
2973
+ const q = await d.quote(domain, { years, ...project ? { projectId: project } : {} });
2814
2974
  if (!q.available || q.price_cents === void 0) {
2815
2975
  if (values.json) return json(q);
2816
2976
  throw new Error(`${q.domain} is taken. Try: vibiz domains search ${q.domain.split(".")[0]}`);
@@ -2837,15 +2997,21 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
2837
2997
  q.agent_limit_cents === null ? "This key can't spend on domains yet. Confirm it in the console, or let agents and the CLI buy domains in Billing \u25B8 Domains bought by agents." : `That's over the ${dollarsOf(q.agent_limit_cents)} the owner lets agents spend per domain (Billing). Confirm it in the console:`
2838
2998
  );
2839
2999
  io.log(` ${q.buy_url}`);
3000
+ if (q.key_url) {
3001
+ io.log(
3002
+ `Or give this key full access, so it can buy from now on: ${q.key_url} (or run vibiz login again and choose Full access).`
3003
+ );
3004
+ }
2840
3005
  if (values.open && q.buy_url) io.openUrl(q.buy_url);
2841
3006
  return;
2842
3007
  }
2843
3008
  await sure(`Buy ${q.domain} for ${dollarsOf(q.price_cents)}?`);
2844
- const bought = await vibiz2.projects.domains.buy(project, {
3009
+ const bought = await d.buy({
2845
3010
  domain: q.domain,
2846
3011
  years: q.years,
2847
3012
  expected_price_cents: q.price_cents,
2848
- ...q.premium ? { confirm_premium: true } : {}
3013
+ ...q.premium ? { confirm_premium: true } : {},
3014
+ project_id: project ?? null
2849
3015
  });
2850
3016
  if (values.json) return json(bought);
2851
3017
  printOwned(io, bought);
@@ -2853,6 +3019,45 @@ async function buyDomainsCommand(io, vibiz2, values, sub, arg, third) {
2853
3019
  io.log(` Live at https://${bought.domain} (HTTPS turns on by itself).`);
2854
3020
  return;
2855
3021
  }
3022
+ if (sub === "use" || sub === "move" || sub === "point") {
3023
+ const given = need();
3024
+ const zone = await zoneFor(vibiz2, given);
3025
+ const name = values.name ?? (given.toLowerCase() === zone ? void 0 : given);
3026
+ const target = values["points-to"];
3027
+ const rest = {
3028
+ ...name ? { name } : {},
3029
+ ...values.elsewhere ? { hosting: "elsewhere" } : {},
3030
+ ...target !== void 0 ? { points_to: target === "" || target === "none" ? null : target } : {}
3031
+ };
3032
+ let out2;
3033
+ if (sub === "use") {
3034
+ out2 = await d.use(zone, values.project ?? await io.project(), rest);
3035
+ } else if (sub === "move") {
3036
+ const to = values.to ?? values.project;
3037
+ if (!to) {
3038
+ throw new Error(
3039
+ "usage: vibiz domains move <domain> --to <project id|slug> [--name app] [--from <project>]"
3040
+ );
3041
+ }
3042
+ out2 = await d.move(zone, to, {
3043
+ ...rest,
3044
+ ...values.from ? { from_project_id: values.from } : {}
3045
+ });
3046
+ } else {
3047
+ const where = third ?? target;
3048
+ if (where === void 0) {
3049
+ throw new Error("usage: vibiz domains point <name> <host or IP|none>");
3050
+ }
3051
+ out2 = await d.point(zone, {
3052
+ ...name ? { name } : {},
3053
+ points_to: where === "" || where === "none" ? null : where,
3054
+ ...values.project ? { project_id: values.project } : {}
3055
+ });
3056
+ }
3057
+ if (values.json) return json(out2);
3058
+ printUse(io, out2);
3059
+ return;
3060
+ }
2856
3061
  if (sub === "owned") {
2857
3062
  const list2 = await d.list();
2858
3063
  if (values.json) return json(list2);
@@ -3032,6 +3237,26 @@ function parseResources(raw) {
3032
3237
  }
3033
3238
  return { resources, services };
3034
3239
  }
3240
+ async function oneKeyLines(vibiz2, id, host) {
3241
+ const links = await vibiz2.projects.envLinks(id);
3242
+ const name = host ? hostName(host) : void 0;
3243
+ const lines = links.app_key_console_url ? [oneKeyMessage(links.app_key_console_url, name)] : [];
3244
+ if (!host || host.push) lines.push(connectHostMessage(host?.kind, name));
3245
+ return lines.join("\n");
3246
+ }
3247
+ function commandLine(argv2) {
3248
+ return [
3249
+ "vibiz",
3250
+ ...argv2.map((a) => /^[\w@%+=:,./-]+$/.test(a) ? a : `'${a.replace(/'/g, `'\\''`)}'`)
3251
+ ].join(" ");
3252
+ }
3253
+ function secretNeeded(io, what, envName, argv2) {
3254
+ const why = io.interactive === false ? "there is no terminal here to type it into (an agent or a script is running this)" : "nothing was typed at the prompt";
3255
+ return new Error(
3256
+ `${what} is needed, and ${why}. It is a secret, so a person types it in their own terminal and it never passes through an agent or a chat. Hand them this command to run there (it asks for the value, hidden): ${commandLine(argv2)}${envName ? `
3257
+ Or they set ${envName} in that terminal first.` : ""}`
3258
+ );
3259
+ }
3035
3260
  function printProject(io, p) {
3036
3261
  io.log(`${p.name} (${p.id})`);
3037
3262
  if (p.url) io.log(` ${p.url}`);
@@ -3376,6 +3601,7 @@ async function runCli(argv2, io) {
3376
3601
  kind: { type: "string" },
3377
3602
  "no-browser": { type: "boolean", default: false },
3378
3603
  elsewhere: { type: "boolean", default: false },
3604
+ "points-to": { type: "string" },
3379
3605
  "replace-mx": { type: "boolean", default: false },
3380
3606
  cc: { type: "string" },
3381
3607
  bcc: { type: "string" },
@@ -3540,15 +3766,25 @@ async function runCli(argv2, io) {
3540
3766
  `Added ${values.domain}${out.domain?.hosting === "elsewhere" ? " (runs on your own host)" : ""}.`
3541
3767
  );
3542
3768
  }
3543
- if (values["no-wait"]) return;
3769
+ const elsewhere = async () => {
3770
+ if (resources === void 0 || resources.includes("hosting")) return;
3771
+ io.log(`
3772
+ ${await oneKeyLines(vibiz2, project.id)}`);
3773
+ };
3774
+ if (values["no-wait"]) return elsewhere();
3544
3775
  const ready = await vibiz2.projects.waitUntilReady(project.id);
3545
3776
  printProject(io, ready);
3777
+ if (!template)
3778
+ io.log(
3779
+ ` In the app: npm install --save-exact @vibiz/app@${APP_SDK_VERSION}, then await vibiz.loadEnv() where the server starts`
3780
+ );
3546
3781
  if (!template && ready.resources.some((r) => r.type === "analytics"))
3547
3782
  io.log(" Analytics tag for your site: vibiz analytics snippet");
3548
3783
  if (ready.resources.some((r) => r.type === "hosting"))
3549
3784
  io.log(
3550
3785
  " Design tip: vibiz design <a site you like> --tailwind writes a brief to build the UI from"
3551
3786
  );
3787
+ await elsewhere();
3552
3788
  return;
3553
3789
  }
3554
3790
  case "status": {
@@ -3570,7 +3806,7 @@ async function runCli(argv2, io) {
3570
3806
  const local = io.local();
3571
3807
  const vibiz2 = await io.client();
3572
3808
  const id = values.project ?? await io.project();
3573
- const dir = resolve(local.cwd(), positionals[0] ?? ".");
3809
+ const dir = resolve2(local.cwd(), positionals[0] ?? ".");
3574
3810
  const { deployment, uploaded, total } = await deployDirectory(vibiz2, id, dir, {
3575
3811
  target: values.preview ? "preview" : "production",
3576
3812
  onProgress: (m) => io.log(m)
@@ -3588,6 +3824,17 @@ async function runCli(argv2, io) {
3588
3824
  if (done.target === "preview") io.log(` Make it live: vibiz promote ${done.id}`);
3589
3825
  return;
3590
3826
  }
3827
+ case "code":
3828
+ return codeCommand(io, positionals, {
3829
+ json: values.json,
3830
+ ...values.deployment ? { deployment: values.deployment } : {}
3831
+ });
3832
+ case "pull":
3833
+ return pullCommand(io, positionals, {
3834
+ json: values.json,
3835
+ force: values.force,
3836
+ ...values.deployment ? { deployment: values.deployment } : {}
3837
+ });
3591
3838
  case "promote": {
3592
3839
  const depId = positionals[0];
3593
3840
  if (!depId) throw new Error("usage: vibiz promote <deployment-id>");
@@ -3656,7 +3903,7 @@ async function runCli(argv2, io) {
3656
3903
  if (!values["client-id"]) throw new Error("--own needs --client-id <id>");
3657
3904
  const envName = `${provider.toUpperCase()}_CLIENT_SECRET`;
3658
3905
  const secret = io.env[envName] || await io.promptHidden(`${provider} client secret: `);
3659
- if (!secret) throw new Error(`The client secret is needed (${envName}, or type it).`);
3906
+ if (!secret) throw secretNeeded(io, `The ${provider} client secret`, envName, argv2);
3660
3907
  settings = await vibiz2.projects.auth.setProvider(
3661
3908
  id,
3662
3909
  provider,
@@ -4243,9 +4490,9 @@ ${link.url}`
4243
4490
  return;
4244
4491
  }
4245
4492
  if (sub === "add") {
4246
- let manifest;
4493
+ let manifest2;
4247
4494
  if (values.file) {
4248
- manifest = JSON.parse(await io.local().readFile(values.file, "utf8"));
4495
+ manifest2 = JSON.parse(await io.local().readFile(values.file, "utf8"));
4249
4496
  } else {
4250
4497
  const [baseUrl, ...ops] = more;
4251
4498
  if (!name || !baseUrl) {
@@ -4256,9 +4503,9 @@ ${link.url}`
4256
4503
  const envName = values.var ?? `${name.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
4257
4504
  const [kind = "none", where = ""] = (values.auth ?? "none").split(":");
4258
4505
  const auth = kind === "bearer" ? { type: "bearer", env: envName } : kind === "header" ? { type: "header", header: where || "X-Api-Key", env: envName } : kind === "query" ? { type: "query", param: where || "api_key", env: envName } : { type: "none" };
4259
- manifest = { name, base_url: baseUrl, auth, operations: ops };
4506
+ manifest2 = { name, base_url: baseUrl, auth, operations: ops };
4260
4507
  }
4261
- const made = await c.create(id, manifest);
4508
+ const made = await c.create(id, manifest2);
4262
4509
  out(made, () => {
4263
4510
  io.log(`${dot("ready")} Added ${made.name} (${made.base_url})`);
4264
4511
  printOps(made.operations);
@@ -4312,7 +4559,7 @@ ${link.url}`
4312
4559
  const [key] = more;
4313
4560
  if (!key) throw new Error("usage: vibiz connectors secret <name> <VAR> [--dev]");
4314
4561
  const value = io.env[key] ?? await io.promptHidden(`${key} (hidden): `);
4315
- if (!value) throw new Error(`No value: set $${key} or type it at the prompt.`);
4562
+ if (!value) throw secretNeeded(io, `A value for ${key}`, key, argv2);
4316
4563
  const k = await c.setSecrets(id, name, { [key]: value }, env);
4317
4564
  out(
4318
4565
  k.ready,
@@ -4411,7 +4658,7 @@ ${link.url}`
4411
4658
  }
4412
4659
  if (sub)
4413
4660
  throw new Error(
4414
- "usage: vibiz domains [add | verify | remove | search | buy | owned | renew | auto-renew | transfer-code | owner]"
4661
+ "usage: vibiz domains [add | verify | remove | search | buy | owned | use | move | point | renew | auto-renew | transfer-code | owner]"
4415
4662
  );
4416
4663
  print(await d.list(id));
4417
4664
  return;
@@ -4447,11 +4694,8 @@ ${link.url}`
4447
4694
  }
4448
4695
  const envName = TOKEN_ENV[host.kind];
4449
4696
  const token = envName && io.env[envName] || await io.promptHidden(`${host.label} token (${host.token_help}): `);
4450
- if (!token) {
4451
- throw new Error(
4452
- `A ${host.label} token is needed${envName ? ` (${envName}, or type it)` : ""}.`
4453
- );
4454
- }
4697
+ if (!token)
4698
+ throw secretNeeded(io, `A ${host.label} token (${host.token_help})`, envName, argv2);
4455
4699
  const t = await vibiz2.projects.hosts.add(id, {
4456
4700
  kind: host.kind,
4457
4701
  token,
@@ -4505,6 +4749,8 @@ Hosting and connected hosts get the new value by themselves.`
4505
4749
  `${k.environment.padEnd(12)} ${k.prefix ? `${k.prefix}\u2026` : "(issued on first use)"}${k.last_used_at ? ` last used ${k.last_used_at}` : ""}`
4506
4750
  );
4507
4751
  }
4752
+ io.log(`
4753
+ ${await oneKeyLines(vibiz2, id)}`);
4508
4754
  return;
4509
4755
  }
4510
4756
  // A site's design as a brief and exports (docs: design).
@@ -4580,11 +4826,20 @@ Hosting and connected hosts get the new value by themselves.`
4580
4826
  );
4581
4827
  }
4582
4828
  case "connect": {
4583
- const found = await detectHosts(io.local().cwd());
4829
+ const local = io.local();
4830
+ const found = await detectHosts(local.cwd());
4831
+ const linked = await local.readFile(PROJECT_FILE, "utf8").then((t) => JSON.parse(String(t)).project_id).catch(() => void 0);
4832
+ const oneKey = async (host) => {
4833
+ if (!linked) {
4834
+ return ` One key, VIBIZ_APP_KEY, gives the app everything on Vibiz. This folder has no ${PROJECT_FILE} yet: run vibiz init <name> here, then vibiz connect again for the link to copy it.`;
4835
+ }
4836
+ return oneKeyLines(await io.client(), linked, host);
4837
+ };
4584
4838
  io.log("Recommended: Vibiz hosting. Every key is already there and stays in sync:");
4585
4839
  io.log(" vibiz deploy\n");
4586
4840
  if (!found.length) {
4587
4841
  io.log("No other host found in this folder. Hosting somewhere else?");
4842
+ io.log(await oneKey());
4588
4843
  io.log(ONE_KEY_PATHS);
4589
4844
  return;
4590
4845
  }
@@ -4592,12 +4847,12 @@ Hosting and connected hosts get the new value by themselves.`
4592
4847
  io.log(`Found ${h.label} (${h.file}).`);
4593
4848
  if (h.push) {
4594
4849
  io.log(` Vibiz can write the env into it and keep it in sync (an owner, once):`);
4595
- io.log(` vibiz hosts add ${h.kind} <its project or service>
4596
- `);
4597
- } else {
4598
- io.log(`${ONE_KEY_PATHS}
4599
- `);
4850
+ io.log(` vibiz hosts add ${h.kind} <its project or service>`);
4851
+ io.log(` Or with one key instead:`);
4600
4852
  }
4853
+ io.log(await oneKey({ ...h, push: false }));
4854
+ io.log(`${ONE_KEY_PATHS}
4855
+ `);
4601
4856
  }
4602
4857
  io.log(
4603
4858
  "Running it elsewhere? Add its domain too, so sign-in accepts it: vibiz domains add <domain> --elsewhere"
@@ -4627,6 +4882,42 @@ Hosting and connected hosts get the new value by themselves.`
4627
4882
  } else io.out(text);
4628
4883
  return;
4629
4884
  }
4885
+ const sub = positionals[0];
4886
+ if (sub === "set" || sub === "unset" || sub === "vars" || sub === "link") {
4887
+ const vibiz2 = await io.client();
4888
+ const id = await io.project();
4889
+ const environment = values.dev ? "development" : "production";
4890
+ if (sub === "vars") {
4891
+ const vars = await vibiz2.projects.vars.list(id);
4892
+ if (values.json) return io.log(JSON.stringify(vars, null, 2));
4893
+ if (!vars.length) return io.log("No variables of your own yet: vibiz env set <NAME>");
4894
+ for (const v2 of vars)
4895
+ io.log(` ${v2.name.padEnd(32)} ${v2.environment.padEnd(12)} set ${v2.updated_at}`);
4896
+ return;
4897
+ }
4898
+ const name = positionals[1];
4899
+ if (!name) throw new Error(`usage: vibiz env ${sub} <NAME> [--dev]`);
4900
+ if (sub === "unset") {
4901
+ await vibiz2.projects.vars.remove(id, name, environment);
4902
+ return io.log(`${dot("ready")} ${name} removed from ${environment}.`);
4903
+ }
4904
+ if (sub === "link") {
4905
+ const link = await vibiz2.projects.secretLink(id, { name, environment });
4906
+ if (values.json) return io.log(JSON.stringify(link, null, 2));
4907
+ return io.log(
4908
+ `Paste ${name} here: ${link.console_url} . It goes straight to Vibiz, never through a chat.`
4909
+ );
4910
+ }
4911
+ const value = io.env[name] ?? await io.promptHidden(`${name} (hidden): `);
4912
+ if (!value) throw secretNeeded(io, `A value for ${name}`, name, argv2);
4913
+ const v = await vibiz2.projects.vars.set(id, name, value, environment);
4914
+ if (values.json) return io.log(JSON.stringify(v, null, 2));
4915
+ io.log(`${dot("ready")} ${name} set in ${environment}. It is never shown again.`);
4916
+ io.log(
4917
+ ` The app reads it as process.env.${name} (after await vibiz.loadEnv()); a running app gets it on its next start.`
4918
+ );
4919
+ return;
4920
+ }
4630
4921
  const env = await (await io.client()).projects.env(await io.project());
4631
4922
  if (values.write) {
4632
4923
  const existing = await io.local().readFile(values.write, "utf8").catch(() => "");
@@ -5125,7 +5416,7 @@ Store the key now: it is not shown again.`
5125
5416
  return;
5126
5417
  }
5127
5418
  case "docs": {
5128
- const { DOC_TOPICS, DOCS } = await import("./src-IAT2AUWC.js");
5419
+ const { DOC_TOPICS, DOCS } = await import("./src-QNWJABRQ.js");
5129
5420
  const topic = positionals[0];
5130
5421
  if (!topic || !DOC_TOPICS.includes(topic)) {
5131
5422
  for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
@@ -5150,7 +5441,7 @@ ${DOCS[topic].body}`);
5150
5441
  if (positionals[0])
5151
5442
  throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
5152
5443
  io.local();
5153
- const { serveStdio } = await import("./src-IAT2AUWC.js");
5444
+ const { serveStdio } = await import("./src-QNWJABRQ.js");
5154
5445
  await serveStdio({ version: cliVersion() });
5155
5446
  return;
5156
5447
  }
@@ -5250,7 +5541,13 @@ async function aiKeysCommand(io, args, values) {
5250
5541
  return;
5251
5542
  }
5252
5543
  const key = io.env.GEMINI_API_KEY || io.env.GOOGLE_API_KEY || await io.promptHidden("API key (hidden): ");
5253
- if (!key) throw new Error("The key is needed: GEMINI_API_KEY, or type it.");
5544
+ if (!key)
5545
+ throw secretNeeded(io, "The Gemini API key", "GEMINI_API_KEY", [
5546
+ "ai",
5547
+ "keys",
5548
+ ...args,
5549
+ ...values.project ? ["--project", values.project] : []
5550
+ ]);
5254
5551
  show(
5255
5552
  await vibiz2.aiKeys.set(
5256
5553
  provider,
@@ -5278,7 +5575,7 @@ async function aiKeysCommand(io, args, values) {
5278
5575
 
5279
5576
  // packages/cli/src/update-check.ts
5280
5577
  import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
5281
- import { join as join7 } from "node:path";
5578
+ import { join as join8 } from "node:path";
5282
5579
  var DAY_MS = 24 * 60 * 60 * 1e3;
5283
5580
  var LATEST_URL = "https://registry.npmjs.org/@vibiz/cli/latest";
5284
5581
  function isNewer(latest, current) {
@@ -5300,7 +5597,7 @@ function updateNotice(latest, current) {
5300
5597
  }
5301
5598
  async function latestVersion(configDir, env, fetchImpl = fetch, now = Date.now()) {
5302
5599
  if (env.VIBIZ_NO_UPDATE_CHECK || env.CI) return null;
5303
- const file = join7(configDir, "update-check.json");
5600
+ const file = join8(configDir, "update-check.json");
5304
5601
  let cache = null;
5305
5602
  try {
5306
5603
  cache = JSON.parse(await readFile2(file, "utf8"));
@@ -5398,10 +5695,10 @@ var terminal = {
5398
5695
  });
5399
5696
  },
5400
5697
  project: async () => {
5401
- for (let dir = process.cwd(); ; dir = dirname5(dir)) {
5402
- const linked = await readJson2(join8(dir, PROJECT_FILE));
5698
+ for (let dir = process.cwd(); ; dir = dirname7(dir)) {
5699
+ const linked = await readJson2(join9(dir, PROJECT_FILE));
5403
5700
  if (linked?.project_id) return linked.project_id;
5404
- if (dirname5(dir) === dir) break;
5701
+ if (dirname7(dir) === dir) break;
5405
5702
  }
5406
5703
  const list2 = await new Vibiz(await login()).projects.list();
5407
5704
  const wanted = process.env.VIBIZ_PROJECT?.trim().toLowerCase();
@@ -5430,6 +5727,7 @@ ${lines.join("\n")}` : `No ${PROJECT_FILE} here and no projects yet. Run: vibiz
5430
5727
  );
5431
5728
  },
5432
5729
  promptHidden,
5730
+ interactive: Boolean(process.stdin.isTTY),
5433
5731
  promptLine,
5434
5732
  openUrl,
5435
5733
  local: () => ({