gipity 1.1.21 → 1.1.23

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/index.js CHANGED
@@ -6965,7 +6965,7 @@ Templates:
6965
6965
  - \`karaoke-captions\` - Forced-alignment app - karaoke captions, subtitle timing, language learning, dubbing alignment
6966
6966
  - \`paid-app\` - App that charges users money - SaaS subscription, paid membership, digital product store, "Pro" upgrade, paywalled content (Stripe one-time + subscriptions)
6967
6967
  - \`notify-demo\` - App that sends push notifications / alerts / reminders to users' phones or desktops - web push, PWA notifications, "notify me when..." features
6968
- When unsure, default to \`web-simple\`. After adding the template, edit the generated files, then \`gipity deploy dev\`.
6968
+ When unsure, default to \`web-simple\`. After adding the template, edit the generated files, then \`gipity deploy\`.
6969
6969
  Only skip this on a build request if the user explicitly says not to.
6970
6970
 
6971
6971
  Hidden types (do NOT suggest unsolicited - use only when the user explicitly asks for that domain):
@@ -7027,15 +7027,17 @@ The other exception is app-level libraries the user imports into their own \`src
7027
7027
 
7028
7028
  ## Build loop
7029
7029
 
7030
- Prefer a live Gipity URL over an ephemeral artifact. When you'd otherwise reach for a Claude Code Artifact (or any host's built-in page preview) to show the user something, build it as a Gipity app and \`gipity deploy dev\` instead - the result is a real, shareable URL on their own project, not a throwaway.
7030
+ Prefer a live Gipity URL over an ephemeral artifact. When you'd otherwise reach for a Claude Code Artifact (or any host's built-in page preview) to show the user something, build it as a Gipity app and \`gipity deploy\` it instead - the result is a real, shareable URL on their own project, not a throwaway.
7031
7031
 
7032
7032
  The full "when to add a template" rule and the definition of done are spelled out in the two sections at the end of this document. In short: if the user wants something deployable (web app, game, API), \`gipity add <template>\` first (default \`web-simple\`); for a one-off task (analysis, PDFs, data work), use \`gipity sandbox run\` instead; to add a reusable building block to an existing app (e.g. multiplayer), \`gipity add <kit>\`.
7033
7033
 
7034
- Build loop: \`gipity add\` \u2192 edit files \u2192 \`gipity deploy dev --inspect\` \u2192 fix any errors \u2192 repeat until the definition of done is met. \`deploy --inspect\` deploys and then runs the page-inspect report on the live URL in one command; use a standalone \`gipity page inspect <url>\` only when re-checking without deploying.
7034
+ Build loop: \`gipity add\` \u2192 edit files \u2192 \`gipity deploy --inspect\` \u2192 fix any errors \u2192 repeat until the definition of done is met. \`deploy --inspect\` deploys and then runs the page-inspect report on the live URL in one command; use a standalone \`gipity page inspect <url>\` only when re-checking without deploying.
7035
+
7036
+ Where a deploy goes: a new app is just **prod**, and a bare \`gipity deploy\` deploys it (\`app.gipity.ai/<account>/<slug>/\`). An app can also have **environments** - isolated copies with their own database, functions and URL (\`gipity deploy dev\` creates \`dev\` at \`dev.gipity.ai/<account>/<slug>/\` on first use). Once an app has any, a bare \`gipity deploy\` is refused until you name one: iterate on \`dev\`, and deploy \`prod\` when the user wants it live. Every other command takes \`--env <name>\` to act on an environment (\`gipity db query "..." --env dev\`). If you're changing an app that real users already rely on and it has no environments yet, prefer \`gipity deploy dev\` over prod. Load the \`deploy\` skill for the details.
7035
7037
 
7036
7038
  \`add\` writes real files to disk - Read a scaffolded file with the Read tool before your first Write/Edit to it, or the call fails \`"File has not been read yet"\` (viewing it with \`cat\`/\`head\` in Bash does not count - the harness only tracks the Read tool). Don't rewrite from memory of the template.
7037
7039
 
7038
- Make your file changes and verify they landed, then run \`gipity deploy dev\` once. \`0 uploaded, N unchanged\` means nothing changed on disk - fix the files, don't re-run deploy or probe the environment.
7040
+ Make your file changes and verify they landed, then run \`gipity deploy\` once. \`0 uploaded, N unchanged\` means nothing changed on disk - fix the files, don't re-run deploy or probe the environment.
7039
7041
 
7040
7042
  Before telling the user the app is online, verify the source tree is consistent: no files named like \`* (conflict from *)*\`, and every package directory has its expected canonical entry file. If a conflict artifact exists, resolve it (keep one copy), re-deploy, and re-inspect before reporting done.
7041
7043
 
@@ -7047,11 +7049,11 @@ If you're pointed at a project that already exists on Gipity but has no local co
7047
7049
  mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <slug>
7048
7050
  \`\`\`
7049
7051
 
7050
- \`init\` matches the existing remote project by slug, links this directory to it, and syncs its files down (you'll see \`Found existing project ...\` and \`Synced N changes\`). There's no separate \`clone\`/\`pull\` - \`init\` against a matching slug *is* the pull. After it finishes, the files are in cwd; edit and \`gipity deploy dev\` as usual. (Already linked to a different project in this dir? Switch and pull instead: \`gipity project <slug>\` then \`gipity sync\`. List your projects with \`gipity project --json\`.)
7052
+ \`init\` matches the existing remote project by slug, links this directory to it, and syncs its files down (you'll see \`Found existing project ...\` and \`Synced N changes\`). There's no separate \`clone\`/\`pull\` - \`init\` against a matching slug *is* the pull. After it finishes, the files are in cwd; edit and \`gipity deploy\` as usual. (Already linked to a different project in this dir? Switch and pull instead: \`gipity project <slug>\` then \`gipity sync\`. List your projects with \`gipity project --json\`.)
7051
7053
 
7052
7054
  ## CLI quick reference
7053
7055
 
7054
- Key commands: \`gipity add <template|kit>\`, \`gipity brand set --emoji <e>|--color <hex>\` (regenerate the app's icons + social share card), \`gipity deploy dev\`, \`gipity sandbox run\`, \`gipity page inspect <url>\`, \`gipity page screenshot <url>\`, \`gipity db query "SQL"\`, \`gipity fn call <name>\`, \`gipity logs fn <name>\`, \`gipity secrets set <NAME> <value> [--account]\` (store an API key/token encrypted; read in functions via \`secrets.get('NAME')\` - never hardcode keys), \`gipity skill read <name>\`.
7056
+ Key commands: \`gipity add <template|kit>\`, \`gipity brand set --emoji <e>|--color <hex>\` (regenerate the app's icons + social share card), \`gipity deploy [prod|<env>]\`, \`gipity env\` (list/create/delete environments), \`gipity sandbox run\`, \`gipity page inspect <url>\`, \`gipity page screenshot <url>\`, \`gipity db query "SQL"\`, \`gipity fn call <name>\`, \`gipity logs fn <name>\`, \`gipity secrets set <NAME> <value> [--account]\` (store an API key/token encrypted; read in functions via \`secrets.get('NAME')\` - never hardcode keys), \`gipity skill read <name>\`.
7055
7057
  Rename for findability: \`gipity project rename <name>\` renames the current project's display name (the slug and deployed URLs never change); it's the label users scan in Monitor and \`gipity project\`, so keep it SHORT: 2-4 words, at most 40 characters, no trailing punctuation (e.g. "Stripe checkout", "Tetris game").
7056
7058
  Pull an existing remote project local (given its URL/slug): \`mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <slug>\` (adopts the matching project and syncs files down - this is the "clone").
7057
7059
  Move whole apps in/out: \`gipity save\` (export this project as a portable \`.gip\` bundle), \`gipity load <file.gip | github:owner/repo>\` (import as a NEW project; \`--inspect\` to preview), \`gipity github connect\` (1-2 click GitHub access for imports). Porting a Vercel/Replit/Lovable app? Load the \`app-import\` skill first.
@@ -7149,8 +7151,8 @@ Other key skills:
7149
7151
  - \`email\` - sending email from a deployed app with the email() service or a workflow notify step (no setup/keys), gipity email test/log, HTML formatting, images
7150
7152
  - \`sandbox-tools\` - cloud sandbox capabilities and pre-installed tools`;
