gipity 1.1.23 → 1.1.24

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
@@ -3974,11 +3974,11 @@ function decodeJwtExp(token) {
3974
3974
  return null;
3975
3975
  }
3976
3976
  }
3977
- function prompt(question) {
3977
+ function prompt(question, output = process.stdout) {
3978
3978
  if (!process.stdin.isTTY) {
3979
3979
  return Promise.reject(new Error(`prompt() called without a TTY: ${question.trim()}`));
3980
3980
  }
3981
- const rl2 = createInterface({ input: process.stdin, output: process.stdout });
3981
+ const rl2 = createInterface({ input: process.stdin, output });
3982
3982
  return new Promise((resolve19) => {
3983
3983
  rl2.question(question, (answer) => {
3984
3984
  rl2.close();
@@ -6991,11 +6991,11 @@ Gipity is the cloud platform your project runs on - hosting, databases, deployme
6991
6991
 
6992
6992
  Prefer the cheapest option that works - CLI and sandbox are instant and free, app services are runtime HTTP calls, and a model call (\`gipity ask\`) costs tokens:
6993
6993
 
6994
- 1. CLI commands (fast, no agent overhead). The \`gipity\` CLI covers add, deploy, db, fn, logs, page, sync, memory, skill, email, and more. All commands support \`--json\`.
6994
+ 1. CLI commands (fast, no agent overhead). The \`gipity\` CLI covers add, deploy, db, fn, logs, page, sync, memory, skill, email, and more. All commands support \`--json\` (except \`gipity build\`, which hands the terminal to your coding agent).
6995
6995
  2. Cloud sandbox via \`gipity sandbox run\` - Docker container with pre-installed tools for media (ffmpeg, ImageMagick, sox), documents (pandoc, LibreOffice), and data (pandas, matplotlib, sqlite3). Run \`gipity skill read sandbox-tools\` for the full toolkit. No network from inside the sandbox - fetch what you need before sending it in.
6996
- 3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime, location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
6996
+ 3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime (a function can push into a room with the injected \`realtime.publish()\`, so a page listens instead of polling; see \`app-realtime\`), location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
6997
6997
 
6998
- You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Grok, Codex, and opencode) auto-sync them to Gipity. Don't run \`npm install\`, \`npm start\`, \`node\`, or \`python\` locally; there is no local runtime. Code runs in the Gipity sandbox.
6998
+ You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Codex, Grok, Antigravity, and opencode) auto-sync them to Gipity. Don't run \`npm install\`, \`npm start\`, \`node\`, or \`python\` locally; there is no local runtime. Code runs in the Gipity sandbox.
6999
6999
 
7000
7000
  ## Use first-party services before reaching outside
7001
7001
 
@@ -7063,7 +7063,7 @@ Run \`gipity --help\` for the full list. Use \`--help\` on any command for detai
7063
7063
 
7064
7064
  Function return shape: \`gipity fn call\`, the in-test \`ctx.fn.call\`/\`callAs\`, and the client \`Gipity.fn\` all return your function's value **unwrapped** - read/assert \`result.field\`. Only raw HTTP/\`curl\` wraps it as \`{ data: ... }\`; never write \`result.data.field\` in a test.
7065
7065
 
7066
- Tests are isolated, not run against your live DB: \`gipity test\` points \`ctx.fn.call\`/\`callAs\` at a throwaway copy of your database (your \`migrations/\` + \`seeds/\`), one per test FILE, reset (truncate + reseed) before the file runs - so files can't interfere, test rows never reach the deployed app, and you don't write teardown. Functions see \`ctx.isTest === true\` during a run (use it to skip your own rate limiting); the platform also suppresses \`notify()\` push so a suite can't spam subscribers. Reference data tests need goes in seed files; a runtime-written settings table that isn't seeded goes under \`test.preserve\` in \`gipity.yaml\`. Build per-file fixtures in \`setup(fn)\` \u2192 \`ctx.fixtures\`.
7066
+ Tests are isolated, not run against your live DB: \`gipity test\` points \`ctx.fn.call\`/\`callAs\` at a throwaway copy of your database (your migrations plus the seed files named by the sql phase's \`seed:\` key in \`gipity.yaml\`), one per test FILE, reset (truncate + reseed) before the file runs - so files can't interfere, test rows never reach the deployed app, and you don't write teardown. Functions see \`ctx.isTest === true\` during a run (use it to skip your own rate limiting); the platform also suppresses \`notify()\` push so a suite can't spam subscribers. Reference data tests need goes in those seed files; a runtime-written settings table that isn't seeded goes under \`test.preserve\` in \`gipity.yaml\`. Build per-file fixtures in \`setup(fn)\` \u2192 \`ctx.fixtures\`.
7067
7067
 
7068
7068
  ## Hit friction on the platform? Report it in real time
7069
7069
 
@@ -7091,7 +7091,9 @@ Every tool call returns its full output with that call. There is no output buffe
7091
7091
 
7092
7092
  This directory is the app root - it holds \`.gipity.json\` (and \`gipity.yaml\` for backends) and is already your cwd, so run app commands here. Don't \`cd\` to a git root (\`git rev-parse --show-toplevel\`): when the app is nested in a larger repo that resolves outside the app.
7093
7093
 
7094
- Write files locally - Gipity's editor hooks (installed into Claude Code, Grok, Codex, and opencode by \`gipity init\`) auto-push every save to Gipity and auto-pull remote changes (sandbox outputs, restored versions) before each turn. Use \`gipity sync\` if things get out of sync (or if the hooks aren't installed - \`gipity status --repair-hooks\` re-enables them). Deletes are safe - \`gipity file rollback <datetime>\` undoes a tree, \`gipity file restore <path> <version>\` a single file.
7094
+ Write files locally - Gipity's editor hooks (installed into Claude Code, Codex, Grok, Antigravity, and opencode by \`gipity init\`) auto-push every save to Gipity and auto-pull remote changes (sandbox outputs, restored versions) before each turn. Use \`gipity sync\` if things get out of sync (or if the hooks aren't installed - \`gipity status --repair-hooks\` re-enables them). Deletes are safe - \`gipity file rollback <datetime>\` undoes a tree, \`gipity file restore <path> <version>\` a single file.
7095
+
7096
+ Files your deployed app stores at runtime through the app uploads API (users' uploads, \`gipity upload\`, or an external service using a project API key; under \`uploads/\` or any custom path) are user content, not source: they stay in Gipity Storage and never sync into this directory, and sync never deletes them. List them with \`gipity file tree\`, read one with \`gipity file cat <path>\`.
7095
7097
 
7096
7098
  To keep local-only material (research clones, scratch data, vendored references) in the project directory without syncing or deploying it, list it in a \`.gipityignore\` at the project root - gitignore-style, one pattern per line, \`#\` comments. Ignored paths are invisible to sync in both directions; anything that already synced before being ignored stays on the server until you delete it.
7097
7099
 
@@ -7099,7 +7101,7 @@ To keep local-only material (research clones, scratch data, vendored references)
7099
7101
 
7100
7102
  ### Where files go: deploy only ships \`src/\`
7101
7103
 
7102
- Deploy is opt-in, not opt-out: the \`files\` phase uploads **only** what's under \`src/\` (plus \`functions/\` and \`migrations/\` as backend, not CDN files). Anything else at the project root is kept but never deployed. Put each kind of file in the right bucket so scratch and reference material can't bloat a deploy:
7104
+ Deploy is opt-in, not opt-out: the \`files\` phase uploads **only** what's under \`src/\` (plus \`functions/\` and \`migrations/\` as backend, not CDN files). Anything else at the project root is kept but never deployed. (A project with no \`src/\` fails the files deploy with \`no src/ directory\`; every template creates it.) Put each kind of file in the right bucket so scratch and reference material can't bloat a deploy:
7103
7105
 
7104
7106
  - **\`src/\`** - the app itself. Synced **and** deployed to the CDN. Only app code, assets, and pages belong here.
7105
7107
  - **\`tmp/\`** - ephemeral scratch: file conversions, intermediate outputs, design staging. **Already ignored** (never synced, never deployed) - the one place to do throwaway work. Use this single root. Leave scratch files where they are when you're done; there's nothing to clean up (no \`rm\` turn) - they're invisible to sync and deploy. (\`*_tmp/\` dirs and \`.gipityscratch/\` are auto-ignored too, as a safety net, so legacy scattered scratch like \`_vsd_tmp/\` can't leak - but write new scratch to \`tmp/\`, not scattered dirs.) Because it never syncs, \`tmp/\` is also never mirrored into the sandbox: **don't stage \`gipity sandbox run\` inputs here** - the sandbox won't see them. Stage inputs under \`src/\`/\`docs/\` and delete them after.
@@ -7124,7 +7126,7 @@ App services skills (load before calling \`/services/*\` endpoints):
7124
7126
  - \`app-notify\` - web push notifications for deployed apps (incl. iOS home-screen web apps) - notify kit + injected notify() service, platform owns the keys
7125
7127
  - \`app-payments\` - charge end-users real money - Stripe one-time purchases & subscriptions, via the stripe kit (gipity add stripe)
7126
7128
  - \`app-realtime\` - Gipity Realtime rooms, relay vs state
7127
- - \`app-tts\` - voices, multi-speaker, languages
7129
+ - \`app-tts\` - voices, models, dialogue, languages, word timestamps
7128
7130
  - \`app-video\` - Gipity Video: models, aspect, resolution
7129
7131
 
7130
7132
  App development skills:
@@ -34561,25 +34563,25 @@ init_colors();
34561
34563
  function newAccountWouldBeUnexpected(email, priorAuth) {
34562
34564
  return !!getConfig() || priorAuth?.email.toLowerCase() === email.toLowerCase().trim();
34563
34565
  }
34564
- function warnBeforeCodeIfUnexpectedNewAccount(isNewUser, email, indent = "") {
34566
+ function warnBeforeCodeIfUnexpectedNewAccount(isNewUser, email, indent = "", log3 = console.log) {
34565
34567
  if (isNewUser !== true) return;
34566
34568
  const priorAuth = getAuth();
34567
34569
  if (!newAccountWouldBeUnexpected(email, priorAuth)) return;
34568
34570
  const config = getConfig();
34569
- console.log(`${indent}${warning(`No existing Gipity account for ${email}: entering the code will CREATE a new one.`)}`);
34571
+ log3(`${indent}${warning(`No existing Gipity account for ${email}: entering the code will CREATE a new one.`)}`);
34570
34572
  if (config) {
34571
- console.log(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}). If you meant to log into that account, stop and re-check the email before entering the code.`)}`);
34573
+ log3(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}). If you meant to log into that account, stop and re-check the email before entering the code.`)}`);
34572
34574
  }
34573
34575
  }
34574
- function warnIfUnexpectedNewAccount(isNewUser, email, priorAuth, indent = "") {
34576
+ function warnIfUnexpectedNewAccount(isNewUser, email, priorAuth, indent = "", log3 = console.log) {
34575
34577
  if (isNewUser !== true) return;
34576
34578
  if (!newAccountWouldBeUnexpected(email, priorAuth)) return;
34577
34579
  const config = getConfig();
34578
- console.log(`${indent}${warning(`Logged into a NEW, empty account for ${email}: no prior account existed for this email.`)}`);
34580
+ log3(`${indent}${warning(`Logged into a NEW, empty account for ${email}: no prior account existed for this email.`)}`);
34579
34581
  if (config) {
34580
- console.log(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}), which the new account does not own: project / skill / sync commands will fail with "not found".`)}`);
34582
+ log3(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}), which the new account does not own: project / skill / sync commands will fail with "not found".`)}`);
34581
34583
  }
34582
- console.log(`${indent}${muted("If you expected an existing account, run gipity status, then gipity login again with the correct email.")}`);
34584
+ log3(`${indent}${muted("If you expected an existing account, run gipity status, then gipity login again with the correct email.")}`);
34583
34585
  }
34584
34586
  async function interactiveLogin() {
34585
34587
  const email = await prompt(" Email: ");
@@ -34617,41 +34619,49 @@ async function interactiveLogin() {
34617
34619
  }
34618
34620
 
34619
34621
  // src/commands/login.ts
34620
- var loginCommand = new Command("login").description("Log in or sign up").option("--email <email>", "Email address").option("--code <code>", "Verification code").action(async (opts) => {
34622
+ var loginCommand = new Command("login").description("Log in or sign up").option("--email <email>", "Email address").option("--code <code>", "Verification code").option("--json", "Output as JSON (prompts and warnings go to stderr)").action(async (opts) => {
34623
+ const json = !!opts.json;
34624
+ const say = json ? (line) => console.error(line) : (line) => console.log(line);
34625
+ const promptOut = json ? process.stderr : process.stdout;
34621
34626
  try {
34622
34627
  let email = opts.email;
34623
34628
  let code = opts.code;
34624
34629
  if (email && code) {
34625
- await verify(email, code);
34630
+ await verify(email, code, json, say);
34626
34631
  return;
34627
34632
  }
34628
34633
  if (email && !code) {
34629
34634
  const sendRes2 = await publicPost("/auth/login", { email });
34630
- console.log("Check your email for a 6-digit code.");
34631
- console.log(muted(`Then run: gipity login --email ${email} --code <code>`));
34632
- warnBeforeCodeIfUnexpectedNewAccount(sendRes2.isNewUser, email);
34635
+ const next = `gipity login --email ${email} --code <code>`;
34636
+ if (json) {
34637
+ console.log(JSON.stringify({ codeSent: true, email, newAccount: sendRes2.isNewUser === true, next }));
34638
+ } else {
34639
+ console.log("Check your email for a 6-digit code.");
34640
+ console.log(muted(`Then run: ${next}`));
34641
+ }
34642
+ warnBeforeCodeIfUnexpectedNewAccount(sendRes2.isNewUser, email, "", say);
34633
34643
  return;
34634
34644
  }
34635
- console.log("Enter your email to log in or create an account.");
34645
+ say("Enter your email to log in or create an account.");
34636
34646
  const existing = getAuth();
34637
- email = await prompt(existing ? `Email [${existing.email}]: ` : "Email: ");
34647
+ email = await prompt(existing ? `Email [${existing.email}]: ` : "Email: ", promptOut);
34638
34648
  if (!email && existing) email = existing.email;
34639
34649
  if (!email) {
34640
34650
  console.error(error("Email required."));
34641
34651
  process.exit(1);
34642
34652
  }
34643
34653
  const sendRes = await publicPost("/auth/login", { email });
34644
- console.log("");
34645
- console.log("Check your email for a 6-digit code.");
34646
- warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email);
34647
- code = await prompt("Code: ");
34648
- await verify(email, code);
34654
+ say("");
34655
+ say("Check your email for a 6-digit code.");
34656
+ warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email, "", say);
34657
+ code = await prompt("Code: ", promptOut);
34658
+ await verify(email, code, json, say);
34649
34659
  } catch (err) {
34650
34660
  console.error(error(`Login failed: ${err.message}`));
34651
34661
  process.exit(1);
34652
34662
  }
34653
34663
  });
34654
- async function verify(email, code) {
34664
+ async function verify(email, code, json, say) {
34655
34665
  const priorAuth = getAuth();
34656
34666
  const res = await publicPost("/auth/verify", { email, code });
34657
34667
  const exp = decodeJwtExp(res.accessToken);
@@ -34666,9 +34676,13 @@ async function verify(email, code) {
34666
34676
  email,
34667
34677
  expiresAt
34668
34678
  });
34669
- console.log(success(`Logged in (${email}).`));
34670
- warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth);
34679
+ if (!json) console.log(success(`Logged in (${email}).`));
34680
+ warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth, "", say);
34671
34681
  const delivered = await flushBugQueue().catch(() => 0);
34682
+ if (json) {
34683
+ console.log(JSON.stringify({ loggedIn: true, email, newAccount: res.isNewUser === true, expiresAt, queuedBugReportsDelivered: delivered }));
34684
+ return;
34685
+ }
34672
34686
  if (delivered > 0) {
34673
34687
  console.log(muted(`Delivered ${delivered} queued bug report${delivered === 1 ? "" : "s"}.`));
34674
34688
  }
@@ -34677,14 +34691,14 @@ async function verify(email, code) {
34677
34691
  // src/commands/logout.ts
34678
34692
  init_auth();
34679
34693
  init_colors();
34680
- var logoutCommand = new Command("logout").description("Log out").action(() => {
34694
+ var logoutCommand = new Command("logout").description("Log out").option("--json", "Output as JSON").action((opts) => {
34681
34695
  const auth = getAuth();
34682
- if (!auth) {
34683
- console.log("Not logged in.");
34684
- } else {
34685
- clearAuth();
34686
- console.log(success(`Logged out (${auth.email}).`));
34696
+ if (auth) clearAuth();
34697
+ if (opts.json) {
34698
+ console.log(JSON.stringify({ loggedOut: !!auth, email: auth?.email ?? null }));
34699
+ return;
34687
34700
  }
34701
+ console.log(auth ? success(`Logged out (${auth.email}).`) : "Not logged in.");
34688
34702
  });
34689
34703
 
34690
34704
  // src/commands/token.ts
@@ -35061,7 +35075,8 @@ function readBaseline(projectGuid2) {
35061
35075
  projectGuid: projectGuid2,
35062
35076
  files: parsed.files ?? {},
35063
35077
  lastFullSync: parsed.lastFullSync ?? null,
35064
- ...parsed.deletesSkippedStreak ? { deletesSkippedStreak: parsed.deletesSkippedStreak } : {}
35078
+ ...parsed.deletesSkippedStreak ? { deletesSkippedStreak: parsed.deletesSkippedStreak } : {},
35079
+ ...parsed.appUploads?.length ? { appUploads: parsed.appUploads } : {}
35065
35080
  };
35066
35081
  } catch {
35067
35082
  return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
@@ -35140,6 +35155,7 @@ function resolveInRoot(root, relPath) {
35140
35155
  async function fetchRemote(projectGuid2) {
35141
35156
  const res = await get(`/projects/${projectGuid2}/files/tree`);
35142
35157
  const out = /* @__PURE__ */ new Map();
35158
+ const appUploads = new Set((res.appUploads ?? []).map(normalizeTreePath));
35143
35159
  for (const f of res.data) {
35144
35160
  if (f.type !== "file") continue;
35145
35161
  const path5 = normalizeTreePath(f.path);
@@ -35151,7 +35167,7 @@ async function fetchRemote(projectGuid2) {
35151
35167
  modified: f.modified
35152
35168
  });
35153
35169
  }
35154
- return out;
35170
+ return { files: out, appUploads };
35155
35171
  }
35156
35172
  function extractTarToMap(stream, idleMs, onBytes, keep) {
35157
35173
  const extract3 = tar2.extract();
@@ -35398,6 +35414,18 @@ function formatPlan(p) {
35398
35414
  for (const a of p.actions) lines.push(formatAction(a));
35399
35415
  return lines.join("\n");
35400
35416
  }
35417
+ function appUploadNote(leftLocal) {
35418
+ const n = leftLocal.length;
35419
+ if (!n) return "";
35420
+ const first = leftLocal[0];
35421
+ const where = first.includes("/") ? `${first.split("/")[0]}/` : first;
35422
+ return `${n} app upload${n === 1 ? "" : "s"} (files your app stored at runtime, e.g. in ${where}) ${n === 1 ? "is" : "are"} no longer synced: ${n === 1 ? "it stays" : "they stay"} in Gipity Storage. The local ${n === 1 ? "copy was" : "copies were"} left in place and ${n === 1 ? "is" : "are"} safe to delete.`;
35423
+ }
35424
+ function withAppUploadNote(summary, leftLocal) {
35425
+ const note = appUploadNote(leftLocal);
35426
+ return note ? `${summary}
35427
+ ${note}` : summary;
35428
+ }
35401
35429
  async function bulkDeleteGuard(p, knownFiles, opts) {
35402
35430
  const totalDeletes = p.deletesLocal + p.deletesRemote;
35403
35431
  if (totalDeletes === 0) return true;
@@ -35432,6 +35460,7 @@ function isLocalTreeClean() {
35432
35460
  const baseline = readBaseline(config.projectGuid);
35433
35461
  if (!baseline.lastFullSync) return false;
35434
35462
  const local = walkLocal(root, effectiveIgnore(root, config.ignore), baseline.files);
35463
+ for (const path5 of baseline.appUploads ?? []) local.delete(path5);
35435
35464
  const baselineFiles = baseline.files;
35436
35465
  if (local.size !== Object.keys(baselineFiles).length) return false;
35437
35466
  for (const [path5, info2] of local) {
@@ -35462,7 +35491,18 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35462
35491
  p?.phase("Scanning local files...");
35463
35492
  const local = walkLocal(root, ignore2, baseline.files);
35464
35493
  p?.phase("Checking Gipity for changes...");
35465
- const remote = await fetchRemote(projectGuid2);
35494
+ const { files: remote, appUploads } = await fetchRemote(projectGuid2);
35495
+ const appUploadsLeftLocal = [];
35496
+ const knownUploads = /* @__PURE__ */ new Set([...appUploads, ...(baseline.appUploads ?? []).filter((p7) => local.has(p7))]);
35497
+ for (const path5 of knownUploads) {
35498
+ if (baseline.files[path5]) {
35499
+ if (local.has(path5)) appUploadsLeftLocal.push(path5);
35500
+ delete baseline.files[path5];
35501
+ }
35502
+ local.delete(path5);
35503
+ }
35504
+ if (knownUploads.size) baseline.appUploads = [...knownUploads].sort();
35505
+ else delete baseline.appUploads;
35466
35506
  for (const path5 of [...remote.keys()]) {
35467
35507
  if (shouldIgnore(path5, ignore2)) remote.delete(path5);
35468
35508
  }
@@ -35481,8 +35521,9 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35481
35521
  applied: 0,
35482
35522
  skipped: 0,
35483
35523
  errors: [],
35484
- summary: formatPlan(planned),
35485
- deferredDeletes: 0
35524
+ summary: withAppUploadNote(formatPlan(planned), appUploadsLeftLocal),
35525
+ deferredDeletes: 0,
35526
+ appUploadsLeftLocal
35486
35527
  };
35487
35528
  }
35488
35529
  if (opts.confirmMerge && remote.size > 0 && // project already has files - a real merge target
@@ -35504,7 +35545,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35504
35545
  `Re-run with --yes to merge, or sync into an empty folder.`
35505
35546
  ].join("\n"),
35506
35547
  deferredDeletes: 0,
35507
- aborted: true
35548
+ aborted: true,
35549
+ appUploadsLeftLocal: []
35508
35550
  });
35509
35551
  if (getAutoConfirm()) {
35510
35552
  } else if (interactive) {
@@ -35944,8 +35986,9 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35944
35986
  applied,
35945
35987
  skipped: skippedByGuard,
35946
35988
  errors,
35947
- summary: formatPlan(planned),
35948
- deferredDeletes: skippedByGuard
35989
+ summary: withAppUploadNote(formatPlan(planned), appUploadsLeftLocal),
35990
+ deferredDeletes: skippedByGuard,
35991
+ appUploadsLeftLocal
35949
35992
  };
35950
35993
  }
35951
35994
  function cleanupEmptyDirs(root, emptiedDirs) {
@@ -35973,15 +36016,16 @@ async function pushFile(filePath) {
35973
36016
  const config = requireConfig2();
35974
36017
  const root = projectDir();
35975
36018
  const rel2 = relative(root, filePath).replace(/\\/g, "/");
35976
- if (shouldIgnore(rel2, effectiveIgnore(root, config.ignore))) return;
36019
+ if (shouldIgnore(rel2, effectiveIgnore(root, config.ignore))) return false;
35977
36020
  try {
35978
- if (lstatSync(filePath).isSymbolicLink()) return;
36021
+ if (lstatSync(filePath).isSymbolicLink()) return false;
35979
36022
  } catch {
35980
- return;
36023
+ return false;
35981
36024
  }
35982
36025
  const releaseLock = await acquireLock();
35983
36026
  try {
35984
36027
  const baseline = readBaseline(config.projectGuid);
36028
+ if (baseline.appUploads?.includes(rel2)) return false;
35985
36029
  const baseEntry = baseline.files[rel2];
35986
36030
  const result = await uploadOneFile(config.projectGuid, filePath, rel2, {
35987
36031
  expectedServerVersion: baseEntry ? baseEntry.serverVersion : null
@@ -35995,6 +36039,7 @@ async function pushFile(filePath) {
35995
36039
  serverVersion: result.serverVersion
35996
36040
  };
35997
36041
  writeBaseline(baseline);
36042
+ return true;
35998
36043
  } catch (err) {
35999
36044
  if (err instanceof UploadConflictError) {
36000
36045
  throw new Error(
@@ -36173,6 +36218,8 @@ async function syncBeforeAction(opts) {
36173
36218
  if (result.applied > 0 && !opts.json) {
36174
36219
  console.log(muted(`Synced ${result.applied} change${result.applied > 1 ? "s" : ""}`));
36175
36220
  }
36221
+ const note = appUploadNote(result.appUploadsLeftLocal);
36222
+ if (note && !opts.json) console.log(muted(note));
36176
36223
  if (result.errors.length > 0 && !opts.json) {
36177
36224
  for (const e of result.errors) console.error(error(`[sync] ${e}`));
36178
36225
  }
@@ -37351,18 +37398,18 @@ function resolveTools(forFlag) {
37351
37398
  (t) => requested.includes(t.key) || !t.optIn && requested.includes("all")
37352
37399
  );
37353
37400
  }
37354
- async function pairForCapture() {
37401
+ async function pairForCapture(log3) {
37355
37402
  try {
37356
37403
  await ensureDevicePaired();
37357
37404
  } catch (err) {
37358
- console.log(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
37405
+ log3(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
37359
37406
  }
37360
37407
  }
37361
37408
  var initCommand = new Command("init").description("Link this directory to a project").addHelpText("after", `
