gipity 1.1.10 → 1.1.12

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
@@ -6905,7 +6905,7 @@ Prefer the cheapest option that works - CLI and sandbox are instant and free, ap
6905
6905
  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>\` or \`gipity chat\` - 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.
6906
6906
  4. Delegate to Gip (\`gipity chat "<task>"\`) - only when the work genuinely needs agent reasoning or a tool not in the CLI, sandbox, or app services. Required for: Twitter/X search, Gmail, calendar, push notifications, video understanding, audio source isolation, cross-model second opinions, multi-step orchestration. Don't use \`gipity chat\` for anything the sandbox can do - it's slower and burns tokens.
6907
6907
 
6908
- You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Grok, and Codex) 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.
6908
+ 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.
6909
6909
 
6910
6910
  ## Use first-party services before reaching outside
6911
6911
 
@@ -6997,7 +6997,7 @@ Every tool call returns its full output with that call. There is no output buffe
6997
6997
 
6998
6998
  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.
6999
6999
 
7000
- Write files locally - Gipity's editor hooks (installed into Claude Code, Grok, and Codex by \`gipity init\`) auto-push every save to Gipity and auto-pull remote changes (images, audio from \`gipity chat\`) 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 - use \`rollback\` with a datetime to undo, or \`file_version_restore\` for individual files.
7000
+ 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 (images, audio from \`gipity chat\`) 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 - use \`rollback\` with a datetime to undo, or \`file_version_restore\` for individual files.
7001
7001
 
7002
7002
  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.
7003
7003
 
@@ -7067,10 +7067,137 @@ If any step fails, fix it before claiming done - do not report success on a brok
7067
7067
  }
7068
7068
  });
7069
7069
 
7070
+ // src/opencode-setup.ts
7071
+ import { execSync as execSync4 } from "child_process";
7072
+ import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2, chmodSync as chmodSync2 } from "fs";
7073
+ import { homedir as homedir3, hostname } from "os";
7074
+ import { dirname as dirname2, join as join5 } from "path";
7075
+ function opencodeConfigDir() {
7076
+ const base = process.env.XDG_CONFIG_HOME || join5(homedir3(), ".config");
7077
+ return join5(base, "opencode");
7078
+ }
7079
+ function opencodePluginDest() {
7080
+ return join5(opencodeConfigDir(), "plugins", "gipity.js");
7081
+ }
7082
+ function stagedPluginPath() {
7083
+ return join5(AGENT_HOOKS_DIR, "opencode-plugin.mjs");
7084
+ }
7085
+ function isOpencodeInstalled() {
7086
+ const cmd = process.platform === "win32" ? "where opencode" : "which opencode";
7087
+ try {
7088
+ execSync4(cmd, { stdio: "ignore", windowsHide: true });
7089
+ return true;
7090
+ } catch {
7091
+ return false;
7092
+ }
7093
+ }
7094
+ function ensureOpencodeInstalled(opts = {}) {
7095
+ if (isOpencodeInstalled()) return true;
7096
+ try {
7097
+ execSync4(`npm install -g ${OPENCODE_PACKAGE}`, {
7098
+ stdio: opts.quiet ? "ignore" : "inherit",
7099
+ windowsHide: true
7100
+ });
7101
+ } catch {
7102
+ }
7103
+ return isOpencodeInstalled();
7104
+ }
7105
+ function ensureOpencodePluginInstalled() {
7106
+ const src = stagedPluginPath();
7107
+ if (!existsSync4(src)) return existsSync4(opencodePluginDest());
7108
+ const dest = opencodePluginDest();
7109
+ try {
7110
+ if (existsSync4(dest) && readFileSync3(dest, "utf-8") === readFileSync3(src, "utf-8")) return true;
7111
+ mkdirSync2(join5(opencodeConfigDir(), "plugins"), { recursive: true });
7112
+ copyFileSync(src, dest);
7113
+ console.log("Installed the Gipity plugin for opencode (models + session capture).");
7114
+ return true;
7115
+ } catch {
7116
+ return existsSync4(dest);
7117
+ }
7118
+ }
7119
+ function opencodePluginState() {
7120
+ const src = stagedPluginPath();
7121
+ const dest = opencodePluginDest();
7122
+ try {
7123
+ return { current: existsSync4(dest) && (!existsSync4(src) || readFileSync3(dest, "utf-8") === readFileSync3(src, "utf-8")) };
7124
+ } catch {
7125
+ return { current: false };
7126
+ }
7127
+ }
7128
+ function removeOpencodePlugin() {
7129
+ const dest = opencodePluginDest();
7130
+ if (!existsSync4(dest)) return false;
7131
+ try {
7132
+ unlinkSync2(dest);
7133
+ } catch {
7134
+ return false;
7135
+ }
7136
+ return true;
7137
+ }
7138
+ function readOpencodeModelToken() {
7139
+ try {
7140
+ const parsed = JSON.parse(readFileSync3(OPENCODE_TOKEN_FILE, "utf-8"));
7141
+ return typeof parsed?.token === "string" && parsed.token ? parsed : null;
7142
+ } catch {
7143
+ return null;
7144
+ }
7145
+ }
7146
+ async function ensureOpencodeModelToken() {
7147
+ const existing = readOpencodeModelToken();
7148
+ if (existing) {
7149
+ try {
7150
+ const res = await fetch(`${resolveApiBase()}/users/me`, {
7151
+ headers: { Authorization: `Bearer ${existing.token}` }
7152
+ });
7153
+ if (res.status !== 401) return existing.token;
7154
+ } catch {
7155
+ return existing.token;
7156
+ }
7157
+ }
7158
+ if (!getAuth()) return null;
7159
+ try {
7160
+ const res = await post(
7161
+ "/auth/agent-tokens",
7162
+ { name: `opencode models on ${hostname()}`, expiresInDays: MODEL_TOKEN_EXPIRY_DAYS }
7163
+ );
7164
+ const stored = {
7165
+ token: res.data.token,
7166
+ guid: res.data.shortGuid,
7167
+ mintedAt: (/* @__PURE__ */ new Date()).toISOString()
7168
+ };
7169
+ mkdirSync2(dirname2(OPENCODE_TOKEN_FILE), { recursive: true, mode: 448 });
7170
+ writeFileSync2(OPENCODE_TOKEN_FILE, JSON.stringify(stored, null, 2), { mode: 384 });
7171
+ try {
7172
+ chmodSync2(OPENCODE_TOKEN_FILE, 384);
7173
+ } catch {
7174
+ }
7175
+ return stored.token;
7176
+ } catch {
7177
+ return null;
7178
+ }
7179
+ }
7180
+ var OPENCODE_PACKAGE, OPENCODE_TOKEN_FILE, MODEL_TOKEN_EXPIRY_DAYS;
7181
+ var init_opencode_setup = __esm({
7182
+ "src/opencode-setup.ts"() {
7183
+ "use strict";
7184
+ init_setup();
7185
+ init_api();
7186
+ init_auth();
7187
+ init_config();
7188
+ OPENCODE_PACKAGE = "opencode-ai";
7189
+ OPENCODE_TOKEN_FILE = join5(
7190
+ process.env.GIPITY_DIR || join5(homedir3(), ".gipity"),
7191
+ "opencode-token.json"
7192
+ );
7193
+ MODEL_TOKEN_EXPIRY_DAYS = 90;
7194
+ }
7195
+ });
7196
+
7070
7197
  // src/setup.ts
7071
- import { resolve, join as join5, dirname as dirname2 } from "path";
7072
- import { homedir as homedir3, tmpdir } from "os";
7073
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync3, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
7198
+ import { resolve, join as join6, dirname as dirname3 } from "path";
7199
+ import { homedir as homedir4, tmpdir } from "os";
7200
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readFileSync as readFileSync4, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
7074
7201
  function isSyncIgnored(name) {
7075
7202
  if (name.startsWith(".")) return true;
7076
7203
  if (DEFAULT_SYNC_IGNORE.includes(name)) return true;
@@ -7107,16 +7234,16 @@ function stripGipityHooks(settings) {
7107
7234
  return changed;
7108
7235
  }
7109
7236
  function readSettingsFile(path5) {
7110
- if (!existsSync4(path5)) return {};
7237
+ if (!existsSync5(path5)) return {};
7111
7238
  try {
7112
- return JSON.parse(readFileSync3(path5, "utf-8"));
7239
+ return JSON.parse(readFileSync4(path5, "utf-8"));
7113
7240
  } catch {
7114
7241
  return {};
7115
7242
  }
7116
7243
  }
7117
7244
  function ensureGipityPlugin(force = false) {
7118
- const claudeDir = join5(homedir3(), ".claude");
7119
- const settingsPath = join5(claudeDir, "settings.json");
7245
+ const claudeDir = join6(homedir4(), ".claude");
7246
+ const settingsPath = join6(claudeDir, "settings.json");
7120
7247
  const settings = readSettingsFile(settingsPath);
7121
7248
  let changed = stripGipityHooks(settings);
7122
7249
  const marketplaces = settings.extraKnownMarketplaces ?? (settings.extraKnownMarketplaces = {});
@@ -7133,8 +7260,8 @@ function ensureGipityPlugin(force = false) {
7133
7260
  changed = true;
7134
7261
  }
7135
7262
  if (!changed) return;
7136
- mkdirSync2(claudeDir, { recursive: true });
7137
- writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7263
+ mkdirSync3(claudeDir, { recursive: true });
7264
+ writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7138
7265
  }
7139
7266
  function versionGte(have, want) {
7140
7267
  const h = have.split(".").map((n) => parseInt(n, 10) || 0);
@@ -7148,8 +7275,8 @@ function versionGte(have, want) {
7148
7275
  }
7149
7276
  function userScopeInstallState() {
7150
7277
  try {
7151
- const p = join5(homedir3(), ".claude", "plugins", "installed_plugins.json");
7152
- const data = JSON.parse(readFileSync3(p, "utf-8"));
7278
+ const p = join6(homedir4(), ".claude", "plugins", "installed_plugins.json");
7279
+ const data = JSON.parse(readFileSync4(p, "utf-8"));
7153
7280
  const entries = data?.plugins?.[GIPITY_PLUGIN_ID];
7154
7281
  if (!Array.isArray(entries)) return { exists: false, current: false };
7155
7282
  const userEntries = entries.filter((e) => e?.scope === "user");
@@ -7164,11 +7291,11 @@ function userScopeInstallState() {
7164
7291
  }
7165
7292
  }
7166
7293
  function removeGipityPluginConfig() {
7167
- const settingsPath = join5(homedir3(), ".claude", "settings.json");
7168
- if (!existsSync4(settingsPath)) return false;
7294
+ const settingsPath = join6(homedir4(), ".claude", "settings.json");
7295
+ if (!existsSync5(settingsPath)) return false;
7169
7296
  let settings;
7170
7297
  try {
7171
- settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
7298
+ settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
7172
7299
  } catch {
7173
7300
  return false;
7174
7301
  }
@@ -7183,7 +7310,7 @@ function removeGipityPluginConfig() {
7183
7310
  if (Object.keys(settings.extraKnownMarketplaces).length === 0) delete settings.extraKnownMarketplaces;
7184
7311
  changed = true;
7185
7312
  }
7186
- if (changed) writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7313
+ if (changed) writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7187
7314
  return changed;
7188
7315
  }
7189
7316
  function binaryOnPath(bin) {
@@ -7209,8 +7336,8 @@ function ensureGipityPluginInstalled() {
7209
7336
  }
7210
7337
  function grokInstallState() {
7211
7338
  try {
7212
- const p = join5(homedir3(), ".grok", "installed-plugins", "registry.json");
7213
- const data = JSON.parse(readFileSync3(p, "utf-8"));
7339
+ const p = join6(homedir4(), ".grok", "installed-plugins", "registry.json");
7340
+ const data = JSON.parse(readFileSync4(p, "utf-8"));
7214
7341
  const versions = [];
7215
7342
  for (const repo of Object.values(data?.repos ?? {})) {
7216
7343
  const v7 = repo?.plugins?.gipity?.version;
@@ -7245,7 +7372,7 @@ function removeGrokPlugin() {
7245
7372
  }
7246
7373
  function skillsManifestState(manifestPath) {
7247
7374
  try {
7248
- const m = JSON.parse(readFileSync3(manifestPath, "utf-8"));
7375
+ const m = JSON.parse(readFileSync4(manifestPath, "utf-8"));
7249
7376
  return {
7250
7377
  current: typeof m?.version === "string" && versionGte(m.version, GIPITY_PLUGIN_VERSION),
7251
7378
  skills: Array.isArray(m?.skills) ? m.skills : []
@@ -7264,7 +7391,7 @@ function removeManifestSkills(skillsDir, manifestPath) {
7264
7391
  const { skills } = skillsManifestState(manifestPath);
7265
7392
  for (const name of skills) {
7266
7393
  try {
7267
- rmSync(join5(skillsDir, name), { recursive: true, force: true });
7394
+ rmSync(join6(skillsDir, name), { recursive: true, force: true });
7268
7395
  } catch {
7269
7396
  }
7270
7397
  }
@@ -7278,38 +7405,38 @@ function removeAgySkills() {
7278
7405
  }
7279
7406
  function installSkillsAndHooks(skillsDir, manifestPath, harnessLabel) {
7280
7407
  if (!binaryOnPath("git")) return;
7281
- const tmp = mkdtempSync(join5(tmpdir(), "gipity-skills-"));
7408
+ const tmp = mkdtempSync(join6(tmpdir(), "gipity-skills-"));
7282
7409
  try {
7283
7410
  const clone = spawnSyncCommand(
7284
7411
  resolveCommand("git"),
7285
- ["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`, join5(tmp, "repo")],
7412
+ ["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`, join6(tmp, "repo")],
7286
7413
  { stdio: "ignore", timeout: 12e4 }
7287
7414
  );
7288
7415
  if (clone.status !== 0) return;
7289
- const repo = join5(tmp, "repo");
7416
+ const repo = join6(tmp, "repo");
7290
7417
  let version = GIPITY_PLUGIN_VERSION;
7291
7418
  try {
7292
- const manifest = JSON.parse(readFileSync3(join5(repo, ".claude-plugin", "plugin.json"), "utf-8"));
7419
+ const manifest = JSON.parse(readFileSync4(join6(repo, ".claude-plugin", "plugin.json"), "utf-8"));
7293
7420
  if (typeof manifest?.version === "string") version = manifest.version;
7294
7421
  } catch {
7295
7422
  }
7296
- const skillsSrc = join5(repo, "skills");
7423
+ const skillsSrc = join6(repo, "skills");
7297
7424
  const names = [];