7151
7153
  DEFINITION_OF_DONE = `## Definition of done (build tasks)
7152
- 1. \`gipity deploy dev\` succeeds and you have a live URL.
7153
- 2. \`gipity page inspect <url>\` returns no console errors and the page loads (HTTP 200, no blank screen). (\`gipity deploy dev --inspect\` covers 1 and 2 in one command.)
7154
+ 1. \`gipity deploy\` succeeds and you have a live URL.
7155
+ 2. \`gipity page inspect <url>\` returns no console errors and the page loads (HTTP 200, no blank screen). (\`gipity deploy --inspect\` covers 1 and 2 in one command.)
7154
7156
  3. For apps with functions: \`gipity test\` passes.
7155
7157
  4. Non-rendered files the task called for (\`llms.txt\`, \`AGENTS.md\`, \`SKILL.md\`, \`robots.txt\`, served JSON, etc.): \`page inspect\` only sees rendered HTML, so verify them with \`gipity page fetch <url> <files...>\`. It flags any that 404 or come back as the static-host shell (a missing file is served as \`index.html\` with a 200, so a bare status check would pass) and checks each \`content-type\`.
7156
7158
  5. You told the user the live URL.
@@ -7299,10 +7301,18 @@ var init_opencode_setup = __esm({
7299
7301
  import { resolve, join as join6, dirname as dirname3 } from "path";
7300
7302
  import { homedir as homedir4, tmpdir } from "os";
7301
7303
  import { existsSync as existsSync5, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readFileSync as readFileSync4, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
7302
- function isSyncIgnored(name) {
7304
+ function primerIgnorePatterns() {
7305
+ return [...new Set(Object.values(PRIMER_FILES))].map((p) => `/${p}`);
7306
+ }
7307
+ function anchorPrimerPatterns(patterns) {
7308
+ const primers = new Set(Object.values(PRIMER_FILES));
7309
+ return patterns.map((p) => primers.has(p) ? `/${p}` : p);
7310
+ }
7311
+ function isSyncIgnored(name, opts = {}) {
7303
7312
  if (name.startsWith(".")) return true;
7304
7313
  if (DEFAULT_SYNC_IGNORE.includes(name)) return true;
7305
7314
  if (DEFAULT_SYNC_IGNORE.includes(`${name}/`)) return true;
7315
+ if (!opts.nested && DEFAULT_SYNC_IGNORE.includes(`/${name}`)) return true;
7306
7316
  return false;
7307
7317
  }
7308
7318
  function isGipityManagedHookCommand(command) {
@@ -7729,6 +7739,21 @@ function writeSkillsFile(relPath, wrap) {
7729
7739
  const next = wrap && existing === null ? wrap(baseNext) : baseNext;
7730
7740
  if (next !== existing) writeFileSync3(path5, next);
7731
7741
  }
7742
+ function refreshExistingPrimers(projectRoot) {
7743
+ const written = [];
7744
+ for (const rel2 of new Set(Object.values(PRIMER_FILES))) {
7745
+ const path5 = resolve(projectRoot, rel2);
7746
+ if (!existsSync5(path5)) continue;
7747
+ const existing = readFileSync4(path5, "utf-8");
7748
+ if (!existing.includes(GIPITY_BLOCK_BEGIN) && !existing.includes("# Gipity Integration")) continue;
7749
+ const next = applySkillsBlock(existing, resolveApiBase());
7750
+ if (next !== existing) {
7751
+ writeFileSync3(path5, next);
7752
+ written.push(rel2);
7753
+ }
7754
+ }
7755
+ return written;
7756
+ }
7732
7757
  function setupClaudeMd() {
7733
7758
  writeSkillsFile(PRIMER_FILES.claude);
7734
7759
  }
@@ -7886,7 +7911,7 @@ var init_setup = __esm({
7886
7911
  ".bash_history",
7887
7912
  ".bash_logout",
7888
7913
  ...SCRATCH_IGNORE,
7889
- ...new Set(Object.values(PRIMER_FILES))
7914
+ ...primerIgnorePatterns()
7890
7915
  ];
7891
7916
  PERMISSIONS_SETTINGS = {
7892
7917
  permissions: {
@@ -7896,7 +7921,8 @@ var init_setup = __esm({
7896
7921
  "Bash(gipity push *)",
7897
7922
  "Bash(gipity test *)",
7898
7923
  "Bash(gipity add *)",
7899
- "Bash(gipity deploy dev *)",
7924
+ "Bash(gipity deploy *)",
7925
+ "Bash(gipity env list *)",
7900
7926
  "Bash(gipity domain *)",
7901
7927
  "Bash(gipity db query *)",
7902
7928
  "Bash(gipity db list *)",
@@ -9151,13 +9177,18 @@ async function getAuthHeader() {
9151
9177
  const headers = await getHeaders();
9152
9178
  return headers.Authorization;
9153
9179
  }
9180
+ function encodeBody(body) {
9181
+ if (body instanceof FormData) return body;
9182
+ return body ? JSON.stringify(body) : void 0;
9183
+ }
9154
9184
  async function request(method, path5, body, retrying = false, timeoutMs = REQUEST_TIMEOUT_MS) {
9155
9185
  const headers = await getHeaders();
9156
9186
  const url = `${baseUrl()}${path5}`;
9187
+ if (body instanceof FormData) delete headers["Content-Type"];
9157
9188
  const res = await fetchWithTimeout(url, {
9158
9189
  method,
9159
9190
  headers,
9160
- body: body ? JSON.stringify(body) : void 0
9191
+ body: encodeBody(body)
9161
9192
  }, timeoutMs, `${method} ${path5}`);
9162
9193
  if (await shouldRetryAfter401(res.status, retrying)) {
9163
9194
  return request(method, path5, body, true, timeoutMs);
@@ -9345,13 +9376,14 @@ async function getAccountSlug() {
9345
9376
  accountSlugCache = res.data.accountSlug;
9346
9377
  return accountSlugCache;
9347
9378
  }
9348
- async function publicRequest(method, path5, body, extraHeaders) {
9379
+ async function publicRequest(method, path5, body, extraHeaders, timeoutMs = REQUEST_TIMEOUT_MS) {
9349
9380
  const url = `${baseUrl()}${path5}`;
9381
+ const isForm = body instanceof FormData;
9350
9382
  const res = await fetchWithTimeout(url, {
9351
9383
  method,
9352
- headers: { ...clientHeaders(), "Content-Type": "application/json", ...extraHeaders },
9353
- body: body === void 0 ? void 0 : JSON.stringify(body)
9354
- }, REQUEST_TIMEOUT_MS, `${method} ${path5}`);
9384
+ headers: { ...clientHeaders(), ...isForm ? {} : { "Content-Type": "application/json" }, ...extraHeaders },
9385
+ body: isForm ? body : body === void 0 ? void 0 : JSON.stringify(body)
9386
+ }, timeoutMs, `${method} ${path5}`);
9355
9387
  if (!res.ok) {
9356
9388
  const json = await res.json().catch(() => null);
9357
9389
  throw apiErrorFrom(res, json, `${method} ${path5}`, false);
@@ -9402,11 +9434,14 @@ var init_api = __esm({
9402
9434
  var config_exports = {};
9403
9435
  __export(config_exports, {
9404
9436
  DEFAULT_API_BASE: () => DEFAULT_API_BASE,
9437
+ PROD_ENV: () => PROD_ENV,
9438
+ applyEnvOverride: () => applyEnvOverride,
9405
9439
  captureEnabled: () => captureEnabled,
9406
9440
  clearConfigCache: () => clearConfigCache,
9407
9441
  getApiBaseOverride: () => getApiBaseOverride,
9408
9442
  getConfig: () => getConfig,
9409
9443
  getConfigPath: () => getConfigPath,
9444
+ getEnvOption: () => getEnvOption,
9410
9445
  getProjectRoot: () => getProjectRoot,
9411
9446
  isAllowedApiHost: () => isAllowedApiHost,
9412
9447
  liveUrl: () => liveUrl,
@@ -9416,10 +9451,22 @@ __export(config_exports, {
9416
9451
  saveConfig: () => saveConfig2,
9417
9452
  saveConfigAt: () => saveConfigAt,
9418
9453
  setApiBaseOverride: () => setApiBaseOverride,
9454
+ setEnvOption: () => setEnvOption,
9419
9455
  shouldIgnore: () => shouldIgnore
9420
9456
  });
9421
9457
  import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6 } from "fs";
9422
9458
  import { dirname as dirname5, resolve as resolve3 } from "path";
9459
+ function setEnvOption(name) {
9460
+ envOption = name;
9461
+ }
9462
+ function getEnvOption() {
9463
+ return envOption;
9464
+ }
9465
+ function applyEnvOverride(env) {
9466
+ const base = getConfig();
9467
+ if (!base) throw new Error("--env needs a Gipity project directory");
9468
+ cached3 = { ...base, projectGuid: env.projectGuid, projectSlug: env.projectSlug, env: { name: env.name, appSlug: base.projectSlug } };
9469
+ }
9423
9470
  function setApiBaseOverride(url) {
9424
9471
  apiBaseOverride = url;
9425
9472
  }
@@ -9546,15 +9593,20 @@ async function resolveProjectContext(opts) {
9546
9593
  oneOff: true
9547
9594
  };
9548
9595
  }
9549
- function liveUrl(config, target = "dev") {
9550
- const host = target === "prod" ? "app.gipity.ai" : "dev.gipity.ai";
9551
- return `https://${host}/${config.accountSlug}/${config.projectSlug}/`;
9596
+ function liveUrl(config, env = config.env?.name ?? PROD_ENV) {
9597
+ const appSlug = config.env?.appSlug ?? config.projectSlug;
9598
+ if (env === PROD_ENV) return `https://app.gipity.ai/${config.accountSlug}/${appSlug}/`;
9599
+ const segment = env === "dev" ? appSlug : `${appSlug}--${env}`;
9600
+ return `https://dev.gipity.ai/${config.accountSlug}/${segment}/`;
9552
9601
  }