37362
37409
  Writes CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks. By default it only sets up the tools actually installed here (${AGENT_ADAPTERS.map((a) => a.displayName).join(", ")}, ...) - use --for to choose explicitly.`).argument("[name]", "Project name/slug (defaults to current directory name)").option("--capture", "Record Claude Code sessions in this directory to your Gipity project (sets captureHooks: true in .gipity.json; new projects start with it off)").option("--no-capture", "Stop recording sessions in this directory (sets captureHooks: false in .gipity.json)").option(
37363
37410
  "--for <tools>",
37364
37411
  `Which AI tool primer files to write (comma-separated). Default: the tools detected on this machine. An explicit --for is remembered in .gipity.json, so later commands don't re-add the others. Choices: ${TOOL_KEYS.join(", ")}, all`
37365
- ).addHelpText("after", `
37412
+ ).option("--json", "Output a structured result as JSON (confirmations need -y; notes go to stderr)").addHelpText("after", `
37366
37413
  Examples:
37367
37414
  $ gipity init Link cwd as a new project (slug = dir name);
37368
37415
  sets up the tools installed on this machine.
@@ -37384,6 +37431,21 @@ Working with an existing Gipity project:
37384
37431
  $ gipity project <slug> Switch this dir's linked project.
37385
37432
  $ gipity sync Pull the project's files down.
37386
37433
  `).action(async (name, opts) => {
37434
+ const json = !!opts.json;
37435
+ const say = (line) => {
37436
+ if (!json) console.log(line);
37437
+ };
37438
+ const note = (line) => {
37439
+ (json ? console.error : console.log)(line);
37440
+ };
37441
+ const ask = async (question, def) => {
37442
+ if (!json) return confirm(question, { default: def });
37443
+ if (getAutoConfirm()) return true;
37444
+ console.error(error(`Confirmation required in --json mode: ${question}`));
37445
+ console.error(`Re-run with --yes:
37446
+ ${rerunWithYes()}`);
37447
+ process.exit(1);
37448
+ };
37387
37449
  let tools;
37388
37450
  try {
37389
37451
  tools = resolveTools(opts.for);
@@ -37404,7 +37466,7 @@ Working with an existing Gipity project:
37404
37466
  const cwd = process.cwd();
37405
37467
  if (existsSync11(resolve8(cwd, ".gipity.json"))) {
37406
37468
  const existing = getConfig();
37407
- console.log(`Already linked to ${info(`"${existing?.projectSlug ?? ""}"`)} ${muted(`(${existing?.projectGuid ?? ""})`)}`);
37469
+ say(`Already linked to ${info(`"${existing?.projectSlug ?? ""}"`)} ${muted(`(${existing?.projectGuid ?? ""})`)}`);
37408
37470
  setupProjectTools(tools);
37409
37471
  if (existing) {
37410
37472
  let changed = false;
@@ -37425,11 +37487,26 @@ Working with an existing Gipity project:
37425
37487
  }
37426
37488
  if (changed) saveConfigAt(cwd, existing);
37427
37489
  }
37428
- console.log(success(`Refreshed primer files: ${primerSummary}.`));
37429
- if (skippedNote) console.log(skippedNote);
37490
+ if (json) {
37491
+ if (opts.capture) await pairForCapture(note);
37492
+ console.log(JSON.stringify({
37493
+ linked: true,
37494
+ alreadyLinked: true,
37495
+ created: false,
37496
+ project: { guid: existing?.projectGuid ?? null, slug: existing?.projectSlug ?? null },
37497
+ dir: cwd,
37498
+ synced: 0,
37499
+ primers: tools.map((t) => t.key),
37500
+ skippedTools: skipped.map((t) => t.key),
37501
+ captureHooks: captureEnabled(existing ?? null)
37502
+ }));
37503
+ return;
37504
+ }
37505
+ say(success(`Refreshed primer files: ${primerSummary}.`));
37506
+ if (skippedNote) say(skippedNote);
37430
37507
  if (opts.capture !== void 0) {
37431
- if (opts.capture) await pairForCapture();
37432
- console.log(success(`Session recording ${opts.capture ? "enabled" : "disabled"} for this project (captureHooks: ${opts.capture} in .gipity.json).`));
37508
+ if (opts.capture) await pairForCapture(note);
37509
+ say(success(`Session recording ${opts.capture ? "enabled" : "disabled"} for this project (captureHooks: ${opts.capture} in .gipity.json).`));
37433
37510
  }
37434
37511
  return;
37435
37512
  }
@@ -37440,13 +37517,10 @@ Working with an existing Gipity project:
37440
37517
  }
37441
37518
  const ancestorConfigPath = getConfigPath();
37442
37519
  if (ancestorConfigPath) {
37443
- console.log(muted(`Note: ${formatCwdLabel(dirname8(ancestorConfigPath))} is already a Gipity project.`));
37444
- const ok = await confirm(
37445
- `Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`,
37446
- { default: "no" }
37447
- );
37520
+ note(muted(`Note: ${formatCwdLabel(dirname8(ancestorConfigPath))} is already a Gipity project.`));
37521
+ const ok = await ask(`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`, "no");
37448
37522
  if (!ok) {
37449
- console.log(muted("Aborted."));
37523
+ say(muted("Aborted."));
37450
37524
  process.exit(1);
37451
37525
  }
37452
37526
  }
@@ -37465,12 +37539,9 @@ Working with an existing Gipity project:
37465
37539
  process.exit(1);
37466
37540
  }
37467
37541
  if (scan.tier === "moderate") {
37468
- const ok = await confirm(
37469
- `About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`,
37470
- { default: "yes" }
37471
- );
37542
+ const ok = await ask(`About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`, "yes");
37472
37543
  if (!ok) {
37473
- console.log(muted("Aborted."));
37544
+ say(muted("Aborted."));
37474
37545
  process.exit(1);
37475
37546
  }
37476
37547
  }
@@ -37480,15 +37551,17 @@ Working with an existing Gipity project:
37480
37551
  projectName,
37481
37552
  projectSlug,
37482
37553
  accountSlug,
37483
- confirmDeletions: true,
37554
+ // No y/N on stdout in JSON mode: a non-interactive sync fails safe
37555
+ // (aborts rather than deleting) instead of asking.
37556
+ confirmDeletions: !json,
37484
37557
  tools
37485
37558
  });
37486
37559
  if (adopted.isNew) {
37487
- console.log(success(`Created project "${adopted.project.name}" (${adopted.project.slug})`));
37560
+ say(success(`Created project "${adopted.project.name}" (${adopted.project.slug})`));
37488
37561
  } else {
37489
- console.log(`Found existing project ${info(`"${adopted.project.name}"`)} ${muted(`(${adopted.project.slug})`)}`);
37562
+ say(`Found existing project ${info(`"${adopted.project.name}"`)} ${muted(`(${adopted.project.slug})`)}`);
37490
37563
  }
37491
- if (adopted.applied > 0) console.log(`Synced ${adopted.applied} change${adopted.applied > 1 ? "s" : ""} with Gipity.`);
37564
+ if (adopted.applied > 0) say(`Synced ${adopted.applied} change${adopted.applied > 1 ? "s" : ""} with Gipity.`);
37492
37565
  const pinnedFresh = pinnedToolKeys(opts.for, tools);
37493
37566
  if (opts.capture !== void 0 || pinnedFresh) {
37494
37567
  try {
@@ -37499,15 +37572,30 @@ Working with an existing Gipity project:
37499
37572
  } catch {
37500
37573
  }
37501
37574
  }
37502
- if (opts.capture) await pairForCapture();
37503
- console.log(success(`Wrote primer files: ${primerSummary}.`));
37504
- if (skippedNote) console.log(skippedNote);
37575
+ if (opts.capture) await pairForCapture(note);
37576
+ if (json) {
37577
+ const cfg = JSON.parse(readFileSync13(resolve8(cwd, ".gipity.json"), "utf-8"));
37578
+ console.log(JSON.stringify({
37579
+ linked: true,
37580
+ alreadyLinked: false,
37581
+ created: adopted.isNew,
37582
+ project: { guid: adopted.project.short_guid, slug: adopted.project.slug, name: adopted.project.name },
37583
+ dir: cwd,
37584
+ synced: adopted.applied,
37585
+ primers: tools.map((t) => t.key),
37586
+ skippedTools: skipped.map((t) => t.key),
37587
+ captureHooks: captureEnabled(cfg)
37588
+ }));
37589
+ return;
37590
+ }
37591
+ say(success(`Wrote primer files: ${primerSummary}.`));
37592
+ if (skippedNote) say(skippedNote);
37505
37593
  if (wantsClaude) {
37506
- console.log(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map((a) => a.key).join(", ")}), or \`gipity build\` to launch one with a picker.`));
37594
+ say(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map((a) => a.key).join(", ")}), or \`gipity build\` to launch one with a picker.`));
37507
37595
  const recording = JSON.parse(readFileSync13(resolve8(cwd, ".gipity.json"), "utf-8")).captureHooks !== false;