7298
7425
  for (const entry of readdirSync2(skillsSrc, { withFileTypes: true })) {
7299
7426
  if (!entry.isDirectory()) continue;
7300
- if (!existsSync4(join5(skillsSrc, entry.name, "SKILL.md"))) continue;
7301
- mkdirSync2(skillsDir, { recursive: true });
7302
- cpSync(join5(skillsSrc, entry.name), join5(skillsDir, entry.name), {
7427
+ if (!existsSync5(join6(skillsSrc, entry.name, "SKILL.md"))) continue;
7428
+ mkdirSync3(skillsDir, { recursive: true });
7429
+ cpSync(join6(skillsSrc, entry.name), join6(skillsDir, entry.name), {
7303
7430
  recursive: true,
7304
7431
  force: true
7305
7432
  });
7306
7433
  names.push(entry.name);
7307
7434
  }
7308
- mkdirSync2(AGENT_HOOKS_DIR, { recursive: true });
7309
- for (const script of readdirSync2(join5(repo, "hooks", "scripts"))) {
7310
- cpSync(join5(repo, "hooks", "scripts", script), join5(AGENT_HOOKS_DIR, script), { force: true });
7435
+ mkdirSync3(AGENT_HOOKS_DIR, { recursive: true });
7436
+ for (const script of readdirSync2(join6(repo, "hooks", "scripts"))) {
7437
+ cpSync(join6(repo, "hooks", "scripts", script), join6(AGENT_HOOKS_DIR, script), { force: true });
7311
7438
  }
7312
- writeFileSync2(manifestPath, JSON.stringify({ version, skills: names }, null, 2) + "\n");
7439
+ writeFileSync3(manifestPath, JSON.stringify({ version, skills: names }, null, 2) + "\n");
7313
7440
  console.log(`Installed ${names.length} Gipity skills for ${harnessLabel} (${skillsDir}).`);
7314
7441
  } catch {
7315
7442
  } finally {
@@ -7327,8 +7454,8 @@ function ensureAgySkillsInstalled() {
7327
7454
  installSkillsAndHooks(AGY_SKILLS_DIR, AGY_SKILLS_MANIFEST, "Antigravity");
7328
7455
  }
7329
7456
  function applyCodexHooks(existing) {
7330
- const launcher = join5(AGENT_HOOKS_DIR, "launch.sh");
7331
- const cmd = (script, ...args) => [`sh "${launcher}" "${join5(AGENT_HOOKS_DIR, script)}"`, ...args].join(" ");
7457
+ const launcher = join6(AGENT_HOOKS_DIR, "launch.sh");
7458
+ const cmd = (script, ...args) => [`sh "${launcher}" "${join6(AGENT_HOOKS_DIR, script)}"`, ...args].join(" ");
7332
7459
  const wanted = [
7333
7460
  { event: "PostToolUse", matcher: "Edit|Write", command: cmd("sync-push.cjs"), timeout: 30 },
7334
7461
  { event: "UserPromptSubmit", command: cmd("sync-pull.cjs"), timeout: 300 },
@@ -7365,13 +7492,13 @@ function applyCodexHooks(existing) {
7365
7492
  function setupCodexHooks() {
7366
7493
  if (process.platform === "win32") return;
7367
7494
  const cwd = resolve(process.cwd());
7368
- if (cwd === resolve(homedir3())) return;
7369
- const path5 = join5(cwd, ".codex", "hooks.json");
7370
- const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
7495
+ if (cwd === resolve(homedir4())) return;
7496
+ const path5 = join6(cwd, ".codex", "hooks.json");
7497
+ const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
7371
7498
  const next = applyCodexHooks(existing);
7372
7499
  if (next === null) return;
7373
- mkdirSync2(dirname2(path5), { recursive: true });
7374
- writeFileSync2(path5, next);
7500
+ mkdirSync3(dirname3(path5), { recursive: true });
7501
+ writeFileSync3(path5, next);
7375
7502
  if (existing === null) {
7376
7503
  console.log("Wrote Codex sync + session-capture hooks (.codex/hooks.json) - approve them once with /hooks inside Codex.");
7377
7504
  } else {
@@ -7383,9 +7510,19 @@ function setupCodexIntegration() {
7383
7510
  ensureAgentSkillsInstalled();
7384
7511
  setupCodexHooks();
7385
7512
  }
7513
+ function ensureOpencodeSkillsInstalled() {
7514
+ if (agentSkillsState().current) return;
7515
+ if (!binaryOnPath("opencode")) return;
7516
+ installSkillsAndHooks(AGENTS_SKILLS_DIR, AGENT_SKILLS_MANIFEST, "opencode");
7517
+ }
7518
+ function setupOpencodeIntegration() {
7519
+ if (!binaryOnPath("opencode")) return;
7520
+ ensureOpencodeSkillsInstalled();
7521
+ ensureOpencodePluginInstalled();
7522
+ }
7386
7523
  function applyAgyHooks(existing) {
7387
- const wrapper = join5(AGENT_HOOKS_DIR, "agy-hooks.cjs");
7388
- const launcher = join5(AGENT_HOOKS_DIR, "launch.sh");
7524
+ const wrapper = join6(AGENT_HOOKS_DIR, "agy-hooks.cjs");
7525
+ const launcher = join6(AGENT_HOOKS_DIR, "launch.sh");
7389
7526
  const wrapCmd = (event) => `sh "${launcher}" "${wrapper}" ${event}`;
7390
7527
  const block = {
7391
7528
  PostToolUse: [
@@ -7415,15 +7552,15 @@ function applyAgyHooks(existing) {
7415
7552
  function setupAgyHooks() {
7416
7553
  if (process.platform === "win32") return;
7417
7554
  const cwd = resolve(process.cwd());
7418
- if (cwd === resolve(homedir3())) return;
7419
- mkdirSync2(AGENT_HOOKS_DIR, { recursive: true });
7420
- writeFileSync2(join5(AGENT_HOOKS_DIR, "agy-hooks.cjs"), AGY_HOOKS_SCRIPT);
7421
- const path5 = join5(cwd, ".agents", "hooks.json");
7422
- const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
7555
+ if (cwd === resolve(homedir4())) return;
7556
+ mkdirSync3(AGENT_HOOKS_DIR, { recursive: true });
7557
+ writeFileSync3(join6(AGENT_HOOKS_DIR, "agy-hooks.cjs"), AGY_HOOKS_SCRIPT);
7558
+ const path5 = join6(cwd, ".agents", "hooks.json");
7559
+ const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
7423
7560
  const next = applyAgyHooks(existing);
7424
7561
  if (next === null) return;
7425
- mkdirSync2(dirname2(path5), { recursive: true });
7426
- writeFileSync2(path5, next);
7562
+ mkdirSync3(dirname3(path5), { recursive: true });
7563
+ writeFileSync3(path5, next);
7427
7564
  console.log(existing === null ? "Wrote Antigravity sync + session-capture hooks (.agents/hooks.json)." : "Updated Antigravity hooks (.agents/hooks.json).");
7428
7565
  }
7429
7566
  function setupAgyIntegration() {
@@ -7434,10 +7571,10 @@ function setupAgyIntegration() {
7434
7571
  function setupClaudeHooks() {
7435
7572
  ensureGipityPlugin();
7436
7573
  const cwd = resolve(process.cwd());
7437
- if (cwd === resolve(homedir3())) return;
7438
- const claudeDir = join5(cwd, ".claude");
7439
- mkdirSync2(claudeDir, { recursive: true });
7440
- const settingsPath = join5(claudeDir, "settings.json");
7574
+ if (cwd === resolve(homedir4())) return;
7575
+ const claudeDir = join6(cwd, ".claude");
7576
+ mkdirSync3(claudeDir, { recursive: true });
7577
+ const settingsPath = join6(claudeDir, "settings.json");
7441
7578
  const settings = readSettingsFile(settingsPath);
7442
7579
  stripGipityHooks(settings);
7443
7580
  const perms = settings.permissions || {};
@@ -7448,7 +7585,7 @@ function setupClaudeHooks() {
7448
7585
  }
7449
7586
  }
7450
7587
  settings.permissions = perms;
7451
- writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7588
+ writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
7452
7589
  }
7453
7590
  function renderManagedBlock(apiBase2) {
7454
7591
  let body = [SKILLS_CONTENT, BUILD_VS_NON_BUILD_RULE, DEFINITION_OF_DONE].join("\n\n");
@@ -7481,11 +7618,11 @@ function applySkillsBlock(existing, apiBase2 = DEFAULT_API_BASE) {
7481
7618
  }
7482
7619
  function writeSkillsFile(relPath, wrap) {
7483
7620
  const path5 = resolve(process.cwd(), relPath);
7484
- mkdirSync2(dirname2(path5), { recursive: true });
7485
- const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
7621
+ mkdirSync3(dirname3(path5), { recursive: true });
7622
+ const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
7486
7623
  const baseNext = applySkillsBlock(existing, resolveApiBase());
7487
7624
  const next = wrap && existing === null ? wrap(baseNext) : baseNext;
7488
- if (next !== existing) writeFileSync2(path5, next);
7625
+ if (next !== existing) writeFileSync3(path5, next);
7489
7626
  }
7490
7627
  function setupClaudeMd() {
7491
7628
  writeSkillsFile(PRIMER_FILES.claude);
@@ -7525,9 +7662,9 @@ function applyAiderConf(existing) {
7525
7662
  function setupAiderMd() {
7526
7663
  writeSkillsFile(PRIMER_FILES.aider);
7527
7664
  const path5 = resolve(process.cwd(), AIDER_CONF_FILE);
7528
- const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
7665
+ const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
7529
7666
  const next = applyAiderConf(existing);
7530
- if (next !== null) writeFileSync2(path5, next);
7667
+ if (next !== null) writeFileSync3(path5, next);
7531
7668
  }
7532
7669
  function setupGeminiMd() {
7533
7670
  writeSkillsFile(PRIMER_FILES.gemini);
@@ -7556,16 +7693,16 @@ function setupProjectTools(tools = DEFAULT_TOOLS) {
7556
7693
  function setupGitignore() {
7557
7694
  const gitignorePath = resolve(process.cwd(), ".gitignore");
7558
7695
  const entries = [".gipity/", ".gipity.json", ...SCRATCH_IGNORE];
7559
- if (existsSync4(gitignorePath)) {
7560
- let content = readFileSync3(gitignorePath, "utf-8");
7696
+ if (existsSync5(gitignorePath)) {
7697
+ let content = readFileSync4(gitignorePath, "utf-8");
7561
7698
  const lines = content.split(/\r?\n/);
7562
7699
  const toAdd = entries.filter((e) => !lines.includes(e));
7563
7700
  if (toAdd.length > 0) {
7564
7701
  content = content.trimEnd() + "\n" + toAdd.join("\n") + "\n";
7565
- writeFileSync2(gitignorePath, content);
7702
+ writeFileSync3(gitignorePath, content);
7566
7703
  }
7567
7704
  } else {
7568
- writeFileSync2(gitignorePath, entries.join("\n") + "\n");
7705
+ writeFileSync3(gitignorePath, entries.join("\n") + "\n");
7569
7706
  }
7570
7707
  }
7571
7708
  function slugify(name) {
@@ -7582,6 +7719,7 @@ var init_setup = __esm({
7582
7719
  init_platform();
7583
7720
  init_knowledge();
7584
7721
  init_config();
7722
+ init_opencode_setup();
7585
7723
  PRIMER_FILES = {
7586
7724
  claude: "CLAUDE.md",
7587
7725
  codex: "AGENTS.md",
@@ -7589,6 +7727,8 @@ var init_setup = __esm({
7589
7727
  // Grok Build reads the AGENTS.md family (and CLAUDE.md) natively
7590
7728
  agy: "AGENTS.md",
7591
7729
  // Antigravity reads the same AGENTS.md/GEMINI.md rules family natively
7730
+ opencode: "AGENTS.md",
7731
+ // opencode reads AGENTS.md (and CLAUDE.md) natively
7592
7732
  aider: "AGENTS.md",
7593
7733
  // shares the Codex primer; aider is pointed at it via .aider.conf.yml
7594
7734
  gemini: "GEMINI.md",
@@ -7660,11 +7800,11 @@ var init_setup = __esm({
7660
7800
  GIPITY_MARKETPLACE_REPO = "GipityAI/skills";
7661
7801
  LEGACY_MARKETPLACE_REPO = "GipityAI/claude-plugin";
7662
7802
  GIPITY_PLUGIN_VERSION = "0.7.0";
7663
- AGENTS_SKILLS_DIR = join5(homedir3(), ".agents", "skills");
7664
- AGENT_HOOKS_DIR = join5(homedir3(), ".gipity", "agent-hooks");
7665
- AGENT_SKILLS_MANIFEST = join5(homedir3(), ".gipity", "agent-skills.json");
7666
- AGY_SKILLS_DIR = join5(homedir3(), ".gemini", "config", "skills");
7667
- AGY_SKILLS_MANIFEST = join5(homedir3(), ".gipity", "agy-skills.json");
7803
+ AGENTS_SKILLS_DIR = join6(homedir4(), ".agents", "skills");
7804
+ AGENT_HOOKS_DIR = join6(homedir4(), ".gipity", "agent-hooks");
7805
+ AGENT_SKILLS_MANIFEST = join6(homedir4(), ".gipity", "agent-skills.json");
7806
+ AGY_SKILLS_DIR = join6(homedir4(), ".gemini", "config", "skills");
7807
+ AGY_SKILLS_MANIFEST = join6(homedir4(), ".gipity", "agy-skills.json");
7668
7808
  AGY_HOOKS_SCRIPT = `#!/usr/bin/env node
7669
7809
  'use strict';
7670
7810
  const { spawnSync } = require('child_process');
@@ -7725,6 +7865,7 @@ main();
7725
7865
  { key: "codex", label: "OpenAI Codex (AGENTS.md + skills + sync hooks)", setup: setupAgentsMd, integrate: setupCodexIntegration },
7726
7866
  { key: "grok", label: "Grok Build (AGENTS.md + Gipity plugin)", setup: setupAgentsMd, integrate: ensureGrokPluginInstalled },
7727
7867
  { key: "agy", label: "Antigravity (AGENTS.md + skills + sync hooks)", setup: setupAgentsMd, integrate: setupAgyIntegration },
7868
+ { key: "opencode", label: "opencode (AGENTS.md + skills + Gipity plugin)", setup: setupAgentsMd, integrate: setupOpencodeIntegration },
7728
7869
  { key: "aider", label: "Aider (AGENTS.md + .aider.conf.yml)", setup: setupAiderMd, optIn: true },
7729
7870
  { key: "gemini", label: "Gemini CLI (GEMINI.md)", setup: setupGeminiMd },
7730
7871
  { key: "copilot", label: "GitHub Copilot (.github/copilot-instructions.md)", setup: setupCopilotMd },
@@ -8160,8 +8301,8 @@ var init_grok = __esm({
8160
8301
  });
8161
8302
 
8162
8303
  // src/agents/grok.ts
8163
- import { homedir as homedir4 } from "os";
8164
- import { join as join6 } from "path";
8304
+ import { homedir as homedir5 } from "os";
8305
+ import { join as join7 } from "path";
8165
8306
  var grokAdapter;
8166
8307
  var init_grok2 = __esm({
8167
8308
  "src/agents/grok.ts"() {
@@ -8219,7 +8360,7 @@ var init_grok2 = __esm({
8219
8360
  resolveTranscriptPath: (hook) => {
8220
8361
  if (!hook.session_id) return null;
8221
8362
  const cwd = hook.cwd ?? process.cwd();
8222
- return join6(homedir4(), ".grok", "sessions", encodeURIComponent(cwd), hook.session_id, "chat_history.jsonl");
8363
+ return join7(homedir5(), ".grok", "sessions", encodeURIComponent(cwd), hook.session_id, "chat_history.jsonl");
8223
8364
  }
8224
8365
  },
8225
8366
  setup: {
@@ -8424,6 +8565,223 @@ var init_agy2 = __esm({
8424
8565
  }
8425
8566
  });
8426
8567
 
8568
+ // src/capture/sources/opencode.ts
8569
+ function toIso(ms2) {
8570
+ return typeof ms2 === "number" && ms2 > 0 ? new Date(ms2).toISOString() : void 0;
8571
+ }
8572
+ function joinTextParts(parts) {
8573
+ const out = [];
8574
+ for (const p of parts) {
8575
+ if (p?.type === "text" && typeof p.text === "string" && !p.synthetic && !p.ignored) {
8576
+ out.push(p.text);
8577
+ }
8578
+ }
8579
+ return out.join("\n");
8580
+ }
8581
+ function messageToEntries(info2, parts) {
8582
+ if (!info2 || typeof info2.id !== "string") return [];
8583
+ const ts2 = toIso(info2?.time?.created);
8584
+ if (info2.role === "user") {
8585
+ const prompt2 = joinTextParts(parts);
8586
+ if (!prompt2) return [];
8587
+ return [{ kind: "prompt", prompt: prompt2, source_uuid: info2.id, ...ts2 ? { ts: ts2 } : {} }];
8588
+ }
8589
+ if (info2.role === "assistant") {
8590
+ const out = [];
8591
+ const text = joinTextParts(parts);
8592
+ const toolParts = parts.filter((p) => p?.type === "tool" && typeof p.callID === "string" && p.callID);
8593
+ if (text || toolParts.length) {
8594
+ out.push({
8595
+ kind: "assistant",
8596
+ text,
8597
+ blocks: text ? [{ type: "text", text }] : [],
8598
+ ...typeof info2?.tokens?.input === "number" ? { input_tokens: info2.tokens.input } : {},
8599
+ ...typeof info2?.tokens?.output === "number" ? { output_tokens: info2.tokens.output } : {},
8600
+ ...typeof info2.modelID === "string" ? { model: info2.modelID } : {},
8601
+ ...typeof info2.finish === "string" ? { stop_reason: info2.finish } : {},
8602
+ source_uuid: info2.id,
8603
+ ...ts2 ? { ts: ts2 } : {}
8604
+ });
8605
+ }
8606
+ for (const p of toolParts) {
8607
+ const toolName = typeof p.tool === "string" && p.tool ? p.tool : "tool";
8608
+ out.push({
8609
+ kind: "tool_use",
8610
+ tool_use_id: p.callID,
8611
+ tool_name: toolName,
8612
+ tool_input: p?.state?.input ?? null,
8613
+ source_uuid: p.callID
8614
+ });
8615
+ const status = p?.state?.status;
8616
+ if (status === "completed" || status === "error") {
8617
+ out.push({
8618
+ kind: "tool_result",
8619
+ tool_use_id: p.callID,
8620
+ tool_name: toolName,
8621
+ content: status === "error" ? p.state.error ?? "" : p.state.output ?? "",
8622
+ ...status === "error" ? { is_error: true } : {},
8623
+ source_uuid: `${p.callID}#out`
8624
+ });
8625
+ }
8626
+ }
8627
+ return out;
8628
+ }
8629
+ return [];
8630
+ }
8631
+ function parseTranscript5(content, afterUuid) {
8632
+ const lines = content.split("\n");
8633
+ let watermarkLine = -1;
8634
+ if (afterUuid) {
8635
+ for (let i = 0; i < lines.length; i++) {
8636
+ const line = lines[i].trim();
8637
+ if (!line) continue;
8638
+ try {
8639
+ if (JSON.parse(line)?.info?.id === afterUuid) {
8640
+ watermarkLine = i;
8641
+ break;
8642
+ }
8643
+ } catch {
8644
+ }
8645
+ }
8646
+ }
8647
+ const foundWatermark = afterUuid === null || watermarkLine !== -1;
8648
+ const out = [];
8649
+ let lastUuid = foundWatermark ? afterUuid : null;
8650
+ for (let i = 0; i < lines.length; i++) {
8651
+ if (watermarkLine !== -1 && i <= watermarkLine) continue;
8652
+ const line = lines[i].trim();
8653
+ if (!line) continue;
8654
+ let parsed;
8655
+ try {
8656
+ parsed = JSON.parse(line);
8657
+ } catch {
8658
+ continue;
8659
+ }
8660
+ const entries = messageToEntries(parsed?.info, Array.isArray(parsed?.parts) ? parsed.parts : []);
8661
+ if (!entries.length) continue;
8662
+ for (const e of entries) out.push(e);
8663
+ if (typeof parsed?.info?.id === "string") lastUuid = parsed.info.id;
8664
+ }
8665
+ return { entries: out, lastUuid, foundWatermark };
8666
+ }
8667
+ var init_opencode = __esm({
8668
+ "src/capture/sources/opencode.ts"() {
8669
+ "use strict";
8670
+ }
8671
+ });
8672
+
8673
+ // src/agents/opencode.ts
8674
+ import { homedir as homedir6 } from "os";
8675
+ import { join as join8 } from "path";
8676
+ function toOpencodeModel(model) {
8677
+ const head = model.split("/", 1)[0];
8678
+ return OPENCODE_NATIVE_PROVIDERS.has(head) ? model : `gipity/${model}`;
8679
+ }
8680
+ var OPENCODE_NATIVE_PROVIDERS, opencodeAdapter;
8681
+ var init_opencode2 = __esm({
8682
+ "src/agents/opencode.ts"() {
8683
+ "use strict";
8684
+ init_types();
8685
+ init_self_update();
8686
+ init_opencode();
8687
+ init_opencode_setup();
8688
+ init_setup();
8689
+ OPENCODE_NATIVE_PROVIDERS = /* @__PURE__ */ new Set([
8690
+ "gipity",
8691
+ "anthropic",
8692
+ "openai",
8693
+ "google",
8694
+ "openrouter",
8695
+ "xai",
8696
+ "groq",
8697
+ "mistral",
8698
+ "azure",
8699
+ "amazon-bedrock",
8700
+ "github-copilot",
8701
+ "opencode"
8702
+ ]);
8703
+ opencodeAdapter = {
8704
+ key: "opencode",
8705
+ source: "opencode",
8706
+ harness: "opencode",
8707
+ displayName: "opencode",
8708
+ providerName: "Anomaly",
8709
+ binary: "opencode",
8710
+ buildInteractiveArgs({ resume, model }) {
8711
+ const args = [];
8712
+ if (model) args.push("--model", toOpencodeModel(model));
8713
+ if (resume) args.push("--session", resume);
8714
+ return args;
8715
+ },
8716
+ buildHeadlessArgs({ message, resume, model, bypassApprovals, jsonStream }) {
8717
+ const args = ["run", message];
8718
+ if (model) args.push("--model", toOpencodeModel(model));
8719
+ if (resume) args.push("--session", resume);
8720
+ if (bypassApprovals) args.push("--auto");
8721
+ if (jsonStream) args.push("--format", "json");
8722
+ return args;
8723
+ },
8724
+ sessionIdFromStreamEvent(event) {
8725
+ const fromProps = event?.properties?.sessionID;
8726
+ if (typeof fromProps === "string" && fromProps) return fromProps;
8727
+ const fromInfo = event?.properties?.info?.id;
8728
+ if (typeof fromInfo === "string" && fromInfo.startsWith("ses")) return fromInfo;
8729
+ return null;
8730
+ },
8731
+ hooksSupportedOnPlatform() {
8732
+ return true;
8733
+ },
8734
+ daemonStreamCapture: false,
8735
+ ensureInstalled() {
8736
+ return ensureOpencodeInstalled();
8737
+ },
8738
+ // Plain literal, not `npm install -g ${OPENCODE_PACKAGE}`: this module sits
8739
+ // in an import cycle (opencode.ts -> opencode-setup.ts -> setup.ts -> ...
8740
+ // -> agents/index.ts -> opencode.ts), so a module-eval read of an imported
8741
+ // binding hits the TDZ when the cycle is entered from setup.ts's side.
8742
+ // Function bodies (updatePlan below) read the live binding safely.
8743
+ installHint: "npm install -g opencode-ai (or: curl -fsSL https://opencode.ai/install | bash)",
8744
+ updatePlan() {
8745
+ return planForInstall(whichFirst("opencode"), OPENCODE_PACKAGE, ["opencode", "upgrade"]);
8746
+ },
8747
+ async prepareLaunch() {
8748
+ await ensureOpencodeModelToken();
8749
+ },
8750
+ detectEnv() {
8751
+ if (!hasEnvPrefix("OPENCODE")) return null;
8752
+ return { harness: "opencode", harnessSession: process.env.OPENCODE_SESSION_ID };
8753
+ },
8754
+ capture: {
8755
+ hookKey: "opencode",
8756
+ parse: (content, afterUuid) => parseTranscript5(content, afterUuid),
8757
+ // The plugin writes the transcript at a derivable path, so a hook payload
8758
+ // without transcript_path still resolves.
8759
+ resolveTranscriptPath: (hook) => {
8760
+ if (!hook.session_id) return null;
8761
+ const gipityDir = process.env.GIPITY_DIR || join8(homedir6(), ".gipity");
8762
+ return join8(gipityDir, "opencode", "transcripts", `${hook.session_id}.jsonl`);
8763
+ }
8764
+ },
8765
+ setup: {
8766
+ state: () => opencodePluginState(),
8767
+ install: () => {
8768
+ ensureOpencodeSkillsInstalled();
8769
+ ensureOpencodePluginInstalled();
8770
+ },
8771
+ uninstall: () => {
8772
+ const removedPlugin = removeOpencodePlugin();
8773
+ const n = removeAgentSkills();
8774
+ if (!removedPlugin && !n) return null;
8775
+ const parts = [];
8776
+ if (removedPlugin) parts.push("Gipity plugin removed from opencode.");
8777
+ if (n) parts.push(`Removed ${n} Gipity skills from ~/.agents/skills.`);
8778
+ return parts.join(" ");
8779
+ }
8780
+ }
8781
+ };
8782
+ }
8783
+ });
8784
+
8427
8785
  // src/agents/index.ts
8428
8786
  function getAdapter(key) {
8429
8787
  const found = AGENT_ADAPTERS.find((a) => a.key === key);
@@ -8443,24 +8801,26 @@ var init_agents = __esm({
8443
8801
  init_codex2();
8444
8802
  init_grok2();
8445
8803
  init_agy2();
8804
+ init_opencode2();
8446
8805
  AGENT_ADAPTERS = [
8447
8806
  claudeCodeAdapter,
8448
8807
  codexAdapter,
8449
8808
  grokAdapter,
8450
- agyAdapter
8809
+ agyAdapter,
8810
+ opencodeAdapter
8451
8811
  ];
8452
8812
  AGENT_KEYS = AGENT_ADAPTERS.map((a) => a.key);
8453
8813
  }
8454
8814
  });
8455
8815
 
8456
8816
  // src/client-context.ts
8457
- import { readFileSync as readFileSync4 } from "fs";
8458
- import { resolve as resolve2, dirname as dirname3 } from "path";
8817
+ import { readFileSync as readFileSync5 } from "fs";
8818
+ import { resolve as resolve2, dirname as dirname4 } from "path";
8459
8819
  import { fileURLToPath } from "url";
8460
8820
  function cliVersion() {
8461
8821
  try {
8462
- const dir = dirname3(fileURLToPath(import.meta.url));
8463
- const pkg2 = JSON.parse(readFileSync4(resolve2(dir, "../package.json"), "utf-8"));
8822
+ const dir = dirname4(fileURLToPath(import.meta.url));
8823
+ const pkg2 = JSON.parse(readFileSync5(resolve2(dir, "../package.json"), "utf-8"));
8464
8824
  return typeof pkg2.version === "string" ? pkg2.version : "unknown";
8465
8825
  } catch {
8466
8826
  return "unknown";
@@ -8863,8 +9223,8 @@ __export(config_exports, {
8863
9223
  setApiBaseOverride: () => setApiBaseOverride,
8864
9224
  shouldIgnore: () => shouldIgnore
8865
9225
  });
8866
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as existsSync5 } from "fs";
8867
- import { dirname as dirname4, resolve as resolve3 } from "path";
9226
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6 } from "fs";
9227
+ import { dirname as dirname5, resolve as resolve3 } from "path";
8868
9228
  function setApiBaseOverride(url) {
8869
9229
  apiBaseOverride = url;
8870
9230
  }
@@ -8873,9 +9233,9 @@ function getApiBaseOverride() {
8873
9233
  }
8874
9234
  function isAllowedApiHost(url) {
8875
9235
  try {
8876
- const { protocol, hostname: hostname6 } = new URL(url);
9236
+ const { protocol, hostname: hostname7 } = new URL(url);
8877
9237
  if (protocol !== "https:") return false;
8878
- return hostname6 === "gipity.ai" || hostname6.endsWith(".gipity.ai");
9238
+ return hostname7 === "gipity.ai" || hostname7.endsWith(".gipity.ai");
8879
9239
  } catch {
8880
9240
  return false;
8881
9241
  }
@@ -8901,7 +9261,7 @@ function findConfigPath() {
8901
9261
  let dir = process.cwd();
8902
9262
  while (true) {
8903
9263
  const candidate = resolve3(dir, CONFIG_FILE);
8904
- if (existsSync5(candidate)) return candidate;
9264
+ if (existsSync6(candidate)) return candidate;
8905
9265
  const parent = resolve3(dir, "..");
8906
9266
  if (parent === dir) return null;
8907
9267
  dir = parent;
@@ -8914,14 +9274,14 @@ function getConfigPath() {
8914
9274
  }
8915
9275
  function getProjectRoot() {
8916
9276
  const path5 = getConfigPath();
8917
- return path5 ? dirname4(path5) : null;
9277
+ return path5 ? dirname5(path5) : null;
8918
9278
  }
8919
9279
  function getConfig() {
8920
9280
  if (cached3) return cached3;
8921
9281
  const path5 = getConfigPath();
8922
9282
  if (!path5) return null;
8923
9283
  try {
8924
- cached3 = JSON.parse(readFileSync5(path5, "utf-8"));
9284
+ cached3 = JSON.parse(readFileSync6(path5, "utf-8"));
8925
9285
  return cached3;
8926
9286
  } catch {
8927
9287
  return null;
@@ -9009,13 +9369,13 @@ function saveConfig(data) {
9009
9369
  "saveConfig: no .gipity.json found to update. Use saveConfigAt(dir, \u2026) to create a new project config."
9010
9370
  );
9011
9371
  }
9012
- writeFileSync3(path5, JSON.stringify(data, null, 2) + "\n");
9372
+ writeFileSync4(path5, JSON.stringify(data, null, 2) + "\n");
9013
9373
  cached3 = data;
9014
9374
  cachedPath = path5;
9015
9375
  }
9016
9376
  function saveConfigAt(dir, data) {
9017
9377
  const path5 = resolve3(dir, CONFIG_FILE);
9018
- writeFileSync3(path5, JSON.stringify(data, null, 2) + "\n");
9378
+ writeFileSync4(path5, JSON.stringify(data, null, 2) + "\n");
9019
9379
  cached3 = data;
9020
9380
  cachedPath = path5;
9021
9381
  }
@@ -33750,9 +34110,9 @@ var {
33750
34110
  // src/index.ts
33751
34111
  init_config();
33752
34112
  init_utils();
33753
- import { readFileSync as readFileSync28 } from "fs";
34113
+ import { readFileSync as readFileSync29 } from "fs";
33754
34114
  import { fileURLToPath as fileURLToPath3 } from "url";
33755
- import { dirname as dirname15, resolve as resolve18 } from "path";
34115
+ import { dirname as dirname16, resolve as resolve18 } from "path";
33756
34116
 
33757
34117
  // src/helpers/output.ts
33758
34118
  var frameOpen = false;
@@ -33836,14 +34196,14 @@ init_colors();
33836
34196
 
33837
34197
  // src/bug-queue.ts
33838
34198
  init_api();
33839
- import { existsSync as existsSync6, mkdirSync as mkdirSync3, readdirSync as readdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2 } from "fs";
33840
- import { join as join7 } from "path";
33841
- import { homedir as homedir5 } from "os";
33842
- var QUEUE_DIR = join7(process.env.GIPITY_DIR || join7(homedir5(), ".gipity"), "bug-queue");
34199
+ import { existsSync as existsSync7, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync5, unlinkSync as unlinkSync3 } from "fs";
34200
+ import { join as join9 } from "path";
34201
+ import { homedir as homedir7 } from "os";
34202
+ var QUEUE_DIR = join9(process.env.GIPITY_DIR || join9(homedir7(), ".gipity"), "bug-queue");
33843
34203
  function queueBugReport(report) {
33844
- mkdirSync3(QUEUE_DIR, { recursive: true, mode: 448 });
33845
- const file = join7(QUEUE_DIR, `${Date.now()}-${Math.random().toString(36).slice(2, 8)}.json`);
33846
- writeFileSync4(file, JSON.stringify(report, null, 2), { mode: 384 });
34204
+ mkdirSync4(QUEUE_DIR, { recursive: true, mode: 448 });
34205
+ const file = join9(QUEUE_DIR, `${Date.now()}-${Math.random().toString(36).slice(2, 8)}.json`);
34206
+ writeFileSync5(file, JSON.stringify(report, null, 2), { mode: 384 });
33847
34207
  }
33848
34208
  function isRetryableFailure(err) {
33849
34209
  if (err?.name === "ApiError") {
@@ -33852,17 +34212,17 @@ function isRetryableFailure(err) {
33852
34212
  return typeof err?.statusCode !== "number";
33853
34213
  }
33854
34214
  async function flushBugQueue() {
33855
- if (!existsSync6(QUEUE_DIR)) return 0;
34215
+ if (!existsSync7(QUEUE_DIR)) return 0;
33856
34216
  let delivered = 0;
33857
34217
  for (const file of readdirSync3(QUEUE_DIR)) {
33858
34218
  if (!file.endsWith(".json")) continue;
33859
- const path5 = join7(QUEUE_DIR, file);
34219
+ const path5 = join9(QUEUE_DIR, file);
33860
34220
  let report;
33861
34221
  try {
33862
- report = JSON.parse(readFileSync6(path5, "utf-8"));
34222
+ report = JSON.parse(readFileSync7(path5, "utf-8"));
33863
34223
  } catch {
33864
34224
  try {
33865
- unlinkSync2(path5);
34225
+ unlinkSync3(path5);
33866
34226
  } catch {
33867
34227
  }
33868
34228
  continue;
@@ -33874,7 +34234,7 @@ async function flushBugQueue() {
33874
34234
  summary: report.summary,
33875
34235
  detail: report.detail
33876
34236
  });
33877
- unlinkSync2(path5);
34237
+ unlinkSync3(path5);
33878
34238
  delivered++;
33879
34239
  } catch {
33880
34240
  }
@@ -34043,9 +34403,9 @@ function run(label2, action) {
34043
34403
  init_api();
34044
34404
  init_config();
34045
34405
  init_utils();
34046
- import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync7, statSync as statSync2, lstatSync, unlinkSync as unlinkSync3, readdirSync as readdirSync4, rmdirSync, readFileSync as readFileSync7, renameSync, openSync as openSync2, closeSync as closeSync2, utimesSync, realpathSync as realpathSync3 } from "fs";
34047
- import { join as join8, relative, dirname as dirname5, extname as extname2, resolve as resolve4, sep as sep2 } from "path";
34048
- import { hostname } from "os";
34406
+ import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, statSync as statSync2, lstatSync, unlinkSync as unlinkSync4, readdirSync as readdirSync4, rmdirSync, readFileSync as readFileSync8, renameSync, openSync as openSync2, closeSync as closeSync2, utimesSync, realpathSync as realpathSync3 } from "fs";
34407
+ import { join as join10, relative, dirname as dirname6, extname as extname2, resolve as resolve4, sep as sep2 } from "path";
34408
+ import { hostname as hostname2 } from "os";
34049
34409
  import { createHash as createHash2 } from "crypto";
34050
34410
 
34051
34411
  // src/upload.ts
@@ -34295,15 +34655,15 @@ var BULK_DELETE_FRACTION = 0.25;
34295
34655
  var DOWNLOAD_IDLE_MS = 3e4;
34296
34656
  function syncStatePath() {
34297
34657
  const configPath = getConfigPath();
34298
- return join8(dirname5(configPath), ".gipity", "sync-state.json");
34658
+ return join10(dirname6(configPath), ".gipity", "sync-state.json");
34299
34659
  }
34300
34660
  function lockPath() {
34301
34661
  const configPath = getConfigPath();
34302
- return join8(dirname5(configPath), ".gipity", "sync.lock");
34662
+ return join10(dirname6(configPath), ".gipity", "sync.lock");
34303
34663
  }
34304
34664
  function projectDir() {
34305
34665
  const configPath = getConfigPath();
34306
- return dirname5(configPath);
34666
+ return dirname6(configPath);
34307
34667
  }
34308
34668
  var LOCK_WAIT_MS2 = 3e4;
34309
34669
  var LOCK_POLL_MS2 = 500;
@@ -34313,7 +34673,7 @@ function isLockReclaimable(path5, now = Date.now()) {
34313
34673
  let raw;
34314
34674
  let mtimeMs;
34315
34675
  try {
34316
- raw = readFileSync7(path5, "utf-8").trim();
34676
+ raw = readFileSync8(path5, "utf-8").trim();
34317
34677
  mtimeMs = statSync2(path5).mtimeMs;
34318
34678
  } catch {
34319
34679
  return false;
@@ -34329,7 +34689,7 @@ function isLockReclaimable(path5, now = Date.now()) {
34329
34689
  }
34330
34690
  async function acquireLock(progress) {
34331
34691
  const path5 = lockPath();
34332
- mkdirSync4(dirname5(path5), { recursive: true });
34692
+ mkdirSync5(dirname6(path5), { recursive: true });
34333
34693
  const start = Date.now();
34334
34694
  let waitSpinner = null;
34335
34695
  const settleWait = (ok) => {
@@ -34341,7 +34701,7 @@ async function acquireLock(progress) {
34341
34701
  while (true) {
34342
34702
  try {
34343
34703
  const fd2 = openSync2(path5, "wx");
34344
- writeFileSync5(fd2, String(process.pid));
34704
+ writeFileSync6(fd2, String(process.pid));
34345
34705
  closeSync2(fd2);
34346
34706
  const beat = setInterval(() => {
34347
34707
  try {
@@ -34354,14 +34714,14 @@ async function acquireLock(progress) {
34354
34714
  return () => {
34355
34715
  clearInterval(beat);
34356
34716
  try {
34357
- unlinkSync3(path5);
34717
+ unlinkSync4(path5);
34358
34718
  } catch {
34359
34719
  }
34360
34720
  };
34361
34721
  } catch {
34362
34722
  if (isLockReclaimable(path5)) {
34363
34723
  try {
34364
- unlinkSync3(path5);
34724
+ unlinkSync4(path5);
34365
34725
  } catch {
34366
34726
  }
34367
34727
  continue;
@@ -34381,9 +34741,9 @@ async function acquireLock(progress) {
34381
34741
  }
34382
34742
  function readBaseline(projectGuid2) {
34383
34743
  const path5 = syncStatePath();
34384
- if (!existsSync7(path5)) return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
34744
+ if (!existsSync8(path5)) return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
34385
34745
  try {
34386
- const parsed = JSON.parse(readFileSync7(path5, "utf-8"));
34746
+ const parsed = JSON.parse(readFileSync8(path5, "utf-8"));
34387
34747
  if (parsed.projectGuid !== projectGuid2) {
34388
34748
  return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
34389
34749
  }
@@ -34399,8 +34759,8 @@ function readBaseline(projectGuid2) {
34399
34759
  }
34400
34760
  function writeBaseline(b7) {
34401
34761
  const path5 = syncStatePath();
34402
- mkdirSync4(dirname5(path5), { recursive: true });
34403
- writeFileSync5(path5, JSON.stringify(b7, null, 2));
34762
+ mkdirSync5(dirname6(path5), { recursive: true });
34763
+ writeFileSync6(path5, JSON.stringify(b7, null, 2));
34404
34764
  }
34405
34765
  function walkLocal(root, ignorePatterns, baseline) {
34406
34766
  const result = /* @__PURE__ */ new Map();
@@ -34412,11 +34772,11 @@ function walkLocal(root, ignorePatterns, baseline) {
34412
34772
  return;
34413
34773
  }
34414
34774
  for (const entry of entries) {
34415
- const full = join8(dir, entry.name);
34775
+ const full = join10(dir, entry.name);
34416
34776
  const rel2 = relative(root, full).replace(/\\/g, "/");
34417
34777
  if (shouldIgnore(rel2, ignorePatterns)) continue;
34418
34778
  if (entry.isDirectory()) {
34419
- if (existsSync7(join8(full, CONFIG_FILE2))) continue;
34779
+ if (existsSync8(join10(full, CONFIG_FILE2))) continue;
34420
34780
  walk(full);
34421
34781
  } else if (entry.isFile()) {
34422
34782
  try {
@@ -34439,7 +34799,7 @@ async function ensureLocalHashes(root, local, paths) {
34439
34799
  const info2 = local.get(path5);
34440
34800
  if (!info2 || info2.sha256) continue;
34441
34801
  try {
34442
- const { sha256 } = await hashFile(join8(root, path5));
34802
+ const { sha256 } = await hashFile(join10(root, path5));
34443
34803
  info2.sha256 = sha256;
34444
34804
  } catch {
34445
34805
  }
@@ -34457,7 +34817,7 @@ function resolveInRoot(root, relPath) {
34457
34817
  try {
34458
34818
  const rootReal = realpathSync3(rootResolved);
34459
34819
  let ancestor = full;
34460
- while (!existsSync7(ancestor) && dirname5(ancestor) !== ancestor) ancestor = dirname5(ancestor);
34820
+ while (!existsSync8(ancestor) && dirname6(ancestor) !== ancestor) ancestor = dirname6(ancestor);
34461
34821
  const ancestorReal = realpathSync3(ancestor);
34462
34822
  if (ancestorReal !== rootReal && !ancestorReal.startsWith(rootReal + sep2)) {
34463
34823
  throw new Error(`Refusing path outside project root (symlink escape): ${relPath}`);
@@ -34576,7 +34936,7 @@ function classifyRemote(info2, base) {
34576
34936
  }
34577
34937
  function conflictedCopyName(path5) {
34578
34938
  const ts2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:T]/g, "-").replace(/\..+$/, "");
34579
- const host = hostname().replace(/[^A-Za-z0-9._-]/g, "_");
34939
+ const host = hostname2().replace(/[^A-Za-z0-9._-]/g, "_");
34580
34940
  const ext = extname2(path5);
34581
34941
  const base = ext ? path5.slice(0, -ext.length) : path5;
34582
34942
  return `${base} (conflict from ${host} ${ts2})${ext}`;
@@ -34746,9 +35106,9 @@ Plan deletes ${totalDeletes} files (${Math.round(fraction * 100)}% of the tree).
34746
35106
  }
34747
35107
  var GIPITY_IGNORE_FILE = ".gipityignore";
34748
35108
  function readGipityIgnore(root) {
34749
- const path5 = join8(root, GIPITY_IGNORE_FILE);
34750
- if (!existsSync7(path5)) return [];
34751
- return readFileSync7(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
35109
+ const path5 = join10(root, GIPITY_IGNORE_FILE);
35110
+ if (!existsSync8(path5)) return [];
35111
+ return readFileSync8(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
34752
35112
  }
34753
35113
  function effectiveIgnore(root, configIgnore) {
34754
35114
  const base = configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE;
@@ -34934,8 +35294,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
34934
35294
  return;
34935
35295
  }
34936
35296
  if (currentBytes) {
34937
- mkdirSync4(dirname5(full), { recursive: true });
34938
- writeFileSync5(full, currentBytes);
35297
+ mkdirSync5(dirname6(full), { recursive: true });
35298
+ writeFileSync6(full, currentBytes);
34939
35299
  const stat2 = statSync2(full);
34940
35300
  baseline.files[a.path] = {
34941
35301
  size: stat2.size,
@@ -34978,7 +35338,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
34978
35338
  errors.push(e.message);
34979
35339
  continue;
34980
35340
  }
34981
- if (existsSync7(full)) {
35341
+ if (existsSync8(full)) {
34982
35342
  const scanSha = local.get(a.path)?.sha256 ?? baseline.files[a.path]?.sha256;
34983
35343
  const remoteSha = remote.get(a.path)?.sha256 ?? void 0;
34984
35344
  let currentSha;
@@ -34991,8 +35351,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
34991
35351
  continue;
34992
35352
  }
34993
35353
  }
34994
- mkdirSync4(dirname5(full), { recursive: true });
34995
- writeFileSync5(full, buf);
35354
+ mkdirSync5(dirname6(full), { recursive: true });
35355
+ writeFileSync6(full, buf);
34996
35356
  const stat2 = statSync2(full);
34997
35357
  local.set(a.path, { size: stat2.size, mtime: stat2.mtime.toISOString(), sha256: void 0 });
34998
35358
  baseline.files[a.path] = {
@@ -35014,7 +35374,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35014
35374
  continue;
35015
35375
  }
35016
35376
  try {
35017
- mkdirSync4(dirname5(renamed), { recursive: true });
35377
+ mkdirSync5(dirname6(renamed), { recursive: true });
35018
35378
  renameSync(full, renamed);
35019
35379
  } catch (err) {
35020
35380
  errors.push(`Could not rename ${a.path} \u2192 ${a.renamedLocalTo}: ${err.message}`);
@@ -35022,8 +35382,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35022
35382
  }
35023
35383
  const buf = downloadedBytes.get(a.path);
35024
35384
  if (buf) {
35025
- mkdirSync4(dirname5(full), { recursive: true });
35026
- writeFileSync5(full, buf);
35385
+ mkdirSync5(dirname6(full), { recursive: true });
35386
+ writeFileSync6(full, buf);
35027
35387
  const stat2 = statSync2(full);
35028
35388
  baseline.files[a.path] = {
35029
35389
  size: stat2.size,
@@ -35204,13 +35564,13 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35204
35564
  continue;
35205
35565
  }
35206
35566
  try {
35207
- unlinkSync3(full);
35208
- dirsTouchedByDelete.add(dirname5(full));
35567
+ unlinkSync4(full);
35568
+ dirsTouchedByDelete.add(dirname6(full));
35209
35569
  delete baseline.files[a.path];
35210
35570
  applied++;
35211
35571
  } catch (err) {
35212
35572
  if (err.code === "ENOENT") {
35213
- dirsTouchedByDelete.add(dirname5(full));
35573
+ dirsTouchedByDelete.add(dirname6(full));
35214
35574
  delete baseline.files[a.path];
35215
35575
  applied++;
35216
35576
  } else {
@@ -35229,8 +35589,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
35229
35589
  const buf = await fetchOne(config.projectGuid, a.path);
35230
35590
  if (!buf) throw new Error("remote bytes unavailable");
35231
35591
  const full = resolveInRoot(root, a.path);
35232
- mkdirSync4(dirname5(full), { recursive: true });
35233
- writeFileSync5(full, buf);
35592
+ mkdirSync5(dirname6(full), { recursive: true });
35593
+ writeFileSync6(full, buf);
35234
35594
  const stat2 = statSync2(full);
35235
35595
  const { sha256 } = await hashFile(full);
35236
35596
  const current = typeof err.data?.current_server_version === "number" ? err.data.current_server_version : null;
@@ -35295,7 +35655,7 @@ function cleanupEmptyDirs(root, emptiedDirs) {
35295
35655
  } catch {
35296
35656
  break;
35297
35657
  }
35298
- dir = dirname5(dir);
35658
+ dir = dirname6(dir);
35299
35659
  }
35300
35660
  }
35301
35661
  }
@@ -35509,11 +35869,11 @@ async function syncBeforeAction(opts) {
35509
35869
  }
35510
35870
 
35511
35871
  // src/helpers/body.ts
35512
- import { readFileSync as readFileSync8 } from "node:fs";
35872
+ import { readFileSync as readFileSync9 } from "node:fs";
35513
35873
  function readStdin() {
35514
35874
  if (process.stdin.isTTY) return "";
35515
35875
  try {
35516
- return readFileSync8(0, "utf-8");
35876
+ return readFileSync9(0, "utf-8");
35517
35877
  } catch {
35518
35878
  return "";
35519
35879
  }
@@ -35529,7 +35889,7 @@ function readFileField(spec) {
35529
35889
  if (!field) throw new Error(`Invalid --file '${spec}': missing field name before '='.`);
35530
35890
  if (!path5) throw new Error(`Invalid --file '${spec}': missing file path after '='.`);
35531
35891
  try {
35532
- return [field, { data: readFileSync8(path5).toString("base64"), media_type: guessMime(path5) }];
35892
+ return [field, { data: readFileSync9(path5).toString("base64"), media_type: guessMime(path5) }];
35533
35893
  } catch (e) {
35534
35894
  throw new Error(`Cannot read --file '${path5}': ${e.message}`);
35535
35895
  }
@@ -35560,7 +35920,7 @@ function resolveJsonBody(raw) {
35560
35920
  } else if (raw.startsWith("@")) {
35561
35921
  const path5 = raw.slice(1);
35562
35922
  try {
35563
- source = readFileSync8(path5, "utf-8");
35923
+ source = readFileSync9(path5, "utf-8");
35564
35924
  } catch (e) {
35565
35925
  throw new Error(`Cannot read body file '${path5}': ${e.message}`);
35566
35926
  }
@@ -35664,7 +36024,7 @@ async function projectGuid(opts) {
35664
36024
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
35665
36025
  return config.projectGuid;
35666
36026
  }
35667
- keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").option("--role <role>", "viewer | editor | owner (default: viewer)", "viewer").option("--expires-days <n>", "Days until the key expires (default: never)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
36027
+ keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
35668
36028
  const body = { name, role: opts.role };
35669
36029
  if (opts.expiresDays !== void 0) {
35670
36030
  const days = parseInt(opts.expiresDays, 10);
@@ -35717,15 +36077,15 @@ init_setup();
35717
36077
  init_agents();
35718
36078
  init_colors();
35719
36079
  init_utils();
35720
- import { basename as basename2, resolve as resolve7, dirname as dirname6 } from "path";
35721
- import { existsSync as existsSync10, readFileSync as readFileSync11 } from "fs";
36080
+ import { basename as basename2, resolve as resolve7, dirname as dirname7 } from "path";
36081
+ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
35722
36082
 
35723
36083
  // src/adopt-cwd.ts
35724
36084
  init_api();
35725
36085
  init_setup();
35726
36086
  import { readdirSync as readdirSync6, statSync as statSync4 } from "fs";
35727
- import { join as join12, resolve as resolve6, sep as sep3, parse as parsePath } from "path";
35728
- import { homedir as homedir8 } from "os";
36087
+ import { join as join14, resolve as resolve6, sep as sep3, parse as parsePath } from "path";
36088
+ import { homedir as homedir10 } from "os";
35729
36089
 
35730
36090
  // src/project-setup.ts
35731
36091
  init_config();
@@ -35734,7 +36094,7 @@ init_setup();
35734
36094
  // src/template-vars.ts
35735
36095
  init_setup();
35736
36096
  import { promises as fs, readdirSync as readdirSync5, statSync as statSync3 } from "fs";
35737
- import { join as join9, relative as relative2, extname as extname3 } from "path";
36097
+ import { join as join11, relative as relative2, extname as extname3 } from "path";
35738
36098
  var SUBSTITUTABLE_EXTS = /* @__PURE__ */ new Set([
35739
36099
  ".html",
35740
36100
  ".htm",
@@ -35883,7 +36243,7 @@ function* walkTextFiles(root) {
35883
36243
  }
35884
36244
  for (const entry of entries) {
35885
36245
  if (isSyncIgnored(entry.name)) continue;
35886
- const full = join9(dir, entry.name);
36246
+ const full = join11(dir, entry.name);
35887
36247
  if (entry.isDirectory()) {
35888
36248
  stack.push(full);
35889
36249
  } else if (entry.isFile()) {
@@ -35905,7 +36265,7 @@ async function substituteDir(dir, vars) {
35905
36265
  for (const rel2 of walkTextFiles(dir)) {
35906
36266
  const ext = extname3(rel2).toLowerCase();
35907
36267
  if (!SUBSTITUTABLE_EXTS.has(ext)) continue;
35908
- const abs = join9(dir, rel2);
36268
+ const abs = join11(dir, rel2);
35909
36269
  let content;
35910
36270
  try {
35911
36271
  content = await fs.readFile(abs, "utf-8");
@@ -35973,19 +36333,19 @@ async function finalizeLocalProject(opts) {
35973
36333
  }
35974
36334
 
35975
36335
  // src/relay/paths.ts
35976
- import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
35977
- import { homedir as homedir6 } from "os";
35978
- import { join as join10, resolve as resolve5 } from "path";
36336
+ import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
36337
+ import { homedir as homedir8 } from "os";
36338
+ import { join as join12, resolve as resolve5 } from "path";
35979
36339
  function getProjectsRoot() {
35980
- const settingsPath = join10(homedir6(), ".gipity", "settings.json");
35981
- const defaultDir = join10(homedir6(), "GipityProjects");
36340
+ const settingsPath = join12(homedir8(), ".gipity", "settings.json");
36341
+ const defaultDir = join12(homedir8(), "GipityProjects");
35982
36342
  try {
35983
- if (existsSync8(settingsPath)) {
35984
- const settings = JSON.parse(readFileSync9(settingsPath, "utf-8"));
36343
+ if (existsSync9(settingsPath)) {
36344
+ const settings = JSON.parse(readFileSync10(settingsPath, "utf-8"));
35985
36345
  if (settings.projectsDir) return resolve5(settings.projectsDir);
35986
36346
  } else {
35987
- mkdirSync5(join10(homedir6(), ".gipity"), { recursive: true });
35988
- writeFileSync6(settingsPath, JSON.stringify({ projectsDir: defaultDir }, null, 2) + "\n");
36347
+ mkdirSync6(join12(homedir8(), ".gipity"), { recursive: true });
36348
+ writeFileSync7(settingsPath, JSON.stringify({ projectsDir: defaultDir }, null, 2) + "\n");
35989
36349
  }
35990
36350
  } catch {
35991
36351
  }
@@ -35993,19 +36353,19 @@ function getProjectsRoot() {
35993
36353
  }
35994
36354
 
35995
36355
  // src/relay/state.ts
35996
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync9, chmodSync as chmodSync2, unlinkSync as unlinkSync4 } from "fs";
35997
- import { join as join11 } from "path";
35998
- import { homedir as homedir7 } from "os";
35999
- var RELAY_DIR = process.env.GIPITY_DIR || join11(homedir7(), ".gipity");
36000
- var RELAY_FILE = join11(RELAY_DIR, "relay.json");
36356
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, existsSync as existsSync10, chmodSync as chmodSync3, unlinkSync as unlinkSync5 } from "fs";
36357
+ import { join as join13 } from "path";
36358
+ import { homedir as homedir9 } from "os";
36359
+ var RELAY_DIR = process.env.GIPITY_DIR || join13(homedir9(), ".gipity");
36360
+ var RELAY_FILE = join13(RELAY_DIR, "relay.json");
36001
36361
  var FILE_MODE = 384;
36002
36362
  function emptyState() {
36003
36363
  return { device: null, paused: false };
36004
36364
  }
36005
36365
  function loadState() {
36006
- if (!existsSync9(RELAY_FILE)) return emptyState();
36366
+ if (!existsSync10(RELAY_FILE)) return emptyState();
36007
36367
  try {
36008
- const raw = JSON.parse(readFileSync10(RELAY_FILE, "utf-8"));
36368
+ const raw = JSON.parse(readFileSync11(RELAY_FILE, "utf-8"));
36009
36369
  return {
36010
36370
  device: raw.device ?? null,
36011
36371
  paused: Boolean(raw.paused),
@@ -36021,10 +36381,10 @@ function loadState() {
36021
36381
  }
36022
36382
  }
36023
36383
  function saveState(state) {
36024
- mkdirSync6(RELAY_DIR, { recursive: true });
36025
- writeFileSync7(RELAY_FILE, JSON.stringify(state, null, 2) + "\n", { mode: FILE_MODE });
36384
+ mkdirSync7(RELAY_DIR, { recursive: true });
36385
+ writeFileSync8(RELAY_FILE, JSON.stringify(state, null, 2) + "\n", { mode: FILE_MODE });
36026
36386
  try {
36027
- chmodSync2(RELAY_FILE, FILE_MODE);
36387
+ chmodSync3(RELAY_FILE, FILE_MODE);
36028
36388
  } catch {
36029
36389
  }
36030
36390
  }
@@ -36107,35 +36467,35 @@ function agentUpdatesEnabled() {
36107
36467
  if (process.env.CI || process.env.NODE_ENV === "test") return false;
36108
36468
  return loadState().agent_updates !== false;
36109
36469
  }
36110
- var RELAY_PID_FILE = join11(RELAY_DIR, "relay.pid");
36470
+ var RELAY_PID_FILE = join13(RELAY_DIR, "relay.pid");
36111
36471
  function getDaemonPidPath() {
36112
36472
  return RELAY_PID_FILE;
36113
36473
  }
36114
36474
  function writeDaemonPid(pid) {
36115
- mkdirSync6(RELAY_DIR, { recursive: true });
36116
- writeFileSync7(RELAY_PID_FILE, String(pid), { flag: "wx" });
36475
+ mkdirSync7(RELAY_DIR, { recursive: true });
36476
+ writeFileSync8(RELAY_PID_FILE, String(pid), { flag: "wx" });
36117
36477
  }
36118
36478
  function clearDaemonPid() {
36119
36479
  try {
36120
- unlinkSync4(RELAY_PID_FILE);
36480
+ unlinkSync5(RELAY_PID_FILE);
36121
36481
  } catch {
36122
36482
  }
36123
36483
  }
36124
36484
  function isDaemonRunning() {
36125
- if (!existsSync9(RELAY_PID_FILE)) return false;
36485
+ if (!existsSync10(RELAY_PID_FILE)) return false;
36126
36486
  try {
36127
- const raw = readFileSync10(RELAY_PID_FILE, "utf-8").trim();
36487
+ const raw = readFileSync11(RELAY_PID_FILE, "utf-8").trim();
36128
36488
  const pid = parseInt(raw, 10);
36129
36489
  if (!pid || isNaN(pid)) {
36130
36490
  try {
36131
- unlinkSync4(RELAY_PID_FILE);
36491
+ unlinkSync5(RELAY_PID_FILE);
36132
36492
  } catch {
36133
36493
  }
36134
36494
  return false;
36135
36495
  }
36136
36496
  if (pid === process.pid) {
36137
36497
  try {
36138
- unlinkSync4(RELAY_PID_FILE);
36498
+ unlinkSync5(RELAY_PID_FILE);
36139
36499
  } catch {
36140
36500
  }
36141
36501
  return false;
@@ -36144,7 +36504,7 @@ function isDaemonRunning() {
36144
36504
  return true;
36145
36505
  } catch {
36146
36506
  try {
36147
- unlinkSync4(RELAY_PID_FILE);
36507
+ unlinkSync5(RELAY_PID_FILE);
36148
36508
  } catch {
36149
36509
  }
36150
36510
  return false;
@@ -36171,7 +36531,7 @@ function scanForAdoption(cwd) {
36171
36531
  for (const name of entries) {
36172
36532
  if (truncated) return;
36173
36533
  if (isSyncIgnored(name)) continue;
36174
- const full = join12(dir, name);
36534
+ const full = join14(dir, name);
36175
36535
  let st2;
36176
36536
  try {
36177
36537
  st2 = statSync4(full);
@@ -36208,7 +36568,7 @@ function isLikelyEmpty(cwd) {
36208
36568
  }
36209
36569
  function canAdoptCwd(cwd) {
36210
36570
  const norm = resolve6(cwd);
36211
- const home = resolve6(homedir8());
36571
+ const home = resolve6(homedir10());
36212
36572
  const blocked = /* @__PURE__ */ new Set([
36213
36573
  sep3,
36214
36574
  home,
@@ -36245,10 +36605,10 @@ function countGitRepoChildren(dir) {
36245
36605
  let count = 0;
36246
36606
  for (const name of entries.slice(0, 50)) {
36247
36607
  if (name.startsWith(".")) continue;
36248
- const child = join12(dir, name);
36608
+ const child = join14(dir, name);
36249
36609
  try {
36250
36610
  if (!statSync4(child).isDirectory()) continue;
36251
- const gitPath = join12(child, ".git");
36611
+ const gitPath = join14(child, ".git");
36252
36612
  if (statSync4(gitPath)) count++;
36253
36613
  } catch {
36254
36614
  }
@@ -36258,7 +36618,7 @@ function countGitRepoChildren(dir) {
36258
36618
  }
36259
36619
  function formatCwdLabel(cwd) {
36260
36620
  const norm = resolve6(cwd);
36261
- const home = resolve6(homedir8());
36621
+ const home = resolve6(homedir10());
36262
36622
  if (norm === home) return "~";
36263
36623
  if (norm.startsWith(home + sep3)) {
36264
36624
  const tail2 = norm.slice(home.length + 1).split(sep3);
@@ -36388,7 +36748,7 @@ Working with an existing Gipity project:
36388
36748
  process.exit(1);
36389
36749
  }
36390
36750
  const cwd = process.cwd();
36391
- if (existsSync10(resolve7(cwd, ".gipity.json"))) {
36751
+ if (existsSync11(resolve7(cwd, ".gipity.json"))) {
36392
36752
  const existing = getConfig();
36393
36753
  console.log(`Already linked to ${info(`"${existing?.projectSlug ?? ""}"`)} ${muted(`(${existing?.projectGuid ?? ""})`)}`);
36394
36754
  setupProjectTools(tools);
@@ -36419,7 +36779,7 @@ Working with an existing Gipity project:
36419
36779
  }
36420
36780
  const ancestorConfigPath = getConfigPath();
36421
36781
  if (ancestorConfigPath) {
36422
- console.log(muted(`Note: ${formatCwdLabel(dirname6(ancestorConfigPath))} is already a Gipity project.`));
36782
+ console.log(muted(`Note: ${formatCwdLabel(dirname7(ancestorConfigPath))} is already a Gipity project.`));
36423
36783
  const ok = await confirm(
36424
36784
  `Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`,
36425
36785
  { default: "no" }
@@ -36471,7 +36831,7 @@ Working with an existing Gipity project:
36471
36831
  if (adopted.applied > 0) console.log(`Synced ${adopted.applied} change${adopted.applied > 1 ? "s" : ""} with Gipity.`);
36472
36832
  if (opts.capture === false) {
36473
36833
  try {
36474
- const cfg = JSON.parse(readFileSync11(resolve7(cwd, ".gipity.json"), "utf-8"));
36834
+ const cfg = JSON.parse(readFileSync12(resolve7(cwd, ".gipity.json"), "utf-8"));
36475
36835
  cfg.captureHooks = false;
36476
36836
  saveConfigAt(cwd, cfg);
36477
36837
  } catch {
@@ -36506,15 +36866,15 @@ init_api();
36506
36866
  init_config();
36507
36867
  init_colors();
36508
36868
  init_setup();
36509
- import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
36510
- import { join as join13, resolve as resolve8 } from "path";
36511
- import { homedir as homedir9 } from "os";
36869
+ import { existsSync as existsSync12, readFileSync as readFileSync13 } from "fs";
36870
+ import { join as join15, resolve as resolve8 } from "path";
36871
+ import { homedir as homedir11 } from "os";
36512
36872
  function checkGipityPlugin() {
36513
- const path5 = join13(homedir9(), ".claude", "settings.json");
36873
+ const path5 = join15(homedir11(), ".claude", "settings.json");
36514
36874
  let settings = {};
36515
- if (existsSync11(path5)) {
36875
+ if (existsSync12(path5)) {
36516
36876
  try {
36517
- settings = JSON.parse(readFileSync12(path5, "utf-8"));
36877
+ settings = JSON.parse(readFileSync13(path5, "utf-8"));
36518
36878
  } catch {
36519
36879
  }
36520
36880
  }
@@ -36631,7 +36991,7 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
36631
36991
  });
36632
36992
 
36633
36993
  // src/commands/sync.ts
36634
- import { dirname as dirname7 } from "node:path";
36994
+ import { dirname as dirname8 } from "node:path";
36635
36995
  init_colors();
36636
36996
  init_utils();
36637
36997
  init_config();
@@ -36649,7 +37009,7 @@ ${result.applied} action${result.applied > 1 ? "s" : ""} applied.`);
36649
37009
  }
36650
37010
  if (isWsl()) {
36651
37011
  const configPath = getConfigPath();
36652
- const twin = configPath ? findWindowsTwinProject(dirname7(configPath)) : null;
37012
+ const twin = configPath ? findWindowsTwinProject(dirname8(configPath)) : null;
36653
37013
  if (twin) {
36654
37014
  console.log(muted(
36655
37015
  `
@@ -36766,7 +37126,7 @@ init_colors();
36766
37126
  init_auth();
36767
37127
 
36768
37128
  // src/commands/page-eval.ts
36769
- import { readFileSync as readFileSync14 } from "node:fs";
37129
+ import { readFileSync as readFileSync15 } from "node:fs";
36770
37130
  init_api();
36771
37131
  init_colors();
36772
37132
  init_auth();
@@ -36799,8 +37159,8 @@ function dropCheckpoint(projectGuid2, database) {
36799
37159
  // src/page-fixtures.ts
36800
37160
  init_api();
36801
37161
  init_config();
36802
- import { readFileSync as readFileSync13, statSync as statSync6, existsSync as existsSync12, readdirSync as readdirSync7 } from "node:fs";
36803
- import { basename as basename4, resolve as resolve10, relative as relative3, join as join14 } from "node:path";
37162
+ import { readFileSync as readFileSync14, statSync as statSync6, existsSync as existsSync13, readdirSync as readdirSync7 } from "node:fs";
37163
+ import { basename as basename4, resolve as resolve10, relative as relative3, join as join16 } from "node:path";
36804
37164
  var FIND_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".gipity", "dist", "build", ".next", "coverage"]);
36805
37165
  function findByBasename(root, name, limit = 3) {
36806
37166
  const hits = [];
@@ -36817,9 +37177,9 @@ function findByBasename(root, name, limit = 3) {
36817
37177
  }
36818
37178
  for (const e of entries) {
36819
37179
  if (e.isDirectory()) {
36820
- if (!FIND_SKIP.has(e.name)) queue.push(join14(dir, e.name));
37180
+ if (!FIND_SKIP.has(e.name)) queue.push(join16(dir, e.name));
36821
37181
  } else if (e.name === name && hits.length < limit) {
36822
- hits.push(join14(dir, e.name));
37182
+ hits.push(join16(dir, e.name));
36823
37183
  }
36824
37184
  }
36825
37185
  }
@@ -36827,7 +37187,7 @@ function findByBasename(root, name, limit = 3) {
36827
37187
  }
36828
37188
  function assertLocalAsset(flag, localPath) {
36829
37189
  const abs = resolve10(localPath);
36830
- if (existsSync12(abs)) return;
37190
+ if (existsSync13(abs)) return;
36831
37191
  const root = getProjectRoot() ?? process.cwd();
36832
37192
  const elsewhere = findByBasename(root, basename4(localPath)).filter((p) => p !== abs);
36833
37193
  const found = elsewhere.length ? `
@@ -36853,7 +37213,7 @@ async function uploadPublicFixture(projectGuid2, localPath, flag = "--fixture")
36853
37213
  const res = await fetch(init.data.url, {
36854
37214
  method: "PUT",
36855
37215
  headers: { "Content-Type": contentType },
36856
- body: readFileSync13(localPath)
37216
+ body: readFileSync14(localPath)
36857
37217
  });
36858
37218
  if (!res.ok) {
36859
37219
  throw new Error(`upload of fixture "${name}" failed: ${res.status} ${res.statusText}`);
@@ -36953,7 +37313,7 @@ function capWaitForTimeoutMs(raw) {
36953
37313
  return WAIT_FOR_MAX_MS;
36954
37314
  }
36955
37315
  function readScriptFile(pathArg) {
36956
- return readFileSync14(pathArg === "-" ? 0 : pathArg, "utf8");
37316
+ return readFileSync15(pathArg === "-" ? 0 : pathArg, "utf8");
36957
37317
  }
36958
37318
  function parsesAsExpression(s) {
36959
37319
  try {
@@ -37397,8 +37757,8 @@ init_config();
37397
37757
  init_auth();
37398
37758
  init_colors();
37399
37759
  init_utils();
37400
- import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "fs";
37401
- import { dirname as dirname8, extname as extname4, join as join15, resolve as resolvePath } from "path";
37760
+ import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9 } from "fs";
37761
+ import { dirname as dirname9, extname as extname4, join as join17, resolve as resolvePath } from "path";
37402
37762
  var DEVICE_PRESETS = {
37403
37763
  default: { width: 1280, height: 720 },
37404
37764
  desktop: { width: 1920, height: 1080 },
@@ -37462,7 +37822,7 @@ function dimSuffix(vp2) {
37462
37822
  }
37463
37823
  function defaultScreenshotDir() {
37464
37824
  const root = getProjectRoot();
37465
- return join15(root ?? ".", "screenshots");
37825
+ return join17(root ?? ".", "screenshots");
37466
37826
  }
37467
37827
  function timestampSlug(d = /* @__PURE__ */ new Date()) {
37468
37828
  const p = (n) => String(n).padStart(2, "0");
@@ -37674,9 +38034,9 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
37674
38034
  return stemPath(opts.output, suffix);
37675
38035
  };
37676
38036
  for (let i = 0; i < pngs.length; i++) {
37677
- const target = opts.output ? outputPath(i) : join15(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
37678
- mkdirSync7(dirname8(target), { recursive: true });
37679
- writeFileSync8(target, pngs[i].buffer);
38037
+ const target = opts.output ? outputPath(i) : join17(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
38038
+ mkdirSync8(dirname9(target), { recursive: true });
38039
+ writeFileSync9(target, pngs[i].buffer);
37680
38040
  savedFiles.push(resolvePath(target));
37681
38041
  }
37682
38042
  if (opts.json) {
@@ -38003,7 +38363,7 @@ function statusIcon(status) {
38003
38363
  if (status === "warning") return warning("\u26A0");
38004
38364
  return muted("\u2192");
38005
38365
  }
38006
- 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)").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 () => {
38366
+ 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 () => {
38007
38367
  if (target !== "dev" && target !== "prod") {
38008
38368
  console.error(error('Target must be "dev" or "prod"'));
38009
38369
  process.exit(1);
@@ -38318,8 +38678,8 @@ memoryCommand.command("delete <topic>").description("Delete a topic").option("--
38318
38678
  init_api();
38319
38679
  init_config();
38320
38680
  init_setup();
38321
- import { readFileSync as readFileSync15, existsSync as existsSync13, statSync as statSync7, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9 } from "fs";
38322
- import { dirname as dirname9, extname as extname5, relative as relative4, resolve as resolve11, sep as sep4 } from "path";
38681
+ import { readFileSync as readFileSync16, existsSync as existsSync14, statSync as statSync7, mkdirSync as mkdirSync9, writeFileSync as writeFileSync10 } from "fs";
38682
+ import { dirname as dirname10, extname as extname5, relative as relative4, resolve as resolve11, sep as sep4 } from "path";
38323
38683
  init_colors();
38324
38684
  var LANG_MAP = {
38325
38685
  js: "javascript",
@@ -38457,7 +38817,7 @@ function isWriteTarget(code, p) {
38457
38817
  function resolveRelativeCwd() {
38458
38818
  const configPath = getConfigPath();
38459
38819
  if (!configPath) return void 0;
38460
- const projectRoot = dirname9(configPath);
38820
+ const projectRoot = dirname10(configPath);
38461
38821
  const rel2 = relative4(projectRoot, process.cwd());
38462
38822
  if (!rel2 || rel2.startsWith("..")) return void 0;
38463
38823
  return rel2.split(/[\\/]/).filter(Boolean).join("/");
@@ -38539,7 +38899,7 @@ GCC/Rust).
38539
38899
  if (args.length >= 2 && INTERPRETERS[args[0].toLowerCase()] !== void 0) {
38540
38900
  langFromInterp = INTERPRETERS[args[0].toLowerCase()];
38541
38901
  const rest = args.slice(1).join(" ");
38542
- if (existsSync13(rest) && statSync7(rest).isFile()) filePath = rest;
38902
+ if (existsSync14(rest) && statSync7(rest).isFile()) filePath = rest;
38543
38903
  else inlineCode = rest;
38544
38904
  } else if (args.length === 1) {
38545
38905
  inlineCode = args[0];
@@ -38560,7 +38920,7 @@ GCC/Rust).
38560
38920
  let source = inlineCode;
38561
38921
  if (filePath) {
38562
38922
  try {
38563
- source = readFileSync15(filePath, "utf8");
38923
+ source = readFileSync16(filePath, "utf8");
38564
38924
  } catch {
38565
38925
  console.error(error(`Cannot read file: ${filePath}`));
38566
38926
  process.exit(1);
@@ -38587,7 +38947,7 @@ GCC/Rust).
38587
38947
  }
38588
38948
  if (source) {
38589
38949
  const scratchReads = scratchRefsInCode(source).filter(
38590
- (p) => shouldIgnore(p, SCRATCH_IGNORE) && existsSync13(resolve11(process.cwd(), p)) && !isWriteTarget(source, p)
38950
+ (p) => shouldIgnore(p, SCRATCH_IGNORE) && existsSync14(resolve11(process.cwd(), p)) && !isWriteTarget(source, p)
38591
38951
  );
38592
38952
  if (scratchReads.length) {
38593
38953
  console.error(error(`Scratch files are never mirrored into the sandbox, so it can't read: ${scratchReads.join(", ")}`));
@@ -38624,8 +38984,8 @@ GCC/Rust).
38624
38984
  const rel2 = f.path.replace(/\\/g, "/");
38625
38985
  const abs = resolve11(base, rel2);
38626
38986
  if (abs !== base && !abs.startsWith(base + sep4)) continue;
38627
- mkdirSync8(dirname9(abs), { recursive: true });
38628
- writeFileSync9(abs, Buffer.from(f.contentBase64, "base64"));
38987
+ mkdirSync9(dirname10(abs), { recursive: true });
38988
+ writeFileSync10(abs, Buffer.from(f.contentBase64, "base64"));
38629
38989
  scratchWritten.push(rel2);
38630
38990
  }
38631
38991
  }
@@ -38648,7 +39008,7 @@ GCC/Rust).
38648
39008
  }
38649
39009
  if (res.data.outputFiles && res.data.outputFiles.length > 0) {
38650
39010
  const projectRoot = getProjectRoot();
38651
- const landed = (f) => pulledLocal && !!projectRoot && existsSync13(resolve11(projectRoot, f));
39011
+ const landed = (f) => pulledLocal && !!projectRoot && existsSync14(resolve11(projectRoot, f));
38652
39012
  const onDisk = res.data.outputFiles.filter(landed);
38653
39013
  const notOnDisk = res.data.outputFiles.filter((f) => !landed(f));
38654
39014
  if (onDisk.length > 0) {
@@ -38800,8 +39160,8 @@ init_config();
38800
39160
  init_setup();
38801
39161
  init_colors();
38802
39162
  init_utils();
38803
- import { join as join16 } from "path";
38804
- import { mkdirSync as mkdirSync9 } from "fs";
39163
+ import { join as join18 } from "path";
39164
+ import { mkdirSync as mkdirSync10 } from "fs";
38805
39165
  var projectCommand = new Command("project").description("Manage projects").argument("[name]", "Switch to project by name/slug").option("--json", "Output as JSON").action((name, opts) => run("Project", async () => {
38806
39166
  const config = requireConfig();
38807
39167
  if (name) {
@@ -38856,8 +39216,8 @@ projectCommand.command("create <name>").description("Create a project").option("
38856
39216
  }
38857
39217
  const res = await post("/projects", body);
38858
39218
  const project = res.data;
38859
- const dir = join16(getProjectsRoot(), project.slug);
38860
- mkdirSync9(dir, { recursive: true });
39219
+ const dir = join18(getProjectsRoot(), project.slug);
39220
+ mkdirSync10(dir, { recursive: true });
38861
39221
  const accountSlug = await getAccountSlug();
38862
39222
  let agentGuid = "";
38863
39223
  try {
@@ -38952,7 +39312,34 @@ var agentCommand = new Command("agent").description("Manage agents").argument("[
38952
39312
  return `${a.name}${active}${def}${model}`;
38953
39313
  });
38954
39314
  }));
38955
- agentCommand.command("create <name>").description("Create an agent").option("--model <model>", "Model preference").option("--switch", "Switch to new agent after creation").option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
39315
+ agentCommand.command("models").description("List the LLM models an agent can use (ids and tier aliases for `agent create --model` and `agent set model`)").option("--json", "Output as JSON").action((opts) => run("Models", async () => {
39316
+ const res = await get("/agents/models");
39317
+ if (opts.json) {
39318
+ console.log(JSON.stringify({ models: res.data, aliases: res.aliases ?? {} }));
39319
+ return;
39320
+ }
39321
+ const width = res.data.reduce((m, x) => Math.max(m, x.id.length), 0);
39322
+ for (const m of res.data) {
39323
+ const notes = [
39324
+ m.displayName,
39325
+ m.provider,
39326
+ `$${m.inputCostPerMTok}/$${m.outputCostPerMTok} per 1M tok`,
39327
+ `${Math.round(m.maxContextTokens / 1e3)}K ctx`
39328
+ ];
39329
+ if (m.blurb) notes.push(m.blurb);
39330
+ if (m.isDefault) notes.push("default");
39331
+ console.log(`${m.id.padEnd(width)} ${muted(notes.join(" \xB7 "))}`);
39332
+ }
39333
+ if (res.aliases && Object.keys(res.aliases).length > 0) {
39334
+ console.log("");
39335
+ console.log("Tier aliases (an agent set to one follows the platform model rotations):");
39336
+ const aw = Object.keys(res.aliases).reduce((m, k7) => Math.max(m, k7.length), 0);
39337
+ for (const [alias, id2] of Object.entries(res.aliases)) {
39338
+ console.log(`${alias.padEnd(aw)} ${muted(`-> ${id2}`)}`);
39339
+ }
39340
+ }
39341
+ }));
39342
+ agentCommand.command("create <name>").description("Create an agent").option("--model <model>", "Model id (pins that model) or tier alias like gipity-default/opus (follows rotations) - see `gipity agent models`. Default: gipity-default").option("--switch", "Switch to new agent after creation").option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
38956
39343
  const body = { name };
38957
39344
  if (opts.model) body.modelPreference = opts.model;
38958
39345
  const res = await post("/agents", body);
@@ -38967,7 +39354,7 @@ agentCommand.command("create <name>").description("Create an agent").option("--m
38967
39354
  if (opts.switch) console.log("Switched.");
38968
39355
  }
38969
39356
  }));
38970
- agentCommand.command("set <field> <value>").description("Set a field (model, temp)").option("--json", "Output as JSON").action((field, value, opts) => run("Set", async () => {
39357
+ agentCommand.command("set <field> <value>").description("Set a field (model, temp). Model ids + tier aliases: `gipity agent models`").option("--json", "Output as JSON").action((field, value, opts) => run("Set", async () => {
38971
39358
  const config = requireConfig();
38972
39359
  const body = {};
38973
39360
  if (field === "model") body.modelPreference = value;
@@ -39776,9 +40163,9 @@ storageCommand.command("retention").description("View or adjust your file versio
39776
40163
  init_platform();
39777
40164
  init_auth();
39778
40165
  init_api();
39779
- import { join as join19, dirname as dirname11, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
39780
- import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync12, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
39781
- import { homedir as homedir13 } from "os";
40166
+ import { join as join21, dirname as dirname12, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
40167
+ import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync19, writeFileSync as writeFileSync13, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
40168
+ import { homedir as homedir15 } from "os";
39782
40169
  import { fileURLToPath as fileURLToPath2 } from "url";
39783
40170
  import { randomUUID } from "crypto";
39784
40171
  init_config();
@@ -39890,8 +40277,8 @@ init_utils();
39890
40277
  init_colors();
39891
40278
 
39892
40279
  // src/relay/installers.ts
39893
- import { homedir as homedir10, platform as osPlatform } from "os";
39894
- import { join as join17 } from "path";
40280
+ import { homedir as homedir12, platform as osPlatform } from "os";
40281
+ import { join as join19 } from "path";
39895
40282
  var UnsupportedPlatformError = class extends Error {
39896
40283
  constructor(plat) {
39897
40284
  super(`gipity relay install does not support ${plat}`);
@@ -39909,8 +40296,8 @@ function display(argvs) {
39909
40296
  }
39910
40297
  function launchdPlan(cliPath) {
39911
40298
  const label2 = "ai.gipity.relay";
39912
- const path5 = join17(homedir10(), "Library", "LaunchAgents", `${label2}.plist`);
39913
- const logDir = join17(homedir10(), "Library", "Logs", "Gipity");
40299
+ const path5 = join19(homedir12(), "Library", "LaunchAgents", `${label2}.plist`);
40300
+ const logDir = join19(homedir12(), "Library", "Logs", "Gipity");
39914
40301
  const uid = process.getuid?.() ?? 0;
39915
40302
  const target = `gui/${uid}`;
39916
40303
  const content = `<?xml version="1.0" encoding="UTF-8"?>
@@ -39934,8 +40321,8 @@ function launchdPlan(cliPath) {
39934
40321
  <dict>
39935
40322
  <key>SuccessfulExit</key><false/>
39936
40323
  </dict>
39937
- <key>StandardOutPath</key><string>${join17(logDir, "relay.out.log")}</string>
39938
- <key>StandardErrorPath</key><string>${join17(logDir, "relay.err.log")}</string>
40324
+ <key>StandardOutPath</key><string>${join19(logDir, "relay.out.log")}</string>
40325
+ <key>StandardErrorPath</key><string>${join19(logDir, "relay.err.log")}</string>
39939
40326
  <key>ProcessType</key><string>Background</string>
39940
40327
  </dict>
39941
40328
  </plist>
@@ -39958,7 +40345,7 @@ function launchdPlan(cliPath) {
39958
40345
  }
39959
40346
  function systemdUserPlan(cliPath) {
39960
40347
  const unitName = "gipity-relay.service";
39961
- const path5 = join17(homedir10(), ".config", "systemd", "user", unitName);
40348
+ const path5 = join19(homedir12(), ".config", "systemd", "user", unitName);
39962
40349
  const content = `[Unit]
39963
40350
  Description=Gipity relay - local Claude Code control from the Gipity web CLI
39964
40351
  After=network-online.target
@@ -39996,7 +40383,7 @@ WantedBy=default.target
39996
40383
  }
39997
40384
  function windowsTaskPlan(cliPath) {
39998
40385
  const taskName = "GipityRelay";
39999
- const path5 = join17(homedir10(), "AppData", "Local", "Gipity", "relay-task.xml");
40386
+ const path5 = join19(homedir12(), "AppData", "Local", "Gipity", "relay-task.xml");
40000
40387
  const runsViaNode = /\.[cm]?js$/i.test(cliPath);
40001
40388
  const command = runsViaNode ? process.execPath : cliPath;
40002
40389
  const argLine = runsViaNode ? `"${cliPath}" relay run` : "relay run";
@@ -40057,15 +40444,15 @@ function windowsTaskPlan(cliPath) {
40057
40444
  // src/relay/setup.ts
40058
40445
  init_platform();
40059
40446
  init_api();
40060
- import { hostname as hostname3, userInfo, platform as osPlatform2 } from "os";
40061
- import { resolve as resolve12, dirname as dirname10 } from "path";
40062
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
40447
+ import { hostname as hostname4, userInfo, platform as osPlatform2 } from "os";
40448
+ import { resolve as resolve12, dirname as dirname11 } from "path";
40449
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
40063
40450
 
40064
40451
  // src/relay/machine-id.ts
40065
40452
  import { createHash as createHash3 } from "crypto";
40066
40453
  import { execFileSync } from "child_process";
40067
- import { readFileSync as readFileSync16 } from "fs";
40068
- import { hostname as hostname2, platform, arch } from "os";
40454
+ import { readFileSync as readFileSync17 } from "fs";
40455
+ import { hostname as hostname3, platform, arch } from "os";
40069
40456
  function rawMachineId() {
40070
40457
  const override = process.env.GIPITY_RELAY_MACHINE_ID?.trim();
40071
40458
  if (override) return `override:${override}`;
@@ -40073,7 +40460,7 @@ function rawMachineId() {
40073
40460
  if (platform() === "linux") {
40074
40461
  for (const path5 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
40075
40462
  try {
40076
- const id2 = readFileSync16(path5, "utf-8").trim();
40463
+ const id2 = readFileSync17(path5, "utf-8").trim();
40077
40464
  if (id2) return `linux:${id2}`;
40078
40465
  } catch {
40079
40466
  }
@@ -40093,7 +40480,7 @@ function rawMachineId() {
40093
40480
  }
40094
40481
  } catch {
40095
40482
  }
40096
- return `fallback:${hostname2()}:${platform()}:${arch()}`;
40483
+ return `fallback:${hostname3()}:${platform()}:${arch()}`;
40097
40484
  }
40098
40485
  function getMachineId() {
40099
40486
  return createHash3("sha256").update(rawMachineId()).digest("hex");
@@ -40116,7 +40503,7 @@ function friendlyDeviceName() {
40116
40503
  const owner = user.charAt(0).toUpperCase() + user.slice(1);
40117
40504
  return `${owner}'s ${kind}`;
40118
40505
  }
40119
- const host = (hostname3() || "").trim();
40506
+ const host = (hostname4() || "").trim();
40120
40507
  return host || `My ${kind}`;
40121
40508
  }
40122
40509
  function resolveCliPath() {
@@ -40141,7 +40528,15 @@ async function pairDevice(opts = {}) {
40141
40528
  throw new Error("Device name must be 1\u2013100 non-whitespace characters.");
40142
40529
  }
40143
40530
  const plat = mapPlatform(osPlatform2());
40144
- const res = await post("/remote-devices", { name, platform: plat, machine_id: getMachineId() });
40531
+ const deviceKind = process.env.GIPITY_DEVICE_KIND;
40532
+ const agentKind = process.env.GIPITY_AGENT_KIND;
40533
+ const res = await post("/remote-devices", {
40534
+ name,
40535
+ platform: plat,
40536
+ machine_id: getMachineId(),
40537
+ ...deviceKind ? { device_kind: deviceKind } : {},
40538
+ ...agentKind ? { agent_kind: agentKind } : {}
40539
+ });
40145
40540
  setDevice({
40146
40541
  guid: res.data.short_guid,
40147
40542
  name,
@@ -40168,8 +40563,8 @@ function startDaemon() {
40168
40563
  function installAutostart(opts = {}) {
40169
40564
  const stdio = opts.stdio ?? "ignore";
40170
40565
  const plan2 = planFor({ cliPath: resolveCliPath() });
40171
- mkdirSync10(dirname10(plan2.path), { recursive: true });
40172
- writeFileSync10(plan2.path, plan2.content);
40566
+ mkdirSync11(dirname11(plan2.path), { recursive: true });
40567
+ writeFileSync11(plan2.path, plan2.content);
40173
40568
  let ok = true;
40174
40569
  for (const argv2 of plan2.enableCmds) {
40175
40570
  const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio });
@@ -40301,10 +40696,10 @@ init_colors();
40301
40696
 
40302
40697
  // src/banner.ts
40303
40698
  init_colors();
40304
- import { homedir as homedir11 } from "os";
40699
+ import { homedir as homedir13 } from "os";
40305
40700
  import { sep as sep5 } from "path";
40306
40701
  function tildify(p) {
40307
- const home = homedir11();
40702
+ const home = homedir13();
40308
40703
  if (!home) return p;
40309
40704
  if (p === home) return "~";
40310
40705
  if (p.startsWith(home + sep5)) return "~" + p.slice(home.length);
@@ -40554,14 +40949,14 @@ init_claude_setup();
40554
40949
  init_agents();
40555
40950
 
40556
40951
  // src/prefs.ts
40557
- import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
40558
- import { homedir as homedir12 } from "os";
40559
- import { join as join18 } from "path";
40560
- var PREFS_PATH = join18(homedir12(), ".gipity", "prefs.json");
40952
+ import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
40953
+ import { homedir as homedir14 } from "os";
40954
+ import { join as join20 } from "path";
40955
+ var PREFS_PATH = join20(homedir14(), ".gipity", "prefs.json");
40561
40956
  function readPrefs() {
40562
- if (!existsSync14(PREFS_PATH)) return {};
40957
+ if (!existsSync15(PREFS_PATH)) return {};
40563
40958
  try {
40564
- const parsed = JSON.parse(readFileSync17(PREFS_PATH, "utf-8"));
40959
+ const parsed = JSON.parse(readFileSync18(PREFS_PATH, "utf-8"));
40565
40960
  return {
40566
40961
  lastAgent: typeof parsed.lastAgent === "string" ? parsed.lastAgent : void 0
40567
40962
  };
@@ -40573,26 +40968,26 @@ function writePrefs(update) {
40573
40968
  try {
40574
40969
  const current = readPrefs();
40575
40970
  const next = { ...current, ...update };
40576
- mkdirSync11(join18(homedir12(), ".gipity"), { recursive: true });
40577
- writeFileSync11(PREFS_PATH, JSON.stringify(next, null, 2) + "\n");
40971
+ mkdirSync12(join20(homedir14(), ".gipity"), { recursive: true });
40972
+ writeFileSync12(PREFS_PATH, JSON.stringify(next, null, 2) + "\n");
40578
40973
  } catch {
40579
40974
  }
40580
40975
  }
40581
40976
 
40582
40977
  // src/commands/build.ts
40583
40978
  init_setup();
40584
- var __clDir = dirname11(fileURLToPath2(import.meta.url));
40979
+ var __clDir = dirname12(fileURLToPath2(import.meta.url));
40585
40980
  function readOwnPkg(fromDir) {
40586
- for (let d = fromDir; ; d = dirname11(d)) {
40587
- const p = join19(d, "package.json");
40588
- if (existsSync15(p)) {
40981
+ for (let d = fromDir; ; d = dirname12(d)) {
40982
+ const p = join21(d, "package.json");
40983
+ if (existsSync16(p)) {
40589
40984
  try {
40590
- const pkg2 = JSON.parse(readFileSync18(p, "utf-8"));
40985
+ const pkg2 = JSON.parse(readFileSync19(p, "utf-8"));
40591
40986
  if (pkg2.name === "gipity") return pkg2;
40592
40987
  } catch {
40593
40988
  }
40594
40989
  }
40595
- if (dirname11(d) === d) return {};
40990
+ if (dirname12(d) === d) return {};
40596
40991
  }
40597
40992
  }
40598
40993
  var __clPkg = readOwnPkg(__clDir);
@@ -40641,7 +41036,7 @@ function localFsFallback(dir) {
40641
41036
  let isDir = false;
40642
41037
  let size = 0;
40643
41038
  try {
40644
- const st2 = statSync8(join19(d, name));
41039
+ const st2 = statSync8(join21(d, name));
40645
41040
  isDir = st2.isDirectory();
40646
41041
  size = st2.isFile() ? st2.size : 0;
40647
41042
  } catch {
@@ -40650,7 +41045,7 @@ function localFsFallback(dir) {
40650
41045
  if (isDir) {
40651
41046
  folderCount++;
40652
41047
  if (depth === 0) topLevelEntries.push(`${name}/`);
40653
- walk(join19(d, name), depth + 1);
41048
+ walk(join21(d, name), depth + 1);
40654
41049
  } else {
40655
41050
  fileCount++;
40656
41051
  totalBytes += size;
@@ -40683,8 +41078,8 @@ function hasStreamJsonFlag(args) {
40683
41078
  }
40684
41079
  function markFolderTrusted(dir) {
40685
41080
  try {
40686
- const file = join19(homedir13(), ".claude.json");
40687
- const cfg = existsSync15(file) ? JSON.parse(readFileSync18(file, "utf-8")) : {};
41081
+ const file = join21(homedir15(), ".claude.json");
41082
+ const cfg = existsSync16(file) ? JSON.parse(readFileSync19(file, "utf-8")) : {};
40688
41083
  if (typeof cfg !== "object" || cfg === null) return;
40689
41084
  if (typeof cfg.projects !== "object" || cfg.projects === null) cfg.projects = {};
40690
41085
  const entry = typeof cfg.projects[dir] === "object" && cfg.projects[dir] !== null ? cfg.projects[dir] : {};
@@ -40692,7 +41087,7 @@ function markFolderTrusted(dir) {
40692
41087
  entry.hasTrustDialogAccepted = true;
40693
41088
  cfg.projects[dir] = entry;
40694
41089
  const tmp = `${file}.gipity-tmp`;
40695
- writeFileSync12(tmp, JSON.stringify(cfg, null, 2));
41090
+ writeFileSync13(tmp, JSON.stringify(cfg, null, 2));
40696
41091
  renameSync2(tmp, file);
40697
41092
  } catch {
40698
41093
  }
@@ -40809,9 +41204,9 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40809
41204
  let existing = getConfig();
40810
41205
  let forceAdoptCwd = false;
40811
41206
  if (existing && !opts.newProject && !opts.project && !nonInteractive) {
40812
- const cwdHasConfig = existsSync15(resolve13(process.cwd(), ".gipity.json"));
41207
+ const cwdHasConfig = existsSync16(resolve13(process.cwd(), ".gipity.json"));
40813
41208
  if (!cwdHasConfig && isLikelyEmpty(process.cwd())) {
40814
- const ancestorRoot = dirname11(getConfigPath());
41209
+ const ancestorRoot = dirname12(getConfigPath());
40815
41210
  console.log(` ${bold("You are inside an existing Gipity project.")}
40816
41211
  `);
40817
41212
  console.log(` ${bold("1.")} Continue in ${brand(existing.projectSlug)} ${muted(`(rooted at ${formatCwdLabel(ancestorRoot)})`)}`);
@@ -40858,8 +41253,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40858
41253
  }
40859
41254
  project = found;
40860
41255
  }
40861
- const projectDir2 = opts.here ? process.cwd() : join19(getProjectsRoot(), project.slug);
40862
- mkdirSync12(projectDir2, { recursive: true });
41256
+ const projectDir2 = opts.here ? process.cwd() : join21(getProjectsRoot(), project.slug);
41257
+ mkdirSync13(projectDir2, { recursive: true });
40863
41258
  process.chdir(projectDir2);
40864
41259
  clearConfigCache();
40865
41260
  let agentGuid = "";
@@ -40901,7 +41296,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40901
41296
  `);
40902
41297
  setupProjectTools();
40903
41298
  let doSync = true;
40904
- const projectRoot = dirname11(getConfigPath());
41299
+ const projectRoot = dirname12(getConfigPath());
40905
41300
  const scan = scanForAdoption(projectRoot);
40906
41301
  if (scan.tier === "refuse" && !nonInteractive) {
40907
41302
  const sizeStr = scan.truncated ? `>${formatBytes(ADOPT_THRESHOLDS.REFUSE_BYTES)}` : formatBytes(scan.bytes);
@@ -40982,8 +41377,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40982
41377
  } else {
40983
41378
  project = result.project;
40984
41379
  isNewProject = result.kind === "create-new";
40985
- const projectDir2 = join19(getProjectsRoot(), project.slug);
40986
- mkdirSync12(projectDir2, { recursive: true });
41380
+ const projectDir2 = join21(getProjectsRoot(), project.slug);
41381
+ mkdirSync13(projectDir2, { recursive: true });
40987
41382
  process.chdir(projectDir2);
40988
41383
  clearConfigCache();
40989
41384
  try {
@@ -41339,6 +41734,12 @@ Sending to ${adapter.displayName}: ${message}
41339
41734
  }
41340
41735
  console.log("");
41341
41736
  }
41737
+ if (adapter.prepareLaunch) {
41738
+ try {
41739
+ await adapter.prepareLaunch();
41740
+ } catch {
41741
+ }
41742
+ }
41342
41743
  const childEnv2 = { ...process.env };
41343
41744
  if (convGuid) childEnv2.GIPITY_CONVERSATION_GUID = convGuid;
41344
41745
  const agentCmd = resolveCommand(adapter.binary);
@@ -41370,8 +41771,8 @@ ${doneLine}
41370
41771
  });
41371
41772
  }
41372
41773
  function flushHeadlessCapture(adapter, sessionId, convGuid) {
41373
- const runner = join19(__clDir, "..", "hooks", "capture-runner.js");
41374
- if (!existsSync15(runner)) return;
41774
+ const runner = join21(__clDir, "..", "hooks", "capture-runner.js");
41775
+ if (!existsSync16(runner)) return;
41375
41776
  const payload = JSON.stringify({ session_id: sessionId, cwd: process.cwd() });
41376
41777
  const env = { ...process.env, GIPITY_CONVERSATION_GUID: convGuid };
41377
41778
  for (const event of ["session-start", "stop"]) {
@@ -41498,7 +41899,7 @@ async function browseProjects(all, opts = {}) {
41498
41899
  function formatNewProjectLabel(existingSlugs) {
41499
41900
  const slug = suggestProjectName(existingSlugs);
41500
41901
  const root = getProjectsRoot();
41501
- const home = homedir13();
41902
+ const home = homedir15();
41502
41903
  const display2 = root === home || root.startsWith(home + sep6) ? "~" + root.slice(home.length) : root;
41503
41904
  return `${display2}${sep6}${slug}`;
41504
41905
  }
@@ -42216,7 +42617,7 @@ and its own error message), use the per-call log instead:
42216
42617
  }
42217
42618
  }
42218
42619
  }));
42219
- logsCommand.command("app").description("Unified recent activity for this app \u2014 JS errors, failed function calls, failed services, network failures. Designed for agents debugging a deployed app.").option("--since <window>", "Window: 5m / 10m / 30m / 1h / 6h / 24h / 7d", "10m").option("--severity <level>", "error | warn | network | all", "all").option("--type <list>", "Comma-separated: errors,functions,services,traffic. Default excludes traffic (high volume).").option("--filter <pattern>", "Substring match against message / fn name / path (case-insensitive)").option("--limit <n>", "Max entries", "100").option("--json", "Output as JSON (parseable by agents / pipes)").addHelpText("after", `
42620
+ logsCommand.command("app").description("Unified recent activity for this app \u2014 JS errors, failed function calls, failed services, network failures. Designed for agents debugging a deployed app.").option("--since <window>", "Window: 5m / 10m / 30m / 1h / 6h / 24h / 7d", "10m").addOption(new Option("--severity <level>", "Severity filter").choices(["error", "warn", "network", "all"]).default("all")).option("--type <list>", "Comma-separated: errors,functions,services,traffic. Default excludes traffic (high volume).").option("--filter <pattern>", "Substring match against message / fn name / path (case-insensitive)").option("--limit <n>", "Max entries", "100").option("--json", "Output as JSON (parseable by agents / pipes)").addHelpText("after", `
42220
42621
  Examples:
42221
42622
  $ gipity logs app Last 10 min of errors + fn failures
42222
42623
  $ gipity logs app --since 1h Last hour
@@ -42712,7 +43113,7 @@ recordsCommand.command("list").description("List record tables").option("--json"
42712
43113
  (t) => `${bold(t.table_name)} ${muted(t.auth_level)} ${muted(`pk=${t.primary_key_column}`)} ${muted(`db=${t.database_name}`)}`
42713
43114
  );
42714
43115
  }));
42715
- recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, etc.)").option("--auth <level>", "Auth level: public (anonymous writes), member (sign-in), or 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 () => {
43116
+ 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 () => {
42716
43117
  const config = requireConfig();
42717
43118
  const base = `/api/${config.projectGuid}/records/${table}/config`;
42718
43119
  const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete;
@@ -42733,7 +43134,7 @@ recordsCommand.command("config <table>").description("Show or set a table's Reco
42733
43134
  res.data
42734
43135
  );
42735
43136
  }));
42736
- 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 (e.g., "status:eq:active")').option("--any <filter>", 'OR filter group, same grammar 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 () => {
43137
+ 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 () => {
42737
43138
  const api = await recordsHttp(opts);
42738
43139
  const params = new URLSearchParams();
42739
43140
  if (opts.q) params.set("q", opts.q);
@@ -42903,9 +43304,10 @@ var SERVICES = [
42903
43304
  { name: "image", method: "POST", desc: "Generate an image ({ prompt, provider?, size? })" },
42904
43305
  { name: "image/models", method: "GET", desc: "List image providers/models" },
42905
43306
  { name: "tts", method: "POST", desc: "Text-to-speech ({ text, voice?, ... })" },
42906
- { name: "tts/voices", method: "GET", desc: "List TTS voices" },
43307
+ { name: "tts/voices", method: "GET", desc: "List TTS voices (append ?provider=elevenlabs|openai|gemini)" },
42907
43308
  { name: "sound", method: "POST", desc: "Sound effect ({ text, duration_seconds? })" },
42908
43309
  { name: "music", method: "POST", desc: "Music generation ({ prompt, duration_seconds? })" },
43310
+ { name: "music/models", method: "GET", desc: "List music models (ids for --model / model)" },
42909
43311
  { name: "video", method: "POST", desc: "Video generation ({ prompt, ... })" },
42910
43312
  { name: "location/ip", method: "POST", desc: "IP geolocation ({ ip? })" },
42911
43313
  { name: "location/geocode", method: "POST", desc: "Reverse geocode ({ lat, lon })" }
@@ -42941,8 +43343,9 @@ function anonBillingHint(name, err) {
42941
43343
  }
42942
43344
  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 () => {
42943
43345
  const config = requireConfig();
42944
- const path5 = name.split("/").map(encodeURIComponent).join("/");
42945
- const url = `/api/${config.projectGuid}/services/${path5}`;
43346
+ const [pathPart, query] = name.split("?", 2);
43347
+ const path5 = pathPart.split("/").map(encodeURIComponent).join("/");
43348
+ const url = `/api/${config.projectGuid}/services/${path5}${query ? `?${query}` : ""}`;
42946
43349
  const body = resolveBody(bodyArg || opts.data, opts.file);
42947
43350
  if (opts.anon) {
42948
43351
  console.error(muted("Auth: anonymous visitor (the public path a signed-out user of your deployed app hits)"));
@@ -43486,11 +43889,11 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
43486
43889
  }
43487
43890
  }));
43488
43891
  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) => {
43489
- const { existsSync: existsSync25, statSync: statSync12 } = await import("node:fs");
43490
- const { resolve: resolve19, join: join29 } = await import("node:path");
43892
+ const { existsSync: existsSync26, statSync: statSync12 } = await import("node:fs");
43893
+ const { resolve: resolve19, join: join31 } = await import("node:path");
43491
43894
  const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
43492
43895
  const jobDir = resolve19(process.cwd(), "jobs", name);
43493
- if (!existsSync25(jobDir) || !statSync12(jobDir).isDirectory()) {
43896
+ if (!existsSync26(jobDir) || !statSync12(jobDir).isDirectory()) {
43494
43897
  console.error(error(`jobs/${name}/ not found in current directory`));
43495
43898
  process.exit(1);
43496
43899
  }
@@ -43511,7 +43914,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
43511
43914
  },
43512
43915
  { file: "main.sh", runtime: "bash", entry: "bash" }
43513
43916
  ];
43514
- const picked = variants.find((v7) => existsSync25(join29(jobDir, v7.file)));
43917
+ const picked = variants.find((v7) => existsSync26(join31(jobDir, v7.file)));
43515
43918
  if (!picked) {
43516
43919
  console.error(error(`No main.py / main.js / main.sh found under jobs/${name}/`));
43517
43920
  process.exit(1);
@@ -43536,7 +43939,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
43536
43939
  "-v",
43537
43940
  `${jobDir}:/work`
43538
43941
  ];
43539
- const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd && existsSync25(join29(jobDir, picked.depsFile));
43942
+ const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd && existsSync26(join31(jobDir, picked.depsFile));
43540
43943
  const handlerCmd = `${picked.entry} /work/${picked.file}`;
43541
43944
  let shellCmd;
43542
43945
  if (needsDeps && picked.installCmd) {
@@ -43686,7 +44089,7 @@ emailCommand.command("test").description("Send a test email through your app's e
43686
44089
  console.log(muted(` ${r.to} \u2014 ${r.status}${r.reason ? `: ${r.reason}` : ""}`));
43687
44090
  }
43688
44091
  }));
43689
- emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").option("--range <range>", "Time range (24h, 7d, 30d)", "7d").option("--limit <n>", "Max rows", "50").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Email", async () => {
44092
+ emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").addOption(new Option("--range <range>", "Time range").choices(["1h", "24h", "7d", "30d", "1y"]).default("7d")).option("--limit <n>", "Max rows", "50").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Email", async () => {
43690
44093
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
43691
44094
  const res = await get(
43692
44095
  `/account/logs/credits?operations=email_send,email_skip&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`
@@ -43714,19 +44117,105 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
43714
44117
  init_api();
43715
44118
  init_config();
43716
44119
  init_colors();
43717
- import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync19 } from "fs";
43718
- import { resolve as resolvePath2, dirname as dirname12, relative as relative5, isAbsolute, basename as basename6 } from "path";
44120
+ import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync14, readFileSync as readFileSync20 } from "fs";
44121
+ import { resolve as resolvePath2, dirname as dirname13, relative as relative5, isAbsolute, basename as basename6 } from "path";
43719
44122
 
43720
44123
  // src/provider-docs.ts
43721
- var IMAGE_MODELS_DOC = `openai: gpt-image-2. bfl: flux-2-pro, flux-2-flex, flux-2-max, flux-2-klein-9b, flux-2-klein-4b. gemini: gemini-3.1-flash-lite-image, gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3-pro-image`;
44124
+ 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`;
44125
+ var IMAGE_GEMINI_ASPECT_RATIO_IDS = [
44126
+ "1:1",
44127
+ "16:9",
44128
+ "9:16",
44129
+ "4:3",
44130
+ "3:4",
44131
+ "3:2",
44132
+ "2:3",
44133
+ "4:5",
44134
+ "5:4",
44135
+ "21:9"
44136
+ ];
44137
+ var IMAGE_GEMINI_SIZE_IDS = [
44138
+ "512",
44139
+ "1K",
44140
+ "2K",
44141
+ "4K"
44142
+ ];
44143
+ var IMAGE_MODELS_TABLE = ` openai gpt-image-2
44144
+ bfl flux-2-pro, flux-2-flex, flux-2-max, flux-2-klein-9b, flux-2-klein-4b
44145
+ gemini gemini-3.1-flash-lite-image, gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3-pro-image`;
44146
+ var IMAGE_PROVIDER_IDS = [
44147
+ "openai",
44148
+ "bfl",
44149
+ "gemini"
44150
+ ];
44151
+ var IMAGE_QUALITY_IDS = [
44152
+ "low",
44153
+ "medium",
44154
+ "high",
44155
+ "auto"
44156
+ ];
44157
+ var IMAGE_TIER_ALIASES_DOC = `fast (gemini/gemini-3.1-flash-lite-image), standard (openai/gpt-image-2), high (bfl/flux-2-pro), ultra (bfl/flux-2-max)`;
44158
+ var IMAGE_TIER_ALIAS_IDS = [
44159
+ "fast",
44160
+ "standard",
44161
+ "high",
44162
+ "ultra"
44163
+ ];
43722
44164
  var TTS_PROVIDER_DESCRIPTIONS = {
43723
- "elevenlabs": `ElevenLabs (many voices - use voice_set list to discover)`,
44165
+ "elevenlabs": `ElevenLabs (many premium voices)`,
43724
44166
  "openai": `OpenAI (alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse)`,
43725
44167
  "gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more). Multi-speaker (up to 2) and 60+ languages`
43726
44168
  };
43727
- var VIDEO_MODELS_DOC = `veo-3.1-generate-preview (best quality, up to 4K, ~$0.40/sec), veo-3.1-fast-generate-preview (faster, ~$0.10/sec), veo-3.1-lite-generate-preview (budget, ~$0.05/sec), gemini-omni-flash-preview (3-10s @ 720p, conversational editing, ~$0.10/sec)`;
44169
+ var TTS_PROVIDER_IDS = [
44170
+ "elevenlabs",
44171
+ "openai",
44172
+ "gemini"
44173
+ ];
44174
+ var VIDEO_ASPECT_RATIOS = `16:9 (landscape), 9:16 (portrait), 1:1 (square)`;
44175
+ var VIDEO_ASPECT_RATIO_IDS = [
44176
+ "16:9",
44177
+ "9:16",
44178
+ "1:1"
44179
+ ];
44180
+ var VIDEO_MODELS_TABLE = ` veo-3.1-generate-preview best quality, up to 4K, ~$0.40/sec
44181
+ veo-3.1-fast-generate-preview faster, ~$0.10/sec
44182
+ veo-3.1-lite-generate-preview budget, ~$0.05/sec`;
44183
+ var VIDEO_MODEL_IDS = [
44184
+ "veo-3.1-generate-preview",
44185
+ "veo-3.1-fast-generate-preview",
44186
+ "veo-3.1-lite-generate-preview"
44187
+ ];
44188
+ var VIDEO_RESOLUTION_IDS = [
44189
+ "720p",
44190
+ "1080p",
44191
+ "4k"
44192
+ ];
43728
44193
 
43729
44194
  // src/commands/generate.ts
44195
+ function printMetrics(metrics) {
44196
+ const rows = metrics.filter((m) => m !== null);
44197
+ const width = Math.max(...rows.map((m) => m.label.length));
44198
+ for (const m of rows) {
44199
+ console.log(` ${muted(`${m.label.padStart(width)}:`)} ${m.value}`);
44200
+ }
44201
+ }
44202
+ function fmtSeconds(s) {
44203
+ if (s >= 60) return `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
44204
+ return `${s < 10 ? Math.round(s * 10) / 10 : Math.round(s)}s`;
44205
+ }
44206
+ function generationMetrics(result, elapsedSeconds) {
44207
+ const speed = result.duration_seconds !== void 0 && elapsedSeconds > 0 ? result.duration_seconds / elapsedSeconds : void 0;
44208
+ return [
44209
+ result.duration_seconds !== void 0 ? { label: "duration", value: `${fmtSeconds(result.duration_seconds)} clip` } : null,
44210
+ { label: "size", value: `${Math.round(result.size_bytes / 1024)}KB` },
44211
+ { label: "time", value: fmtSeconds(elapsedSeconds) },
44212
+ speed !== void 0 ? { label: "speed", value: `${speed >= 1 ? Math.round(speed * 10) / 10 : Math.round(speed * 100) / 100}x realtime` } : null,
44213
+ result.credits_deducted !== void 0 ? { label: "credits", value: `${result.credits_deducted.toLocaleString("en-US")} (${result.remaining_balance.toLocaleString("en-US")} remaining)` } : null
44214
+ ];
44215
+ }
44216
+ function jsonResult(result, elapsedSeconds, savedPath) {
44217
+ return JSON.stringify({ ...result, generation_seconds: Math.round(elapsedSeconds * 10) / 10, saved: savedPath });
44218
+ }
43730
44219
  async function downloadFile(url, filename, explicit) {
43731
44220
  const res = await fetch(url);
43732
44221
  if (!res.ok) throw new Error(`Download failed: ${res.status}`);
@@ -43734,7 +44223,7 @@ async function downloadFile(url, filename, explicit) {
43734
44223
  const outPath = explicit ? filename : correctExtension(filename, buffer);
43735
44224
  if (explicit) noteFormatMismatch(filename, buffer);
43736
44225
  ensureOutputDir(outPath);
43737
- writeFileSync13(outPath, buffer);
44226
+ writeFileSync14(outPath, buffer);
43738
44227
  const savedPath = resolvePath2(outPath);
43739
44228
  await pushGenerated(savedPath);
43740
44229
  return savedPath;
@@ -43778,9 +44267,9 @@ function noteFormatMismatch(filename, buf) {
43778
44267
  ));
43779
44268
  }
43780
44269
  function ensureOutputDir(output) {
43781
- const dir = dirname12(resolvePath2(output));
44270
+ const dir = dirname13(resolvePath2(output));
43782
44271
  try {
43783
- mkdirSync13(dir, { recursive: true });
44272
+ mkdirSync14(dir, { recursive: true });
43784
44273
  } catch (err) {
43785
44274
  throw new Error(`can't create the output directory ${dir} (${err.code || err.message}). Pick a different -o path.`);
43786
44275
  }
@@ -43788,7 +44277,7 @@ function ensureOutputDir(output) {
43788
44277
  async function pushGenerated(savedPath) {
43789
44278
  const configPath = getConfigPath();
43790
44279
  if (!configPath) return;
43791
- const rel2 = relative5(dirname12(configPath), savedPath);
44280
+ const rel2 = relative5(dirname13(configPath), savedPath);
43792
44281
  if (rel2.startsWith("..") || isAbsolute(rel2)) return;
43793
44282
  try {
43794
44283
  await pushFile(savedPath);
@@ -43800,7 +44289,7 @@ function readInputImages(paths) {
43800
44289
  return paths.map((p) => {
43801
44290
  let buf;
43802
44291
  try {
43803
- buf = readFileSync19(p);
44292
+ buf = readFileSync20(p);
43804
44293
  } catch (e) {
43805
44294
  throw new Error(`can't read --input image ${p} (${e.code || e.message}).`);
43806
44295
  }
@@ -43812,7 +44301,11 @@ function readInputImages(paths) {
43812
44301
  });
43813
44302
  }
43814
44303
  var imageCommand = new Command("image").description("Generate an image from a text prompt, or edit existing images with --input").addHelpText("after", `
43815
- Models: ${IMAGE_MODELS_DOC}
44304
+ Models (one line per provider; pass an id with --model, the provider with --provider):
44305
+ ${IMAGE_MODELS_TABLE}
44306
+
44307
+ Tier aliases (pass to --model instead of an id; each names a provider+model):
44308
+ ${IMAGE_TIER_ALIASES_DOC}
43816
44309
 
43817
44310
  Editing (--input): pass one or more source images and the prompt becomes an edit
43818
44311
  instruction applied to them - "make it night time", "add a hat", "remove the car
@@ -43826,7 +44319,7 @@ Examples:
43826
44319
  gipity generate image "landscape sunset" --provider gemini --aspect-ratio 16:9 --image-size 2K
43827
44320
  gipity generate image "product photo" --provider openai --model gpt-image-2 --size 1536x1024 --quality high
43828
44321
  gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png
43829
- `).argument("<prompt>", "Text description of the image, or (with --input) the edit instruction to apply").option("--input <file>", "Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.", (v7, acc) => (acc || []).concat(v7)).option("--provider <provider>", "Image provider: openai, bfl, or gemini (default: bfl)").option("--model <model>", "Model ID (see provider list above)").option("--size <size>", 'Dimensions as WxH, e.g. "1024x1024" (OpenAI/BFL)').option("--quality <quality>", "Quality: low|medium|high|auto (gpt-image-2)").option("--aspect-ratio <ratio>", "Aspect ratio (Gemini only): 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 4:5, 5:4, 21:9").option("--image-size <size>", "Output resolution (Gemini only): 512, 1K, 2K, 4K").option("--seed <n>", "Deterministic seed (BFL only): reuse one seed to keep a set of images visually coherent", (v7) => parseInt(v7, 10)).option("-o, --output <file>", "Output path (default ./generated.png). For an image your app ships, write it into the source tree so it deploys, e.g. -o src/assets/images/hero.png; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
44322
+ `).argument("<prompt>", "Text description of the image, or (with --input) the edit instruction to apply").option("--input <file>", "Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.", (v7, acc) => (acc || []).concat(v7)).addOption(new Option("--provider <provider>", "Image provider (default: bfl)").choices(IMAGE_PROVIDER_IDS)).option("--model <model>", `Model id for the chosen provider, or a tier alias (${IMAGE_TIER_ALIAS_IDS.join(", ")}); see Models below`).option("--size <size>", 'Dimensions as WxH, e.g. "1024x1024" (OpenAI/BFL)').addOption(new Option("--quality <quality>", "Quality (gpt-image-2 only)").choices(IMAGE_QUALITY_IDS)).addOption(new Option("--aspect-ratio <ratio>", "Aspect ratio (Gemini only)").choices(IMAGE_GEMINI_ASPECT_RATIO_IDS)).addOption(new Option("--image-size <size>", "Output resolution (Gemini only)").choices(IMAGE_GEMINI_SIZE_IDS)).option("--seed <n>", "Deterministic seed (BFL only): reuse one seed to keep a set of images visually coherent", (v7) => parseInt(v7, 10)).option("-o, --output <file>", "Output path (default ./generated.png). For an image your app ships, write it into the source tree so it deploys, e.g. -o src/assets/images/hero.png; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
43830
44323
  try {
43831
44324
  const { config } = await resolveProjectContext();
43832
44325
  if (opts.output) ensureOutputDir(opts.output);
@@ -43843,18 +44336,20 @@ Examples:
43843
44336
  input_images: inputImages
43844
44337
  });
43845
44338
  const verb = inputImages ? "Editing image..." : "Generating image...";
44339
+ const started = Date.now();
43846
44340
  const result = opts.json ? await doGenerate() : await withSpinner(verb, doGenerate, { done: null });
44341
+ const elapsed = (Date.now() - started) / 1e3;
43847
44342
  const ext = result.content_type.includes("png") ? "png" : "jpg";
43848
44343
  const filename = opts.output || `generated.${ext}`;
43849
44344
  const savedPath = await downloadFile(result.url, filename, !!opts.output);
43850
44345
  if (opts.json) {
43851
- console.log(JSON.stringify({ ...result, saved: savedPath }));
44346
+ console.log(jsonResult(result, elapsed, savedPath));
43852
44347
  } else {
43853
- const sizeKb = Math.round(result.size_bytes / 1024);
43854
- console.log(`${muted(`Generated with ${result.provider}/${result.model} (${sizeKb}KB)`)}`);
43855
- if (result.seed !== void 0) {
43856
- console.log(muted(`Seed ${result.seed} \u2014 pass --seed ${result.seed} to keep the next image coherent`));
43857
- }
44348
+ console.log(muted(`Generated with ${result.provider}/${result.model}`));
44349
+ printMetrics([
44350
+ ...generationMetrics(result, elapsed),
44351
+ result.seed !== void 0 ? { label: "seed", value: `${result.seed} ${muted(`(pass --seed ${result.seed} to keep the next image coherent)`)}` } : null
44352
+ ]);
43858
44353
  console.log(success(`Saved to ${savedPath}`));
43859
44354
  }
43860
44355
  } catch (err) {
@@ -43863,7 +44358,10 @@ Examples:
43863
44358
  }
43864
44359
  });
43865
44360
  var videoCommand = new Command("video").description("Generate a short video (up to 8 seconds) from a text prompt using Google Veo").addHelpText("after", `
43866
- Models: ${VIDEO_MODELS_DOC}
44361
+ Models (default: veo-3.1-generate-preview):
44362
+ ${VIDEO_MODELS_TABLE}
44363
+
44364
+ Aspect ratios: ${VIDEO_ASPECT_RATIOS}
43867
44365
 
43868
44366
  Tips:
43869
44367
  - Describe the scene, camera movement, lighting, and any dialogue
@@ -43875,7 +44373,7 @@ Examples:
43875
44373
  gipity generate video "close-up of coffee being poured" --model veo-3.1-fast-generate-preview
43876
44374
  gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4
43877
44375
  gipity generate video "a wave crashing" --duration 4 --model veo-3.1-lite-generate-preview
43878
- `).argument("<prompt>", "Description of the video scene, action, camera movement, and dialogue").option("--model <model>", "Veo model: veo-3.1-generate-preview (quality), veo-3.1-fast-generate-preview (speed), veo-3.1-lite-generate-preview (budget)").option("--aspect <ratio>", "Aspect ratio: 16:9 (landscape), 9:16 (portrait), 1:1 (square)").option("--resolution <res>", "Video resolution: 720p, 1080p, 4k").option("--duration <seconds>", "Clip length in seconds. Veo models: 4, 6, or 8 (8 required at 1080p/4K); omni-flash: 3-10. Default 8. Billing is per second, so shorter is cheaper.").option("-o, --output <file>", "Output path (default ./generated.mp4). For a clip your app ships, write it into the source tree so it deploys, e.g. -o src/assets/video/clip.mp4; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
44376
+ `).argument("<prompt>", "Description of the video scene, action, camera movement, and dialogue").addOption(new Option("--model <model>", "Video model; see Models below for quality/price").choices(VIDEO_MODEL_IDS)).addOption(new Option("--aspect <ratio>", "Aspect ratio (landscape, portrait, square)").choices(VIDEO_ASPECT_RATIO_IDS)).addOption(new Option("--resolution <res>", "Video resolution").choices(VIDEO_RESOLUTION_IDS)).option("--duration <seconds>", "Clip length in seconds. Veo models: 4, 6, or 8 (8 required at 1080p/4K); omni-flash: 3-10. Default 8. Billing is per second, so shorter is cheaper.").option("-o, --output <file>", "Output path (default ./generated.mp4). For a clip your app ships, write it into the source tree so it deploys, e.g. -o src/assets/video/clip.mp4; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
43879
44377
  try {
43880
44378
  const { config } = await resolveProjectContext();
43881
44379
  if (opts.output) ensureOutputDir(opts.output);
@@ -43886,14 +44384,16 @@ Examples:
43886
44384
  resolution: opts.resolution,
43887
44385
  duration_seconds: opts.duration ? Number(opts.duration) : void 0
43888
44386
  });
44387
+ const started = Date.now();
43889
44388
  const result = opts.json ? await doGenerate() : await withSpinner("Generating video...", doGenerate, { done: null });
44389
+ const elapsed = (Date.now() - started) / 1e3;
43890
44390
  const filename = opts.output || "generated.mp4";
43891
44391
  const savedPath = await downloadFile(result.url, filename, !!opts.output);
43892
44392
  if (opts.json) {
43893
- console.log(JSON.stringify({ ...result, saved: savedPath }));
44393
+ console.log(jsonResult(result, elapsed, savedPath));
43894
44394
  } else {
43895
- const sizeKb = Math.round(result.size_bytes / 1024);
43896
- console.log(`${muted(`Generated with ${result.provider}/${result.model} (${sizeKb}KB)`)}`);
44395
+ console.log(muted(`Generated with ${result.provider}/${result.model}`));
44396
+ printMetrics(generationMetrics(result, elapsed));
43897
44397
  console.log(success(`Saved to ${savedPath}`));
43898
44398
  }
43899
44399
  } catch (err) {
@@ -43902,7 +44402,13 @@ Examples:
43902
44402
  }
43903
44403
  });
43904
44404
  var speechCommand = new Command("speech").description("Generate speech audio from text using text-to-speech").addHelpText("after", `
43905
- Providers: ${Object.entries(TTS_PROVIDER_DESCRIPTIONS).map(([k7, v7]) => `${k7} - ${v7}`).join("\n ")}
44405
+ Providers:
44406
+ ${Object.entries(TTS_PROVIDER_DESCRIPTIONS).map(([k7, v7]) => ` ${k7.padEnd(10)} ${v7}`).join("\n")}
44407
+
44408
+ Voices: openai voices are the list above; the full Gemini list is below. ElevenLabs
44409
+ voice ids: gipity service call "tts/voices?provider=elevenlabs" --get
44410
+
44411
+ Gemini voices: ${GEMINI_TTS_VOICES_DOC}
43906
44412
 
43907
44413
  Multi-speaker (--speakers, Gemini only): JSON array like
43908
44414
  [{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]; format the
@@ -43913,7 +44419,7 @@ Examples:
43913
44419
  gipity generate speech "\u3053\u3093\u306B\u3061\u306F\u4E16\u754C" --provider gemini --voice Kore --language ja-JP
43914
44420
  gipity generate speech "Bonjour le monde" --provider gemini --language fr-FR
43915
44421
  gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'
43916
- `).argument("<text>", "Text to convert to speech (max 5000 characters)").option("--provider <provider>", "TTS provider: elevenlabs (default), openai, or gemini").option("--voice <voice>", "Voice ID or name (provider-specific)").option("--language <code>", "BCP-47 language code, e.g. ja-JP, es-ES (Gemini only, 60+ languages)").option("--speakers <json>", "Multi-speaker config as JSON array (Gemini only, up to 2 speakers)").option("-o, --output <file>", "Output path (default ./speech.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/sounds/intro.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (text, opts) => {
44422
+ `).argument("<text>", "Text to convert to speech (max 5000 characters)").addOption(new Option("--provider <provider>", "TTS provider (default: elevenlabs)").choices(TTS_PROVIDER_IDS)).option("--voice <voice>", "Voice ID or name (provider-specific; see Voices below)").option("--language <code>", "BCP-47 language code, e.g. ja-JP, es-ES (Gemini only, 60+ languages)").option("--speakers <json>", "Multi-speaker config as JSON array (Gemini only, up to 2 speakers)").option("-o, --output <file>", "Output path (default ./speech.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/sounds/intro.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (text, opts) => {
43917
44423
  try {
43918
44424
  const { config } = await resolveProjectContext();
43919
44425
  if (opts.output) ensureOutputDir(opts.output);
@@ -43933,14 +44439,16 @@ Examples:
43933
44439
  language: opts.language,
43934
44440
  speakers
43935
44441
  });
44442
+ const started = Date.now();
43936
44443
  const result = opts.json ? await doGenerate() : await withSpinner("Generating speech...", doGenerate, { done: null });
44444
+ const elapsed = (Date.now() - started) / 1e3;
43937
44445
  const filename = opts.output || "speech.mp3";
43938
44446
  const savedPath = await downloadFile(result.url, filename, !!opts.output);
43939
44447
  if (opts.json) {
43940
- console.log(JSON.stringify({ ...result, saved: savedPath }));
44448
+ console.log(jsonResult(result, elapsed, savedPath));
43941
44449
  } else {
43942
- const sizeKb = Math.round(result.size_bytes / 1024);
43943
- console.log(`${muted(`Generated with ${result.provider} (${sizeKb}KB)`)}`);
44450
+ console.log(muted(`Generated with ${result.provider}`));
44451
+ printMetrics(generationMetrics(result, elapsed));
43944
44452
  console.log(success(`Saved to ${savedPath}`));
43945
44453
  }
43946
44454
  } catch (err) {
@@ -43955,31 +44463,44 @@ default; pass --model <id> only if you want a specific one (see the catalog with
43955
44463
 
43956
44464
  Tips:
43957
44465
  - Describe genre, mood, instruments, and tempo (e.g. "upbeat lo-fi hip hop with mellow piano")
43958
- - Music is instrumental by default; pass --vocals to allow singing
44466
+ - Music is instrumental by default; pass --vocals to allow singing, or --lyrics /
44467
+ --lyrics-file to have the vocalist sing YOUR exact words (section tags like
44468
+ [Verse] / [Chorus] are understood; keep the prompt to style only)
44469
+ - With lyrics, size --duration to the words (roughly 10s per short section)
43959
44470
  - Longer clips cost more; the max length depends on the model
43960
44471
 
43961
44472
  Examples:
43962
44473
  gipity generate music "chill lo-fi beat for studying"
43963
44474
  gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
43964
44475
  gipity generate music "indie pop chorus" --vocals --duration 20
43965
- `).argument("<prompt>", "Text description of the music to generate").option("--duration <seconds>", "Clip length in seconds (default 30; max depends on the model)", (v7) => parseInt(v7, 10)).option("--model <model>", "Music model id (default: platform default)").option("--vocals", "Allow vocals (default: instrumental only)").option("-o, --output <file>", "Output path (default ./music.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/audio/theme.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
44476
+ gipity generate music "80s synth-pop, female vocals" --lyrics-file lyrics.txt --duration 120 -o song.mp3
44477
+ `).argument("<prompt>", "Text description of the music to generate").option("--duration <seconds>", "Clip length in seconds (default 30; max depends on the model)", (v7) => parseInt(v7, 10)).option("--model <model>", "Music model id (default: platform default; list ids: gipity service call music/models --get)").option("--vocals", "Allow vocals (default: instrumental only)").option("--lyrics <text>", "Exact lyrics to sing (implies vocals; only lyrics-capable models)").option("--lyrics-file <file>", "Read the exact lyrics to sing from a file (implies vocals)").option("-o, --output <file>", "Output path (default ./music.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/audio/theme.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
43966
44478
  try {
43967
44479
  const { config } = await resolveProjectContext();
43968
44480
  if (opts.output) ensureOutputDir(opts.output);
44481
+ if (opts.lyrics && opts.lyricsFile) {
44482
+ console.error(error("Pass --lyrics or --lyrics-file, not both."));
44483
+ process.exit(1);
44484
+ }
44485
+ const lyrics = opts.lyricsFile ? readFileSync20(opts.lyricsFile, "utf8").trim() : opts.lyrics;
43969
44486
  const doGenerate = () => post(`/projects/${config.projectGuid}/generate/music`, {
43970
44487
  prompt: prompt2,
43971
44488
  duration_seconds: opts.duration,
43972
44489
  model: opts.model,
43973
- instrumental: !opts.vocals
44490
+ // Lyrics imply vocals; otherwise instrumental unless --vocals.
44491
+ instrumental: lyrics ? false : !opts.vocals,
44492
+ lyrics: lyrics || void 0
43974
44493
  });
44494
+ const started = Date.now();
43975
44495
  const result = opts.json ? await doGenerate() : await withSpinner("Generating music...", doGenerate, { done: null });
44496
+ const elapsed = (Date.now() - started) / 1e3;
43976
44497
  const filename = opts.output || "music.mp3";
43977
44498
  const savedPath = await downloadFile(result.url, filename, !!opts.output);
43978
44499
  if (opts.json) {
43979
- console.log(JSON.stringify({ ...result, saved: savedPath }));
44500
+ console.log(jsonResult(result, elapsed, savedPath));
43980
44501
  } else {
43981
- const sizeKb = Math.round(result.size_bytes / 1024);
43982
- console.log(`${muted(`Generated with ${result.model} (${sizeKb}KB)`)}`);
44502
+ console.log(muted(`Generated with ${result.model}`));
44503
+ printMetrics(generationMetrics(result, elapsed));
43983
44504
  console.log(success(`Saved to ${savedPath}`));
43984
44505
  }
43985
44506
  } catch (err) {
@@ -44010,14 +44531,16 @@ Examples:
44010
44531
  duration_seconds: opts.duration,
44011
44532
  prompt_influence: opts.influence
44012
44533
  });
44534
+ const started = Date.now();
44013
44535
  const result = opts.json ? await doGenerate() : await withSpinner("Generating sound effect...", doGenerate, { done: null });
44536
+ const elapsed = (Date.now() - started) / 1e3;
44014
44537
  const filename = opts.output || "sound.mp3";
44015
44538
  const savedPath = await downloadFile(result.url, filename, !!opts.output);
44016
44539
  if (opts.json) {
44017
- console.log(JSON.stringify({ ...result, saved: savedPath }));
44540
+ console.log(jsonResult(result, elapsed, savedPath));
44018
44541
  } else {
44019
- const sizeKb = Math.round(result.size_bytes / 1024);
44020
- console.log(`${muted(`Generated sound effect (${sizeKb}KB)`)}`);
44542
+ console.log(muted("Generated sound effect"));
44543
+ printMetrics(generationMetrics(result, elapsed));
44021
44544
  console.log(success(`Saved to ${savedPath}`));
44022
44545
  }
44023
44546
  } catch (err) {
@@ -44031,14 +44554,14 @@ var generateCommand = new Command("generate").description("Generate images, vide
44031
44554
  init_api();
44032
44555
  init_config();
44033
44556
  init_colors();
44034
- import { existsSync as existsSync16, readFileSync as readFileSync20 } from "fs";
44035
- import { join as join20 } from "path";
44557
+ import { existsSync as existsSync17, readFileSync as readFileSync21 } from "fs";
44558
+ import { join as join22 } from "path";
44036
44559
  function readInstalledKitReadme(name) {
44037
44560
  const root = getProjectRoot() ?? process.cwd();
44038
- const kitDir = join20(root, "src", "packages", name);
44039
- if (!existsSync16(join20(kitDir, "package.json"))) return null;
44040
- const readme = join20(kitDir, "README.md");
44041
- return existsSync16(readme) ? readFileSync20(readme, "utf-8") : null;
44561
+ const kitDir = join22(root, "src", "packages", name);
44562
+ if (!existsSync17(join22(kitDir, "package.json"))) return null;
44563
+ const readme = join22(kitDir, "README.md");
44564
+ return existsSync17(readme) ? readFileSync21(readme, "utf-8") : null;
44042
44565
  }
44043
44566
  function slugify2(title) {
44044
44567
  return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -44311,17 +44834,17 @@ var domainCommand = new Command("domain").description("Manage custom domains").a
44311
44834
  }));
44312
44835
 
44313
44836
  // src/commands/realtime.ts
44314
- import { existsSync as existsSync17 } from "fs";
44315
- import { dirname as dirname13, resolve as resolve14 } from "path";
44837
+ import { existsSync as existsSync18 } from "fs";
44838
+ import { dirname as dirname14, resolve as resolve14 } from "path";
44316
44839
  init_api();
44317
44840
  init_config();
44318
44841
  init_colors();
44319
44842
  function hasDeployManifest() {
44320
44843
  const cfgPath = getConfigPath();
44321
44844
  if (!cfgPath) return false;
44322
- return existsSync17(resolve14(dirname13(cfgPath), "gipity.yaml"));
44845
+ return existsSync18(resolve14(dirname14(cfgPath), "gipity.yaml"));
44323
44846
  }
44324
- var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").option("--type <type>", "room type for create: state | relay", "state").option("--auth <level>", "auth level for create: public | user", "public").option("--max-clients <n>", "max clients for create (1-200)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
44847
+ 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("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
44325
44848
  const config = requireConfig();
44326
44849
  const base = `/projects/${config.projectGuid}/realtime-rooms`;
44327
44850
  const sub = (action || "list").toLowerCase();
@@ -44728,21 +45251,21 @@ var locationCommand = new Command("location").description("Show location").argum
44728
45251
  }));
44729
45252
 
44730
45253
  // src/commands/doctor.ts
44731
- import { existsSync as existsSync19, readFileSync as readFileSync22, statSync as statSync9 } from "fs";
44732
- import { join as join22, resolve as resolve15 } from "path";
44733
- import { homedir as homedir15 } from "os";
45254
+ import { existsSync as existsSync20, readFileSync as readFileSync23, statSync as statSync9 } from "fs";
45255
+ import { join as join24, resolve as resolve15 } from "path";
45256
+ import { homedir as homedir17 } from "os";
44734
45257
 
44735
45258
  // src/updater/state.ts
44736
- import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as existsSync18 } from "fs";
44737
- import { join as join21 } from "path";
44738
- import { homedir as homedir14 } from "os";
44739
- var GIPITY_DIR = join21(homedir14(), ".gipity");
44740
- var LOCAL_DIR = join21(GIPITY_DIR, "local");
44741
- var LOCAL_PKG_DIR = join21(LOCAL_DIR, "node_modules", "gipity");
44742
- var LOCAL_ENTRY = join21(LOCAL_PKG_DIR, "dist", "index.js");
44743
- var STATE_FILE = join21(GIPITY_DIR, "update-state.json");
44744
- var SETTINGS_FILE = join21(GIPITY_DIR, "settings.json");
44745
- var UPDATE_LOG = join21(GIPITY_DIR, "update.log");
45259
+ import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, mkdirSync as mkdirSync15, existsSync as existsSync19 } from "fs";
45260
+ import { join as join23 } from "path";
45261
+ import { homedir as homedir16 } from "os";
45262
+ var GIPITY_DIR = join23(homedir16(), ".gipity");
45263
+ var LOCAL_DIR = join23(GIPITY_DIR, "local");
45264
+ var LOCAL_PKG_DIR = join23(LOCAL_DIR, "node_modules", "gipity");
45265
+ var LOCAL_ENTRY = join23(LOCAL_PKG_DIR, "dist", "index.js");
45266
+ var STATE_FILE = join23(GIPITY_DIR, "update-state.json");
45267
+ var SETTINGS_FILE = join23(GIPITY_DIR, "settings.json");
45268
+ var UPDATE_LOG = join23(GIPITY_DIR, "update.log");
44746
45269
  var DEFAULT_STATE = {
44747
45270
  installedVersion: null,
44748
45271
  lastCheckAt: 0,
@@ -44753,24 +45276,24 @@ var DEFAULT_SETTINGS = {
44753
45276
  autoUpdates: true
44754
45277
  };
44755
45278
  function ensureDir() {
44756
- mkdirSync14(GIPITY_DIR, { recursive: true });
45279
+ mkdirSync15(GIPITY_DIR, { recursive: true });
44757
45280
  }
44758
45281
  function readState() {
44759
- if (!existsSync18(STATE_FILE)) return { ...DEFAULT_STATE };
45282
+ if (!existsSync19(STATE_FILE)) return { ...DEFAULT_STATE };
44760
45283
  try {
44761
- return { ...DEFAULT_STATE, ...JSON.parse(readFileSync21(STATE_FILE, "utf-8")) };
45284
+ return { ...DEFAULT_STATE, ...JSON.parse(readFileSync22(STATE_FILE, "utf-8")) };
44762
45285
  } catch {
44763
45286
  return { ...DEFAULT_STATE };
44764
45287
  }
44765
45288
  }
44766
45289
  function writeState(state) {
44767
45290
  ensureDir();
44768
- writeFileSync14(STATE_FILE, JSON.stringify(state, null, 2));
45291
+ writeFileSync15(STATE_FILE, JSON.stringify(state, null, 2));
44769
45292
  }
44770
45293
  function readSettings() {
44771
- if (!existsSync18(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
45294
+ if (!existsSync19(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
44772
45295
  try {
44773
- return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync21(SETTINGS_FILE, "utf-8")) };
45296
+ return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync22(SETTINGS_FILE, "utf-8")) };
44774
45297
  } catch {
44775
45298
  return { ...DEFAULT_SETTINGS };
44776
45299
  }
@@ -44787,7 +45310,7 @@ init_colors();
44787
45310
  init_auth();
44788
45311
  init_claude_setup();
44789
45312
  var NODE_MIN_MAJOR = 18;
44790
- function versionManagerNode(execPath, env = process.env, home = homedir15()) {
45313
+ function versionManagerNode(execPath, env = process.env, home = homedir17()) {
44791
45314
  const norm = (s) => s.replace(/\\/g, "/").replace(/\/+$/, "") + "/";
44792
45315
  const p = norm(execPath);
44793
45316
  const h = norm(home);
@@ -44804,10 +45327,10 @@ function versionManagerNode(execPath, env = process.env, home = homedir15()) {
44804
45327
  return null;
44805
45328
  }
44806
45329
  function localVersion() {
44807
- const pkgPath = join22(LOCAL_PKG_DIR, "package.json");
44808
- if (!existsSync19(pkgPath)) return null;
45330
+ const pkgPath = join24(LOCAL_PKG_DIR, "package.json");
45331
+ if (!existsSync20(pkgPath)) return null;
44809
45332
  try {
44810
- return JSON.parse(readFileSync22(pkgPath, "utf-8")).version ?? null;
45333
+ return JSON.parse(readFileSync23(pkgPath, "utf-8")).version ?? null;
44811
45334
  } catch {
44812
45335
  return null;
44813
45336
  }
@@ -44815,7 +45338,7 @@ function localVersion() {
44815
45338
  function shimVersion() {
44816
45339
  try {
44817
45340
  const url = new URL("../../package.json", import.meta.url);
44818
- return JSON.parse(readFileSync22(url, "utf-8")).version;
45341
+ return JSON.parse(readFileSync23(url, "utf-8")).version;
44819
45342
  } catch {
44820
45343
  return "unknown";
44821
45344
  }
@@ -44830,7 +45353,7 @@ function rel(t) {
44830
45353
  }
44831
45354
  function relayAutostartInstalled() {
44832
45355
  try {
44833
- return existsSync19(planFor({ cliPath: resolveCliPath() }).path);
45356
+ return existsSync20(planFor({ cliPath: resolveCliPath() }).path);
44834
45357
  } catch (err) {
44835
45358
  if (err instanceof UnsupportedPlatformError) return null;
44836
45359
  return null;
@@ -44868,7 +45391,7 @@ function gatherEnv(opts = {}) {
44868
45391
  const cli = {
44869
45392
  shim_version: shimVersion(),
44870
45393
  local_version: localVersion(),
44871
- local_install_ok: existsSync19(LOCAL_ENTRY),
45394
+ local_install_ok: existsSync20(LOCAL_ENTRY),
44872
45395
  auto_updates: !dis.disabled,
44873
45396
  updates_disabled_reason: dis.disabled ? dis.reason ?? null : null,
44874
45397
  last_check_at: updState.lastCheckAt,
@@ -44898,7 +45421,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
44898
45421
  console.log(`${muted("claude code ")} installed ${yn(env.claude.installed)} \xB7 authenticated ${yn(env.claude.authenticated)}`);
44899
45422
  const autostartLabel = env.relay.autostart === null ? muted("n/a") : yn(env.relay.autostart);
44900
45423
  console.log(`${muted("relay ")} paired ${yn(env.relay.paired)} \xB7 running ${yn(env.relay.running)} \xB7 autostart ${autostartLabel}${env.relay.paused ? warning(" \xB7 paused") : ""}${env.relay.device ? muted(` (${env.relay.device.name})`) : ""}`);
44901
- if (existsSync19(resolve15(process.cwd(), ".codex", "hooks.json"))) {
45424
+ if (existsSync20(resolve15(process.cwd(), ".codex", "hooks.json"))) {
44902
45425
  console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
44903
45426
  }
44904
45427
  console.log(`${muted("ready ")} ${env.ready ? success("yes") : warning("no - run `gipity build` (or the desktop app) to finish setup")}`);
@@ -44906,7 +45429,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
44906
45429
  const settings = readSettings();
44907
45430
  const dis = updatesDisabled();
44908
45431
  const local = localVersion();
44909
- const localOk = existsSync19(LOCAL_ENTRY);
45432
+ const localOk = existsSync20(LOCAL_ENTRY);
44910
45433
  console.log("");
44911
45434
  console.log(bold("CLI install"));
44912
45435
  console.log(`${muted("shim version ")} ${shimVersion()}`);
@@ -44914,11 +45437,11 @@ var doctorCommand = new Command("doctor").description("Check install + environme
44914
45437
  console.log(`${muted("local install ")} ${LOCAL_PKG_DIR}`);
44915
45438
  console.log("");
44916
45439
  console.log(`${muted("auto-updates ")} ${dis.disabled ? warning(`disabled (${dis.reason})`) : success("enabled")}`);
44917
- console.log(`${muted("settings file ")} ${existsSync19(SETTINGS_FILE) ? SETTINGS_FILE : dim("(default)")} autoUpdates=${settings.autoUpdates}`);
45440
+ console.log(`${muted("settings file ")} ${existsSync20(SETTINGS_FILE) ? SETTINGS_FILE : dim("(default)")} autoUpdates=${settings.autoUpdates}`);
44918
45441
  console.log(`${muted("last check ")} ${rel(state.lastCheckAt)}`);
44919
45442
  console.log(`${muted("last error ")} ${state.lastError ? error(state.lastError) : dim("none")}`);
44920
- console.log(`${muted("state file ")} ${existsSync19(STATE_FILE) ? STATE_FILE : dim("(none yet)")}`);
44921
- console.log(`${muted("update log ")} ${existsSync19(UPDATE_LOG) ? `${UPDATE_LOG} (${statSync9(UPDATE_LOG).size} bytes)` : dim("(none yet)")}`);
45443
+ console.log(`${muted("state file ")} ${existsSync20(STATE_FILE) ? STATE_FILE : dim("(none yet)")}`);
45444
+ console.log(`${muted("update log ")} ${existsSync20(UPDATE_LOG) ? `${UPDATE_LOG} (${statSync9(UPDATE_LOG).size} bytes)` : dim("(none yet)")}`);
44922
45445
  console.log("");
44923
45446
  console.log(dim("Force an update with: gipity update"));
44924
45447
  });
@@ -44927,10 +45450,10 @@ var doctorCommand = new Command("doctor").description("Check install + environme
44927
45450
  import { appendFileSync } from "fs";
44928
45451
 
44929
45452
  // src/updater/install.ts
44930
- import { existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync5, writeFileSync as writeFileSync15 } from "fs";
44931
- import { dirname as dirname14, join as join23 } from "path";
45453
+ import { existsSync as existsSync21, mkdirSync as mkdirSync16, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync16 } from "fs";
45454
+ import { dirname as dirname15, join as join25 } from "path";
44932
45455
  init_platform();
44933
- var UPDATE_LOCK = join23(GIPITY_DIR, "update.lock");
45456
+ var UPDATE_LOCK = join25(GIPITY_DIR, "update.lock");
44934
45457
  var LOCK_STALE_MS2 = 10 * 60 * 1e3;
44935
45458
  function npmInstallGipity(version) {
44936
45459
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
@@ -44939,7 +45462,7 @@ function npmInstallGipity(version) {
44939
45462
  encoding: "utf-8"
44940
45463
  });
44941
45464
  return {
44942
- ok: res.status === 0 && existsSync20(LOCAL_ENTRY),
45465
+ ok: res.status === 0 && existsSync21(LOCAL_ENTRY),
44943
45466
  status: res.status,
44944
45467
  stderr: (res.stderr || "").toString(),
44945
45468
  spawnError: res.error
@@ -44950,21 +45473,21 @@ function isWedged(stderr) {
44950
45473
  return WEDGE_CODES.test(stderr);
44951
45474
  }
44952
45475
  function resetLocalTree(dir = LOCAL_DIR) {
44953
- mkdirSync15(dir, { recursive: true });
44954
- rmSync2(join23(dir, "node_modules"), { recursive: true, force: true });
44955
- rmSync2(join23(dir, "package-lock.json"), { force: true });
44956
- writeFileSync15(join23(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
45476
+ mkdirSync16(dir, { recursive: true });
45477
+ rmSync2(join25(dir, "node_modules"), { recursive: true, force: true });
45478
+ rmSync2(join25(dir, "package-lock.json"), { force: true });
45479
+ writeFileSync16(join25(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
44957
45480
  }
44958
45481
  function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
44959
- mkdirSync15(dirname14(lockPath2), { recursive: true });
45482
+ mkdirSync16(dirname15(lockPath2), { recursive: true });
44960
45483
  try {
44961
- writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
45484
+ writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
44962
45485
  return true;
44963
45486
  } catch {
44964
45487
  try {
44965
45488
  if (Date.now() - statSync10(lockPath2).mtimeMs > LOCK_STALE_MS2) {
44966
- unlinkSync5(lockPath2);
44967
- writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
45489
+ unlinkSync6(lockPath2);
45490
+ writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
44968
45491
  return true;
44969
45492
  }
44970
45493
  } catch {
@@ -44974,7 +45497,7 @@ function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
44974
45497
  }
44975
45498
  function releaseUpdateLock(lockPath2 = UPDATE_LOCK) {
44976
45499
  try {
44977
- unlinkSync5(lockPath2);
45500
+ unlinkSync6(lockPath2);
44978
45501
  } catch {
44979
45502
  }
44980
45503
  }
@@ -45113,17 +45636,17 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
45113
45636
  init_api();
45114
45637
  init_utils();
45115
45638
  init_colors();
45116
- import { existsSync as existsSync23, readFileSync as readFileSync25, unlinkSync as unlinkSync8 } from "fs";
45639
+ import { existsSync as existsSync24, readFileSync as readFileSync26, unlinkSync as unlinkSync9 } from "fs";
45117
45640
  import { spawn as spawn2 } from "child_process";
45118
45641
 
45119
45642
  // src/relay/daemon.ts
45120
45643
  init_platform();
45121
45644
  init_config();
45122
- import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync17, existsSync as existsSync22, readFileSync as readFileSync24, writeFileSync as writeFileSync16, chmodSync as chmodSync3, closeSync as closeSync4, openSync as openSync4, unlinkSync as unlinkSync7 } from "fs";
45645
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync18, existsSync as existsSync23, readFileSync as readFileSync25, writeFileSync as writeFileSync17, chmodSync as chmodSync4, closeSync as closeSync4, openSync as openSync4, unlinkSync as unlinkSync8 } from "fs";
45123
45646
  import { stat, readFile } from "fs/promises";
45124
45647
  import { createInterface as createInterface2 } from "readline";
45125
- import { homedir as homedir17, hostname as hostname5, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
45126
- import { join as join26 } from "path";
45648
+ import { homedir as homedir19, hostname as hostname6, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
45649
+ import { join as join28 } from "path";
45127
45650
  init_setup();
45128
45651
  init_auth();
45129
45652
  init_api();
@@ -45835,7 +46358,7 @@ import { randomUUID as randomUUID2 } from "crypto";
45835
46358
  // src/relay/agent-token.ts
45836
46359
  init_api();
45837
46360
  init_config();
45838
- import { hostname as hostname4 } from "os";
46361
+ import { hostname as hostname5 } from "os";
45839
46362
  var RELAY_AGENT_TOKEN_EXPIRY_DAYS = 60;
45840
46363
  async function tokenValid(token) {
45841
46364
  try {
@@ -45854,7 +46377,7 @@ async function ensureRelayAgentToken() {
45854
46377
  setAgentToken(null, null);
45855
46378
  }
45856
46379
  try {
45857
- const name = `Relay on ${getDevice()?.name ?? hostname4()}`;
46380
+ const name = `Relay on ${getDevice()?.name ?? hostname5()}`;
45858
46381
  const res = await post(
45859
46382
  "/auth/agent-tokens",
45860
46383
  { name, expiresInDays: RELAY_AGENT_TOKEN_EXPIRY_DAYS }
@@ -45880,9 +46403,9 @@ async function revokeRelayAgentToken() {
45880
46403
  init_platform();
45881
46404
  init_client_context();
45882
46405
  init_agents();
45883
- import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as homedir16 } from "os";
46406
+ import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as homedir18 } from "os";
45884
46407
  import { statfsSync, readdirSync as readdirSync9 } from "fs";
45885
- import { join as join24 } from "path";
46408
+ import { join as join26 } from "path";
45886
46409
  var PROBE_TIMEOUT_MS = 4e3;
45887
46410
  function parseVersion(out) {
45888
46411
  const m = out.match(/\d+\.\d+(?:\.\d+)?(?:[-.\w]*)?/);
@@ -45949,12 +46472,12 @@ async function detectGpu() {
45949
46472
  function diskUsage() {
45950
46473
  try {
45951
46474
  if (typeof statfsSync !== "function") return void 0;
45952
- const st2 = statfsSync(join24(homedir16(), "GipityProjects"), { bigint: false });
46475
+ const st2 = statfsSync(join26(homedir18(), "GipityProjects"), { bigint: false });
45953
46476
  if (!st2 || !st2.bsize) return void 0;
45954
46477
  return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
45955
46478
  } catch {
45956
46479
  try {
45957
- const st2 = statfsSync(homedir16(), { bigint: false });
46480
+ const st2 = statfsSync(homedir18(), { bigint: false });
45958
46481
  return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
45959
46482
  } catch {
45960
46483
  return void 0;
@@ -45963,7 +46486,7 @@ function diskUsage() {
45963
46486
  }
45964
46487
  function localProjectCount() {
45965
46488
  try {
45966
- return readdirSync9(join24(homedir16(), "GipityProjects"), { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).length;
46489
+ return readdirSync9(join26(homedir18(), "GipityProjects"), { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).length;
45967
46490
  } catch {
45968
46491
  return void 0;
45969
46492
  }
@@ -46415,7 +46938,7 @@ var SessionPool = class {
46415
46938
  init_config();
46416
46939
  init_api();
46417
46940
  init_agents();
46418
- var RELAY_LOG_PATH = join26(homedir17(), ".gipity", "relay.log");
46941
+ var RELAY_LOG_PATH = join28(homedir19(), ".gipity", "relay.log");
46419
46942
  var HEARTBEAT_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_HEARTBEAT_MS || "60000", 10);
46420
46943
  var DIAGNOSTICS_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_DIAGNOSTICS_MS || String(24 * 60 * 60 * 1e3), 10);
46421
46944
  var LONG_POLL_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_POLL_TIMEOUT_MS || "35000", 10);
@@ -46442,7 +46965,7 @@ function mapPlatform2(p) {
46442
46965
  return "linux";
46443
46966
  }
46444
46967
  async function registerDevice() {
46445
- const name = (hostname5() || "my-pc").trim().slice(0, 100) || "my-pc";
46968
+ const name = (hostname6() || "my-pc").trim().slice(0, 100) || "my-pc";
46446
46969
  const res = await post("/remote-devices", { name, platform: mapPlatform2(osPlatform3()), machine_id: getMachineId() });
46447
46970
  const device = {
46448
46971
  guid: res.data.short_guid,
@@ -46512,17 +47035,17 @@ var permsLocked = false;
46512
47035
  function lockLogPerms(dir, file) {
46513
47036
  if (permsLocked) return;
46514
47037
  try {
46515
- chmodSync3(dir, 448);
47038
+ chmodSync4(dir, 448);
46516
47039
  } catch {
46517
47040
  }
46518
- if (!existsSync22(file)) {
47041
+ if (!existsSync23(file)) {
46519
47042
  try {
46520
47043
  closeSync4(openSync4(file, "a", 384));
46521
47044
  } catch {
46522
47045
  }
46523
47046
  }
46524
47047
  try {
46525
- chmodSync3(file, 384);
47048
+ chmodSync4(file, 384);
46526
47049
  } catch {
46527
47050
  }
46528
47051
  permsLocked = true;
@@ -46532,8 +47055,8 @@ function log2(level, msg, extra) {
46532
47055
  const pretty = `${C7.dim(hhmmss())} ${badge(level)} ${C7.bold(msg)}${formatExtra(extra)}`;
46533
47056
  process.stderr.write(pretty + "\n");
46534
47057
  try {
46535
- const dir = join26(homedir17(), ".gipity");
46536
- mkdirSync17(dir, { recursive: true });
47058
+ const dir = join28(homedir19(), ".gipity");
47059
+ mkdirSync18(dir, { recursive: true });
46537
47060
  lockLogPerms(dir, RELAY_LOG_PATH);
46538
47061
  const json = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level, msg, ...extra ?? {} });
46539
47062
  appendFileSync3(RELAY_LOG_PATH, json + "\n");
@@ -46964,7 +47487,7 @@ function isSafeSessionId(s) {
46964
47487
  function transcriptPathFor(cwd, sessionId) {
46965
47488
  if (!isSafeSessionId(sessionId)) return null;
46966
47489
  const slug = cwd.replace(/[^a-zA-Z0-9]/g, "-");
46967
- return join26(homedir17(), ".claude", "projects", slug, `${sessionId}.jsonl`);
47490
+ return join28(homedir19(), ".claude", "projects", slug, `${sessionId}.jsonl`);
46968
47491
  }
46969
47492
  function formatDuration(ms2) {
46970
47493
  const totalSec = ms2 / 1e3;
@@ -47418,11 +47941,11 @@ async function resolveCwdForProject(d) {
47418
47941
  throw new Error(`Invalid project slug: ${JSON.stringify(d.project_slug)}`);
47419
47942
  }
47420
47943
  const root = getProjectsRoot();
47421
- const path5 = join26(root, d.project_slug);
47422
- const configPath = join26(path5, ".gipity.json");
47423
- if (existsSync22(configPath)) {
47944
+ const path5 = join28(root, d.project_slug);
47945
+ const configPath = join28(path5, ".gipity.json");
47946
+ if (existsSync23(configPath)) {
47424
47947
  try {
47425
- const cfg = JSON.parse(readFileSync24(configPath, "utf-8"));
47948
+ const cfg = JSON.parse(readFileSync25(configPath, "utf-8"));
47426
47949
  if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
47427
47950
  log2("warn", "project dir exists but guid mismatch - using it anyway", {
47428
47951
  path: path5,
@@ -47434,9 +47957,9 @@ async function resolveCwdForProject(d) {
47434
47957
  }
47435
47958
  }
47436
47959
  log2("info", "bootstrapping new project dir", { slug: d.project_slug, path: path5 });
47437
- mkdirSync17(path5, { recursive: true });
47960
+ mkdirSync18(path5, { recursive: true });
47438
47961
  const apiBase2 = getApiBaseOverride() || DEFAULT_API_BASE;
47439
- writeFileSync16(configPath, JSON.stringify({
47962
+ writeFileSync17(configPath, JSON.stringify({
47440
47963
  projectGuid: d.project_guid,
47441
47964
  projectSlug: d.project_slug,
47442
47965
  accountSlug: d.account_slug,
@@ -47557,7 +48080,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
47557
48080
  } catch {
47558
48081
  }
47559
48082
  try {
47560
- unlinkSync7(join26(cwd, ".gipity", "sync.lock"));
48083
+ unlinkSync8(join28(cwd, ".gipity", "sync.lock"));
47561
48084
  } catch {
47562
48085
  }
47563
48086
  finish(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s`)));
@@ -47994,11 +48517,11 @@ relayCommand.command("run").description("Run the background service").option("-v
47994
48517
  });
47995
48518
  relayCommand.command("stop").description("Stop the background service").option("--force", "Force-stop if it doesn't exit cleanly within 5s").action(async (opts) => {
47996
48519
  const pidPath = getDaemonPidPath();
47997
- if (!existsSync23(pidPath)) {
48520
+ if (!existsSync24(pidPath)) {
47998
48521
  console.log(muted("Background service isn't running."));
47999
48522
  return;
48000
48523
  }
48001
- const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
48524
+ const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
48002
48525
  if (!pid || isNaN(pid)) {
48003
48526
  console.error(error("PID file is empty or malformed."));
48004
48527
  process.exit(1);
@@ -48009,7 +48532,7 @@ relayCommand.command("stop").description("Stop the background service").option("
48009
48532
  if (err?.code === "ESRCH") {
48010
48533
  console.log(muted(`PID ${pid} not running - cleaning up stale PID file.`));
48011
48534
  try {
48012
- unlinkSync8(pidPath);
48535
+ unlinkSync9(pidPath);
48013
48536
  } catch {
48014
48537
  }
48015
48538
  return;
@@ -48146,8 +48669,8 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
48146
48669
  } catch {
48147
48670
  }
48148
48671
  const pidPath = getDaemonPidPath();
48149
- if (existsSync23(pidPath)) {
48150
- const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
48672
+ if (existsSync24(pidPath)) {
48673
+ const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
48151
48674
  if (pid && !isNaN(pid)) {
48152
48675
  try {
48153
48676
  process.kill(pid, "SIGTERM");
@@ -48160,13 +48683,13 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
48160
48683
  });
48161
48684
  relayCommand.command("log").description("Tail the service log").option("-n, --lines <n>", "How many lines to print (default 100)", "100").option("-f, --follow", "Follow the log like `tail -f`").action((opts) => {
48162
48685
  const path5 = RELAY_LOG_PATH;
48163
- if (!existsSync23(path5)) {
48686
+ if (!existsSync24(path5)) {
48164
48687
  console.log(muted("No log file yet. Start the service with `gipity relay run` (or install it)."));
48165
48688
  return;
48166
48689
  }
48167
48690
  const lines = parseInt(opts.lines, 10) || 100;
48168
48691
  try {
48169
- const all = readFileSync25(path5, "utf-8").split("\n");
48692
+ const all = readFileSync26(path5, "utf-8").split("\n");
48170
48693
  const tail2 = all.slice(-lines - 1).join("\n");
48171
48694
  process.stdout.write(tail2);
48172
48695
  } catch (err) {
@@ -48237,20 +48760,20 @@ init_api();
48237
48760
  init_auth();
48238
48761
  init_utils();
48239
48762
  init_colors();
48240
- import { existsSync as existsSync24, rmSync as rmSync4, unlinkSync as unlinkSync9, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "fs";
48241
- import { homedir as homedir18, platform as osPlatform4 } from "os";
48242
- import { join as join27, resolve as resolve17 } from "path";
48763
+ import { existsSync as existsSync25, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "fs";
48764
+ import { homedir as homedir20, platform as osPlatform4 } from "os";
48765
+ import { join as join29, resolve as resolve17 } from "path";
48243
48766
  init_agents();
48244
48767
  function removeInstallerPathLines() {
48245
48768
  if (osPlatform4() === "win32") return [];
48246
48769
  const marker = "# Added by the Gipity installer";
48247
48770
  const touched = [];
48248
48771
  for (const name of [".bashrc", ".zshrc", ".profile"]) {
48249
- const rc2 = join27(homedir18(), name);
48250
- if (!existsSync24(rc2)) continue;
48772
+ const rc2 = join29(homedir20(), name);
48773
+ if (!existsSync25(rc2)) continue;
48251
48774
  let text;
48252
48775
  try {
48253
- text = readFileSync26(rc2, "utf-8");
48776
+ text = readFileSync27(rc2, "utf-8");
48254
48777
  } catch {
48255
48778
  continue;
48256
48779
  }
@@ -48260,7 +48783,7 @@ function removeInstallerPathLines() {
48260
48783
  );
48261
48784
  if (kept.length === lines.length) continue;
48262
48785
  try {
48263
- writeFileSync17(rc2, kept.join("\n"));
48786
+ writeFileSync18(rc2, kept.join("\n"));
48264
48787
  touched.push(rc2);
48265
48788
  } catch {
48266
48789
  }
@@ -48268,7 +48791,7 @@ function removeInstallerPathLines() {
48268
48791
  return touched;
48269
48792
  }
48270
48793
  function tildify2(p) {
48271
- const home = homedir18();
48794
+ const home = homedir20();
48272
48795
  return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
48273
48796
  }
48274
48797
  function resolveCliPath2() {
@@ -48306,9 +48829,9 @@ function removeServiceUnit() {
48306
48829
  const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio: "ignore" });
48307
48830
  if (r.status !== 0) allOk = false;
48308
48831
  }
48309
- if (existsSync24(plan2.path)) {
48832
+ if (existsSync25(plan2.path)) {
48310
48833
  try {
48311
- unlinkSync9(plan2.path);
48834
+ unlinkSync10(plan2.path);
48312
48835
  } catch {
48313
48836
  }
48314
48837
  }
@@ -48329,9 +48852,9 @@ async function revokeDeviceBestEffort() {
48329
48852
  }
48330
48853
  var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
48331
48854
  const autoYes = opts.yes || getAutoConfirm();
48332
- const gipityDir = join27(homedir18(), ".gipity");
48333
- const launcherBin = join27(gipityDir, "launcher", "bin", "gipity");
48334
- const installedViaLauncher = existsSync24(launcherBin);
48855
+ const gipityDir = join29(homedir20(), ".gipity");
48856
+ const launcherBin = join29(gipityDir, "launcher", "bin", "gipity");
48857
+ const installedViaLauncher = existsSync25(launcherBin);
48335
48858
  console.log(`${bold("Gipity uninstall")} - this will:`);
48336
48859
  console.log(`\u2022 Stop the running relay daemon (if any)`);
48337
48860
  console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
@@ -48372,7 +48895,7 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
48372
48895
  if (!anyAgentIntegration) {
48373
48896
  console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
48374
48897
  }
48375
- if (existsSync24(gipityDir)) {
48898
+ if (existsSync25(gipityDir)) {
48376
48899
  try {
48377
48900
  rmSync4(gipityDir, { recursive: true, force: true });
48378
48901
  console.log(`${success(`Removed ${gipityDir}/`)}`);
@@ -48414,7 +48937,7 @@ function keyToIndex(key) {
48414
48937
  return code >= 0 && code < 26 ? code : -1;
48415
48938
  }
48416
48939
  var approvalCommand = new Command("approval").description("Manage approvals");
48417
- approvalCommand.command("list").description("List pending approvals").option("--status <status>", "pending|approved|denied|cancelled|expired|all", "pending").option("--json", "Output as JSON").action((opts) => run("List", async () => {
48940
+ approvalCommand.command("list").description("List pending approvals").addOption(new Option("--status <status>", "Filter by status").choices(["pending", "approved", "denied", "cancelled", "expired", "all"]).default("pending")).option("--json", "Output as JSON").action((opts) => run("List", async () => {
48418
48941
  const res = await get(`/approvals?status=${encodeURIComponent(opts.status)}`);
48419
48942
  printList(
48420
48943
  res.data,
@@ -48423,7 +48946,7 @@ approvalCommand.command("list").description("List pending approvals").option("--
48423
48946
  (a) => `${a.guid} ${a.title} ${muted(`[${a.status}] ${timeAgo(a.created_at)}`)}`
48424
48947
  );
48425
48948
  }));
48426
- approvalCommand.command("create <title...>").description("Create a pending approval").option("--description <text>", "Detailed context").option("--type <type>", "yes_no | choice | text", "yes_no").option("--choices <a,b,c>", "Comma-separated options (for --type choice)").option("--prompt <text>", "Custom prompt shown to the user").option("--expires-in <minutes>", "Minutes until expiry (default: 10080 = 7d)").option("--json", "Output as JSON").action((titleParts, opts) => run("Create", async () => {
48949
+ approvalCommand.command("create <title...>").description("Create a pending approval").option("--description <text>", "Detailed context").addOption(new Option("--type <type>", "Approval type").choices(["yes_no", "choice", "text"]).default("yes_no")).option("--choices <a,b,c>", "Comma-separated options (for --type choice)").option("--prompt <text>", "Custom prompt shown to the user").option("--expires-in <minutes>", "Minutes until expiry (default: 10080 = 7d)").option("--json", "Output as JSON").action((titleParts, opts) => run("Create", async () => {
48427
48950
  const body = { title: titleParts.join(" ") };
48428
48951
  if (opts.description) body.description = opts.description;
48429
48952
  if (opts.type) body.response_type = opts.type;
@@ -48535,7 +49058,7 @@ gmailCommand.command("reply").description("Reply to a Gmail thread. Get thread-i
48535
49058
  }));
48536
49059
 
48537
49060
  // src/commands/text.ts
48538
- import { readFileSync as readFileSync27 } from "fs";
49061
+ import { readFileSync as readFileSync28 } from "fs";
48539
49062
  init_colors();
48540
49063
 
48541
49064
  // src/helpers/text-analysis.ts
@@ -48690,10 +49213,10 @@ function areAnagrams(a, b7) {
48690
49213
 
48691
49214
  // src/commands/text.ts
48692
49215
  function resolveInput(args, opts) {
48693
- if (opts.file) return readFileSync27(opts.file, "utf-8");
49216
+ if (opts.file) return readFileSync28(opts.file, "utf-8");
48694
49217
  if (args.length) return args.join(" ");
48695
49218
  try {
48696
- return readFileSync27(0, "utf-8");
49219
+ return readFileSync28(0, "utf-8");
48697
49220
  } catch {
48698
49221
  return "";
48699
49222
  }
@@ -48899,9 +49422,9 @@ function collectRealFlags(argv2, program3) {
48899
49422
  }
48900
49423
 
48901
49424
  // src/trace.ts
48902
- import { openSync as openSync5, writeSync, mkdirSync as mkdirSync18 } from "fs";
48903
- import { join as join28 } from "path";
48904
- import { homedir as homedir19 } from "os";
49425
+ import { openSync as openSync5, writeSync, mkdirSync as mkdirSync19 } from "fs";
49426
+ import { join as join30 } from "path";
49427
+ import { homedir as homedir21 } from "os";
48905
49428
  var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
48906
49429
  function installOutputTrace(label2) {
48907
49430
  if (process.env.GIPITY_TRACE_OUTPUT !== "1") return;
@@ -48912,10 +49435,10 @@ function installOutputTrace(label2) {
48912
49435
  existing.emit({ event: "reenter", label: label2 });
48913
49436
  return;
48914
49437
  }
48915
- const dir = join28(process.env.GIPITY_DIR || join28(homedir19(), ".gipity"), "trace");
48916
- mkdirSync18(dir, { recursive: true });
49438
+ const dir = join30(process.env.GIPITY_DIR || join30(homedir21(), ".gipity"), "trace");
49439
+ mkdirSync19(dir, { recursive: true });
48917
49440
  const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
48918
- const fd2 = openSync5(join28(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
49441
+ const fd2 = openSync5(join30(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
48919
49442
  const emit = (rec) => {
48920
49443
  try {
48921
49444
  writeSync(fd2, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
@@ -48950,12 +49473,12 @@ function installOutputTrace(label2) {
48950
49473
 
48951
49474
  // src/index.ts
48952
49475
  installOutputTrace("index");
48953
- var __dirname = dirname15(fileURLToPath3(import.meta.url));
48954
- var pkg = JSON.parse(readFileSync28(resolve18(__dirname, "../package.json"), "utf-8"));
49476
+ var __dirname = dirname16(fileURLToPath3(import.meta.url));
49477
+ var pkg = JSON.parse(readFileSync29(resolve18(__dirname, "../package.json"), "utf-8"));
48955
49478
  function versionLabel() {
48956
49479
  const base = `v${pkg.version}`;
48957
49480
  try {
48958
- const info2 = JSON.parse(readFileSync28(resolve18(__dirname, "build-info.json"), "utf-8"));
49481
+ const info2 = JSON.parse(readFileSync29(resolve18(__dirname, "build-info.json"), "utf-8"));
48959
49482
  if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
48960
49483
  } catch {
48961
49484
  }