gipity 1.1.11 → 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
  }
@@ -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) {
@@ -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,10 +39312,10 @@ var agentCommand = new Command("agent").description("Manage agents").argument("[
38952
39312
  return `${a.name}${active}${def}${model}`;
38953
39313
  });
38954
39314
  }));
38955
- agentCommand.command("models").description("List the LLM models an agent can use (ids for `agent create --model` and `agent set model`)").option("--json", "Output as JSON").action((opts) => run("Models", 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 () => {
38956
39316
  const res = await get("/agents/models");
38957
39317
  if (opts.json) {
38958
- console.log(JSON.stringify(res.data));
39318
+ console.log(JSON.stringify({ models: res.data, aliases: res.aliases ?? {} }));
38959
39319
  return;
38960
39320
  }
38961
39321
  const width = res.data.reduce((m, x) => Math.max(m, x.id.length), 0);
@@ -38970,8 +39330,16 @@ agentCommand.command("models").description("List the LLM models an agent can use
38970
39330
  if (m.isDefault) notes.push("default");
38971
39331
  console.log(`${m.id.padEnd(width)} ${muted(notes.join(" \xB7 "))}`);
38972
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
+ }
38973
39341
  }));
38974
- agentCommand.command("create <name>").description("Create an agent").option("--model <model>", "Model preference (an id from `gipity agent models`; default: platform default)").option("--switch", "Switch to new agent after creation").option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
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 () => {
38975
39343
  const body = { name };
38976
39344
  if (opts.model) body.modelPreference = opts.model;
38977
39345
  const res = await post("/agents", body);
@@ -38986,7 +39354,7 @@ agentCommand.command("create <name>").description("Create an agent").option("--m
38986
39354
  if (opts.switch) console.log("Switched.");
38987
39355
  }
38988
39356
  }));