37508
- console.log(muted(recording ? "Claude Code sessions here are recorded to your Gipity project (Chats in your Gipity dashboard). Turn off: gipity init --no-capture." : "Claude Code sessions here are not recorded. To keep them in your Gipity project (Chats in your dashboard): gipity init --capture."));
37596
+ say(muted(recording ? "Claude Code sessions here are recorded to your Gipity project (Chats in your Gipity dashboard). Turn off: gipity init --no-capture." : "Claude Code sessions here are not recorded. To keep them in your Gipity project (Chats in your dashboard): gipity init --capture."));
37509
37597
  } else {
37510
- console.log(success("Ready! Open this directory in your AI coding tool."));
37598
+ say(success("Ready! Open this directory in your AI coding tool."));
37511
37599
  }
37512
37600
  } catch (err) {
37513
37601
  const msg = err?.message ?? String(err);
@@ -37697,7 +37785,7 @@ ${result.deferredDeletes} file${result.deferredDeletes > 1 ? "s" : ""} on Gipity
37697
37785
  // src/commands/push.ts
37698
37786
  import { resolve as resolve10 } from "path";
37699
37787
  init_colors();
37700
- var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").action(async (files, opts) => {
37788
+ var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").option("--json", "Output as JSON").action(async (files, opts) => {
37701
37789
  try {
37702
37790
  const fullPaths = files.map((f) => resolve10(f));
37703
37791
  if (opts.background) {
@@ -37707,12 +37795,17 @@ var pushCommand = new Command("push").description("Push one or more files").argu
37707
37795
  stdio: "ignore"
37708
37796
  });
37709
37797
  child.unref();
37798
+ if (opts.json) console.log(JSON.stringify({ background: true, files }));
37710
37799
  return;
37711
37800
  }