9553
9602
  function clearConfigCache() {
9554
9603
  cached3 = null;
9555
9604
  cachedPath = null;
9556
9605
  }
9557
9606
  function saveConfig2(data) {
9607
+ if (cached3?.env || data.env) {
9608
+ throw new Error("Can't change the linked project while --env is set: run it without --env.");
9609
+ }
9558
9610
  const path5 = getConfigPath();
9559
9611
  if (!path5) {
9560
9612
  throw new Error(
@@ -9589,12 +9641,13 @@ function shouldIgnore(filePath, ignorePatterns) {
9589
9641
  if (!rel2 || rel2 === ".") return false;
9590
9642
  return matcher.ignores(rel2);
9591
9643
  }
9592
- var import_ignore, CONFIG_FILE, DEFAULT_API_BASE, cached3, cachedPath, apiBaseOverride, warnedHosts, ignoreMatcherCache;
9644
+ var import_ignore, CONFIG_FILE, PROD_ENV, DEFAULT_API_BASE, cached3, cachedPath, envOption, apiBaseOverride, warnedHosts, ignoreMatcherCache;
9593
9645
  var init_config = __esm({
9594
9646
  "src/config.ts"() {
9595
9647
  "use strict";
9596
9648
  import_ignore = __toESM(require_ignore(), 1);
9597
9649
  CONFIG_FILE = ".gipity.json";
9650
+ PROD_ENV = "prod";
9598
9651
  DEFAULT_API_BASE = "https://a.gipity.ai";
9599
9652
  cached3 = null;
9600
9653
  cachedPath = null;
@@ -34307,6 +34360,7 @@ var {
34307
34360
 
34308
34361
  // src/index.ts
34309
34362
  init_config();
34363
+ init_setup();
34310
34364
  init_utils();
34311
34365
  import { readFileSync as readFileSync30 } from "fs";
34312
34366
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -35367,7 +35421,7 @@ function readGipityIgnore(root) {
35367
35421
  return readFileSync8(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
35368
35422
  }
35369
35423
  function effectiveIgnore(root, configIgnore) {
35370
- const base = configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE;
35424
+ const base = anchorPrimerPatterns(configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE);
35371
35425
  const merged = [...base, GIPITY_IGNORE_FILE, ...readGipityIgnore(root)];
35372
35426
  return [...merged, ...SCRATCH_IGNORE.filter((p) => !merged.includes(p))];
35373
35427
  }
@@ -36126,6 +36180,7 @@ async function syncBeforeAction(opts) {
36126
36180
 
36127
36181
  // src/helpers/body.ts
36128
36182
  import { readFileSync as readFileSync9 } from "node:fs";
36183
+ import { basename as basename2 } from "node:path";
36129
36184
  function readStdin() {
36130
36185
  if (process.stdin.isTTY) return "";
36131
36186
  try {
@@ -36191,6 +36246,32 @@ function resolveJsonBody(raw) {
36191
36246
  throw new Error(`Invalid JSON in ${origin}: ${e.message}`);
36192
36247
  }
36193
36248
  }
36249
+ function resolveFormBody(specs) {
36250
+ const form = new FormData();
36251
+ for (const spec of specs) {
36252
+ const eq2 = spec.indexOf("=");
36253
+ if (eq2 === -1) {
36254
+ throw new Error(`Invalid --form '${spec}': expected field=@path for a file or field=value for text (e.g. --form audio=@talk.mp3).`);
36255
+ }
36256
+ const field = spec.slice(0, eq2).trim();
36257
+ const value = spec.slice(eq2 + 1);
36258
+ if (!field) throw new Error(`Invalid --form '${spec}': missing field name before '='.`);
36259
+ if (!value.startsWith("@")) {
36260
+ form.append(field, value);
36261
+ continue;
36262
+ }
36263
+ const path5 = value.slice(1);
36264
+ if (!path5) throw new Error(`Invalid --form '${spec}': missing file path after '@'.`);
36265
+ let data;
36266
+ try {
36267
+ data = readFileSync9(path5);
36268
+ } catch (e) {
36269
+ throw new Error(`Cannot read --form '${path5}': ${e.message}`);
36270
+ }
36271
+ form.append(field, new Blob([new Uint8Array(data)], { type: guessMime(path5) }), basename2(path5));
36272
+ }
36273
+ return form;
36274
+ }
36194
36275
 
36195
36276
  // src/helpers/duration.ts
36196
36277
  var UNIT_TO_MS = { ms: 1, s: 1e3, m: 6e4 };
@@ -36333,7 +36414,7 @@ init_setup();
36333
36414
  init_agents();
36334
36415
  init_colors();
36335
36416
  init_utils();
36336
- import { basename as basename2, resolve as resolve8, dirname as dirname8 } from "path";
36417
+ import { basename as basename3, resolve as resolve8, dirname as dirname8 } from "path";
36337
36418
  import { existsSync as existsSync11, readFileSync as readFileSync13 } from "fs";
36338
36419
 
36339
36420
  // src/adopt-cwd.ts
@@ -36498,7 +36579,7 @@ function* walkTextFiles(root) {
36498
36579
  continue;
36499
36580
  }
36500
36581
  for (const entry of entries) {
36501
- if (isSyncIgnored(entry.name)) continue;
36582
+ if (isSyncIgnored(entry.name, { nested: dir !== root })) continue;
36502
36583
  const full = join11(dir, entry.name);
36503
36584
  if (entry.isDirectory()) {
36504
36585
  stack.push(full);
@@ -36626,7 +36707,7 @@ function scanForAdoption(cwd) {
36626
36707
  }
36627
36708
  for (const name of entries) {
36628
36709
  if (truncated) return;
36629
- if (isSyncIgnored(name)) continue;
36710
+ if (isSyncIgnored(name, { nested: dir !== cwd })) continue;
36630
36711
  const full = join13(dir, name);
36631
36712
  let st2;
36632
36713
  try {
@@ -36660,7 +36741,7 @@ function isLikelyEmpty(cwd) {
36660
36741
  } catch {
36661
36742
  return true;
36662
36743
  }
36663
- return entries.every(isSyncIgnored);
36744
+ return entries.every((name) => isSyncIgnored(name));
36664
36745
  }
36665
36746
  function canAdoptCwd(cwd) {
36666
36747
  const norm = resolve6(cwd);
@@ -37369,7 +37450,7 @@ Working with an existing Gipity project:
37369
37450
  process.exit(1);
37370
37451
  }
37371
37452
  }
37372
- const projectName = (name || basename2(cwd)).slice(0, 100);
37453
+ const projectName = (name || basename3(cwd)).slice(0, 100);
37373
37454
  const projectSlug = slugify(projectName);
37374
37455
  if (!projectSlug) {
37375
37456
  console.error(error("Could not derive a valid project slug. Provide a name: gipity init my-app"));
@@ -37496,7 +37577,8 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
37496
37577
  account: config.accountSlug,
37497
37578
  apiBase: config.apiBase,
37498
37579
  apiBaseInUse,
37499
- url: liveUrl(config)
37580
+ url: liveUrl(config),
37581
+ ...config.env ? { env: config.env.name } : {}
37500
37582
  } : null,
37501
37583
  // `valid` reflects the refresh token (the real session) - access
37502
37584
  // tokens auto-renew, so their expiry must not read as "invalid".
@@ -37520,6 +37602,7 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
37520
37602
  } else {
37521
37603
  console.log(`${muted("Project:")} ${brand(config.projectSlug)} ${muted(`(${config.projectGuid})`)}`);
37522
37604
  console.log(`${muted("Account:")} ${config.accountSlug}`);
37605
+ if (config.env) console.log(`${muted("Env:")} ${config.env.name}`);
37523
37606
  console.log(`${muted("Live:")} ${liveUrl(config)}`);
37524
37607
  console.log(`${muted("API:")} ${config.apiBase}`);
37525
37608
  if (apiBaseInUse !== config.apiBase) {
@@ -37644,7 +37727,7 @@ var pushCommand = new Command("push").description("Push one or more files").argu
37644
37727
  init_api();
37645
37728
  init_config();
37646
37729
  import { statSync as statSync5 } from "fs";
37647
- import { basename as basename3 } from "path";
37730
+ import { basename as basename4 } from "path";
37648
37731
  init_utils();
37649
37732
  init_colors();
37650
37733
  var uploadCommand = new Command("upload").description("Upload a file and print a durable public URL (works immediately, no deploy)").argument("<file>", "Local file to upload").option("--private", "Store as a private token-signed serve URL instead of a public CDN url").option("--content-type <mime>", "Override the content type (default: detected from the file extension)").option("--json", "Output as JSON").addHelpText("after", `
@@ -37664,7 +37747,7 @@ Public by default (a media.gipity.ai CDN url any job or function can fetch);
37664
37747
  throw new Error(`can't read ${file}: ${err.message}`);
37665
37748
  }
37666
37749
  if (size === 0) throw new Error(`${file} is empty - nothing to upload.`);
37667
- const filename = basename3(file);
37750
+ const filename = basename4(file);
37668
37751
  const contentType = opts.contentType || guessMime(file);
37669
37752
  const doUpload = async () => {
37670
37753
  const init = await post(`/api/${config.projectGuid}/uploads/init`, {
@@ -37739,7 +37822,7 @@ function dropCheckpoint(projectGuid2, database) {
37739
37822
  init_api();
37740
37823
  init_config();
37741
37824
  import { readFileSync as readFileSync15, statSync as statSync6, existsSync as existsSync13, readdirSync as readdirSync7 } from "node:fs";
37742
- import { basename as basename4, resolve as resolve11, relative as relative3, join as join17 } from "node:path";
37825
+ import { basename as basename5, resolve as resolve11, relative as relative3, join as join17 } from "node:path";
37743
37826
  var FIND_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".gipity", "dist", "build", ".next", "coverage"]);
37744
37827
  function findByBasename(root, name, limit = 3) {
37745
37828
  const hits = [];
@@ -37768,18 +37851,18 @@ function assertLocalAsset(flag, localPath) {
37768
37851
  const abs = resolve11(localPath);
37769
37852
  if (existsSync13(abs)) return;
37770
37853
  const root = getProjectRoot() ?? process.cwd();
37771
- const elsewhere = findByBasename(root, basename4(localPath)).filter((p) => p !== abs);
37854
+ const elsewhere = findByBasename(root, basename5(localPath)).filter((p) => p !== abs);
37772
37855
  const found = elsewhere.length ? `
37773
37856
  That file DOES exist here. Pass this path instead:
37774
37857
  ${elsewhere.map((p) => ` ${flag} ${relative3(process.cwd(), p) || p}`).join("\n")}` : `
37775
- Nothing named "${basename4(localPath)}" under ${root} either. Generate a frame with \`gipity generate image "<description>" -o ${localPath}\`, or check the path.`;
37858
+ Nothing named "${basename5(localPath)}" under ${root} either. Generate a frame with \`gipity generate image "<description>" -o ${localPath}\`, or check the path.`;
37776
37859
  throw new Error(
37777
37860
  `${flag} ${localPath}: no such file. Looked for ${abs} (relative paths resolve against the current directory, ${process.cwd()}).${found}`
37778
37861
  );
37779
37862
  }
37780
37863
  async function uploadPublicFixture(projectGuid2, localPath, flag = "--fixture") {
37781
37864
  assertLocalAsset(flag, localPath);
37782
- const name = basename4(localPath);
37865
+ const name = basename5(localPath);
37783
37866
  const size = statSync6(localPath).size;
37784
37867
  const contentType = guessMime(localPath);
37785
37868
  const init = await post(
@@ -37812,7 +37895,7 @@ function assertCameraFile(localPath) {
37812
37895
  const ext = localPath.slice(localPath.lastIndexOf(".")).toLowerCase();
37813
37896
  if (CAMERA_EXTS.includes(ext)) return;
37814
37897
  throw new Error(
37815
- `--camera ${basename4(localPath)}: unsupported file type "${ext || "(none)"}": the camera feed must be an image or video (${CAMERA_EXTS.join(", ")}).
37898
+ `--camera ${basename5(localPath)}: unsupported file type "${ext || "(none)"}": the camera feed must be an image or video (${CAMERA_EXTS.join(", ")}).
37816
37899
  A still image is played as a looping single-frame feed, which is what a gesture/pose/object model needs.
37817
37900
  No frame to hand? Generate one: gipity generate image "a hand making a closed fist, palm to camera, plain background"`
37818
37901
  );
@@ -38949,10 +39032,35 @@ function statusIcon(status) {
38949
39032
  if (status === "warning") return warning("\u26A0");
38950
39033
  return muted("\u2192");
38951
39034
  }
38952
- var deployCommand = new Command("deploy").description("Deploy to dev or prod").argument("[target]", "dev or prod", "dev").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", "Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)").option("--no-optimize", 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((target, opts) => run("Deploy", async () => {
38953
- if (target !== "dev" && target !== "prod") {
38954
- console.error(error('Target must be "dev" or "prod"'));
38955
- process.exit(1);
39035
+ async function printPlan(appGuid2, env, json) {
39036
+ const res = await get(`/projects/${appGuid2}/envs/${encodeURIComponent(env)}/plan`);
39037
+ const p = res.data;
39038
+ if (json) {
39039
+ console.log(JSON.stringify(p));
39040
+ return;
39041
+ }
39042
+ console.log(brand(bold(`Deploy plan for ${p.env}`)));
39043
+ console.log(muted("\u2500".repeat(40)));
39044
+ if (p.pending.length === 0) {
39045
+ console.log(success(`\u2713 No pending migrations: ${p.env}'s database is up to date.`));
39046
+ return;
39047
+ }
39048
+ for (const m of p.pending) {
39049
+ const where = m.ranOn.length ? muted(`ran on ${m.ranOn.map((r) => `${r.env} ${new Date(r.appliedAt).toLocaleDateString()}`).join(", ")}`) : warning("has not run anywhere yet");
39050
+ const edited = p.changed.includes(m.file) ? muted(" (edited since it ran here; runs again)") : "";
39051
+ console.log(`${m.destructive.length ? error("!") : muted("\u2192")} ${bold(m.file)} ${where}${edited}`);
39052
+ for (const d of m.destructive) console.log(` ${error(d)}`);
39053
+ }
39054
+ if (p.env === "prod" && p.pending.some((m) => m.destructive.length)) {
39055
+ console.log("");
39056
+ console.log(warning("A prod deploy stops on the destructive statements above until you pass --yes-destructive."));
39057
+ }
39058
+ }
39059
+ var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", "Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)").option("--no-optimize", 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((envArg, opts) => run("Deploy", async () => {
39060
+ const env = envArg ?? getEnvOption();
39061
+ if (opts.plan) {
39062
+ await printPlan(requireConfig2().projectGuid, env ?? "prod", !!opts.json);
39063
+ return;
38956
39064
  }
38957
39065
  if (!opts.inspect && (opts.waitFor || deployCommand.getOptionValueSource("wait") !== void 0)) {
38958
39066
  opts.inspect = true;
@@ -38960,14 +39068,16 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
38960
39068
  const config = requireConfig2();
38961
39069
  await syncBeforeAction(opts);
38962
39070
  const doDeploy = () => post(`/projects/${config.projectGuid}/deploy`, {
38963
- target,
39071
+ ...env ? { env } : {},
39072
+ ...opts.yesDestructive ? { yesDestructive: true } : {},
38964
39073
  sourceDir: opts.sourceDir,
38965
39074
  optimize: opts.optimize,
38966
39075
  force: opts.force,
38967
39076
  only: opts.only?.split(",").map((s) => s.trim())
38968
39077
  });
38969
- const res = opts.json ? await doDeploy() : await withSpinner(`Deploying to ${target}...`, doDeploy, { done: null });
39078
+ const res = opts.json ? await doDeploy() : await withSpinner(env ? `Deploying to ${env}...` : "Deploying...", doDeploy, { done: null });
38970
39079
  const d = res.data;
39080
+ const where = d.env ?? d.target;
38971
39081
  const inspectAfter = async () => {
38972
39082
  if (!opts.inspect) return;
38973
39083
  if (!d.url) {
@@ -38990,11 +39100,12 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
38990
39100
  if (opts.json) {
38991
39101
  console.log(JSON.stringify(d));
38992
39102
  const failedJson = d.phases?.some((p) => p.status === "failed");
38993
- if (!failedJson) await inspectAfter();
39103
+ if (failedJson) process.exit(1);
39104
+ await inspectAfter();
38994
39105
  return;
38995
39106
  }
38996
39107
  const batchLabel = d.batch ? muted(` (batch ${d.batch})`) : "";
38997
- console.log(brand(bold(`Deploy to ${target}`)) + batchLabel);
39108
+ console.log(brand(bold(`Deploy to ${where}`)) + batchLabel + (d.created ? muted(" (new environment)") : ""));
38998
39109
  console.log(muted("\u2500".repeat(40)));
38999
39110
  if (d.phases && d.phases.length > 0) {
39000
39111
  for (const phase of d.phases) {
@@ -39030,16 +39141,157 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
39030
39141
  console.log(error(`Deploy failed`) + muted(` (${d.elapsedMs}ms)`));
39031
39142
  process.exit(1);
39032
39143
  } else {
39033
- console.log(success(`\u2713 Deployed to ${target}`) + muted(` (${d.elapsedMs}ms)`));
39144
+ console.log(success(`\u2713 Deployed to ${where}`) + muted(` (${d.elapsedMs}ms)`));
39034
39145
  if (d.url) console.log(`${muted("Live:")} ${brand(d.url)}`);
39035
39146
  if (d.phases?.some((p) => p.name === "functions")) {
39036
- console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${config.projectGuid}/fn/<name>`)}`);
39037
- console.log(muted(" (same address on dev and prod; names: gipity fn list; verify the public path: gipity fn call <name> --anon)"));
39147
+ console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${d.appGuid ?? config.projectGuid}/fn/<name>`)}`);
39148
+ const envFlag = d.env && d.env !== "prod" ? ` --env ${d.env}` : "";
39149
+ console.log(muted(` (names: gipity fn list${envFlag}; verify the public path: gipity fn call <name>${envFlag} --anon)`));
39038
39150
  }
39151
+ for (const hint of d.hints ?? []) console.log(muted(hint));
39039
39152
  await inspectAfter();
39040
39153
  }
39041
39154
  }));
39042
39155
 
39156
+ // src/commands/env.ts
39157
+ init_api();
39158
+ init_config();
39159
+ init_utils();
39160
+ init_colors();
39161
+ init_utils();
39162
+ function appGuid() {
39163
+ return requireConfig2().projectGuid;
39164
+ }
39165
+ var envCommand = new Command("env").description("App environments: prod plus any number of isolated copies (dev, staging, ...), each with its own database, functions and URL").addHelpText("after", `
39166
+ An environment is created the first time you deploy to it:
39167
+ gipity deploy dev # creates "dev" (own DB from migrations, own functions), deploys
39168
+ gipity deploy prod # the live app
39169
+
39170
+ Run any project command against one with --env:
39171
+ gipity db query "SELECT count(*) FROM orders" --env dev
39172
+ gipity fn call checkout --env staging
39173
+ gipity logs fn checkout --env dev
39174
+
39175
+ Envs share the app's secrets (an env can override one: gipity secrets set NAME value --env staging),
39176
+ members and players. Cron workflows are off in an env until: gipity env set <name> --schedules on.
39177
+ Email from an env reaches only the app owner and members; payments run in prod only.`);
39178
+ envCommand.command("list", { isDefault: true }).description("List the app's environments").option("--json", "Output as JSON").action((opts) => run("Env", async () => {
39179
+ const res = await get(`/projects/${appGuid()}/envs`);
39180
+ const d = res.data;
39181
+ if (opts.json) {
39182
+ console.log(JSON.stringify(d));
39183
+ return;
39184
+ }
39185
+ console.log(`${bold("prod")} ${brand(d.prod.url)}`);
39186
+ if (d.envs.length === 0) {
39187
+ console.log(muted("No environments yet. `gipity deploy dev` creates one."));
39188
+ return;
39189
+ }
39190
+ for (const e of d.envs) {
39191
+ const deployed = e.lastDeploy ? `deployed ${new Date(e.lastDeploy).toLocaleString()}` : "never deployed";
39192
+ const parts = [deployed, `DB ${formatSize(e.dbBytes)}`, e.schedules ? "schedules on" : "schedules off"];
39193
+ if (e.customDomains.length) parts.push(e.customDomains.join(", "));
39194
+ console.log(`${bold(e.name)} ${brand(e.url)} ${muted(parts.join(" \xB7 "))}`);
39195
+ }
39196
+ }));
39197
+ function printCopy(copy) {
39198
+ if (!copy) return;
39199
+ for (const d of copy.databases) {
39200
+ console.log(muted(`Copied ${d.rows} rows (${d.tables} tables) from ${copy.from}'s ${d.database} database`));
39201
+ }
39202
+ }
39203
+ envCommand.command("create <name>").description("Create an environment and deploy the app to it (`gipity deploy <name>` does the same, without --data)").option("--data", "Copy the rows of prod (or --from) into it, to try a change against real data").option("--from <env>", "With --data: the environment to copy from (default prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
39204
+ if (name === PROD_ENV) {
39205
+ console.error(error("prod is the app itself. Deploy it with: gipity deploy prod"));
39206
+ process.exit(1);
39207
+ }
39208
+ if (opts.from && !opts.data) {
39209
+ console.error(error("--from goes with --data"));
39210
+ process.exit(1);
39211
+ }
39212
+ const create = () => post(
39213
+ `/projects/${appGuid()}/envs`,
39214
+ { name, ...opts.data ? { data: true } : {}, ...opts.from ? { from: opts.from } : {} }
39215
+ );
39216
+ const res = opts.json ? await create() : await withSpinner(`Creating ${name}...`, create, { done: null });
39217
+ if (opts.json) {
39218
+ console.log(JSON.stringify(res.data));
39219
+ return;
39220
+ }
39221
+ const failed = res.data.phases.filter((p) => p.status === "failed");
39222
+ for (const p of failed) console.log(`${error("\u2717")} ${bold(p.name)}: ${p.summary}`);
39223
+ if (failed.length > 0) {
39224
+ console.log(error(`Created ${name}, but its first deploy failed. Fix it and run: gipity deploy ${name}`));
39225
+ process.exit(1);
39226
+ }
39227
+ console.log(success(`\u2713 Created ${name}`));
39228
+ printCopy(res.data.data);
39229
+ console.log(`${muted("Live:")} ${brand(res.data.url)}`);
39230
+ }));
39231
+ envCommand.command("reset <name>").description("Start an environment over: drop its database, rerun every migration from zero, redeploy").option("--data", "Then copy the rows of prod (or --from) into it").option("--from <env>", "With --data: the environment to copy from (default prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
39232
+ if (name === PROD_ENV) {
39233
+ console.error(error("prod can't be reset."));
39234
+ process.exit(1);
39235
+ }
39236
+ if (opts.from && !opts.data) {
39237
+ console.error(error("--from goes with --data"));
39238
+ process.exit(1);
39239
+ }
39240
+ const ok = await confirm(`Reset ${bold(name)}? Its database is dropped and rebuilt${opts.data ? ` from ${opts.from ?? "prod"}'s data` : " empty"}.`, { default: "no" });
39241
+ if (!ok) {
39242
+ console.log(muted("Aborted."));
39243
+ process.exit(1);
39244
+ }
39245
+ const reset = () => post(
39246
+ `/projects/${appGuid()}/envs/${encodeURIComponent(name)}/reset`,
39247
+ { ...opts.data ? { data: true } : {}, ...opts.from ? { from: opts.from } : {} }
39248
+ );
39249
+ const res = opts.json ? await reset() : await withSpinner(`Resetting ${name}...`, reset, { done: null });
39250
+ if (opts.json) {
39251
+ console.log(JSON.stringify(res.data));
39252
+ return;
39253
+ }
39254
+ const failed = res.data.phases.filter((p) => p.status === "failed");
39255
+ for (const p of failed) console.log(`${error("\u2717")} ${bold(p.name)}: ${p.summary}`);
39256
+ if (failed.length > 0) {
39257
+ console.log(error(`Reset ${name}, but its deploy failed.`));
39258
+ process.exit(1);
39259
+ }
39260
+ console.log(success(`\u2713 Reset ${name}`));
39261
+ printCopy(res.data.data);
39262
+ if (res.data.url) console.log(`${muted("Live:")} ${brand(res.data.url)}`);
39263
+ }));
39264
+ envCommand.command("set <name>").description("Change an environment's settings").requiredOption("--schedules <on|off>", "Turn the environment's cron workflows on or off").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
39265
+ const value = String(opts.schedules).toLowerCase();
39266
+ if (value !== "on" && value !== "off") {
39267
+ console.error(error("--schedules takes on or off"));
39268
+ process.exit(1);
39269
+ }
39270
+ const res = await patch(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`, { schedules: value === "on" });
39271
+ if (opts.json) {
39272
+ console.log(JSON.stringify(res.data));
39273
+ return;
39274
+ }
39275
+ console.log(success(`\u2713 Schedules ${value} in ${name}`));
39276
+ }));
39277
+ envCommand.command("delete <name>").description("Delete an environment: its database, functions, files and custom domains (never prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
39278
+ if (name === PROD_ENV) {
39279
+ console.error(error("prod is the app itself and can't be deleted as an environment."));
39280
+ process.exit(1);
39281
+ }
39282
+ const ok = await confirm(`Delete the ${bold(name)} environment and its database?`, { default: "no" });
39283
+ if (!ok) {
39284
+ console.log(muted("Aborted."));
39285
+ process.exit(1);
39286
+ }
39287
+ const res = await del(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`);
39288
+ if (opts.json) {
39289
+ console.log(JSON.stringify(res.data));
39290
+ return;
39291
+ }
39292
+ console.log(success(`\u2713 Deleted ${name}`));
39293
+ }));
39294
+
39043
39295
  // src/commands/db.ts
39044
39296
  init_api();
39045
39297
  init_config();
@@ -40561,7 +40813,7 @@ storageCommand.command("retention").description("View or adjust your file versio
40561
40813
  init_platform();
40562
40814
  init_auth();
40563
40815
  init_api();
40564
- import { join as join22, dirname as dirname12, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
40816
+ import { join as join22, dirname as dirname12, resolve as resolve13, basename as basename6, sep as sep6 } from "path";
40565
40817
  import { existsSync as existsSync17, mkdirSync as mkdirSync14, readFileSync as readFileSync19, writeFileSync as writeFileSync14, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
40566
40818
  import { homedir as homedir15 } from "os";
40567
40819
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -40593,7 +40845,7 @@ function humanBytes(n) {
40593
40845
  return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
40594
40846
  }
40595
40847
  function buildHeader(opts) {
40596
- const deployUrl = opts.accountSlug ? `https://dev.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
40848
+ const deployUrl = opts.accountSlug ? `https://app.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
40597
40849
  const filesLine = opts.fileCount === 0 ? `- Files: empty (no files yet)` : `- Files: ${opts.fileCount} file${opts.fileCount === 1 ? "" : "s"} in ${opts.folderCount} folder${opts.folderCount === 1 ? "" : "s"} (${humanBytes(opts.totalBytes)}) - ${opts.topLevel}`;
40598
40850
  return [
40599
40851
  `## Gipity project`,
@@ -40645,7 +40897,7 @@ var USER_MSG_OPEN = "<gipity-user-message>";
40645
40897
  var USER_MSG_CLOSE = "</gipity-user-message>";
40646
40898
  var RESPONSE_DIRECTIVE = `Respond to the user message below. Don't greet or reintroduce yourself.`;
40647
40899
  function buildResumeWrap(opts, userMsg) {
40648
- const deployUrl = opts.accountSlug ? `https://dev.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
40900
+ const deployUrl = opts.accountSlug ? `https://app.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
40649
40901
  return [
40650
40902
  `Project: ${opts.projectName} (\`${opts.projectGuid}\`) - ${deployUrl}`,
40651
40903
  PLATFORM_REMINDER,
@@ -41314,7 +41566,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
41314
41566
  let accountSlug = "";
41315
41567
  const result = forceAdoptCwd ? { kind: "adopt-cwd" } : projects.length > 0 ? await pickOrCreateProject(projects, existingSlugs) : { kind: "create-new", project: await createNewProject(existingSlugs) };
41316
41568
  if (result.kind === "adopt-cwd") {
41317
- const cwdBase = basename5(process.cwd());
41569
+ const cwdBase = basename6(process.cwd());
41318
41570
  const adoptSlug = slugify(cwdBase) || "project";
41319
41571
  const adoptName = (cwdBase || adoptSlug).slice(0, 100);
41320
41572
  accountSlug = await getAccountSlug();
@@ -42193,7 +42445,7 @@ function printBrand(d) {
42193
42445
  if (d.branding.app_name) console.log(`${bold("Name:")} ${d.branding.app_name}`);
42194
42446
  if (d.branding.tagline) console.log(`${bold("Tagline:")} ${d.branding.tagline}`);
42195
42447
  }
42196
- var DEPLOY_HINT = "Deploy to publish the new assets: gipity deploy dev";
42448
+ var DEPLOY_HINT = "Deploy to publish the new assets: gipity deploy";
42197
42449
  var brandCommand = new Command("brand").description("The app's generated icons + share card (favicons, iOS icon, og-image)").addHelpText("after", `
42198
42450
  Examples:
42199
42451
  gipity brand Show the current brand
@@ -42517,7 +42769,7 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
42517
42769
  console.warn(warning("The project was still created and linked; the files above are missing from it."));
42518
42770
  }
42519
42771
  console.log("");
42520
- console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy dev")}`);
42772
+ console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy")}`);
42521
42773
  }));
42522
42774
 
42523
42775
  // src/commands/logs.ts
@@ -43293,7 +43545,7 @@ fnCommand.command("list").description("List functions").option("--json", "Output
43293
43545
  ${muted(f.description)}` : line;
43294
43546
  });
43295
43547
  if (!opts.json && res.data.length > 0) {
43296
- console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (same on dev and prod; public path: gipity fn call <name> --anon)`));
43548
+ console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (this is ${config.env ? `the ${config.env.name} environment` : "prod"}; each environment has its own address, see --env; public path: gipity fn call <name> --anon)`));
43297
43549
  }
43298
43550
  }));
43299
43551
  fnCommand.command("logs <name>").description("Show recent logs").option("--limit <n>", "Max entries", "20").option("--json", "Output as JSON").action((name, opts) => run("Logs", async () => {
@@ -43375,6 +43627,7 @@ var SERVICES = [
43375
43627
  { name: "music", method: "POST", desc: "Music generation ({ prompt, duration_seconds? })" },
43376
43628
  { name: "music/models", method: "GET", desc: "List music models (ids for --model / model)" },
43377
43629
  { name: "video", method: "POST", desc: "Video generation ({ prompt, ... })" },
43630
+ { name: "transcribe", method: "POST", desc: "Speech-to-text, multipart (--form audio=@talk.mp3 [--form language=en] [--form diarize=true])" },
43378
43631
  { name: "location/ip", method: "POST", desc: "IP geolocation ({ ip? })" },
43379
43632
  { name: "location/geocode", method: "POST", desc: "Reverse geocode ({ lat, lon })" }
43380
43633
  ];
@@ -43405,14 +43658,17 @@ function anonBillingHint(name, err) {
43405
43658
  service_definitions:
43406
43659
  - service: ${service}
43407
43660
  billing_mode: owner_pays
43408
- gipity deploy dev --only services`;
43661
+ gipity deploy --only services`;
43409
43662
  }
43410
- serviceCommand.command("call <name> [body]").description("Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling; --anon calls it as a signed-out visitor instead.").option("-d, --data <json>", "JSON request body: inline JSON, @file to read a file, or @- / - for stdin (alternative to the positional [body])").option("--file <field=@path>", "Attach a file as { data, media_type } under <field> (the vision/media shape these services expect), repeatable, e.g. --file image=@receipt.png", (v7, acc) => (acc || []).concat(v7)).option("--anon", "Call as an anonymous visitor (the public path a signed-out user of your deployed app hits) instead of as your signed-in account").option("--get", "Issue a GET (for listing endpoints like llm/models, tts/voices)").option("--field <path>", "Print only this field of the result (dot path, e.g. choices.0.message.content)").option("--json", "Output compact JSON").action((name, bodyArg, opts) => run("Call", async () => {
43663
+ serviceCommand.command("call <name> [body]").description("Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling; --anon calls it as a signed-out visitor instead.").option("-d, --data <json>", "JSON request body: inline JSON, @file to read a file, or @- / - for stdin (alternative to the positional [body])").option("--file <field=@path>", "Attach a file as { data, media_type } under <field> in the JSON body (the shape image/vision services expect), repeatable, e.g. --file image=@receipt.png", (v7, acc) => (acc || []).concat(v7)).option("--form <field=value>", "Send multipart/form-data instead of JSON, curl -F style: field=@path attaches a file, field=value a text field. Repeatable. For upload endpoints like transcribe: --form audio=@talk.mp3 --form language=en", (v7, acc) => (acc || []).concat(v7)).option("--anon", "Call as an anonymous visitor (the public path a signed-out user of your deployed app hits) instead of as your signed-in account").option("--get", "Issue a GET (for listing endpoints like llm/models, tts/voices)").option("--field <path>", "Print only this field of the result (dot path, e.g. choices.0.message.content)").option("--json", "Output compact JSON").action((name, bodyArg, opts) => run("Call", async () => {
43411
43664
  const config = requireConfig2();
43412
43665
  const [pathPart, query] = name.split("?", 2);
43413
43666
  const path5 = pathPart.split("/").map(encodeURIComponent).join("/");
43414
43667
  const url = `/api/${config.projectGuid}/services/${path5}${query ? `?${query}` : ""}`;
43415
- const body = resolveBody(bodyArg || opts.data, opts.file);
43668
+ if (opts.form && (bodyArg || opts.data || opts.file || opts.get)) {
43669
+ throw new Error("--form sends a multipart body, so it cannot be combined with a JSON body, --data, --file, or --get.");
43670
+ }
43671
+ const body = opts.form ? resolveFormBody(opts.form) : resolveBody(bodyArg || opts.data, opts.file);
43416
43672
  if (opts.anon) {
43417
43673
  console.error(muted("Auth: anonymous visitor (the public path a signed-out user of your deployed app hits)"));
43418
43674
  } else {
@@ -43425,10 +43681,10 @@ serviceCommand.command("call <name> [body]").description("Call an app service by
43425
43681
  const headers = await mintAppToken(config.projectGuid);
43426
43682
  if (!headers) {
43427
43683
  throw new Error(
43428
- `Could not mint a visitor token for this project, so there is no anonymous path to call. That means the app is not deployed on this API base yet: run \`gipity deploy dev\` first, then re-run this command.`
43684
+ `Could not mint a visitor token for this project, so there is no anonymous path to call. That means the app is not deployed on this API base yet: run \`gipity deploy\` first, then re-run this command.`
43429
43685
  );
43430
43686
  }
43431
- res = await publicRequest(opts.get ? "GET" : "POST", url, opts.get ? void 0 : body, headers);
43687
+ res = await publicRequest(opts.get ? "GET" : "POST", url, opts.get ? void 0 : body, headers, LONG_REQUEST_TIMEOUT_MS);
43432
43688
  } else {
43433
43689
  res = opts.get ? await get(url) : await post(url, body, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
43434
43690
  }
@@ -44157,7 +44413,7 @@ init_api();
44157
44413
  init_config();
44158
44414
  init_colors();
44159
44415
  import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync15, readFileSync as readFileSync20 } from "fs";
44160
- import { resolve as resolvePath2, dirname as dirname13, relative as relative5, isAbsolute, basename as basename6 } from "path";
44416
+ import { resolve as resolvePath2, dirname as dirname13, relative as relative5, isAbsolute, basename as basename7 } from "path";
44161
44417
 
44162
44418
  // src/provider-docs.ts
44163
44419
  var GEMINI_TTS_VOICES_DOC = `Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat`;
@@ -44298,7 +44554,7 @@ function noteFormatMismatch(filename, buf) {
44298
44554
  const asked = dot > 0 ? filename.slice(dot + 1).toLowerCase() : "";
44299
44555
  if (!asked || canonicalExt(asked) === actual) return;
44300
44556
  console.error(muted(
44301
- `Note: ${basename6(filename)} holds ${formatName(actual)} bytes though its name ends .${asked}: that's fine (browsers and image/video/edit tools sniff the bytes, not the name). Saved at the exact path you requested; reference it as-is.`
44557
+ `Note: ${basename7(filename)} holds ${formatName(actual)} bytes though its name ends .${asked}: that's fine (browsers and image/video/edit tools sniff the bytes, not the name). Saved at the exact path you requested; reference it as-is.`
44302
44558
  ));
44303
44559
  }
44304
44560
  function ensureOutputDir(output) {
@@ -45288,9 +45544,9 @@ var testCommand = new Command("test").description("Run tests").argument("[path]"
45288
45544
  if (undeployed.length > 0) {
45289
45545
  const list = undeployed.map((n) => `'${n}'`).join(", ");
45290
45546
  console.log(warning(
45291
- `${undeployed.length === 1 ? "Function" : "Functions"} ${list} 404'd: tests call functions against the DEPLOYED build, and ${undeployed.length === 1 ? "this one is" : "these are"} not deployed yet.`
45547
+ `${undeployed.length === 1 ? "Function" : "Functions"} ${list} 404'd: \`gipity test\` registers every file in functions/ before the run, so ${undeployed.length === 1 ? "that name has" : "those names have"} no function file, or failed to register.`
45292
45548
  ));
45293
- console.log(muted("Deploy first, then re-run: gipity deploy dev && gipity test"));
45549
+ console.log(muted("Check the name against functions/<name>.js (or functions/<name>/index.js) and gipity.yaml."));
45294
45550
  console.log("");
45295
45551
  }
45296
45552
  const parts = [];
@@ -49887,7 +50143,7 @@ function configureHelp(cmd) {
49887
50143
  var program2 = new Command();
49888
50144
  program2.enablePositionalOptions();
49889
50145
  var startGroup = [statusCommand, initCommand, skillCommand, projectCommand];
49890
- var buildGroup = [addCommand, removeCommand, brandCommand, saveCommand, loadCommand, deployCommand, pageCommand, testCommand];
50146
+ var buildGroup = [addCommand, removeCommand, brandCommand, saveCommand, loadCommand, deployCommand, envCommand, pageCommand, testCommand];
49891
50147
  var backendGroup = [dbCommand, fnCommand, secretsCommand, keyCommand, logsCommand, jobCommand, workflowCommand, approvalCommand, memoryCommand];
49892
50148
  var servicesGroup = [serviceCommand, generateCommand, askCommand, notifyCommand, paymentsCommand, realtimeCommand, recordsCommand, rbacCommand, auditCommand, domainCommand, tokenCommand];
49893
50149
  var filesGroup = [syncCommand, fileCommand, pushCommand, uploadCommand, storageCommand];
@@ -49928,13 +50184,46 @@ var SKILL_DOCS = {
49928
50184
  };
49929
50185
  program2.name("gipity").description(`${brand(bold("Gipity CLI"))} ${dim("-")} ${GIPITY_TAGLINE.replace(/\.$/, "")}
49930
50186
 
49931
- ${dim("Hosting, databases, deploys, workflows, code execution, and monitoring - one place, agent-tuned. Pair with Claude Code or use standalone.")}`).version(pkg.version, "-v, --version").addOption(new Option("--api-base <url>", "API base URL").hideHelp()).option("-y, --yes", "Skip confirmation prompts");
49932
- program2.hook("preAction", (_thisCommand, actionCommand) => {
50187
+ ${dim("Hosting, databases, deploys, workflows, code execution, and monitoring - one place, agent-tuned. Pair with Claude Code or use standalone.")}`).version(pkg.version, "-v, --version").addOption(new Option("--api-base <url>", "API base URL").hideHelp()).option("-y, --yes", "Skip confirmation prompts").option("--env <name>", "Act on an app environment (dev, staging, ...) instead of prod");
50188
+ var SELF_ENV_COMMANDS = /* @__PURE__ */ new Set(["deploy", "env"]);
50189
+ program2.hook("preAction", async (_thisCommand, actionCommand) => {
49933
50190
  const globalOpts = program2.opts();
49934
50191
  if (globalOpts.apiBase) setApiBaseOverride(globalOpts.apiBase);
50192
+ const envName = actionCommand.opts().env ?? globalOpts.env;
50193
+ setEnvOption(envName);
50194
+ let top = actionCommand;
50195
+ while (top.parent && top.parent !== program2) top = top.parent;
50196
+ if (envName && !SELF_ENV_COMMANDS.has(top.name())) await resolveEnvOverride(envName);
50197
+ refreshPrimersQuietly();
49935
50198
  if (globalOpts.yes || actionCommand.opts().yes) setAutoConfirm(true);
49936
50199
  rejectBlankIdArgs(actionCommand);
49937
50200
  });
50201
+ function refreshPrimersQuietly() {
50202
+ const root = getProjectRoot();
50203
+ if (!root) return;
50204
+ try {
50205
+ refreshExistingPrimers(root);
50206
+ } catch (err) {
50207
+ console.error(`Could not refresh this project's Gipity docs block: ${err.message}`);
50208
+ }
50209
+ }
50210
+ async function resolveEnvOverride(name) {
50211
+ const config = getConfig();
50212
+ if (!config) {
50213
+ console.error("--env needs a Gipity project directory (run it where .gipity.json is).");
50214
+ process.exit(1);
50215
+ }
50216
+ const { get: get3 } = await Promise.resolve().then(() => (init_api(), api_exports));
50217
+ try {
50218
+ const res = await get3(
50219
+ `/projects/${config.projectGuid}/envs/${encodeURIComponent(name)}`
50220
+ );
50221
+ applyEnvOverride({ name, projectGuid: res.data.guid, projectSlug: res.data.slug });
50222
+ } catch (err) {
50223
+ console.error(err.message);
50224
+ process.exit(1);
50225
+ }
50226
+ }
49938
50227
  var ID_ARG = /(guid|id)$/i;
49939
50228
  function rejectBlankIdArgs(cmd) {
49940
50229
  cmd.registeredArguments.forEach((arg, i) => {
@@ -50108,6 +50397,16 @@ function enableYesEverywhere(cmd) {
50108
50397
  if (!hasYes) cmd.addOption(new Option("-y, --yes", "Skip confirmation prompts").hideHelp());
50109
50398
  }
50110
50399
  enableYesEverywhere(program2);
50400
+ function enableEnvEverywhere(cmd) {
50401
+ if (cmd.commands.length > 0) {
50402
+ for (const sub of cmd.commands) enableEnvEverywhere(sub);
50403
+ return;
50404
+ }
50405
+ if (!cmd.options.some((o) => o.long === "--env")) {
50406
+ cmd.addOption(new Option("--env <name>", "Act on an app environment (dev, staging, ...) instead of prod").hideHelp());
50407
+ }
50408
+ }
50409
+ enableEnvEverywhere(program2);
50111
50410
  {
50112
50411
  const target = resolveTarget(process.argv, program2);
50113
50412
  const helpAsked = process.argv.slice(2).some((a) => a === "--help" || a === "-h");