38989
- agentCommand.command("set <field> <value>").description("Set a field (model, temp). Model ids: `gipity agent models`").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 () => {
38990
39358
  const config = requireConfig();
38991
39359
  const body = {};
38992
39360
  if (field === "model") body.modelPreference = value;
@@ -39795,9 +40163,9 @@ storageCommand.command("retention").description("View or adjust your file versio
39795
40163
  init_platform();
39796
40164
  init_auth();
39797
40165
  init_api();
39798
- import { join as join19, dirname as dirname11, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
39799
- import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync12, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
39800
- 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";
39801
40169
  import { fileURLToPath as fileURLToPath2 } from "url";
39802
40170
  import { randomUUID } from "crypto";
39803
40171
  init_config();
@@ -39909,8 +40277,8 @@ init_utils();
39909
40277
  init_colors();
39910
40278
 
39911
40279
  // src/relay/installers.ts
39912
- import { homedir as homedir10, platform as osPlatform } from "os";
39913
- import { join as join17 } from "path";
40280
+ import { homedir as homedir12, platform as osPlatform } from "os";
40281
+ import { join as join19 } from "path";
39914
40282
  var UnsupportedPlatformError = class extends Error {
39915
40283
  constructor(plat) {
39916
40284
  super(`gipity relay install does not support ${plat}`);
@@ -39928,8 +40296,8 @@ function display(argvs) {
39928
40296
  }
39929
40297
  function launchdPlan(cliPath) {
39930
40298
  const label2 = "ai.gipity.relay";
39931
- const path5 = join17(homedir10(), "Library", "LaunchAgents", `${label2}.plist`);
39932
- const logDir = join17(homedir10(), "Library", "Logs", "Gipity");
40299
+ const path5 = join19(homedir12(), "Library", "LaunchAgents", `${label2}.plist`);
40300
+ const logDir = join19(homedir12(), "Library", "Logs", "Gipity");
39933
40301
  const uid = process.getuid?.() ?? 0;
39934
40302
  const target = `gui/${uid}`;
39935
40303
  const content = `<?xml version="1.0" encoding="UTF-8"?>
@@ -39953,8 +40321,8 @@ function launchdPlan(cliPath) {
39953
40321
  <dict>
39954
40322
  <key>SuccessfulExit</key><false/>
39955
40323
  </dict>
39956
- <key>StandardOutPath</key><string>${join17(logDir, "relay.out.log")}</string>
39957
- <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>
39958
40326
  <key>ProcessType</key><string>Background</string>
39959
40327
  </dict>
39960
40328
  </plist>
@@ -39977,7 +40345,7 @@ function launchdPlan(cliPath) {
39977
40345
  }
39978
40346
  function systemdUserPlan(cliPath) {
39979
40347
  const unitName = "gipity-relay.service";
39980
- const path5 = join17(homedir10(), ".config", "systemd", "user", unitName);
40348
+ const path5 = join19(homedir12(), ".config", "systemd", "user", unitName);
39981
40349
  const content = `[Unit]
39982
40350
  Description=Gipity relay - local Claude Code control from the Gipity web CLI
39983
40351
  After=network-online.target
@@ -40015,7 +40383,7 @@ WantedBy=default.target
40015
40383
  }
40016
40384
  function windowsTaskPlan(cliPath) {
40017
40385
  const taskName = "GipityRelay";
40018
- const path5 = join17(homedir10(), "AppData", "Local", "Gipity", "relay-task.xml");
40386
+ const path5 = join19(homedir12(), "AppData", "Local", "Gipity", "relay-task.xml");
40019
40387
  const runsViaNode = /\.[cm]?js$/i.test(cliPath);
40020
40388
  const command = runsViaNode ? process.execPath : cliPath;
40021
40389
  const argLine = runsViaNode ? `"${cliPath}" relay run` : "relay run";
@@ -40076,15 +40444,15 @@ function windowsTaskPlan(cliPath) {
40076
40444
  // src/relay/setup.ts
40077
40445
  init_platform();
40078
40446
  init_api();
40079
- import { hostname as hostname3, userInfo, platform as osPlatform2 } from "os";
40080
- import { resolve as resolve12, dirname as dirname10 } from "path";
40081
- 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";
40082
40450
 
40083
40451
  // src/relay/machine-id.ts
40084
40452
  import { createHash as createHash3 } from "crypto";
40085
40453
  import { execFileSync } from "child_process";
40086
- import { readFileSync as readFileSync16 } from "fs";
40087
- import { hostname as hostname2, platform, arch } from "os";
40454
+ import { readFileSync as readFileSync17 } from "fs";
40455
+ import { hostname as hostname3, platform, arch } from "os";
40088
40456
  function rawMachineId() {
40089
40457
  const override = process.env.GIPITY_RELAY_MACHINE_ID?.trim();
40090
40458
  if (override) return `override:${override}`;
@@ -40092,7 +40460,7 @@ function rawMachineId() {
40092
40460
  if (platform() === "linux") {
40093
40461
  for (const path5 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
40094
40462
  try {
40095
- const id2 = readFileSync16(path5, "utf-8").trim();
40463
+ const id2 = readFileSync17(path5, "utf-8").trim();
40096
40464
  if (id2) return `linux:${id2}`;
40097
40465
  } catch {
40098
40466
  }
@@ -40112,7 +40480,7 @@ function rawMachineId() {
40112
40480
  }
40113
40481
  } catch {
40114
40482
  }
40115
- return `fallback:${hostname2()}:${platform()}:${arch()}`;
40483
+ return `fallback:${hostname3()}:${platform()}:${arch()}`;
40116
40484
  }
40117
40485
  function getMachineId() {
40118
40486
  return createHash3("sha256").update(rawMachineId()).digest("hex");
@@ -40135,7 +40503,7 @@ function friendlyDeviceName() {
40135
40503
  const owner = user.charAt(0).toUpperCase() + user.slice(1);
40136
40504
  return `${owner}'s ${kind}`;
40137
40505
  }
40138
- const host = (hostname3() || "").trim();
40506
+ const host = (hostname4() || "").trim();
40139
40507
  return host || `My ${kind}`;
40140
40508
  }
40141
40509
  function resolveCliPath() {
@@ -40160,7 +40528,15 @@ async function pairDevice(opts = {}) {
40160
40528
  throw new Error("Device name must be 1\u2013100 non-whitespace characters.");
40161
40529
  }
40162
40530
  const plat = mapPlatform(osPlatform2());
40163
- 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
+ });
40164
40540
  setDevice({
40165
40541
  guid: res.data.short_guid,
40166
40542
  name,
@@ -40187,8 +40563,8 @@ function startDaemon() {
40187
40563
  function installAutostart(opts = {}) {
40188
40564
  const stdio = opts.stdio ?? "ignore";
40189
40565
  const plan2 = planFor({ cliPath: resolveCliPath() });
40190
- mkdirSync10(dirname10(plan2.path), { recursive: true });
40191
- writeFileSync10(plan2.path, plan2.content);
40566
+ mkdirSync11(dirname11(plan2.path), { recursive: true });
40567
+ writeFileSync11(plan2.path, plan2.content);
40192
40568
  let ok = true;
40193
40569
  for (const argv2 of plan2.enableCmds) {
40194
40570
  const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio });
@@ -40320,10 +40696,10 @@ init_colors();
40320
40696
 
40321
40697
  // src/banner.ts
40322
40698
  init_colors();
40323
- import { homedir as homedir11 } from "os";
40699
+ import { homedir as homedir13 } from "os";
40324
40700
  import { sep as sep5 } from "path";
40325
40701
  function tildify(p) {
40326
- const home = homedir11();
40702
+ const home = homedir13();
40327
40703
  if (!home) return p;
40328
40704
  if (p === home) return "~";
40329
40705
  if (p.startsWith(home + sep5)) return "~" + p.slice(home.length);
@@ -40573,14 +40949,14 @@ init_claude_setup();
40573
40949
  init_agents();
40574
40950
 
40575
40951
  // src/prefs.ts
40576
- import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
40577
- import { homedir as homedir12 } from "os";
40578
- import { join as join18 } from "path";
40579
- 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");
40580
40956
  function readPrefs() {
40581
- if (!existsSync14(PREFS_PATH)) return {};
40957
+ if (!existsSync15(PREFS_PATH)) return {};
40582
40958
  try {
40583
- const parsed = JSON.parse(readFileSync17(PREFS_PATH, "utf-8"));
40959
+ const parsed = JSON.parse(readFileSync18(PREFS_PATH, "utf-8"));
40584
40960
  return {
40585
40961
  lastAgent: typeof parsed.lastAgent === "string" ? parsed.lastAgent : void 0
40586
40962
  };
@@ -40592,26 +40968,26 @@ function writePrefs(update) {
40592
40968
  try {
40593
40969
  const current = readPrefs();
40594
40970
  const next = { ...current, ...update };
40595
- mkdirSync11(join18(homedir12(), ".gipity"), { recursive: true });
40596
- 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");
40597
40973
  } catch {
40598
40974
  }
40599
40975
  }
40600
40976
 
40601
40977
  // src/commands/build.ts
40602
40978
  init_setup();
40603
- var __clDir = dirname11(fileURLToPath2(import.meta.url));
40979
+ var __clDir = dirname12(fileURLToPath2(import.meta.url));
40604
40980
  function readOwnPkg(fromDir) {
40605
- for (let d = fromDir; ; d = dirname11(d)) {
40606
- const p = join19(d, "package.json");
40607
- if (existsSync15(p)) {
40981
+ for (let d = fromDir; ; d = dirname12(d)) {
40982
+ const p = join21(d, "package.json");
40983
+ if (existsSync16(p)) {
40608
40984
  try {
40609
- const pkg2 = JSON.parse(readFileSync18(p, "utf-8"));
40985
+ const pkg2 = JSON.parse(readFileSync19(p, "utf-8"));
40610
40986
  if (pkg2.name === "gipity") return pkg2;
40611
40987
  } catch {
40612
40988
  }
40613
40989
  }
40614
- if (dirname11(d) === d) return {};
40990
+ if (dirname12(d) === d) return {};
40615
40991
  }
40616
40992
  }
40617
40993
  var __clPkg = readOwnPkg(__clDir);
@@ -40660,7 +41036,7 @@ function localFsFallback(dir) {
40660
41036
  let isDir = false;
40661
41037
  let size = 0;
40662
41038
  try {
40663
- const st2 = statSync8(join19(d, name));
41039
+ const st2 = statSync8(join21(d, name));
40664
41040
  isDir = st2.isDirectory();
40665
41041
  size = st2.isFile() ? st2.size : 0;
40666
41042
  } catch {
@@ -40669,7 +41045,7 @@ function localFsFallback(dir) {
40669
41045
  if (isDir) {
40670
41046
  folderCount++;
40671
41047
  if (depth === 0) topLevelEntries.push(`${name}/`);
40672
- walk(join19(d, name), depth + 1);
41048
+ walk(join21(d, name), depth + 1);
40673
41049
  } else {
40674
41050
  fileCount++;
40675
41051
  totalBytes += size;
@@ -40702,8 +41078,8 @@ function hasStreamJsonFlag(args) {
40702
41078
  }
40703
41079
  function markFolderTrusted(dir) {
40704
41080
  try {
40705
- const file = join19(homedir13(), ".claude.json");
40706
- 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")) : {};
40707
41083
  if (typeof cfg !== "object" || cfg === null) return;
40708
41084
  if (typeof cfg.projects !== "object" || cfg.projects === null) cfg.projects = {};
40709
41085
  const entry = typeof cfg.projects[dir] === "object" && cfg.projects[dir] !== null ? cfg.projects[dir] : {};
@@ -40711,7 +41087,7 @@ function markFolderTrusted(dir) {
40711
41087
  entry.hasTrustDialogAccepted = true;
40712
41088
  cfg.projects[dir] = entry;
40713
41089
  const tmp = `${file}.gipity-tmp`;
40714
- writeFileSync12(tmp, JSON.stringify(cfg, null, 2));
41090
+ writeFileSync13(tmp, JSON.stringify(cfg, null, 2));
40715
41091
  renameSync2(tmp, file);
40716
41092
  } catch {
40717
41093
  }
@@ -40828,9 +41204,9 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40828
41204
  let existing = getConfig();
40829
41205
  let forceAdoptCwd = false;
40830
41206
  if (existing && !opts.newProject && !opts.project && !nonInteractive) {
40831
- const cwdHasConfig = existsSync15(resolve13(process.cwd(), ".gipity.json"));
41207
+ const cwdHasConfig = existsSync16(resolve13(process.cwd(), ".gipity.json"));
40832
41208
  if (!cwdHasConfig && isLikelyEmpty(process.cwd())) {
40833
- const ancestorRoot = dirname11(getConfigPath());
41209
+ const ancestorRoot = dirname12(getConfigPath());
40834
41210
  console.log(` ${bold("You are inside an existing Gipity project.")}
40835
41211
  `);
40836
41212
  console.log(` ${bold("1.")} Continue in ${brand(existing.projectSlug)} ${muted(`(rooted at ${formatCwdLabel(ancestorRoot)})`)}`);
@@ -40877,8 +41253,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40877
41253
  }
40878
41254
  project = found;
40879
41255
  }
40880
- const projectDir2 = opts.here ? process.cwd() : join19(getProjectsRoot(), project.slug);
40881
- mkdirSync12(projectDir2, { recursive: true });
41256
+ const projectDir2 = opts.here ? process.cwd() : join21(getProjectsRoot(), project.slug);
41257
+ mkdirSync13(projectDir2, { recursive: true });
40882
41258
  process.chdir(projectDir2);
40883
41259
  clearConfigCache();
40884
41260
  let agentGuid = "";
@@ -40920,7 +41296,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
40920
41296
  `);
40921
41297
  setupProjectTools();
40922
41298
  let doSync = true;
40923
- const projectRoot = dirname11(getConfigPath());
41299
+ const projectRoot = dirname12(getConfigPath());
40924
41300
  const scan = scanForAdoption(projectRoot);
40925
41301
  if (scan.tier === "refuse" && !nonInteractive) {
40926
41302
  const sizeStr = scan.truncated ? `>${formatBytes(ADOPT_THRESHOLDS.REFUSE_BYTES)}` : formatBytes(scan.bytes);
@@ -41001,8 +41377,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
41001
41377
  } else {
41002
41378
  project = result.project;
41003
41379
  isNewProject = result.kind === "create-new";
41004
- const projectDir2 = join19(getProjectsRoot(), project.slug);
41005
- mkdirSync12(projectDir2, { recursive: true });
41380
+ const projectDir2 = join21(getProjectsRoot(), project.slug);
41381
+ mkdirSync13(projectDir2, { recursive: true });
41006
41382
  process.chdir(projectDir2);
41007
41383
  clearConfigCache();
41008
41384
  try {
@@ -41358,6 +41734,12 @@ Sending to ${adapter.displayName}: ${message}
41358
41734
  }
41359
41735
  console.log("");
41360
41736
  }
41737
+ if (adapter.prepareLaunch) {
41738
+ try {
41739
+ await adapter.prepareLaunch();
41740
+ } catch {
41741
+ }
41742
+ }
41361
41743
  const childEnv2 = { ...process.env };
41362
41744
  if (convGuid) childEnv2.GIPITY_CONVERSATION_GUID = convGuid;
41363
41745
  const agentCmd = resolveCommand(adapter.binary);
@@ -41389,8 +41771,8 @@ ${doneLine}
41389
41771
  });
41390
41772
  }
41391
41773
  function flushHeadlessCapture(adapter, sessionId, convGuid) {
41392
- const runner = join19(__clDir, "..", "hooks", "capture-runner.js");
41393
- if (!existsSync15(runner)) return;
41774
+ const runner = join21(__clDir, "..", "hooks", "capture-runner.js");
41775
+ if (!existsSync16(runner)) return;
41394
41776
  const payload = JSON.stringify({ session_id: sessionId, cwd: process.cwd() });
41395
41777
  const env = { ...process.env, GIPITY_CONVERSATION_GUID: convGuid };
41396
41778
  for (const event of ["session-start", "stop"]) {
@@ -41517,7 +41899,7 @@ async function browseProjects(all, opts = {}) {
41517
41899
  function formatNewProjectLabel(existingSlugs) {
41518
41900
  const slug = suggestProjectName(existingSlugs);
41519
41901
  const root = getProjectsRoot();
41520
- const home = homedir13();
41902
+ const home = homedir15();
41521
41903
  const display2 = root === home || root.startsWith(home + sep6) ? "~" + root.slice(home.length) : root;
41522
41904
  return `${display2}${sep6}${slug}`;
41523
41905
  }
@@ -43507,11 +43889,11 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
43507
43889
  }
43508
43890
  }));
43509
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) => {
43510
- const { existsSync: existsSync25, statSync: statSync12 } = await import("node:fs");
43511
- 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");
43512
43894
  const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
43513
43895
  const jobDir = resolve19(process.cwd(), "jobs", name);
43514
- if (!existsSync25(jobDir) || !statSync12(jobDir).isDirectory()) {
43896
+ if (!existsSync26(jobDir) || !statSync12(jobDir).isDirectory()) {
43515
43897
  console.error(error(`jobs/${name}/ not found in current directory`));
43516
43898
  process.exit(1);
43517
43899
  }
@@ -43532,7 +43914,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
43532
43914
  },
43533
43915
  { file: "main.sh", runtime: "bash", entry: "bash" }
43534
43916
  ];
43535
- const picked = variants.find((v7) => existsSync25(join29(jobDir, v7.file)));
43917
+ const picked = variants.find((v7) => existsSync26(join31(jobDir, v7.file)));
43536
43918
  if (!picked) {
43537
43919
  console.error(error(`No main.py / main.js / main.sh found under jobs/${name}/`));
43538
43920
  process.exit(1);
@@ -43557,7 +43939,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
43557
43939
  "-v",
43558
43940
  `${jobDir}:/work`
43559
43941
  ];
43560
- 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));
43561
43943
  const handlerCmd = `${picked.entry} /work/${picked.file}`;
43562
43944
  let shellCmd;
43563
43945
  if (needsDeps && picked.installCmd) {
@@ -43735,8 +44117,8 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
43735
44117
  init_api();
43736
44118
  init_config();
43737
44119
  init_colors();
43738
- import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync19 } from "fs";
43739
- 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";
43740
44122
 
43741
44123
  // src/provider-docs.ts
43742
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`;
@@ -43797,13 +44179,11 @@ var VIDEO_ASPECT_RATIO_IDS = [
43797
44179
  ];
43798
44180
  var VIDEO_MODELS_TABLE = ` veo-3.1-generate-preview best quality, up to 4K, ~$0.40/sec
43799
44181
  veo-3.1-fast-generate-preview faster, ~$0.10/sec
43800
- veo-3.1-lite-generate-preview budget, ~$0.05/sec
43801
- gemini-omni-flash-preview 3-10s @ 720p, conversational editing, ~$0.10/sec`;
44182
+ veo-3.1-lite-generate-preview budget, ~$0.05/sec`;
43802
44183
  var VIDEO_MODEL_IDS = [
43803
44184
  "veo-3.1-generate-preview",
43804
44185
  "veo-3.1-fast-generate-preview",
43805
- "veo-3.1-lite-generate-preview",
43806
- "gemini-omni-flash-preview"
44186
+ "veo-3.1-lite-generate-preview"
43807
44187
  ];
43808
44188
  var VIDEO_RESOLUTION_IDS = [
43809
44189
  "720p",
@@ -43843,7 +44223,7 @@ async function downloadFile(url, filename, explicit) {
43843
44223
  const outPath = explicit ? filename : correctExtension(filename, buffer);
43844
44224
  if (explicit) noteFormatMismatch(filename, buffer);
43845
44225
  ensureOutputDir(outPath);
43846
- writeFileSync13(outPath, buffer);
44226
+ writeFileSync14(outPath, buffer);
43847
44227
  const savedPath = resolvePath2(outPath);
43848
44228
  await pushGenerated(savedPath);
43849
44229
  return savedPath;
@@ -43887,9 +44267,9 @@ function noteFormatMismatch(filename, buf) {
43887
44267
  ));
43888
44268
  }
43889
44269
  function ensureOutputDir(output) {
43890
- const dir = dirname12(resolvePath2(output));
44270
+ const dir = dirname13(resolvePath2(output));
43891
44271
  try {
43892
- mkdirSync13(dir, { recursive: true });
44272
+ mkdirSync14(dir, { recursive: true });
43893
44273
  } catch (err) {
43894
44274
  throw new Error(`can't create the output directory ${dir} (${err.code || err.message}). Pick a different -o path.`);
43895
44275
  }
@@ -43897,7 +44277,7 @@ function ensureOutputDir(output) {
43897
44277
  async function pushGenerated(savedPath) {
43898
44278
  const configPath = getConfigPath();
43899
44279
  if (!configPath) return;
43900
- const rel2 = relative5(dirname12(configPath), savedPath);
44280
+ const rel2 = relative5(dirname13(configPath), savedPath);
43901
44281
  if (rel2.startsWith("..") || isAbsolute(rel2)) return;
43902
44282
  try {
43903
44283
  await pushFile(savedPath);
@@ -43909,7 +44289,7 @@ function readInputImages(paths) {
43909
44289
  return paths.map((p) => {
43910
44290
  let buf;
43911
44291
  try {
43912
- buf = readFileSync19(p);
44292
+ buf = readFileSync20(p);
43913
44293
  } catch (e) {
43914
44294
  throw new Error(`can't read --input image ${p} (${e.code || e.message}).`);
43915
44295
  }
@@ -44083,22 +44463,33 @@ default; pass --model <id> only if you want a specific one (see the catalog with
44083
44463
 
44084
44464
  Tips:
44085
44465
  - Describe genre, mood, instruments, and tempo (e.g. "upbeat lo-fi hip hop with mellow piano")
44086
- - 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)
44087
44470
  - Longer clips cost more; the max length depends on the model
44088
44471
 
44089
44472
  Examples:
44090
44473
  gipity generate music "chill lo-fi beat for studying"
44091
44474
  gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
44092
44475
  gipity generate music "indie pop chorus" --vocals --duration 20
44093
- `).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("-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) => {
44094
44478
  try {
44095
44479
  const { config } = await resolveProjectContext();
44096
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;
44097
44486
  const doGenerate = () => post(`/projects/${config.projectGuid}/generate/music`, {
44098
44487
  prompt: prompt2,
44099
44488
  duration_seconds: opts.duration,
44100
44489
  model: opts.model,
44101
- instrumental: !opts.vocals
44490
+ // Lyrics imply vocals; otherwise instrumental unless --vocals.
44491
+ instrumental: lyrics ? false : !opts.vocals,
44492
+ lyrics: lyrics || void 0
44102
44493
  });
44103
44494
  const started = Date.now();
44104
44495
  const result = opts.json ? await doGenerate() : await withSpinner("Generating music...", doGenerate, { done: null });
@@ -44163,14 +44554,14 @@ var generateCommand = new Command("generate").description("Generate images, vide
44163
44554
  init_api();
44164
44555
  init_config();
44165
44556
  init_colors();
44166
- import { existsSync as existsSync16, readFileSync as readFileSync20 } from "fs";
44167
- import { join as join20 } from "path";
44557
+ import { existsSync as existsSync17, readFileSync as readFileSync21 } from "fs";
44558
+ import { join as join22 } from "path";
44168
44559
  function readInstalledKitReadme(name) {
44169
44560
  const root = getProjectRoot() ?? process.cwd();
44170
- const kitDir = join20(root, "src", "packages", name);
44171
- if (!existsSync16(join20(kitDir, "package.json"))) return null;
44172
- const readme = join20(kitDir, "README.md");
44173
- 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;
44174
44565
  }
44175
44566
  function slugify2(title) {
44176
44567
  return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -44443,15 +44834,15 @@ var domainCommand = new Command("domain").description("Manage custom domains").a
44443
44834
  }));
44444
44835
 
44445
44836
  // src/commands/realtime.ts
44446
- import { existsSync as existsSync17 } from "fs";
44447
- 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";
44448
44839
  init_api();
44449
44840
  init_config();
44450
44841
  init_colors();
44451
44842
  function hasDeployManifest() {
44452
44843
  const cfgPath = getConfigPath();
44453
44844
  if (!cfgPath) return false;
44454
- return existsSync17(resolve14(dirname13(cfgPath), "gipity.yaml"));
44845
+ return existsSync18(resolve14(dirname14(cfgPath), "gipity.yaml"));
44455
44846
  }
44456
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 () => {
44457
44848
  const config = requireConfig();
@@ -44860,21 +45251,21 @@ var locationCommand = new Command("location").description("Show location").argum
44860
45251
  }));
44861
45252
 
44862
45253
  // src/commands/doctor.ts
44863
- import { existsSync as existsSync19, readFileSync as readFileSync22, statSync as statSync9 } from "fs";
44864
- import { join as join22, resolve as resolve15 } from "path";
44865
- 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";
44866
45257
 
44867
45258
  // src/updater/state.ts
44868
- import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as existsSync18 } from "fs";
44869
- import { join as join21 } from "path";
44870
- import { homedir as homedir14 } from "os";
44871
- var GIPITY_DIR = join21(homedir14(), ".gipity");
44872
- var LOCAL_DIR = join21(GIPITY_DIR, "local");
44873
- var LOCAL_PKG_DIR = join21(LOCAL_DIR, "node_modules", "gipity");
44874
- var LOCAL_ENTRY = join21(LOCAL_PKG_DIR, "dist", "index.js");
44875
- var STATE_FILE = join21(GIPITY_DIR, "update-state.json");
44876
- var SETTINGS_FILE = join21(GIPITY_DIR, "settings.json");
44877
- 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");
44878
45269
  var DEFAULT_STATE = {
44879
45270
  installedVersion: null,
44880
45271
  lastCheckAt: 0,
@@ -44885,24 +45276,24 @@ var DEFAULT_SETTINGS = {
44885
45276
  autoUpdates: true
44886
45277
  };
44887
45278
  function ensureDir() {
44888
- mkdirSync14(GIPITY_DIR, { recursive: true });
45279
+ mkdirSync15(GIPITY_DIR, { recursive: true });
44889
45280
  }
44890
45281
  function readState() {
44891
- if (!existsSync18(STATE_FILE)) return { ...DEFAULT_STATE };
45282
+ if (!existsSync19(STATE_FILE)) return { ...DEFAULT_STATE };
44892
45283
  try {
44893
- return { ...DEFAULT_STATE, ...JSON.parse(readFileSync21(STATE_FILE, "utf-8")) };
45284
+ return { ...DEFAULT_STATE, ...JSON.parse(readFileSync22(STATE_FILE, "utf-8")) };
44894
45285
  } catch {
44895
45286
  return { ...DEFAULT_STATE };
44896
45287
  }
44897
45288
  }
44898
45289
  function writeState(state) {
44899
45290
  ensureDir();
44900
- writeFileSync14(STATE_FILE, JSON.stringify(state, null, 2));
45291
+ writeFileSync15(STATE_FILE, JSON.stringify(state, null, 2));
44901
45292
  }
44902
45293
  function readSettings() {
44903
- if (!existsSync18(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
45294
+ if (!existsSync19(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
44904
45295
  try {
44905
- return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync21(SETTINGS_FILE, "utf-8")) };
45296
+ return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync22(SETTINGS_FILE, "utf-8")) };
44906
45297
  } catch {
44907
45298
  return { ...DEFAULT_SETTINGS };
44908
45299
  }
@@ -44919,7 +45310,7 @@ init_colors();
44919
45310
  init_auth();
44920
45311
  init_claude_setup();
44921
45312
  var NODE_MIN_MAJOR = 18;
44922
- function versionManagerNode(execPath, env = process.env, home = homedir15()) {
45313
+ function versionManagerNode(execPath, env = process.env, home = homedir17()) {
44923
45314
  const norm = (s) => s.replace(/\\/g, "/").replace(/\/+$/, "") + "/";
44924
45315
  const p = norm(execPath);
44925
45316
  const h = norm(home);
@@ -44936,10 +45327,10 @@ function versionManagerNode(execPath, env = process.env, home = homedir15()) {
44936
45327
  return null;
44937
45328
  }
44938
45329
  function localVersion() {
44939
- const pkgPath = join22(LOCAL_PKG_DIR, "package.json");
44940
- if (!existsSync19(pkgPath)) return null;
45330
+ const pkgPath = join24(LOCAL_PKG_DIR, "package.json");
45331
+ if (!existsSync20(pkgPath)) return null;
44941
45332
  try {
44942
- return JSON.parse(readFileSync22(pkgPath, "utf-8")).version ?? null;
45333
+ return JSON.parse(readFileSync23(pkgPath, "utf-8")).version ?? null;
44943
45334
  } catch {
44944
45335
  return null;
44945
45336
  }
@@ -44947,7 +45338,7 @@ function localVersion() {
44947
45338
  function shimVersion() {
44948
45339
  try {
44949
45340
  const url = new URL("../../package.json", import.meta.url);
44950
- return JSON.parse(readFileSync22(url, "utf-8")).version;
45341
+ return JSON.parse(readFileSync23(url, "utf-8")).version;
44951
45342
  } catch {
44952
45343
  return "unknown";
44953
45344
  }
@@ -44962,7 +45353,7 @@ function rel(t) {
44962
45353
  }
44963
45354
  function relayAutostartInstalled() {
44964
45355
  try {
44965
- return existsSync19(planFor({ cliPath: resolveCliPath() }).path);
45356
+ return existsSync20(planFor({ cliPath: resolveCliPath() }).path);
44966
45357
  } catch (err) {
44967
45358
  if (err instanceof UnsupportedPlatformError) return null;
44968
45359
  return null;
@@ -45000,7 +45391,7 @@ function gatherEnv(opts = {}) {
45000
45391
  const cli = {
45001
45392
  shim_version: shimVersion(),
45002
45393
  local_version: localVersion(),
45003
- local_install_ok: existsSync19(LOCAL_ENTRY),
45394
+ local_install_ok: existsSync20(LOCAL_ENTRY),
45004
45395
  auto_updates: !dis.disabled,
45005
45396
  updates_disabled_reason: dis.disabled ? dis.reason ?? null : null,
45006
45397
  last_check_at: updState.lastCheckAt,
@@ -45030,7 +45421,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
45030
45421
  console.log(`${muted("claude code ")} installed ${yn(env.claude.installed)} \xB7 authenticated ${yn(env.claude.authenticated)}`);
45031
45422
  const autostartLabel = env.relay.autostart === null ? muted("n/a") : yn(env.relay.autostart);
45032
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})`) : ""}`);
45033
- if (existsSync19(resolve15(process.cwd(), ".codex", "hooks.json"))) {
45424
+ if (existsSync20(resolve15(process.cwd(), ".codex", "hooks.json"))) {
45034
45425
  console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
45035
45426
  }
45036
45427
  console.log(`${muted("ready ")} ${env.ready ? success("yes") : warning("no - run `gipity build` (or the desktop app) to finish setup")}`);
@@ -45038,7 +45429,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
45038
45429
  const settings = readSettings();
45039
45430
  const dis = updatesDisabled();
45040
45431
  const local = localVersion();
45041
- const localOk = existsSync19(LOCAL_ENTRY);
45432
+ const localOk = existsSync20(LOCAL_ENTRY);
45042
45433
  console.log("");
45043
45434
  console.log(bold("CLI install"));
45044
45435
  console.log(`${muted("shim version ")} ${shimVersion()}`);
@@ -45046,11 +45437,11 @@ var doctorCommand = new Command("doctor").description("Check install + environme
45046
45437
  console.log(`${muted("local install ")} ${LOCAL_PKG_DIR}`);
45047
45438
  console.log("");
45048
45439
  console.log(`${muted("auto-updates ")} ${dis.disabled ? warning(`disabled (${dis.reason})`) : success("enabled")}`);
45049
- 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}`);
45050
45441
  console.log(`${muted("last check ")} ${rel(state.lastCheckAt)}`);
45051
45442
  console.log(`${muted("last error ")} ${state.lastError ? error(state.lastError) : dim("none")}`);
45052
- console.log(`${muted("state file ")} ${existsSync19(STATE_FILE) ? STATE_FILE : dim("(none yet)")}`);
45053
- 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)")}`);
45054
45445
  console.log("");
45055
45446
  console.log(dim("Force an update with: gipity update"));
45056
45447
  });
@@ -45059,10 +45450,10 @@ var doctorCommand = new Command("doctor").description("Check install + environme
45059
45450
  import { appendFileSync } from "fs";
45060
45451
 
45061
45452
  // src/updater/install.ts
45062
- import { existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync5, writeFileSync as writeFileSync15 } from "fs";
45063
- 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";
45064
45455
  init_platform();
45065
- var UPDATE_LOCK = join23(GIPITY_DIR, "update.lock");
45456
+ var UPDATE_LOCK = join25(GIPITY_DIR, "update.lock");
45066
45457
  var LOCK_STALE_MS2 = 10 * 60 * 1e3;
45067
45458
  function npmInstallGipity(version) {
45068
45459
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
@@ -45071,7 +45462,7 @@ function npmInstallGipity(version) {
45071
45462
  encoding: "utf-8"
45072
45463
  });
45073
45464
  return {
45074
- ok: res.status === 0 && existsSync20(LOCAL_ENTRY),
45465
+ ok: res.status === 0 && existsSync21(LOCAL_ENTRY),
45075
45466
  status: res.status,
45076
45467
  stderr: (res.stderr || "").toString(),
45077
45468
  spawnError: res.error
@@ -45082,21 +45473,21 @@ function isWedged(stderr) {
45082
45473
  return WEDGE_CODES.test(stderr);
45083
45474
  }
45084
45475
  function resetLocalTree(dir = LOCAL_DIR) {
45085
- mkdirSync15(dir, { recursive: true });
45086
- rmSync2(join23(dir, "node_modules"), { recursive: true, force: true });
45087
- rmSync2(join23(dir, "package-lock.json"), { force: true });
45088
- 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));
45089
45480
  }
45090
45481
  function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
45091
- mkdirSync15(dirname14(lockPath2), { recursive: true });
45482
+ mkdirSync16(dirname15(lockPath2), { recursive: true });
45092
45483
  try {
45093
- writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
45484
+ writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
45094
45485
  return true;
45095
45486
  } catch {
45096
45487
  try {
45097
45488
  if (Date.now() - statSync10(lockPath2).mtimeMs > LOCK_STALE_MS2) {
45098
- unlinkSync5(lockPath2);
45099
- writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
45489
+ unlinkSync6(lockPath2);
45490
+ writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
45100
45491
  return true;
45101
45492
  }
45102
45493
  } catch {
@@ -45106,7 +45497,7 @@ function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
45106
45497
  }
45107
45498
  function releaseUpdateLock(lockPath2 = UPDATE_LOCK) {
45108
45499
  try {
45109
- unlinkSync5(lockPath2);
45500
+ unlinkSync6(lockPath2);
45110
45501
  } catch {
45111
45502
  }
45112
45503
  }
@@ -45245,17 +45636,17 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
45245
45636
  init_api();
45246
45637
  init_utils();
45247
45638
  init_colors();
45248
- 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";
45249
45640
  import { spawn as spawn2 } from "child_process";
45250
45641
 
45251
45642
  // src/relay/daemon.ts
45252
45643
  init_platform();
45253
45644
  init_config();
45254
- 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";
45255
45646
  import { stat, readFile } from "fs/promises";
45256
45647
  import { createInterface as createInterface2 } from "readline";
45257
- import { homedir as homedir17, hostname as hostname5, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
45258
- 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";
45259
45650
  init_setup();
45260
45651
  init_auth();
45261
45652
  init_api();
@@ -45967,7 +46358,7 @@ import { randomUUID as randomUUID2 } from "crypto";
45967
46358
  // src/relay/agent-token.ts
45968
46359
  init_api();
45969
46360
  init_config();
45970
- import { hostname as hostname4 } from "os";
46361
+ import { hostname as hostname5 } from "os";
45971
46362
  var RELAY_AGENT_TOKEN_EXPIRY_DAYS = 60;
45972
46363
  async function tokenValid(token) {
45973
46364
  try {
@@ -45986,7 +46377,7 @@ async function ensureRelayAgentToken() {
45986
46377
  setAgentToken(null, null);
45987
46378
  }
45988
46379
  try {
45989
- const name = `Relay on ${getDevice()?.name ?? hostname4()}`;
46380
+ const name = `Relay on ${getDevice()?.name ?? hostname5()}`;
45990
46381
  const res = await post(
45991
46382
  "/auth/agent-tokens",
45992
46383
  { name, expiresInDays: RELAY_AGENT_TOKEN_EXPIRY_DAYS }
@@ -46012,9 +46403,9 @@ async function revokeRelayAgentToken() {
46012
46403
  init_platform();
46013
46404
  init_client_context();
46014
46405
  init_agents();
46015
- 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";
46016
46407
  import { statfsSync, readdirSync as readdirSync9 } from "fs";
46017
- import { join as join24 } from "path";
46408
+ import { join as join26 } from "path";
46018
46409
  var PROBE_TIMEOUT_MS = 4e3;
46019
46410
  function parseVersion(out) {
46020
46411
  const m = out.match(/\d+\.\d+(?:\.\d+)?(?:[-.\w]*)?/);
@@ -46081,12 +46472,12 @@ async function detectGpu() {
46081
46472
  function diskUsage() {
46082
46473
  try {
46083
46474
  if (typeof statfsSync !== "function") return void 0;
46084
- const st2 = statfsSync(join24(homedir16(), "GipityProjects"), { bigint: false });
46475
+ const st2 = statfsSync(join26(homedir18(), "GipityProjects"), { bigint: false });
46085
46476
  if (!st2 || !st2.bsize) return void 0;
46086
46477
  return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
46087
46478
  } catch {
46088
46479
  try {
46089
- const st2 = statfsSync(homedir16(), { bigint: false });
46480
+ const st2 = statfsSync(homedir18(), { bigint: false });
46090
46481
  return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
46091
46482
  } catch {
46092
46483
  return void 0;
@@ -46095,7 +46486,7 @@ function diskUsage() {
46095
46486
  }
46096
46487
  function localProjectCount() {
46097
46488
  try {
46098
- 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;
46099
46490
  } catch {
46100
46491
  return void 0;
46101
46492
  }
@@ -46547,7 +46938,7 @@ var SessionPool = class {
46547
46938
  init_config();
46548
46939
  init_api();
46549
46940
  init_agents();
46550
- var RELAY_LOG_PATH = join26(homedir17(), ".gipity", "relay.log");
46941
+ var RELAY_LOG_PATH = join28(homedir19(), ".gipity", "relay.log");
46551
46942
  var HEARTBEAT_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_HEARTBEAT_MS || "60000", 10);
46552
46943
  var DIAGNOSTICS_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_DIAGNOSTICS_MS || String(24 * 60 * 60 * 1e3), 10);
46553
46944
  var LONG_POLL_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_POLL_TIMEOUT_MS || "35000", 10);
@@ -46574,7 +46965,7 @@ function mapPlatform2(p) {
46574
46965
  return "linux";
46575
46966
  }
46576
46967
  async function registerDevice() {
46577
- const name = (hostname5() || "my-pc").trim().slice(0, 100) || "my-pc";
46968
+ const name = (hostname6() || "my-pc").trim().slice(0, 100) || "my-pc";
46578
46969
  const res = await post("/remote-devices", { name, platform: mapPlatform2(osPlatform3()), machine_id: getMachineId() });
46579
46970
  const device = {
46580
46971
  guid: res.data.short_guid,
@@ -46644,17 +47035,17 @@ var permsLocked = false;
46644
47035
  function lockLogPerms(dir, file) {
46645
47036
  if (permsLocked) return;
46646
47037
  try {
46647
- chmodSync3(dir, 448);
47038
+ chmodSync4(dir, 448);
46648
47039
  } catch {
46649
47040
  }
46650
- if (!existsSync22(file)) {
47041
+ if (!existsSync23(file)) {
46651
47042
  try {
46652
47043
  closeSync4(openSync4(file, "a", 384));
46653
47044
  } catch {
46654
47045
  }
46655
47046
  }
46656
47047
  try {
46657
- chmodSync3(file, 384);
47048
+ chmodSync4(file, 384);
46658
47049
  } catch {
46659
47050
  }
46660
47051
  permsLocked = true;
@@ -46664,8 +47055,8 @@ function log2(level, msg, extra) {
46664
47055
  const pretty = `${C7.dim(hhmmss())} ${badge(level)} ${C7.bold(msg)}${formatExtra(extra)}`;
46665
47056
  process.stderr.write(pretty + "\n");
46666
47057
  try {
46667
- const dir = join26(homedir17(), ".gipity");
46668
- mkdirSync17(dir, { recursive: true });
47058
+ const dir = join28(homedir19(), ".gipity");
47059
+ mkdirSync18(dir, { recursive: true });
46669
47060
  lockLogPerms(dir, RELAY_LOG_PATH);
46670
47061
  const json = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level, msg, ...extra ?? {} });
46671
47062
  appendFileSync3(RELAY_LOG_PATH, json + "\n");
@@ -47096,7 +47487,7 @@ function isSafeSessionId(s) {
47096
47487
  function transcriptPathFor(cwd, sessionId) {
47097
47488
  if (!isSafeSessionId(sessionId)) return null;
47098
47489
  const slug = cwd.replace(/[^a-zA-Z0-9]/g, "-");
47099
- return join26(homedir17(), ".claude", "projects", slug, `${sessionId}.jsonl`);
47490
+ return join28(homedir19(), ".claude", "projects", slug, `${sessionId}.jsonl`);
47100
47491
  }
47101
47492
  function formatDuration(ms2) {
47102
47493
  const totalSec = ms2 / 1e3;
@@ -47550,11 +47941,11 @@ async function resolveCwdForProject(d) {
47550
47941
  throw new Error(`Invalid project slug: ${JSON.stringify(d.project_slug)}`);
47551
47942
  }
47552
47943
  const root = getProjectsRoot();
47553
- const path5 = join26(root, d.project_slug);
47554
- const configPath = join26(path5, ".gipity.json");
47555
- if (existsSync22(configPath)) {
47944
+ const path5 = join28(root, d.project_slug);
47945
+ const configPath = join28(path5, ".gipity.json");
47946
+ if (existsSync23(configPath)) {
47556
47947
  try {
47557
- const cfg = JSON.parse(readFileSync24(configPath, "utf-8"));
47948
+ const cfg = JSON.parse(readFileSync25(configPath, "utf-8"));
47558
47949
  if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
47559
47950
  log2("warn", "project dir exists but guid mismatch - using it anyway", {
47560
47951
  path: path5,
@@ -47566,9 +47957,9 @@ async function resolveCwdForProject(d) {
47566
47957
  }
47567
47958
  }
47568
47959
  log2("info", "bootstrapping new project dir", { slug: d.project_slug, path: path5 });
47569
- mkdirSync17(path5, { recursive: true });
47960
+ mkdirSync18(path5, { recursive: true });
47570
47961
  const apiBase2 = getApiBaseOverride() || DEFAULT_API_BASE;
47571
- writeFileSync16(configPath, JSON.stringify({
47962
+ writeFileSync17(configPath, JSON.stringify({
47572
47963
  projectGuid: d.project_guid,
47573
47964
  projectSlug: d.project_slug,
47574
47965
  accountSlug: d.account_slug,
@@ -47689,7 +48080,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
47689
48080
  } catch {
47690
48081
  }
47691
48082
  try {
47692
- unlinkSync7(join26(cwd, ".gipity", "sync.lock"));
48083
+ unlinkSync8(join28(cwd, ".gipity", "sync.lock"));
47693
48084
  } catch {
47694
48085
  }
47695
48086
  finish(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s`)));
@@ -48126,11 +48517,11 @@ relayCommand.command("run").description("Run the background service").option("-v
48126
48517
  });
48127
48518
  relayCommand.command("stop").description("Stop the background service").option("--force", "Force-stop if it doesn't exit cleanly within 5s").action(async (opts) => {
48128
48519
  const pidPath = getDaemonPidPath();
48129
- if (!existsSync23(pidPath)) {
48520
+ if (!existsSync24(pidPath)) {
48130
48521
  console.log(muted("Background service isn't running."));
48131
48522
  return;
48132
48523
  }
48133
- const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
48524
+ const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
48134
48525
  if (!pid || isNaN(pid)) {
48135
48526
  console.error(error("PID file is empty or malformed."));
48136
48527
  process.exit(1);
@@ -48141,7 +48532,7 @@ relayCommand.command("stop").description("Stop the background service").option("
48141
48532
  if (err?.code === "ESRCH") {
48142
48533
  console.log(muted(`PID ${pid} not running - cleaning up stale PID file.`));
48143
48534
  try {
48144
- unlinkSync8(pidPath);
48535
+ unlinkSync9(pidPath);
48145
48536
  } catch {
48146
48537
  }
48147
48538
  return;
@@ -48278,8 +48669,8 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
48278
48669
  } catch {
48279
48670
  }
48280
48671
  const pidPath = getDaemonPidPath();
48281
- if (existsSync23(pidPath)) {
48282
- const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
48672
+ if (existsSync24(pidPath)) {
48673
+ const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
48283
48674
  if (pid && !isNaN(pid)) {
48284
48675
  try {
48285
48676
  process.kill(pid, "SIGTERM");
@@ -48292,13 +48683,13 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
48292
48683
  });
48293
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) => {
48294
48685
  const path5 = RELAY_LOG_PATH;
48295
- if (!existsSync23(path5)) {
48686
+ if (!existsSync24(path5)) {
48296
48687
  console.log(muted("No log file yet. Start the service with `gipity relay run` (or install it)."));
48297
48688
  return;
48298
48689
  }
48299
48690
  const lines = parseInt(opts.lines, 10) || 100;
48300
48691
  try {
48301
- const all = readFileSync25(path5, "utf-8").split("\n");
48692
+ const all = readFileSync26(path5, "utf-8").split("\n");
48302
48693
  const tail2 = all.slice(-lines - 1).join("\n");
48303
48694
  process.stdout.write(tail2);
48304
48695
  } catch (err) {
@@ -48369,20 +48760,20 @@ init_api();
48369
48760
  init_auth();
48370
48761
  init_utils();
48371
48762
  init_colors();
48372
- import { existsSync as existsSync24, rmSync as rmSync4, unlinkSync as unlinkSync9, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "fs";
48373
- import { homedir as homedir18, platform as osPlatform4 } from "os";
48374
- 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";
48375
48766
  init_agents();
48376
48767
  function removeInstallerPathLines() {
48377
48768
  if (osPlatform4() === "win32") return [];
48378
48769
  const marker = "# Added by the Gipity installer";
48379
48770
  const touched = [];
48380
48771
  for (const name of [".bashrc", ".zshrc", ".profile"]) {
48381
- const rc2 = join27(homedir18(), name);
48382
- if (!existsSync24(rc2)) continue;
48772
+ const rc2 = join29(homedir20(), name);
48773
+ if (!existsSync25(rc2)) continue;
48383
48774
  let text;
48384
48775
  try {
48385
- text = readFileSync26(rc2, "utf-8");
48776
+ text = readFileSync27(rc2, "utf-8");
48386
48777
  } catch {
48387
48778
  continue;
48388
48779
  }
@@ -48392,7 +48783,7 @@ function removeInstallerPathLines() {
48392
48783
  );
48393
48784
  if (kept.length === lines.length) continue;
48394
48785
  try {
48395
- writeFileSync17(rc2, kept.join("\n"));
48786
+ writeFileSync18(rc2, kept.join("\n"));
48396
48787
  touched.push(rc2);
48397
48788
  } catch {
48398
48789
  }
@@ -48400,7 +48791,7 @@ function removeInstallerPathLines() {
48400
48791
  return touched;
48401
48792
  }
48402
48793
  function tildify2(p) {
48403
- const home = homedir18();
48794
+ const home = homedir20();
48404
48795
  return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
48405
48796
  }
48406
48797
  function resolveCliPath2() {
@@ -48438,9 +48829,9 @@ function removeServiceUnit() {
48438
48829
  const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio: "ignore" });
48439
48830
  if (r.status !== 0) allOk = false;
48440
48831
  }
48441
- if (existsSync24(plan2.path)) {
48832
+ if (existsSync25(plan2.path)) {
48442
48833
  try {
48443
- unlinkSync9(plan2.path);
48834
+ unlinkSync10(plan2.path);
48444
48835
  } catch {
48445
48836
  }
48446
48837
  }
@@ -48461,9 +48852,9 @@ async function revokeDeviceBestEffort() {
48461
48852
  }
48462
48853
  var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
48463
48854
  const autoYes = opts.yes || getAutoConfirm();
48464
- const gipityDir = join27(homedir18(), ".gipity");
48465
- const launcherBin = join27(gipityDir, "launcher", "bin", "gipity");
48466
- const installedViaLauncher = existsSync24(launcherBin);
48855
+ const gipityDir = join29(homedir20(), ".gipity");
48856
+ const launcherBin = join29(gipityDir, "launcher", "bin", "gipity");
48857
+ const installedViaLauncher = existsSync25(launcherBin);
48467
48858
  console.log(`${bold("Gipity uninstall")} - this will:`);
48468
48859
  console.log(`\u2022 Stop the running relay daemon (if any)`);
48469
48860
  console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
@@ -48504,7 +48895,7 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
48504
48895
  if (!anyAgentIntegration) {
48505
48896
  console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
48506
48897
  }
48507
- if (existsSync24(gipityDir)) {
48898
+ if (existsSync25(gipityDir)) {
48508
48899
  try {
48509
48900
  rmSync4(gipityDir, { recursive: true, force: true });
48510
48901
  console.log(`${success(`Removed ${gipityDir}/`)}`);
@@ -48667,7 +49058,7 @@ gmailCommand.command("reply").description("Reply to a Gmail thread. Get thread-i
48667
49058
  }));
48668
49059
 
48669
49060
  // src/commands/text.ts
48670
- import { readFileSync as readFileSync27 } from "fs";
49061
+ import { readFileSync as readFileSync28 } from "fs";
48671
49062
  init_colors();
48672
49063
 
48673
49064
  // src/helpers/text-analysis.ts
@@ -48822,10 +49213,10 @@ function areAnagrams(a, b7) {
48822
49213
 
48823
49214
  // src/commands/text.ts
48824
49215
  function resolveInput(args, opts) {
48825
- if (opts.file) return readFileSync27(opts.file, "utf-8");
49216
+ if (opts.file) return readFileSync28(opts.file, "utf-8");
48826
49217
  if (args.length) return args.join(" ");
48827
49218
  try {
48828
- return readFileSync27(0, "utf-8");
49219
+ return readFileSync28(0, "utf-8");
48829
49220
  } catch {
48830
49221
  return "";
48831
49222
  }
@@ -49031,9 +49422,9 @@ function collectRealFlags(argv2, program3) {
49031
49422
  }
49032
49423
 
49033
49424
  // src/trace.ts
49034
- import { openSync as openSync5, writeSync, mkdirSync as mkdirSync18 } from "fs";
49035
- import { join as join28 } from "path";
49036
- 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";
49037
49428
  var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
49038
49429
  function installOutputTrace(label2) {
49039
49430
  if (process.env.GIPITY_TRACE_OUTPUT !== "1") return;
@@ -49044,10 +49435,10 @@ function installOutputTrace(label2) {
49044
49435
  existing.emit({ event: "reenter", label: label2 });
49045
49436
  return;
49046
49437
  }
49047
- const dir = join28(process.env.GIPITY_DIR || join28(homedir19(), ".gipity"), "trace");
49048
- mkdirSync18(dir, { recursive: true });
49438
+ const dir = join30(process.env.GIPITY_DIR || join30(homedir21(), ".gipity"), "trace");
49439
+ mkdirSync19(dir, { recursive: true });
49049
49440
  const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
49050
- const fd2 = openSync5(join28(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
49441
+ const fd2 = openSync5(join30(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
49051
49442
  const emit = (rec) => {
49052
49443
  try {
49053
49444
  writeSync(fd2, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
@@ -49082,12 +49473,12 @@ function installOutputTrace(label2) {
49082
49473
 
49083
49474
  // src/index.ts
49084
49475
  installOutputTrace("index");
49085
- var __dirname = dirname15(fileURLToPath3(import.meta.url));
49086
- 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"));
49087
49478
  function versionLabel() {
49088
49479
  const base = `v${pkg.version}`;
49089
49480
  try {
49090
- 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"));
49091
49482
  if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
49092
49483
  } catch {
49093
49484
  }