37712
- for (const fullPath of fullPaths) {
37713
- await pushFile(fullPath);
37801
+ const pushed = [];
37802
+ const skipped = [];
37803
+ for (let i = 0; i < fullPaths.length; i++) {
37804
+ (await pushFile(fullPaths[i]) ? pushed : skipped).push(files[i]);
37714
37805
  }
37715
- if (!opts.quiet) {
37806
+ if (opts.json) {
37807
+ console.log(JSON.stringify({ pushed, skipped }));
37808
+ } else if (!opts.quiet) {
37716
37809
  console.log(success(files.length === 1 ? `Pushed ${files[0]}` : `Pushed ${files.length} files`));
37717
37810
  }
37718
37811
  } catch (err) {
@@ -40654,9 +40747,10 @@ syncs; ideal for throwaway test fixtures (delete the file to revoke the link).
40654
40747
  }));
40655
40748
  fileCommand.command("tree [path]").description("Show the file tree").option("--json", "Output as JSON").action((path5, opts) => run("Tree", async () => {
40656
40749
  const { config } = await resolveProjectContext();
40657
- const query = path5 ? `?path=${encodeURIComponent(path5)}` : "";
40750
+ const qs = new URLSearchParams({ include: "app_uploads" });
40751
+ if (path5) qs.set("path", path5);
40658
40752
  const res = await get(
40659
- `/projects/${config.projectGuid}/files/tree${query}`
40753
+ `/projects/${config.projectGuid}/files/tree?${qs.toString()}`
40660
40754
  );
40661
40755
  printList(res.data, opts, "(empty)", (f) => {
40662
40756
  const size = f.type === "dir" ? "" : ` (${formatSize(Number(f.size))})`;
@@ -42769,7 +42863,7 @@ var loadCommand = new Command("load").description("Create a new app from a .gip
42769
42863
  console.warn(warning("The project was still created and linked; the files above are missing from it."));
42770
42864
  }
42771
42865
  console.log("");
42772
- console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy")}`);
42866
+ console.log(`${muted("Next:")} cd ${dir} && ${brand("gipity deploy dev")}`);
42773
42867
  }));
42774
42868
 
42775
42869
  // src/commands/logs.ts
@@ -43436,10 +43530,10 @@ recordsCommand.command("list").description("List record tables").option("--json"
43436
43530
  (t) => `${bold(t.table_name)} ${muted(t.auth_level)} ${muted(`pk=${t.primary_key_column}`)} ${muted(`db=${t.database_name}`)}`
43437
43531
  );
43438
43532
  }));
43439
- recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, etc.)").addOption(new Option("--auth <level>", "Auth level: public (anonymous writes), member (sign-in), or user").choices(["public", "member", "user"])).option("--searchable <bool>", "Enable full-text search (true/false)").option("--primary-key <col>", "Primary key column (default: id)").option("--soft-delete <col>", 'Soft-delete column (pass "none" to clear)').option("--json", "Output as JSON").action((table, opts) => run("Config", async () => {
43533
+ recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, auto-numbering, etc.)").addOption(new Option("--auth <level>", "Auth level: public (anonymous writes), user (any signed-in caller), or member (owner and project members only)").choices(["public", "member", "user"])).option("--searchable <bool>", "Enable full-text search (true/false)").option("--primary-key <col>", "Primary key column (default: id)").option("--soft-delete <col>", 'Soft-delete column (pass "none" to clear)').option("--auto-number <prefix>", 'Number new records automatically, e.g. INC -> INC0001001 (pass "none" to turn off). Same as auto_number in gipity.yaml').option("--auto-number-pad <n>", "Zero-pad width of the auto-number (default 7)").option("--auto-number-column <col>", "Column the auto-number is written to (default: number)").option("--json", "Output as JSON").action((table, opts) => run("Config", async () => {
43440
43534
  const config = requireConfig2();
43441
43535
  const base = `/api/${config.projectGuid}/records/${table}/config`;
43442
- const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete;
43536
+ const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete || opts.autoNumber || opts.autoNumberPad || opts.autoNumberColumn;
43443
43537
  if (!setting) {
43444
43538
  const res2 = await get(base);
43445
43539
  printResult(JSON.stringify(res2.data, null, 2), opts, res2.data);
@@ -43450,11 +43544,20 @@ recordsCommand.command("config <table>").description("Show or set a table's Reco
43450
43544
  if (opts.searchable !== void 0) body.searchable = /^(true|1|on|yes)$/i.test(String(opts.searchable));
43451
43545
  if (opts.primaryKey) body.primary_key_column = opts.primaryKey;
43452
43546
  if (opts.softDelete) body.soft_delete_column = opts.softDelete === "none" ? null : opts.softDelete;
43547
+ if (opts.autoNumber) body.auto_number_prefix = opts.autoNumber === "none" ? null : opts.autoNumber;
43548
+ if (opts.autoNumberPad) {
43549
+ const pad = Number(opts.autoNumberPad);
43550
+ if (!Number.isInteger(pad)) throw new Error(`--auto-number-pad must be a whole number (got '${opts.autoNumberPad}')`);
43551
+ body.auto_number_pad = pad;
43552
+ }
43553
+ if (opts.autoNumberColumn) body.auto_number_column = opts.autoNumberColumn;
43453
43554
  const res = await patch(base, body);
43555
+ const d = res.data;
43556
+ const autoNumber = d.auto_number_prefix ? `${d.auto_number_prefix} (pad ${d.auto_number_pad}, column ${d.auto_number_column})` : "off";
43454
43557
  printResult(
43455
- `Configured "${table}": auth=${res.data.auth_level}, searchable=${res.data.searchable}, pk=${res.data.primary_key_column}`,
43558
+ `Configured "${table}": auth=${d.auth_level}, searchable=${d.searchable}, pk=${d.primary_key_column}, auto-number=${autoNumber}`,
43456
43559
  opts,
43457
- res.data
43560
+ d
43458
43561
  );
43459
43562
  }));
43460
43563
  recordsCommand.command("query <table>").description("List records (full-text search, filter, sort, recycle bin)").option("-q, --q <text>", "Full-text search across the table's text columns (needs `--searchable true` on the table)").option("--filter <filter>", 'AND filter string, "col:op:value" comma-joined. Ops: eq, neq, gt, gte, lt, lte, like, ilike, in (pipe-separated values), is_null, not_null. Full grammar: gipity skill read app-records').option("--any <filter>", 'OR filter group, same grammar and ops as --filter (e.g., "owner:eq:me,shared:eq:true")').option("--sort <sort>", 'Sort string (e.g., "created_at:desc")').option("--limit <n>", "Max rows", "20").option("--offset <n>", "Offset", "0").option("--fields <fields>", "Comma-separated column names").option("--include-deleted", "Include soft-deleted rows (owner/editor)").option("--only-deleted", "Only soft-deleted rows - the recycle bin (owner/editor)").option(ANON_FLAG, ANON_HELP).option("--json", "Output as JSON").action((table, opts) => run("Query", async () => {
@@ -44210,7 +44313,7 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
44210
44313
  console.log(`${success("cancelled")} ${muted(runGuid)}`);
44211
44314
  }
44212
44315
  }));
44213
- jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").action(async (name, opts) => {
44316
+ jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").option("--json", "Capture the job's output and print one JSON result (exitCode, stdout, stderr) instead of streaming it").action(async (name, opts) => {
44214
44317
  const { existsSync: existsSync27, statSync: statSync12 } = await import("node:fs");
44215
44318
  const { resolve: resolve19, join: join32 } = await import("node:path");
44216
44319
  const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
@@ -44271,12 +44374,34 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
44271
44374
  shellCmd = `echo '[run-local] running ${handlerCmd} (${picked.runtime})' >&2 && exec ${handlerCmd}`;
44272
44375
  }
44273
44376
  const runArgs = ["run", ...sharedArgs, "--entrypoint", "sh", opts.image, "-c", shellCmd];
44274
- const child = spawnCommand2("docker", runArgs, { stdio: "inherit" });
44377
+ const startedAt = Date.now();
44378
+ const child = spawnCommand2("docker", runArgs, { stdio: opts.json ? ["ignore", "pipe", "pipe"] : "inherit" });
44379
+ const captured = { stdout: "", stderr: "" };
44380
+ if (opts.json) {
44381
+ child.stdout?.on("data", (d) => {
44382
+ captured.stdout += d.toString();
44383
+ });
44384
+ child.stderr?.on("data", (d) => {
44385
+ captured.stderr += d.toString();
44386
+ });
44387
+ }
44275
44388
  child.on("error", (err) => {
44276
44389
  console.error(error(err.code === "ENOENT" ? "Docker not found. Install Docker to use `gipity job run-local`." : `Failed to launch docker: ${err.message}`));
44277
44390
  process.exit(1);
44278
44391
  });
44279
- child.on("exit", (code) => {
44392
+ child.on("close", (code) => {
44393
+ if (opts.json) {
44394
+ console.log(JSON.stringify({
44395
+ name,
44396
+ runtime: picked.runtime,
44397
+ image: opts.image,
44398
+ exitCode: code,
44399
+ durationMs: Date.now() - startedAt,
44400
+ stdout: captured.stdout,
44401
+ stderr: captured.stderr
44402
+ }));
44403
+ process.exit(code ?? 1);
44404
+ }
44280
44405
  if (code === 0) console.error(muted(`[run-local] ${success("done")}`));
44281
44406
  else console.error(muted(`[run-local] ${error("failed")} (exit ${code})`));
44282
44407
  process.exit(code ?? 1);
@@ -44312,7 +44437,7 @@ rbacCommand.command("create <table>").description("Create or update a policy").r
44312
44437
  const res = await post(`/projects/${config.projectGuid}/rbac`, body);
44313
44438
  printResult("Policy created.", opts, res.data);
44314
44439
  }));
44315
- rbacCommand.command("delete <table>").description("Delete a policy").requiredOption("--role <role>", "Role").requiredOption("--op <operation>", "Operation").action((table, opts) => run("Delete", async () => {
44440
+ rbacCommand.command("delete <table>").description("Delete a policy").requiredOption("--role <role>", "Role").requiredOption("--op <operation>", "Operation").option("--json", "Output as JSON").action((table, opts) => run("Delete", async () => {
44316
44441
  if (!await confirm(`Delete RBAC policy for "${table}"?`)) {
44317
44442
  console.log("Cancelled.");
44318
44443
  return;
@@ -44323,7 +44448,7 @@ rbacCommand.command("delete <table>").description("Delete a policy").requiredOpt
44323
44448
  role: opts.role,
44324
44449
  operation: opts.op
44325
44450
  });
44326
- printResult("Policy deleted.", { json: false });
44451
+ printResult("Policy deleted.", opts, { success: true, table, role: opts.role, operation: opts.op });
44327
44452
  }));
44328
44453
 
44329
44454
  // src/commands/audit.ts
@@ -44459,7 +44584,7 @@ var IMAGE_TIER_ALIAS_IDS = [
44459
44584
  var TTS_PROVIDER_DESCRIPTIONS = {
44460
44585
  "elevenlabs": `ElevenLabs (many premium voices)`,
44461
44586
  "openai": `OpenAI (alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse)`,
44462
- "gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more). Multi-speaker (up to 2) and 60+ languages`
44587
+ "gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more). Two-voice dialogue (speakers) and an explicit language`
44463
44588
  };
44464
44589
  var TTS_PROVIDER_IDS = [
44465
44590
  "elevenlabs",
@@ -45230,7 +45355,7 @@ function hasDeployManifest() {
45230
45355
  if (!cfgPath) return false;
45231
45356
  return existsSync19(resolve14(dirname14(cfgPath), "gipity.yaml"));
45232
45357
  }
45233
- var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").addOption(new Option("--type <type>", "Room type for create").choices(["state", "relay"]).default("state")).addOption(new Option("--auth <level>", "Auth level for create").choices(["public", "user"]).default("public")).option("--max-clients <n>", "max clients for create (1-200)").option("--seat-hold <seconds>", "create: how long a dropped client keeps its seat (0-300, default 30)").option("--host-hold <seconds>", "create: how long the host role waits for a dropped or reloading host (0-600, default 60)").option("--host-handoff", "create: move the host role to another player when the host is gone").option("--host-grace <seconds>", "create: with handoff, how long the host may be unreachable before the role moves (1-60, default 5)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
45358
+ var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").addOption(new Option("--type <type>", "Room type for create").choices(["state", "relay"]).default("state")).addOption(new Option("--auth <level>", "Auth level for create").choices(["public", "user"]).default("public")).option("--max-clients <n>", "max clients for create (1-200)").option("--seat-hold <seconds>", "create: how long a dropped client keeps its seat (0-300, default 30)").option("--host-hold <seconds>", "create: how long the host role waits for a dropped or reloading host (0-600, default 60)").option("--host-handoff", "create: move the host role to another player when the host is gone").option("--host-grace <seconds>", "create: with handoff, how long the host may be unreachable before the role moves (1-60, default 5)").option("--server-channels <names>", "create: comma-separated channels only the app's functions may publish on (realtime.publish)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
45234
45359
  const config = requireConfig2();
45235
45360
  const base = `/projects/${config.projectGuid}/realtime-rooms`;
45236
45361
  const sub = (action || "list").toLowerCase();
@@ -45256,6 +45381,9 @@ var roomCommand = new Command("room").description("Manage realtime rooms").argum
45256
45381
  if (opts.hostHold !== void 0) body.host_hold_seconds = Number(opts.hostHold);
45257
45382
  if (opts.hostHandoff) body.host_handoff = true;
45258
45383
  if (opts.hostGrace !== void 0) body.host_grace_seconds = Number(opts.hostGrace);
45384
+ if (opts.serverChannels !== void 0) {
45385
+ body.server_channels = String(opts.serverChannels).split(",").map((c) => c.trim()).filter(Boolean);
45386
+ }
45259
45387
  const res = await post(base, body);
45260
45388
  if (opts.json) {
45261
45389
  console.log(JSON.stringify(res.data));
@@ -45301,6 +45429,8 @@ var roomCommand = new Command("room").description("Manage realtime rooms").argum
45301
45429
  console.log(`Max clients: ${room.max_clients}`);
45302
45430
  console.log(`Seat hold: ${room.config?.seat_hold_seconds ?? 30}s (host ${room.config?.host_hold_seconds ?? 60}s)`);
45303
45431
  console.log(`Handoff: ${room.config?.host_handoff ? `on, after ${room.config?.host_grace_seconds ?? 5}s` : "off"}`);
45432
+ const serverChannels = Array.isArray(room.config?.server_channels) ? room.config.server_channels : [];
45433
+ console.log(`Server-only: ${serverChannels.length ? serverChannels.join(", ") : "none"}`);
45304
45434
  console.log(`Live: ${live ? `${live.instances} instance(s), ${live.clients} client(s)` : muted("Gipity Realtime unreachable")}`);
45305
45435
  }
45306
45436
  break;
@@ -46069,9 +46199,20 @@ if (isDirect) {
46069
46199
 
46070
46200
  // src/commands/update.ts
46071
46201
  init_colors();
46072
- var updateCommand = new Command("update").description("Update the CLI").action(async () => {
46073
- console.log(info("Checking for updates..."));
46202
+ var updateCommand = new Command("update").description("Update the CLI").option("--json", "Output as JSON").action(async (opts) => {
46203
+ if (!opts.json) console.log(info("Checking for updates..."));
46074
46204
  const result = await runCheck({ force: true, verbose: true });
46205
+ if (opts.json) {
46206
+ console.log(JSON.stringify({
46207
+ updated: result.updated,
46208
+ upToDate: result.reason === "up-to-date",
46209
+ from: result.from ?? null,
46210
+ to: result.to ?? null,
46211
+ reason: result.updated || result.reason === "up-to-date" ? null : result.reason ?? null
46212
+ }));
46213
+ if (!result.updated && result.reason !== "up-to-date") process.exitCode = 1;
46214
+ return;
46215
+ }
46075
46216
  console.log("");
46076
46217
  if (result.updated) {
46077
46218
  console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
@@ -49441,73 +49582,94 @@ async function revokeDeviceBestEffort() {
49441
49582
  } catch {
49442
49583
  }
49443
49584
  }
49444
- var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
49585
+ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").option("--json", "Output a structured result as JSON (requires --yes)").action(async (opts) => {
49445
49586
  const autoYes = opts.yes || getAutoConfirm();
49587
+ if (opts.json && !autoYes) {
49588
+ console.error(error("uninstall --json needs --yes (there is no prompt in JSON mode)."));
49589
+ process.exit(1);
49590
+ }
49591
+ const say = (line) => {
49592
+ if (!opts.json) console.log(line);
49593
+ };
49446
49594
  const gipityDir = join30(homedir20(), ".gipity");
49447
49595
  const launcherBin = join30(gipityDir, "launcher", "bin", "gipity");
49448
49596
  const installedViaLauncher = existsSync26(launcherBin);
49449
- console.log(`${bold("Gipity uninstall")} - this will:`);
49450
- console.log(`\u2022 Stop the running relay daemon (if any)`);
49451
- console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
49452
- console.log(`\u2022 Revoke this device on the server (best-effort)`);
49453
- console.log(`\u2022 Remove the Gipity Claude Code plugin enablement (all Gipity hooks)`);
49454
- console.log(`\u2022 Delete ${gipityDir}/${installedViaLauncher ? dim(" (includes the gipity launcher binary itself)") : ""}`);
49455
- if (installedViaLauncher) console.log(`\u2022 Remove the launcher PATH line from your shell startup files`);
49456
- console.log("");
49597
+ say(`${bold("Gipity uninstall")} - this will:`);
49598
+ say(`\u2022 Stop the running relay daemon (if any)`);
49599
+ say(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
49600
+ say(`\u2022 Revoke this device on the server (best-effort)`);
49601
+ say(`\u2022 Remove the Gipity Claude Code plugin enablement (all Gipity hooks)`);
49602
+ say(`\u2022 Delete ${gipityDir}/${installedViaLauncher ? dim(" (includes the gipity launcher binary itself)") : ""}`);
49603
+ if (installedViaLauncher) say(`\u2022 Remove the launcher PATH line from your shell startup files`);
49604
+ say("");
49457
49605
  if (installedViaLauncher) {
49458
- console.log(`${dim("The `gipity` launcher lives under ~/.gipity, so this removes the binary too - no separate `npm uninstall` needed.")}`);
49606
+ say(`${dim("The `gipity` launcher lives under ~/.gipity, so this removes the binary too - no separate `npm uninstall` needed.")}`);
49459
49607
  } else {
49460
- console.log(`${dim("It will NOT remove the `gipity` binary. Run `npm uninstall -g gipity` afterward if you want that too.")}`);
49608
+ say(`${dim("It will NOT remove the `gipity` binary. Run `npm uninstall -g gipity` afterward if you want that too.")}`);
49461
49609
  }
49462
- console.log("");
49610
+ say("");
49463
49611
  if (!autoYes) {
49464
49612
  const ok = await confirm("Proceed?");
49465
49613
  if (!ok) {
49466
- console.log(`${muted("Cancelled.")}`);
49614
+ say(`${muted("Cancelled.")}`);
49467
49615
  return;
49468
49616
  }
49469
49617
  }
49470
49618
  await stopDaemon();
49471
- console.log(`${success("Daemon stopped.")}`);
49619
+ say(`${success("Daemon stopped.")}`);
49472
49620
  const svc = removeServiceUnit();
49473
- if (svc.ran && svc.ok) console.log(`${success("Autostart service removed.")} ${svc.note ? dim(`(${svc.note})`) : ""}`);
49474
- else if (svc.ran) console.log(`${muted("Autostart service not installed or already gone.")}`);
49475
- else console.log(`${muted(svc.note ?? "Autostart skipped.")}`);
49621
+ if (svc.ran && svc.ok) say(`${success("Autostart service removed.")} ${svc.note ? dim(`(${svc.note})`) : ""}`);
49622
+ else if (svc.ran) say(`${muted("Autostart service not installed or already gone.")}`);
49623
+ else say(`${muted(svc.note ?? "Autostart skipped.")}`);
49476
49624
  await revokeDeviceBestEffort();
49477
- console.log(`${success("Device revoked on server (or was already revoked).")}`);
49478
- let anyAgentIntegration = false;
49625
+ say(`${success("Device revoked on server (or was already revoked).")}`);
49626
+ const agentNotes = [];
49479
49627
  for (const agent of AGENT_ADAPTERS) {
49480
49628
  const note = agent.setup?.uninstall();
49481
49629
  if (note) {
49482
- console.log(`${success(note)}`);
49483
- anyAgentIntegration = true;
49630
+ say(`${success(note)}`);
49631
+ agentNotes.push(note);
49484
49632
  }
49485
49633
  }
49486
- if (!anyAgentIntegration) {
49487
- console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
49634
+ if (!agentNotes.length) {
49635
+ say(`${muted("No Gipity entries in any detected coding agent.")}`);
49488
49636
  }
49637
+ let gipityDirRemoved = false;
49489
49638
  if (existsSync26(gipityDir)) {
49490
49639
  try {
49491
49640
  rmSync4(gipityDir, { recursive: true, force: true });
49492
- console.log(`${success(`Removed ${gipityDir}/`)}`);
49641
+ gipityDirRemoved = true;
49642
+ say(`${success(`Removed ${gipityDir}/`)}`);
49493
49643
  } catch (err) {
49494
49644
  console.error(`${error(`Could not remove ${gipityDir}: ${err?.message || err}`)}`);
49495
49645
  }
49496
49646
  } else {
49497
- console.log(`${muted(`${gipityDir}/ already gone.`)}`);
49647
+ say(`${muted(`${gipityDir}/ already gone.`)}`);
49498
49648
  }
49499
49649
  const touchedRc = removeInstallerPathLines();
49650
+ if (opts.json) {
49651
+ console.log(JSON.stringify({
49652
+ success: true,
49653
+ autostartService: svc.ran ? svc.ok ? "removed" : "not_installed" : "skipped",
49654
+ agentIntegrationsRemoved: agentNotes,
49655
+ gipityDir,
49656
+ gipityDirRemoved,
49657
+ shellRcFilesUpdated: touchedRc,
49658
+ binaryRemoved: installedViaLauncher
49659
+ }));
49660
+ return;
49661
+ }
49500
49662
  if (touchedRc.length) {
49501
- console.log(`${success("Removed the launcher PATH line from")} ${dim(touchedRc.map(tildify2).join(", "))}`);
49663
+ say(`${success("Removed the launcher PATH line from")} ${dim(touchedRc.map(tildify2).join(", "))}`);
49502
49664
  }
49503
- console.log("");
49504
- console.log(`${success("Uninstall complete.")}`);
49665
+ say("");
49666
+ say(`${success("Uninstall complete.")}`);
49505
49667
  if (installedViaLauncher) {
49506
- console.log(`${dim("The launcher binary was under ~/.gipity and is now gone - nothing left to remove.")}`);
49668
+ say(`${dim("The launcher binary was under ~/.gipity and is now gone - nothing left to remove.")}`);
49507
49669
  } else {
49508
- console.log(`${dim("Run")} ${brand("npm uninstall -g gipity")} ${dim("to remove the `gipity` binary too.")}`);
49670
+ say(`${dim("Run")} ${brand("npm uninstall -g gipity")} ${dim("to remove the `gipity` binary too.")}`);
49509
49671
  }
49510
- console.log(`${dim("Open a new terminal - or run")} ${brand("hash -r")} ${dim("in this one - so your shell forgets the removed binary\u2019s path.")}`);
49672
+ say(`${dim("Open a new terminal - or run")} ${brand("hash -r")} ${dim("in this one - so your shell forgets the removed binary\u2019s path.")}`);
49511
49673
  });
49512
49674
 
49513
49675
  // src/commands/approval.ts