gipity 1.1.9 → 1.1.11
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/agents/claude-code.js +8 -0
- package/dist/agents/codex.js +6 -0
- package/dist/agents/self-update.js +64 -0
- package/dist/commands/agent.js +28 -3
- package/dist/commands/approval.js +3 -3
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/email.js +2 -2
- package/dist/commands/generate.js +97 -34
- package/dist/commands/key.js +2 -2
- package/dist/commands/logs.js +2 -2
- package/dist/commands/realtime.js +3 -3
- package/dist/commands/records.js +4 -4
- package/dist/commands/relay.js +30 -0
- package/dist/commands/service.js +8 -4
- package/dist/commands/update.js +1 -1
- package/dist/index.js +714 -318
- package/dist/provider-docs.js +65 -1
- package/dist/relay/agent-updates.js +155 -0
- package/dist/relay/daemon.js +50 -1
- package/dist/relay/state.js +30 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6582,11 +6582,50 @@ var require_tar_stream = __commonJS({
|
|
|
6582
6582
|
}
|
|
6583
6583
|
});
|
|
6584
6584
|
|
|
6585
|
-
// src/
|
|
6585
|
+
// src/agents/self-update.ts
|
|
6586
6586
|
import { execSync } from "child_process";
|
|
6587
|
-
import { existsSync as existsSync2 } from "fs";
|
|
6587
|
+
import { existsSync as existsSync2, realpathSync as realpathSync2 } from "fs";
|
|
6588
|
+
import { dirname, join as join3, sep } from "path";
|
|
6589
|
+
function whichFirst(binary) {
|
|
6590
|
+
const cmd = process.platform === "win32" ? `where ${binary}` : `which ${binary}`;
|
|
6591
|
+
try {
|
|
6592
|
+
const out = execSync(cmd, { stdio: ["ignore", "pipe", "ignore"], encoding: "utf-8", windowsHide: true });
|
|
6593
|
+
return out.split("\n").map((l7) => l7.trim()).find(Boolean) || null;
|
|
6594
|
+
} catch {
|
|
6595
|
+
return null;
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
function isNpmManaged(binPath, pkg2) {
|
|
6599
|
+
const marker = join3("node_modules", ...pkg2.split("/")) + sep;
|
|
6600
|
+
try {
|
|
6601
|
+
if (realpathSync2(binPath).includes(marker)) return true;
|
|
6602
|
+
} catch {
|
|
6603
|
+
}
|
|
6604
|
+
try {
|
|
6605
|
+
return existsSync2(join3(dirname(binPath), "node_modules", ...pkg2.split("/")));
|
|
6606
|
+
} catch {
|
|
6607
|
+
return false;
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
function npmLatestArgv(pkg2) {
|
|
6611
|
+
return ["npm", "install", "-g", "--no-audit", "--no-fund", `${pkg2}@latest`];
|
|
6612
|
+
}
|
|
6613
|
+
function planForInstall(binPath, pkg2, selfUpdateArgv) {
|
|
6614
|
+
if (!binPath) return null;
|
|
6615
|
+
if (isNpmManaged(binPath, pkg2)) return { argv: npmLatestArgv(pkg2), label: "npm", pkg: pkg2 };
|
|
6616
|
+
return selfUpdateArgv ? { argv: selfUpdateArgv, label: selfUpdateArgv.join(" ") } : null;
|
|
6617
|
+
}
|
|
6618
|
+
var init_self_update = __esm({
|
|
6619
|
+
"src/agents/self-update.ts"() {
|
|
6620
|
+
"use strict";
|
|
6621
|
+
}
|
|
6622
|
+
});
|
|
6623
|
+
|
|
6624
|
+
// src/claude-setup.ts
|
|
6625
|
+
import { execSync as execSync2 } from "child_process";
|
|
6626
|
+
import { existsSync as existsSync3 } from "fs";
|
|
6588
6627
|
import { homedir as homedir2 } from "os";
|
|
6589
|
-
import { join as
|
|
6628
|
+
import { join as join4 } from "path";
|
|
6590
6629
|
function claudeInstallPlan(platformOverride) {
|
|
6591
6630
|
const plat = platformOverride ?? process.platform;
|
|
6592
6631
|
return {
|
|
@@ -6596,7 +6635,7 @@ function claudeInstallPlan(platformOverride) {
|
|
|
6596
6635
|
}
|
|
6597
6636
|
function isClaudeInstalled(platformOverride) {
|
|
6598
6637
|
try {
|
|
6599
|
-
|
|
6638
|
+
execSync2(claudeInstallPlan(platformOverride).checkCmd, { stdio: "ignore", windowsHide: true });
|
|
6600
6639
|
return true;
|
|
6601
6640
|
} catch {
|
|
6602
6641
|
return false;
|
|
@@ -6604,12 +6643,12 @@ function isClaudeInstalled(platformOverride) {
|
|
|
6604
6643
|
}
|
|
6605
6644
|
function isClaudeAuthenticated() {
|
|
6606
6645
|
if (process.env.CLAUDE_CODE_OAUTH_TOKEN || process.env.ANTHROPIC_API_KEY) return true;
|
|
6607
|
-
return
|
|
6646
|
+
return existsSync3(join4(homedir2(), ".claude", ".credentials.json"));
|
|
6608
6647
|
}
|
|
6609
6648
|
function probeClaudeAuthenticated() {
|
|
6610
6649
|
if (!isClaudeInstalled()) return false;
|
|
6611
6650
|
try {
|
|
6612
|
-
const out =
|
|
6651
|
+
const out = execSync2('claude -p "Reply with the single word: PONG"', {
|
|
6613
6652
|
timeout: 6e4,
|
|
6614
6653
|
stdio: ["ignore", "pipe", "ignore"],
|
|
6615
6654
|
encoding: "utf-8",
|
|
@@ -6624,7 +6663,7 @@ function ensureClaudeInstalled(opts = {}) {
|
|
|
6624
6663
|
if (!opts.force && isClaudeInstalled()) return { installed: true, alreadyPresent: true };
|
|
6625
6664
|
const { installArgv } = claudeInstallPlan();
|
|
6626
6665
|
try {
|
|
6627
|
-
|
|
6666
|
+
execSync2(installArgv.join(" "), { stdio: opts.quiet ? "ignore" : "inherit", windowsHide: true });
|
|
6628
6667
|
} catch {
|
|
6629
6668
|
}
|
|
6630
6669
|
return { installed: isClaudeInstalled(), alreadyPresent: false };
|
|
@@ -6775,11 +6814,11 @@ __export(platform_exports, {
|
|
|
6775
6814
|
spawnSyncCommand: () => spawnSyncCommand,
|
|
6776
6815
|
winBatchInvocation: () => winBatchInvocation
|
|
6777
6816
|
});
|
|
6778
|
-
import { execSync as
|
|
6817
|
+
import { execSync as execSync3, spawn, spawnSync } from "child_process";
|
|
6779
6818
|
function resolveCommand(cmd) {
|
|
6780
6819
|
if (process.platform !== "win32") return cmd;
|
|
6781
6820
|
try {
|
|
6782
|
-
const lines =
|
|
6821
|
+
const lines = execSync3(`where ${cmd}`, { encoding: "utf-8", windowsHide: true }).split(/\r?\n/).map((l7) => l7.trim()).filter(Boolean);
|
|
6783
6822
|
return lines.find((l7) => l7.endsWith(".exe")) || lines.find((l7) => l7.endsWith(".cmd")) || cmd;
|
|
6784
6823
|
} catch {
|
|
6785
6824
|
return `${cmd}.cmd`;
|
|
@@ -7029,9 +7068,9 @@ If any step fails, fix it before claiming done - do not report success on a brok
|
|
|
7029
7068
|
});
|
|
7030
7069
|
|
|
7031
7070
|
// src/setup.ts
|
|
7032
|
-
import { resolve, join as
|
|
7071
|
+
import { resolve, join as join5, dirname as dirname2 } from "path";
|
|
7033
7072
|
import { homedir as homedir3, tmpdir } from "os";
|
|
7034
|
-
import { existsSync as
|
|
7073
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync3, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
|
|
7035
7074
|
function isSyncIgnored(name) {
|
|
7036
7075
|
if (name.startsWith(".")) return true;
|
|
7037
7076
|
if (DEFAULT_SYNC_IGNORE.includes(name)) return true;
|
|
@@ -7068,7 +7107,7 @@ function stripGipityHooks(settings) {
|
|
|
7068
7107
|
return changed;
|
|
7069
7108
|
}
|
|
7070
7109
|
function readSettingsFile(path5) {
|
|
7071
|
-
if (!
|
|
7110
|
+
if (!existsSync4(path5)) return {};
|
|
7072
7111
|
try {
|
|
7073
7112
|
return JSON.parse(readFileSync3(path5, "utf-8"));
|
|
7074
7113
|
} catch {
|
|
@@ -7076,8 +7115,8 @@ function readSettingsFile(path5) {
|
|
|
7076
7115
|
}
|
|
7077
7116
|
}
|
|
7078
7117
|
function ensureGipityPlugin(force = false) {
|
|
7079
|
-
const claudeDir =
|
|
7080
|
-
const settingsPath =
|
|
7118
|
+
const claudeDir = join5(homedir3(), ".claude");
|
|
7119
|
+
const settingsPath = join5(claudeDir, "settings.json");
|
|
7081
7120
|
const settings = readSettingsFile(settingsPath);
|
|
7082
7121
|
let changed = stripGipityHooks(settings);
|
|
7083
7122
|
const marketplaces = settings.extraKnownMarketplaces ?? (settings.extraKnownMarketplaces = {});
|
|
@@ -7109,7 +7148,7 @@ function versionGte(have, want) {
|
|
|
7109
7148
|
}
|
|
7110
7149
|
function userScopeInstallState() {
|
|
7111
7150
|
try {
|
|
7112
|
-
const p =
|
|
7151
|
+
const p = join5(homedir3(), ".claude", "plugins", "installed_plugins.json");
|
|
7113
7152
|
const data = JSON.parse(readFileSync3(p, "utf-8"));
|
|
7114
7153
|
const entries = data?.plugins?.[GIPITY_PLUGIN_ID];
|
|
7115
7154
|
if (!Array.isArray(entries)) return { exists: false, current: false };
|
|
@@ -7125,8 +7164,8 @@ function userScopeInstallState() {
|
|
|
7125
7164
|
}
|
|
7126
7165
|
}
|
|
7127
7166
|
function removeGipityPluginConfig() {
|
|
7128
|
-
const settingsPath =
|
|
7129
|
-
if (!
|
|
7167
|
+
const settingsPath = join5(homedir3(), ".claude", "settings.json");
|
|
7168
|
+
if (!existsSync4(settingsPath)) return false;
|
|
7130
7169
|
let settings;
|
|
7131
7170
|
try {
|
|
7132
7171
|
settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
|
|
@@ -7170,7 +7209,7 @@ function ensureGipityPluginInstalled() {
|
|
|
7170
7209
|
}
|
|
7171
7210
|
function grokInstallState() {
|
|
7172
7211
|
try {
|
|
7173
|
-
const p =
|
|
7212
|
+
const p = join5(homedir3(), ".grok", "installed-plugins", "registry.json");
|
|
7174
7213
|
const data = JSON.parse(readFileSync3(p, "utf-8"));
|
|
7175
7214
|
const versions = [];
|
|
7176
7215
|
for (const repo of Object.values(data?.repos ?? {})) {
|
|
@@ -7225,7 +7264,7 @@ function removeManifestSkills(skillsDir, manifestPath) {
|
|
|
7225
7264
|
const { skills } = skillsManifestState(manifestPath);
|
|
7226
7265
|
for (const name of skills) {
|
|
7227
7266
|
try {
|
|
7228
|
-
rmSync(
|
|
7267
|
+
rmSync(join5(skillsDir, name), { recursive: true, force: true });
|
|
7229
7268
|
} catch {
|
|
7230
7269
|
}
|
|
7231
7270
|
}
|
|
@@ -7239,36 +7278,36 @@ function removeAgySkills() {
|
|
|
7239
7278
|
}
|
|
7240
7279
|
function installSkillsAndHooks(skillsDir, manifestPath, harnessLabel) {
|
|
7241
7280
|
if (!binaryOnPath("git")) return;
|
|
7242
|
-
const tmp = mkdtempSync(
|
|
7281
|
+
const tmp = mkdtempSync(join5(tmpdir(), "gipity-skills-"));
|
|
7243
7282
|
try {
|
|
7244
7283
|
const clone = spawnSyncCommand(
|
|
7245
7284
|
resolveCommand("git"),
|
|
7246
|
-
["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`,
|
|
7285
|
+
["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`, join5(tmp, "repo")],
|
|
7247
7286
|
{ stdio: "ignore", timeout: 12e4 }
|
|
7248
7287
|
);
|
|
7249
7288
|
if (clone.status !== 0) return;
|
|
7250
|
-
const repo =
|
|
7289
|
+
const repo = join5(tmp, "repo");
|
|
7251
7290
|
let version = GIPITY_PLUGIN_VERSION;
|
|
7252
7291
|
try {
|
|
7253
|
-
const manifest = JSON.parse(readFileSync3(
|
|
7292
|
+
const manifest = JSON.parse(readFileSync3(join5(repo, ".claude-plugin", "plugin.json"), "utf-8"));
|
|
7254
7293
|
if (typeof manifest?.version === "string") version = manifest.version;
|
|
7255
7294
|
} catch {
|
|
7256
7295
|
}
|
|
7257
|
-
const skillsSrc =
|
|
7296
|
+
const skillsSrc = join5(repo, "skills");
|
|
7258
7297
|
const names = [];
|
|
7259
7298
|
for (const entry of readdirSync2(skillsSrc, { withFileTypes: true })) {
|
|
7260
7299
|
if (!entry.isDirectory()) continue;
|
|
7261
|
-
if (!
|
|
7300
|
+
if (!existsSync4(join5(skillsSrc, entry.name, "SKILL.md"))) continue;
|
|
7262
7301
|
mkdirSync2(skillsDir, { recursive: true });
|
|
7263
|
-
cpSync(
|
|
7302
|
+
cpSync(join5(skillsSrc, entry.name), join5(skillsDir, entry.name), {
|
|
7264
7303
|
recursive: true,
|
|
7265
7304
|
force: true
|
|
7266
7305
|
});
|
|
7267
7306
|
names.push(entry.name);
|
|
7268
7307
|
}
|
|
7269
7308
|
mkdirSync2(AGENT_HOOKS_DIR, { recursive: true });
|
|
7270
|
-
for (const script of readdirSync2(
|
|
7271
|
-
cpSync(
|
|
7309
|
+
for (const script of readdirSync2(join5(repo, "hooks", "scripts"))) {
|
|
7310
|
+
cpSync(join5(repo, "hooks", "scripts", script), join5(AGENT_HOOKS_DIR, script), { force: true });
|
|
7272
7311
|
}
|
|
7273
7312
|
writeFileSync2(manifestPath, JSON.stringify({ version, skills: names }, null, 2) + "\n");
|
|
7274
7313
|
console.log(`Installed ${names.length} Gipity skills for ${harnessLabel} (${skillsDir}).`);
|
|
@@ -7288,8 +7327,8 @@ function ensureAgySkillsInstalled() {
|
|
|
7288
7327
|
installSkillsAndHooks(AGY_SKILLS_DIR, AGY_SKILLS_MANIFEST, "Antigravity");
|
|
7289
7328
|
}
|
|
7290
7329
|
function applyCodexHooks(existing) {
|
|
7291
|
-
const launcher =
|
|
7292
|
-
const cmd = (script, ...args) => [`sh "${launcher}" "${
|
|
7330
|
+
const launcher = join5(AGENT_HOOKS_DIR, "launch.sh");
|
|
7331
|
+
const cmd = (script, ...args) => [`sh "${launcher}" "${join5(AGENT_HOOKS_DIR, script)}"`, ...args].join(" ");
|
|
7293
7332
|
const wanted = [
|
|
7294
7333
|
{ event: "PostToolUse", matcher: "Edit|Write", command: cmd("sync-push.cjs"), timeout: 30 },
|
|
7295
7334
|
{ event: "UserPromptSubmit", command: cmd("sync-pull.cjs"), timeout: 300 },
|
|
@@ -7327,11 +7366,11 @@ function setupCodexHooks() {
|
|
|
7327
7366
|
if (process.platform === "win32") return;
|
|
7328
7367
|
const cwd = resolve(process.cwd());
|
|
7329
7368
|
if (cwd === resolve(homedir3())) return;
|
|
7330
|
-
const path5 =
|
|
7331
|
-
const existing =
|
|
7369
|
+
const path5 = join5(cwd, ".codex", "hooks.json");
|
|
7370
|
+
const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
|
|
7332
7371
|
const next = applyCodexHooks(existing);
|
|
7333
7372
|
if (next === null) return;
|
|
7334
|
-
mkdirSync2(
|
|
7373
|
+
mkdirSync2(dirname2(path5), { recursive: true });
|
|
7335
7374
|
writeFileSync2(path5, next);
|
|
7336
7375
|
if (existing === null) {
|
|
7337
7376
|
console.log("Wrote Codex sync + session-capture hooks (.codex/hooks.json) - approve them once with /hooks inside Codex.");
|
|
@@ -7345,8 +7384,8 @@ function setupCodexIntegration() {
|
|
|
7345
7384
|
setupCodexHooks();
|
|
7346
7385
|
}
|
|
7347
7386
|
function applyAgyHooks(existing) {
|
|
7348
|
-
const wrapper =
|
|
7349
|
-
const launcher =
|
|
7387
|
+
const wrapper = join5(AGENT_HOOKS_DIR, "agy-hooks.cjs");
|
|
7388
|
+
const launcher = join5(AGENT_HOOKS_DIR, "launch.sh");
|
|
7350
7389
|
const wrapCmd = (event) => `sh "${launcher}" "${wrapper}" ${event}`;
|
|
7351
7390
|
const block = {
|
|
7352
7391
|
PostToolUse: [
|
|
@@ -7378,12 +7417,12 @@ function setupAgyHooks() {
|
|
|
7378
7417
|
const cwd = resolve(process.cwd());
|
|
7379
7418
|
if (cwd === resolve(homedir3())) return;
|
|
7380
7419
|
mkdirSync2(AGENT_HOOKS_DIR, { recursive: true });
|
|
7381
|
-
writeFileSync2(
|
|
7382
|
-
const path5 =
|
|
7383
|
-
const existing =
|
|
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;
|
|
7384
7423
|
const next = applyAgyHooks(existing);
|
|
7385
7424
|
if (next === null) return;
|
|
7386
|
-
mkdirSync2(
|
|
7425
|
+
mkdirSync2(dirname2(path5), { recursive: true });
|
|
7387
7426
|
writeFileSync2(path5, next);
|
|
7388
7427
|
console.log(existing === null ? "Wrote Antigravity sync + session-capture hooks (.agents/hooks.json)." : "Updated Antigravity hooks (.agents/hooks.json).");
|
|
7389
7428
|
}
|
|
@@ -7396,9 +7435,9 @@ function setupClaudeHooks() {
|
|
|
7396
7435
|
ensureGipityPlugin();
|
|
7397
7436
|
const cwd = resolve(process.cwd());
|
|
7398
7437
|
if (cwd === resolve(homedir3())) return;
|
|
7399
|
-
const claudeDir =
|
|
7438
|
+
const claudeDir = join5(cwd, ".claude");
|
|
7400
7439
|
mkdirSync2(claudeDir, { recursive: true });
|
|
7401
|
-
const settingsPath =
|
|
7440
|
+
const settingsPath = join5(claudeDir, "settings.json");
|
|
7402
7441
|
const settings = readSettingsFile(settingsPath);
|
|
7403
7442
|
stripGipityHooks(settings);
|
|
7404
7443
|
const perms = settings.permissions || {};
|
|
@@ -7442,8 +7481,8 @@ function applySkillsBlock(existing, apiBase2 = DEFAULT_API_BASE) {
|
|
|
7442
7481
|
}
|
|
7443
7482
|
function writeSkillsFile(relPath, wrap) {
|
|
7444
7483
|
const path5 = resolve(process.cwd(), relPath);
|
|
7445
|
-
mkdirSync2(
|
|
7446
|
-
const existing =
|
|
7484
|
+
mkdirSync2(dirname2(path5), { recursive: true });
|
|
7485
|
+
const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
|
|
7447
7486
|
const baseNext = applySkillsBlock(existing, resolveApiBase());
|
|
7448
7487
|
const next = wrap && existing === null ? wrap(baseNext) : baseNext;
|
|
7449
7488
|
if (next !== existing) writeFileSync2(path5, next);
|
|
@@ -7486,7 +7525,7 @@ function applyAiderConf(existing) {
|
|
|
7486
7525
|
function setupAiderMd() {
|
|
7487
7526
|
writeSkillsFile(PRIMER_FILES.aider);
|
|
7488
7527
|
const path5 = resolve(process.cwd(), AIDER_CONF_FILE);
|
|
7489
|
-
const existing =
|
|
7528
|
+
const existing = existsSync4(path5) ? readFileSync3(path5, "utf-8") : null;
|
|
7490
7529
|
const next = applyAiderConf(existing);
|
|
7491
7530
|
if (next !== null) writeFileSync2(path5, next);
|
|
7492
7531
|
}
|
|
@@ -7517,7 +7556,7 @@ function setupProjectTools(tools = DEFAULT_TOOLS) {
|
|
|
7517
7556
|
function setupGitignore() {
|
|
7518
7557
|
const gitignorePath = resolve(process.cwd(), ".gitignore");
|
|
7519
7558
|
const entries = [".gipity/", ".gipity.json", ...SCRATCH_IGNORE];
|
|
7520
|
-
if (
|
|
7559
|
+
if (existsSync4(gitignorePath)) {
|
|
7521
7560
|
let content = readFileSync3(gitignorePath, "utf-8");
|
|
7522
7561
|
const lines = content.split(/\r?\n/);
|
|
7523
7562
|
const toAdd = entries.filter((e) => !lines.includes(e));
|
|
@@ -7621,11 +7660,11 @@ var init_setup = __esm({
|
|
|
7621
7660
|
GIPITY_MARKETPLACE_REPO = "GipityAI/skills";
|
|
7622
7661
|
LEGACY_MARKETPLACE_REPO = "GipityAI/claude-plugin";
|
|
7623
7662
|
GIPITY_PLUGIN_VERSION = "0.7.0";
|
|
7624
|
-
AGENTS_SKILLS_DIR =
|
|
7625
|
-
AGENT_HOOKS_DIR =
|
|
7626
|
-
AGENT_SKILLS_MANIFEST =
|
|
7627
|
-
AGY_SKILLS_DIR =
|
|
7628
|
-
AGY_SKILLS_MANIFEST =
|
|
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");
|
|
7629
7668
|
AGY_HOOKS_SCRIPT = `#!/usr/bin/env node
|
|
7630
7669
|
'use strict';
|
|
7631
7670
|
const { spawnSync } = require('child_process');
|
|
@@ -7701,6 +7740,7 @@ var claudeCodeAdapter;
|
|
|
7701
7740
|
var init_claude_code2 = __esm({
|
|
7702
7741
|
"src/agents/claude-code.ts"() {
|
|
7703
7742
|
"use strict";
|
|
7743
|
+
init_self_update();
|
|
7704
7744
|
init_claude_setup();
|
|
7705
7745
|
init_claude_code();
|
|
7706
7746
|
init_setup();
|
|
@@ -7739,6 +7779,9 @@ var init_claude_code2 = __esm({
|
|
|
7739
7779
|
return ensureClaudeInstalled().installed;
|
|
7740
7780
|
},
|
|
7741
7781
|
installHint: `npm install -g ${CLAUDE_PACKAGE}`,
|
|
7782
|
+
updatePlan() {
|
|
7783
|
+
return planForInstall(whichFirst("claude"), CLAUDE_PACKAGE, ["claude", "update"]);
|
|
7784
|
+
},
|
|
7742
7785
|
detectEnv() {
|
|
7743
7786
|
if (process.env.CLAUDECODE === "1" || process.env.CLAUDE_CODE_ENTRYPOINT) {
|
|
7744
7787
|
const version = process.env.CLAUDE_CODE_EXECPATH?.match(/versions\/([^/\\]+)/)?.[1];
|
|
@@ -7921,6 +7964,7 @@ var init_codex2 = __esm({
|
|
|
7921
7964
|
"src/agents/codex.ts"() {
|
|
7922
7965
|
"use strict";
|
|
7923
7966
|
init_types();
|
|
7967
|
+
init_self_update();
|
|
7924
7968
|
init_codex();
|
|
7925
7969
|
init_setup();
|
|
7926
7970
|
codexAdapter = {
|
|
@@ -7967,6 +8011,9 @@ var init_codex2 = __esm({
|
|
|
7967
8011
|
daemonStreamCapture: false,
|
|
7968
8012
|
oneTimeSetupNote: "Codex runs project hooks only after a one-time approval: run /hooks inside Codex and approve the Gipity entries, or session recording stays off.",
|
|
7969
8013
|
installHint: "npm install -g @openai/codex",
|
|
8014
|
+
updatePlan() {
|
|
8015
|
+
return planForInstall(whichFirst("codex"), "@openai/codex", null);
|
|
8016
|
+
},
|
|
7970
8017
|
detectEnv() {
|
|
7971
8018
|
return hasEnvPrefix("CODEX_") ? { harness: "codex" } : null;
|
|
7972
8019
|
},
|
|
@@ -8114,7 +8161,7 @@ var init_grok = __esm({
|
|
|
8114
8161
|
|
|
8115
8162
|
// src/agents/grok.ts
|
|
8116
8163
|
import { homedir as homedir4 } from "os";
|
|
8117
|
-
import { join as
|
|
8164
|
+
import { join as join6 } from "path";
|
|
8118
8165
|
var grokAdapter;
|
|
8119
8166
|
var init_grok2 = __esm({
|
|
8120
8167
|
"src/agents/grok.ts"() {
|
|
@@ -8172,7 +8219,7 @@ var init_grok2 = __esm({
|
|
|
8172
8219
|
resolveTranscriptPath: (hook) => {
|
|
8173
8220
|
if (!hook.session_id) return null;
|
|
8174
8221
|
const cwd = hook.cwd ?? process.cwd();
|
|
8175
|
-
return
|
|
8222
|
+
return join6(homedir4(), ".grok", "sessions", encodeURIComponent(cwd), hook.session_id, "chat_history.jsonl");
|
|
8176
8223
|
}
|
|
8177
8224
|
},
|
|
8178
8225
|
setup: {
|
|
@@ -8408,11 +8455,11 @@ var init_agents = __esm({
|
|
|
8408
8455
|
|
|
8409
8456
|
// src/client-context.ts
|
|
8410
8457
|
import { readFileSync as readFileSync4 } from "fs";
|
|
8411
|
-
import { resolve as resolve2, dirname as
|
|
8458
|
+
import { resolve as resolve2, dirname as dirname3 } from "path";
|
|
8412
8459
|
import { fileURLToPath } from "url";
|
|
8413
8460
|
function cliVersion() {
|
|
8414
8461
|
try {
|
|
8415
|
-
const dir =
|
|
8462
|
+
const dir = dirname3(fileURLToPath(import.meta.url));
|
|
8416
8463
|
const pkg2 = JSON.parse(readFileSync4(resolve2(dir, "../package.json"), "utf-8"));
|
|
8417
8464
|
return typeof pkg2.version === "string" ? pkg2.version : "unknown";
|
|
8418
8465
|
} catch {
|
|
@@ -8816,8 +8863,8 @@ __export(config_exports, {
|
|
|
8816
8863
|
setApiBaseOverride: () => setApiBaseOverride,
|
|
8817
8864
|
shouldIgnore: () => shouldIgnore
|
|
8818
8865
|
});
|
|
8819
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as
|
|
8820
|
-
import { dirname as
|
|
8866
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as existsSync5 } from "fs";
|
|
8867
|
+
import { dirname as dirname4, resolve as resolve3 } from "path";
|
|
8821
8868
|
function setApiBaseOverride(url) {
|
|
8822
8869
|
apiBaseOverride = url;
|
|
8823
8870
|
}
|
|
@@ -8854,7 +8901,7 @@ function findConfigPath() {
|
|
|
8854
8901
|
let dir = process.cwd();
|
|
8855
8902
|
while (true) {
|
|
8856
8903
|
const candidate = resolve3(dir, CONFIG_FILE);
|
|
8857
|
-
if (
|
|
8904
|
+
if (existsSync5(candidate)) return candidate;
|
|
8858
8905
|
const parent = resolve3(dir, "..");
|
|
8859
8906
|
if (parent === dir) return null;
|
|
8860
8907
|
dir = parent;
|
|
@@ -8867,7 +8914,7 @@ function getConfigPath() {
|
|
|
8867
8914
|
}
|
|
8868
8915
|
function getProjectRoot() {
|
|
8869
8916
|
const path5 = getConfigPath();
|
|
8870
|
-
return path5 ?
|
|
8917
|
+
return path5 ? dirname4(path5) : null;
|
|
8871
8918
|
}
|
|
8872
8919
|
function getConfig() {
|
|
8873
8920
|
if (cached3) return cached3;
|
|
@@ -33705,7 +33752,7 @@ init_config();
|
|
|
33705
33752
|
init_utils();
|
|
33706
33753
|
import { readFileSync as readFileSync28 } from "fs";
|
|
33707
33754
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33708
|
-
import { dirname as
|
|
33755
|
+
import { dirname as dirname15, resolve as resolve18 } from "path";
|
|
33709
33756
|
|
|
33710
33757
|
// src/helpers/output.ts
|
|
33711
33758
|
var frameOpen = false;
|
|
@@ -33789,13 +33836,13 @@ init_colors();
|
|
|
33789
33836
|
|
|
33790
33837
|
// src/bug-queue.ts
|
|
33791
33838
|
init_api();
|
|
33792
|
-
import { existsSync as
|
|
33793
|
-
import { join as
|
|
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";
|
|
33794
33841
|
import { homedir as homedir5 } from "os";
|
|
33795
|
-
var QUEUE_DIR =
|
|
33842
|
+
var QUEUE_DIR = join7(process.env.GIPITY_DIR || join7(homedir5(), ".gipity"), "bug-queue");
|
|
33796
33843
|
function queueBugReport(report) {
|
|
33797
33844
|
mkdirSync3(QUEUE_DIR, { recursive: true, mode: 448 });
|
|
33798
|
-
const file =
|
|
33845
|
+
const file = join7(QUEUE_DIR, `${Date.now()}-${Math.random().toString(36).slice(2, 8)}.json`);
|
|
33799
33846
|
writeFileSync4(file, JSON.stringify(report, null, 2), { mode: 384 });
|
|
33800
33847
|
}
|
|
33801
33848
|
function isRetryableFailure(err) {
|
|
@@ -33805,11 +33852,11 @@ function isRetryableFailure(err) {
|
|
|
33805
33852
|
return typeof err?.statusCode !== "number";
|
|
33806
33853
|
}
|
|
33807
33854
|
async function flushBugQueue() {
|
|
33808
|
-
if (!
|
|
33855
|
+
if (!existsSync6(QUEUE_DIR)) return 0;
|
|
33809
33856
|
let delivered = 0;
|
|
33810
33857
|
for (const file of readdirSync3(QUEUE_DIR)) {
|
|
33811
33858
|
if (!file.endsWith(".json")) continue;
|
|
33812
|
-
const path5 =
|
|
33859
|
+
const path5 = join7(QUEUE_DIR, file);
|
|
33813
33860
|
let report;
|
|
33814
33861
|
try {
|
|
33815
33862
|
report = JSON.parse(readFileSync6(path5, "utf-8"));
|
|
@@ -33996,8 +34043,8 @@ function run(label2, action) {
|
|
|
33996
34043
|
init_api();
|
|
33997
34044
|
init_config();
|
|
33998
34045
|
init_utils();
|
|
33999
|
-
import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as
|
|
34000
|
-
import { join as
|
|
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";
|
|
34001
34048
|
import { hostname } from "os";
|
|
34002
34049
|
import { createHash as createHash2 } from "crypto";
|
|
34003
34050
|
|
|
@@ -34248,15 +34295,15 @@ var BULK_DELETE_FRACTION = 0.25;
|
|
|
34248
34295
|
var DOWNLOAD_IDLE_MS = 3e4;
|
|
34249
34296
|
function syncStatePath() {
|
|
34250
34297
|
const configPath = getConfigPath();
|
|
34251
|
-
return
|
|
34298
|
+
return join8(dirname5(configPath), ".gipity", "sync-state.json");
|
|
34252
34299
|
}
|
|
34253
34300
|
function lockPath() {
|
|
34254
34301
|
const configPath = getConfigPath();
|
|
34255
|
-
return
|
|
34302
|
+
return join8(dirname5(configPath), ".gipity", "sync.lock");
|
|
34256
34303
|
}
|
|
34257
34304
|
function projectDir() {
|
|
34258
34305
|
const configPath = getConfigPath();
|
|
34259
|
-
return
|
|
34306
|
+
return dirname5(configPath);
|
|
34260
34307
|
}
|
|
34261
34308
|
var LOCK_WAIT_MS2 = 3e4;
|
|
34262
34309
|
var LOCK_POLL_MS2 = 500;
|
|
@@ -34282,7 +34329,7 @@ function isLockReclaimable(path5, now = Date.now()) {
|
|
|
34282
34329
|
}
|
|
34283
34330
|
async function acquireLock(progress) {
|
|
34284
34331
|
const path5 = lockPath();
|
|
34285
|
-
mkdirSync4(
|
|
34332
|
+
mkdirSync4(dirname5(path5), { recursive: true });
|
|
34286
34333
|
const start = Date.now();
|
|
34287
34334
|
let waitSpinner = null;
|
|
34288
34335
|
const settleWait = (ok) => {
|
|
@@ -34334,7 +34381,7 @@ async function acquireLock(progress) {
|
|
|
34334
34381
|
}
|
|
34335
34382
|
function readBaseline(projectGuid2) {
|
|
34336
34383
|
const path5 = syncStatePath();
|
|
34337
|
-
if (!
|
|
34384
|
+
if (!existsSync7(path5)) return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
|
|
34338
34385
|
try {
|
|
34339
34386
|
const parsed = JSON.parse(readFileSync7(path5, "utf-8"));
|
|
34340
34387
|
if (parsed.projectGuid !== projectGuid2) {
|
|
@@ -34352,7 +34399,7 @@ function readBaseline(projectGuid2) {
|
|
|
34352
34399
|
}
|
|
34353
34400
|
function writeBaseline(b7) {
|
|
34354
34401
|
const path5 = syncStatePath();
|
|
34355
|
-
mkdirSync4(
|
|
34402
|
+
mkdirSync4(dirname5(path5), { recursive: true });
|
|
34356
34403
|
writeFileSync5(path5, JSON.stringify(b7, null, 2));
|
|
34357
34404
|
}
|
|
34358
34405
|
function walkLocal(root, ignorePatterns, baseline) {
|
|
@@ -34365,11 +34412,11 @@ function walkLocal(root, ignorePatterns, baseline) {
|
|
|
34365
34412
|
return;
|
|
34366
34413
|
}
|
|
34367
34414
|
for (const entry of entries) {
|
|
34368
|
-
const full =
|
|
34415
|
+
const full = join8(dir, entry.name);
|
|
34369
34416
|
const rel2 = relative(root, full).replace(/\\/g, "/");
|
|
34370
34417
|
if (shouldIgnore(rel2, ignorePatterns)) continue;
|
|
34371
34418
|
if (entry.isDirectory()) {
|
|
34372
|
-
if (
|
|
34419
|
+
if (existsSync7(join8(full, CONFIG_FILE2))) continue;
|
|
34373
34420
|
walk(full);
|
|
34374
34421
|
} else if (entry.isFile()) {
|
|
34375
34422
|
try {
|
|
@@ -34392,7 +34439,7 @@ async function ensureLocalHashes(root, local, paths) {
|
|
|
34392
34439
|
const info2 = local.get(path5);
|
|
34393
34440
|
if (!info2 || info2.sha256) continue;
|
|
34394
34441
|
try {
|
|
34395
|
-
const { sha256 } = await hashFile(
|
|
34442
|
+
const { sha256 } = await hashFile(join8(root, path5));
|
|
34396
34443
|
info2.sha256 = sha256;
|
|
34397
34444
|
} catch {
|
|
34398
34445
|
}
|
|
@@ -34404,15 +34451,15 @@ function normalizeTreePath(p) {
|
|
|
34404
34451
|
function resolveInRoot(root, relPath) {
|
|
34405
34452
|
const rootResolved = resolve4(root);
|
|
34406
34453
|
const full = resolve4(rootResolved, relPath);
|
|
34407
|
-
if (full !== rootResolved && !full.startsWith(rootResolved +
|
|
34454
|
+
if (full !== rootResolved && !full.startsWith(rootResolved + sep2)) {
|
|
34408
34455
|
throw new Error(`Refusing path outside project root: ${relPath}`);
|
|
34409
34456
|
}
|
|
34410
34457
|
try {
|
|
34411
|
-
const rootReal =
|
|
34458
|
+
const rootReal = realpathSync3(rootResolved);
|
|
34412
34459
|
let ancestor = full;
|
|
34413
|
-
while (!
|
|
34414
|
-
const ancestorReal =
|
|
34415
|
-
if (ancestorReal !== rootReal && !ancestorReal.startsWith(rootReal +
|
|
34460
|
+
while (!existsSync7(ancestor) && dirname5(ancestor) !== ancestor) ancestor = dirname5(ancestor);
|
|
34461
|
+
const ancestorReal = realpathSync3(ancestor);
|
|
34462
|
+
if (ancestorReal !== rootReal && !ancestorReal.startsWith(rootReal + sep2)) {
|
|
34416
34463
|
throw new Error(`Refusing path outside project root (symlink escape): ${relPath}`);
|
|
34417
34464
|
}
|
|
34418
34465
|
} catch (e) {
|
|
@@ -34699,8 +34746,8 @@ Plan deletes ${totalDeletes} files (${Math.round(fraction * 100)}% of the tree).
|
|
|
34699
34746
|
}
|
|
34700
34747
|
var GIPITY_IGNORE_FILE = ".gipityignore";
|
|
34701
34748
|
function readGipityIgnore(root) {
|
|
34702
|
-
const path5 =
|
|
34703
|
-
if (!
|
|
34749
|
+
const path5 = join8(root, GIPITY_IGNORE_FILE);
|
|
34750
|
+
if (!existsSync7(path5)) return [];
|
|
34704
34751
|
return readFileSync7(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
|
|
34705
34752
|
}
|
|
34706
34753
|
function effectiveIgnore(root, configIgnore) {
|
|
@@ -34887,7 +34934,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34887
34934
|
return;
|
|
34888
34935
|
}
|
|
34889
34936
|
if (currentBytes) {
|
|
34890
|
-
mkdirSync4(
|
|
34937
|
+
mkdirSync4(dirname5(full), { recursive: true });
|
|
34891
34938
|
writeFileSync5(full, currentBytes);
|
|
34892
34939
|
const stat2 = statSync2(full);
|
|
34893
34940
|
baseline.files[a.path] = {
|
|
@@ -34931,7 +34978,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34931
34978
|
errors.push(e.message);
|
|
34932
34979
|
continue;
|
|
34933
34980
|
}
|
|
34934
|
-
if (
|
|
34981
|
+
if (existsSync7(full)) {
|
|
34935
34982
|
const scanSha = local.get(a.path)?.sha256 ?? baseline.files[a.path]?.sha256;
|
|
34936
34983
|
const remoteSha = remote.get(a.path)?.sha256 ?? void 0;
|
|
34937
34984
|
let currentSha;
|
|
@@ -34944,7 +34991,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34944
34991
|
continue;
|
|
34945
34992
|
}
|
|
34946
34993
|
}
|
|
34947
|
-
mkdirSync4(
|
|
34994
|
+
mkdirSync4(dirname5(full), { recursive: true });
|
|
34948
34995
|
writeFileSync5(full, buf);
|
|
34949
34996
|
const stat2 = statSync2(full);
|
|
34950
34997
|
local.set(a.path, { size: stat2.size, mtime: stat2.mtime.toISOString(), sha256: void 0 });
|
|
@@ -34967,7 +35014,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34967
35014
|
continue;
|
|
34968
35015
|
}
|
|
34969
35016
|
try {
|
|
34970
|
-
mkdirSync4(
|
|
35017
|
+
mkdirSync4(dirname5(renamed), { recursive: true });
|
|
34971
35018
|
renameSync(full, renamed);
|
|
34972
35019
|
} catch (err) {
|
|
34973
35020
|
errors.push(`Could not rename ${a.path} \u2192 ${a.renamedLocalTo}: ${err.message}`);
|
|
@@ -34975,7 +35022,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34975
35022
|
}
|
|
34976
35023
|
const buf = downloadedBytes.get(a.path);
|
|
34977
35024
|
if (buf) {
|
|
34978
|
-
mkdirSync4(
|
|
35025
|
+
mkdirSync4(dirname5(full), { recursive: true });
|
|
34979
35026
|
writeFileSync5(full, buf);
|
|
34980
35027
|
const stat2 = statSync2(full);
|
|
34981
35028
|
baseline.files[a.path] = {
|
|
@@ -35158,12 +35205,12 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35158
35205
|
}
|
|
35159
35206
|
try {
|
|
35160
35207
|
unlinkSync3(full);
|
|
35161
|
-
dirsTouchedByDelete.add(
|
|
35208
|
+
dirsTouchedByDelete.add(dirname5(full));
|
|
35162
35209
|
delete baseline.files[a.path];
|
|
35163
35210
|
applied++;
|
|
35164
35211
|
} catch (err) {
|
|
35165
35212
|
if (err.code === "ENOENT") {
|
|
35166
|
-
dirsTouchedByDelete.add(
|
|
35213
|
+
dirsTouchedByDelete.add(dirname5(full));
|
|
35167
35214
|
delete baseline.files[a.path];
|
|
35168
35215
|
applied++;
|
|
35169
35216
|
} else {
|
|
@@ -35182,7 +35229,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35182
35229
|
const buf = await fetchOne(config.projectGuid, a.path);
|
|
35183
35230
|
if (!buf) throw new Error("remote bytes unavailable");
|
|
35184
35231
|
const full = resolveInRoot(root, a.path);
|
|
35185
|
-
mkdirSync4(
|
|
35232
|
+
mkdirSync4(dirname5(full), { recursive: true });
|
|
35186
35233
|
writeFileSync5(full, buf);
|
|
35187
35234
|
const stat2 = statSync2(full);
|
|
35188
35235
|
const { sha256 } = await hashFile(full);
|
|
@@ -35242,13 +35289,13 @@ function cleanupEmptyDirs(root, emptiedDirs) {
|
|
|
35242
35289
|
const rootResolved = resolve4(root);
|
|
35243
35290
|
for (const start of emptiedDirs) {
|
|
35244
35291
|
let dir = resolve4(start);
|
|
35245
|
-
while (dir !== rootResolved && dir.startsWith(rootResolved +
|
|
35292
|
+
while (dir !== rootResolved && dir.startsWith(rootResolved + sep2) && isEmpty(dir)) {
|
|
35246
35293
|
try {
|
|
35247
35294
|
rmdirSync(dir);
|
|
35248
35295
|
} catch {
|
|
35249
35296
|
break;
|
|
35250
35297
|
}
|
|
35251
|
-
dir =
|
|
35298
|
+
dir = dirname5(dir);
|
|
35252
35299
|
}
|
|
35253
35300
|
}
|
|
35254
35301
|
}
|
|
@@ -35617,7 +35664,7 @@ async function projectGuid(opts) {
|
|
|
35617
35664
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
35618
35665
|
return config.projectGuid;
|
|
35619
35666
|
}
|
|
35620
|
-
keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").
|
|
35667
|
+
keyCommand.command("create <name>").description("Mint a project API key (shown once). Give it a name you will recognize later").addOption(new Option("--role <role>", "Access role for the key").choices(["viewer", "editor", "owner"]).default("viewer")).option("--expires-days <n>", "Days until the key expires (default: never)").option(...projectOpt).option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
|
|
35621
35668
|
const body = { name, role: opts.role };
|
|
35622
35669
|
if (opts.expiresDays !== void 0) {
|
|
35623
35670
|
const days = parseInt(opts.expiresDays, 10);
|
|
@@ -35670,14 +35717,14 @@ init_setup();
|
|
|
35670
35717
|
init_agents();
|
|
35671
35718
|
init_colors();
|
|
35672
35719
|
init_utils();
|
|
35673
|
-
import { basename as basename2, resolve as resolve7, dirname as
|
|
35674
|
-
import { existsSync as
|
|
35720
|
+
import { basename as basename2, resolve as resolve7, dirname as dirname6 } from "path";
|
|
35721
|
+
import { existsSync as existsSync10, readFileSync as readFileSync11 } from "fs";
|
|
35675
35722
|
|
|
35676
35723
|
// src/adopt-cwd.ts
|
|
35677
35724
|
init_api();
|
|
35678
35725
|
init_setup();
|
|
35679
35726
|
import { readdirSync as readdirSync6, statSync as statSync4 } from "fs";
|
|
35680
|
-
import { join as
|
|
35727
|
+
import { join as join12, resolve as resolve6, sep as sep3, parse as parsePath } from "path";
|
|
35681
35728
|
import { homedir as homedir8 } from "os";
|
|
35682
35729
|
|
|
35683
35730
|
// src/project-setup.ts
|
|
@@ -35687,7 +35734,7 @@ init_setup();
|
|
|
35687
35734
|
// src/template-vars.ts
|
|
35688
35735
|
init_setup();
|
|
35689
35736
|
import { promises as fs, readdirSync as readdirSync5, statSync as statSync3 } from "fs";
|
|
35690
|
-
import { join as
|
|
35737
|
+
import { join as join9, relative as relative2, extname as extname3 } from "path";
|
|
35691
35738
|
var SUBSTITUTABLE_EXTS = /* @__PURE__ */ new Set([
|
|
35692
35739
|
".html",
|
|
35693
35740
|
".htm",
|
|
@@ -35836,7 +35883,7 @@ function* walkTextFiles(root) {
|
|
|
35836
35883
|
}
|
|
35837
35884
|
for (const entry of entries) {
|
|
35838
35885
|
if (isSyncIgnored(entry.name)) continue;
|
|
35839
|
-
const full =
|
|
35886
|
+
const full = join9(dir, entry.name);
|
|
35840
35887
|
if (entry.isDirectory()) {
|
|
35841
35888
|
stack.push(full);
|
|
35842
35889
|
} else if (entry.isFile()) {
|
|
@@ -35858,7 +35905,7 @@ async function substituteDir(dir, vars) {
|
|
|
35858
35905
|
for (const rel2 of walkTextFiles(dir)) {
|
|
35859
35906
|
const ext = extname3(rel2).toLowerCase();
|
|
35860
35907
|
if (!SUBSTITUTABLE_EXTS.has(ext)) continue;
|
|
35861
|
-
const abs =
|
|
35908
|
+
const abs = join9(dir, rel2);
|
|
35862
35909
|
let content;
|
|
35863
35910
|
try {
|
|
35864
35911
|
content = await fs.readFile(abs, "utf-8");
|
|
@@ -35926,18 +35973,18 @@ async function finalizeLocalProject(opts) {
|
|
|
35926
35973
|
}
|
|
35927
35974
|
|
|
35928
35975
|
// src/relay/paths.ts
|
|
35929
|
-
import { existsSync as
|
|
35976
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
|
|
35930
35977
|
import { homedir as homedir6 } from "os";
|
|
35931
|
-
import { join as
|
|
35978
|
+
import { join as join10, resolve as resolve5 } from "path";
|
|
35932
35979
|
function getProjectsRoot() {
|
|
35933
|
-
const settingsPath =
|
|
35934
|
-
const defaultDir =
|
|
35980
|
+
const settingsPath = join10(homedir6(), ".gipity", "settings.json");
|
|
35981
|
+
const defaultDir = join10(homedir6(), "GipityProjects");
|
|
35935
35982
|
try {
|
|
35936
|
-
if (
|
|
35983
|
+
if (existsSync8(settingsPath)) {
|
|
35937
35984
|
const settings = JSON.parse(readFileSync9(settingsPath, "utf-8"));
|
|
35938
35985
|
if (settings.projectsDir) return resolve5(settings.projectsDir);
|
|
35939
35986
|
} else {
|
|
35940
|
-
mkdirSync5(
|
|
35987
|
+
mkdirSync5(join10(homedir6(), ".gipity"), { recursive: true });
|
|
35941
35988
|
writeFileSync6(settingsPath, JSON.stringify({ projectsDir: defaultDir }, null, 2) + "\n");
|
|
35942
35989
|
}
|
|
35943
35990
|
} catch {
|
|
@@ -35946,17 +35993,17 @@ function getProjectsRoot() {
|
|
|
35946
35993
|
}
|
|
35947
35994
|
|
|
35948
35995
|
// src/relay/state.ts
|
|
35949
|
-
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as
|
|
35950
|
-
import { join as
|
|
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";
|
|
35951
35998
|
import { homedir as homedir7 } from "os";
|
|
35952
|
-
var RELAY_DIR = process.env.GIPITY_DIR ||
|
|
35953
|
-
var RELAY_FILE =
|
|
35999
|
+
var RELAY_DIR = process.env.GIPITY_DIR || join11(homedir7(), ".gipity");
|
|
36000
|
+
var RELAY_FILE = join11(RELAY_DIR, "relay.json");
|
|
35954
36001
|
var FILE_MODE = 384;
|
|
35955
36002
|
function emptyState() {
|
|
35956
36003
|
return { device: null, paused: false };
|
|
35957
36004
|
}
|
|
35958
36005
|
function loadState() {
|
|
35959
|
-
if (!
|
|
36006
|
+
if (!existsSync9(RELAY_FILE)) return emptyState();
|
|
35960
36007
|
try {
|
|
35961
36008
|
const raw = JSON.parse(readFileSync10(RELAY_FILE, "utf-8"));
|
|
35962
36009
|
return {
|
|
@@ -35965,6 +36012,7 @@ function loadState() {
|
|
|
35965
36012
|
relay_enabled: typeof raw.relay_enabled === "boolean" ? raw.relay_enabled : void 0,
|
|
35966
36013
|
onboard_shown: Boolean(raw.onboard_shown),
|
|
35967
36014
|
diagnostics_consent: typeof raw.diagnostics_consent === "boolean" ? raw.diagnostics_consent : void 0,
|
|
36015
|
+
agent_updates: typeof raw.agent_updates === "boolean" ? raw.agent_updates : void 0,
|
|
35968
36016
|
agent_token: typeof raw.agent_token === "string" ? raw.agent_token : null,
|
|
35969
36017
|
agent_token_guid: typeof raw.agent_token_guid === "string" ? raw.agent_token_guid : null
|
|
35970
36018
|
};
|
|
@@ -36043,7 +36091,23 @@ function diagnosticsConsented() {
|
|
|
36043
36091
|
if (env && env !== "0" && env.toLowerCase() !== "false") return false;
|
|
36044
36092
|
return loadState().diagnostics_consent !== false;
|
|
36045
36093
|
}
|
|
36046
|
-
|
|
36094
|
+
function getAgentUpdatesPref() {
|
|
36095
|
+
return loadState().agent_updates;
|
|
36096
|
+
}
|
|
36097
|
+
function setAgentUpdatesPref(on2) {
|
|
36098
|
+
mutate((s) => {
|
|
36099
|
+
s.agent_updates = on2;
|
|
36100
|
+
});
|
|
36101
|
+
}
|
|
36102
|
+
function agentUpdatesEnabled() {
|
|
36103
|
+
if (process.env.DISABLE_AUTOUPDATER === "1") return false;
|
|
36104
|
+
const env = (process.env.GIPITY_RELAY_AGENT_UPDATES || "").toLowerCase();
|
|
36105
|
+
if (["0", "off", "false", "no"].includes(env)) return false;
|
|
36106
|
+
if (["1", "on", "true", "yes"].includes(env)) return true;
|
|
36107
|
+
if (process.env.CI || process.env.NODE_ENV === "test") return false;
|
|
36108
|
+
return loadState().agent_updates !== false;
|
|
36109
|
+
}
|
|
36110
|
+
var RELAY_PID_FILE = join11(RELAY_DIR, "relay.pid");
|
|
36047
36111
|
function getDaemonPidPath() {
|
|
36048
36112
|
return RELAY_PID_FILE;
|
|
36049
36113
|
}
|
|
@@ -36058,7 +36122,7 @@ function clearDaemonPid() {
|
|
|
36058
36122
|
}
|
|
36059
36123
|
}
|
|
36060
36124
|
function isDaemonRunning() {
|
|
36061
|
-
if (!
|
|
36125
|
+
if (!existsSync9(RELAY_PID_FILE)) return false;
|
|
36062
36126
|
try {
|
|
36063
36127
|
const raw = readFileSync10(RELAY_PID_FILE, "utf-8").trim();
|
|
36064
36128
|
const pid = parseInt(raw, 10);
|
|
@@ -36107,7 +36171,7 @@ function scanForAdoption(cwd) {
|
|
|
36107
36171
|
for (const name of entries) {
|
|
36108
36172
|
if (truncated) return;
|
|
36109
36173
|
if (isSyncIgnored(name)) continue;
|
|
36110
|
-
const full =
|
|
36174
|
+
const full = join12(dir, name);
|
|
36111
36175
|
let st2;
|
|
36112
36176
|
try {
|
|
36113
36177
|
st2 = statSync4(full);
|
|
@@ -36146,7 +36210,7 @@ function canAdoptCwd(cwd) {
|
|
|
36146
36210
|
const norm = resolve6(cwd);
|
|
36147
36211
|
const home = resolve6(homedir8());
|
|
36148
36212
|
const blocked = /* @__PURE__ */ new Set([
|
|
36149
|
-
|
|
36213
|
+
sep3,
|
|
36150
36214
|
home,
|
|
36151
36215
|
resolve6(getProjectsRoot()),
|
|
36152
36216
|
"/tmp",
|
|
@@ -36165,8 +36229,8 @@ function canAdoptCwd(cwd) {
|
|
|
36165
36229
|
if (v7 && norm === resolve6(v7)) return false;
|
|
36166
36230
|
}
|
|
36167
36231
|
if (blocked.has(norm)) return false;
|
|
36168
|
-
if (norm.startsWith(home +
|
|
36169
|
-
const depth = norm.slice(home.length + 1).split(
|
|
36232
|
+
if (norm.startsWith(home + sep3)) {
|
|
36233
|
+
const depth = norm.slice(home.length + 1).split(sep3).length;
|
|
36170
36234
|
if (depth <= 1 && countGitRepoChildren(norm) >= 3) return false;
|
|
36171
36235
|
}
|
|
36172
36236
|
return true;
|
|
@@ -36181,10 +36245,10 @@ function countGitRepoChildren(dir) {
|
|
|
36181
36245
|
let count = 0;
|
|
36182
36246
|
for (const name of entries.slice(0, 50)) {
|
|
36183
36247
|
if (name.startsWith(".")) continue;
|
|
36184
|
-
const child =
|
|
36248
|
+
const child = join12(dir, name);
|
|
36185
36249
|
try {
|
|
36186
36250
|
if (!statSync4(child).isDirectory()) continue;
|
|
36187
|
-
const gitPath =
|
|
36251
|
+
const gitPath = join12(child, ".git");
|
|
36188
36252
|
if (statSync4(gitPath)) count++;
|
|
36189
36253
|
} catch {
|
|
36190
36254
|
}
|
|
@@ -36196,12 +36260,12 @@ function formatCwdLabel(cwd) {
|
|
|
36196
36260
|
const norm = resolve6(cwd);
|
|
36197
36261
|
const home = resolve6(homedir8());
|
|
36198
36262
|
if (norm === home) return "~";
|
|
36199
|
-
if (norm.startsWith(home +
|
|
36200
|
-
const
|
|
36201
|
-
if (
|
|
36202
|
-
return "~/.../" +
|
|
36263
|
+
if (norm.startsWith(home + sep3)) {
|
|
36264
|
+
const tail2 = norm.slice(home.length + 1).split(sep3);
|
|
36265
|
+
if (tail2.length <= 2) return "~/" + tail2.join("/");
|
|
36266
|
+
return "~/.../" + tail2.slice(-2).join("/");
|
|
36203
36267
|
}
|
|
36204
|
-
const parts = norm.split(
|
|
36268
|
+
const parts = norm.split(sep3).filter(Boolean);
|
|
36205
36269
|
if (parts.length <= 1) return norm;
|
|
36206
36270
|
return parts.slice(-2).join("/");
|
|
36207
36271
|
}
|
|
@@ -36324,7 +36388,7 @@ Working with an existing Gipity project:
|
|
|
36324
36388
|
process.exit(1);
|
|
36325
36389
|
}
|
|
36326
36390
|
const cwd = process.cwd();
|
|
36327
|
-
if (
|
|
36391
|
+
if (existsSync10(resolve7(cwd, ".gipity.json"))) {
|
|
36328
36392
|
const existing = getConfig();
|
|
36329
36393
|
console.log(`Already linked to ${info(`"${existing?.projectSlug ?? ""}"`)} ${muted(`(${existing?.projectGuid ?? ""})`)}`);
|
|
36330
36394
|
setupProjectTools(tools);
|
|
@@ -36355,7 +36419,7 @@ Working with an existing Gipity project:
|
|
|
36355
36419
|
}
|
|
36356
36420
|
const ancestorConfigPath = getConfigPath();
|
|
36357
36421
|
if (ancestorConfigPath) {
|
|
36358
|
-
console.log(muted(`Note: ${formatCwdLabel(
|
|
36422
|
+
console.log(muted(`Note: ${formatCwdLabel(dirname6(ancestorConfigPath))} is already a Gipity project.`));
|
|
36359
36423
|
const ok = await confirm(
|
|
36360
36424
|
`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`,
|
|
36361
36425
|
{ default: "no" }
|
|
@@ -36442,13 +36506,13 @@ init_api();
|
|
|
36442
36506
|
init_config();
|
|
36443
36507
|
init_colors();
|
|
36444
36508
|
init_setup();
|
|
36445
|
-
import { existsSync as
|
|
36446
|
-
import { join as
|
|
36509
|
+
import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
|
|
36510
|
+
import { join as join13, resolve as resolve8 } from "path";
|
|
36447
36511
|
import { homedir as homedir9 } from "os";
|
|
36448
36512
|
function checkGipityPlugin() {
|
|
36449
|
-
const path5 =
|
|
36513
|
+
const path5 = join13(homedir9(), ".claude", "settings.json");
|
|
36450
36514
|
let settings = {};
|
|
36451
|
-
if (
|
|
36515
|
+
if (existsSync11(path5)) {
|
|
36452
36516
|
try {
|
|
36453
36517
|
settings = JSON.parse(readFileSync12(path5, "utf-8"));
|
|
36454
36518
|
} catch {
|
|
@@ -36567,7 +36631,7 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
|
|
|
36567
36631
|
});
|
|
36568
36632
|
|
|
36569
36633
|
// src/commands/sync.ts
|
|
36570
|
-
import { dirname as
|
|
36634
|
+
import { dirname as dirname7 } from "node:path";
|
|
36571
36635
|
init_colors();
|
|
36572
36636
|
init_utils();
|
|
36573
36637
|
init_config();
|
|
@@ -36585,7 +36649,7 @@ ${result.applied} action${result.applied > 1 ? "s" : ""} applied.`);
|
|
|
36585
36649
|
}
|
|
36586
36650
|
if (isWsl()) {
|
|
36587
36651
|
const configPath = getConfigPath();
|
|
36588
|
-
const twin = configPath ? findWindowsTwinProject(
|
|
36652
|
+
const twin = configPath ? findWindowsTwinProject(dirname7(configPath)) : null;
|
|
36589
36653
|
if (twin) {
|
|
36590
36654
|
console.log(muted(
|
|
36591
36655
|
`
|
|
@@ -36735,8 +36799,8 @@ function dropCheckpoint(projectGuid2, database) {
|
|
|
36735
36799
|
// src/page-fixtures.ts
|
|
36736
36800
|
init_api();
|
|
36737
36801
|
init_config();
|
|
36738
|
-
import { readFileSync as readFileSync13, statSync as statSync6, existsSync as
|
|
36739
|
-
import { basename as basename4, resolve as resolve10, relative as relative3, join as
|
|
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";
|
|
36740
36804
|
var FIND_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".gipity", "dist", "build", ".next", "coverage"]);
|
|
36741
36805
|
function findByBasename(root, name, limit = 3) {
|
|
36742
36806
|
const hits = [];
|
|
@@ -36753,9 +36817,9 @@ function findByBasename(root, name, limit = 3) {
|
|
|
36753
36817
|
}
|
|
36754
36818
|
for (const e of entries) {
|
|
36755
36819
|
if (e.isDirectory()) {
|
|
36756
|
-
if (!FIND_SKIP.has(e.name)) queue.push(
|
|
36820
|
+
if (!FIND_SKIP.has(e.name)) queue.push(join14(dir, e.name));
|
|
36757
36821
|
} else if (e.name === name && hits.length < limit) {
|
|
36758
|
-
hits.push(
|
|
36822
|
+
hits.push(join14(dir, e.name));
|
|
36759
36823
|
}
|
|
36760
36824
|
}
|
|
36761
36825
|
}
|
|
@@ -36763,7 +36827,7 @@ function findByBasename(root, name, limit = 3) {
|
|
|
36763
36827
|
}
|
|
36764
36828
|
function assertLocalAsset(flag, localPath) {
|
|
36765
36829
|
const abs = resolve10(localPath);
|
|
36766
|
-
if (
|
|
36830
|
+
if (existsSync12(abs)) return;
|
|
36767
36831
|
const root = getProjectRoot() ?? process.cwd();
|
|
36768
36832
|
const elsewhere = findByBasename(root, basename4(localPath)).filter((p) => p !== abs);
|
|
36769
36833
|
const found = elsewhere.length ? `
|
|
@@ -37334,7 +37398,7 @@ init_auth();
|
|
|
37334
37398
|
init_colors();
|
|
37335
37399
|
init_utils();
|
|
37336
37400
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
37337
|
-
import { dirname as
|
|
37401
|
+
import { dirname as dirname8, extname as extname4, join as join15, resolve as resolvePath } from "path";
|
|
37338
37402
|
var DEVICE_PRESETS = {
|
|
37339
37403
|
default: { width: 1280, height: 720 },
|
|
37340
37404
|
desktop: { width: 1920, height: 1080 },
|
|
@@ -37398,7 +37462,7 @@ function dimSuffix(vp2) {
|
|
|
37398
37462
|
}
|
|
37399
37463
|
function defaultScreenshotDir() {
|
|
37400
37464
|
const root = getProjectRoot();
|
|
37401
|
-
return
|
|
37465
|
+
return join15(root ?? ".", "screenshots");
|
|
37402
37466
|
}
|
|
37403
37467
|
function timestampSlug(d = /* @__PURE__ */ new Date()) {
|
|
37404
37468
|
const p = (n) => String(n).padStart(2, "0");
|
|
@@ -37610,8 +37674,8 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
|
|
|
37610
37674
|
return stemPath(opts.output, suffix);
|
|
37611
37675
|
};
|
|
37612
37676
|
for (let i = 0; i < pngs.length; i++) {
|
|
37613
|
-
const target = opts.output ? outputPath(i) :
|
|
37614
|
-
mkdirSync7(
|
|
37677
|
+
const target = opts.output ? outputPath(i) : join15(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
|
|
37678
|
+
mkdirSync7(dirname8(target), { recursive: true });
|
|
37615
37679
|
writeFileSync8(target, pngs[i].buffer);
|
|
37616
37680
|
savedFiles.push(resolvePath(target));
|
|
37617
37681
|
}
|
|
@@ -37939,7 +38003,7 @@ function statusIcon(status) {
|
|
|
37939
38003
|
if (status === "warning") return warning("\u26A0");
|
|
37940
38004
|
return muted("\u2192");
|
|
37941
38005
|
}
|
|
37942
|
-
var deployCommand = new Command("deploy").description("Deploy to dev or prod").argument("[target]", "dev or prod", "dev").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases
|
|
38006
|
+
var deployCommand = new Command("deploy").description("Deploy to dev or prod").argument("[target]", "dev or prod", "dev").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", "Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)").option("--no-optimize", 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((target, opts) => run("Deploy", async () => {
|
|
37943
38007
|
if (target !== "dev" && target !== "prod") {
|
|
37944
38008
|
console.error(error('Target must be "dev" or "prod"'));
|
|
37945
38009
|
process.exit(1);
|
|
@@ -38254,8 +38318,8 @@ memoryCommand.command("delete <topic>").description("Delete a topic").option("--
|
|
|
38254
38318
|
init_api();
|
|
38255
38319
|
init_config();
|
|
38256
38320
|
init_setup();
|
|
38257
|
-
import { readFileSync as readFileSync15, existsSync as
|
|
38258
|
-
import { dirname as
|
|
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";
|
|
38259
38323
|
init_colors();
|
|
38260
38324
|
var LANG_MAP = {
|
|
38261
38325
|
js: "javascript",
|
|
@@ -38393,7 +38457,7 @@ function isWriteTarget(code, p) {
|
|
|
38393
38457
|
function resolveRelativeCwd() {
|
|
38394
38458
|
const configPath = getConfigPath();
|
|
38395
38459
|
if (!configPath) return void 0;
|
|
38396
|
-
const projectRoot =
|
|
38460
|
+
const projectRoot = dirname9(configPath);
|
|
38397
38461
|
const rel2 = relative4(projectRoot, process.cwd());
|
|
38398
38462
|
if (!rel2 || rel2.startsWith("..")) return void 0;
|
|
38399
38463
|
return rel2.split(/[\\/]/).filter(Boolean).join("/");
|
|
@@ -38475,7 +38539,7 @@ GCC/Rust).
|
|
|
38475
38539
|
if (args.length >= 2 && INTERPRETERS[args[0].toLowerCase()] !== void 0) {
|
|
38476
38540
|
langFromInterp = INTERPRETERS[args[0].toLowerCase()];
|
|
38477
38541
|
const rest = args.slice(1).join(" ");
|
|
38478
|
-
if (
|
|
38542
|
+
if (existsSync13(rest) && statSync7(rest).isFile()) filePath = rest;
|
|
38479
38543
|
else inlineCode = rest;
|
|
38480
38544
|
} else if (args.length === 1) {
|
|
38481
38545
|
inlineCode = args[0];
|
|
@@ -38523,7 +38587,7 @@ GCC/Rust).
|
|
|
38523
38587
|
}
|
|
38524
38588
|
if (source) {
|
|
38525
38589
|
const scratchReads = scratchRefsInCode(source).filter(
|
|
38526
|
-
(p) => shouldIgnore(p, SCRATCH_IGNORE) &&
|
|
38590
|
+
(p) => shouldIgnore(p, SCRATCH_IGNORE) && existsSync13(resolve11(process.cwd(), p)) && !isWriteTarget(source, p)
|
|
38527
38591
|
);
|
|
38528
38592
|
if (scratchReads.length) {
|
|
38529
38593
|
console.error(error(`Scratch files are never mirrored into the sandbox, so it can't read: ${scratchReads.join(", ")}`));
|
|
@@ -38559,8 +38623,8 @@ GCC/Rust).
|
|
|
38559
38623
|
for (const f of res.data.scratchFiles) {
|
|
38560
38624
|
const rel2 = f.path.replace(/\\/g, "/");
|
|
38561
38625
|
const abs = resolve11(base, rel2);
|
|
38562
|
-
if (abs !== base && !abs.startsWith(base +
|
|
38563
|
-
mkdirSync8(
|
|
38626
|
+
if (abs !== base && !abs.startsWith(base + sep4)) continue;
|
|
38627
|
+
mkdirSync8(dirname9(abs), { recursive: true });
|
|
38564
38628
|
writeFileSync9(abs, Buffer.from(f.contentBase64, "base64"));
|
|
38565
38629
|
scratchWritten.push(rel2);
|
|
38566
38630
|
}
|
|
@@ -38584,7 +38648,7 @@ GCC/Rust).
|
|
|
38584
38648
|
}
|
|
38585
38649
|
if (res.data.outputFiles && res.data.outputFiles.length > 0) {
|
|
38586
38650
|
const projectRoot = getProjectRoot();
|
|
38587
|
-
const landed = (f) => pulledLocal && !!projectRoot &&
|
|
38651
|
+
const landed = (f) => pulledLocal && !!projectRoot && existsSync13(resolve11(projectRoot, f));
|
|
38588
38652
|
const onDisk = res.data.outputFiles.filter(landed);
|
|
38589
38653
|
const notOnDisk = res.data.outputFiles.filter((f) => !landed(f));
|
|
38590
38654
|
if (onDisk.length > 0) {
|
|
@@ -38736,7 +38800,7 @@ init_config();
|
|
|
38736
38800
|
init_setup();
|
|
38737
38801
|
init_colors();
|
|
38738
38802
|
init_utils();
|
|
38739
|
-
import { join as
|
|
38803
|
+
import { join as join16 } from "path";
|
|
38740
38804
|
import { mkdirSync as mkdirSync9 } from "fs";
|
|
38741
38805
|
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 () => {
|
|
38742
38806
|
const config = requireConfig();
|
|
@@ -38792,7 +38856,7 @@ projectCommand.command("create <name>").description("Create a project").option("
|
|
|
38792
38856
|
}
|
|
38793
38857
|
const res = await post("/projects", body);
|
|
38794
38858
|
const project = res.data;
|
|
38795
|
-
const dir =
|
|
38859
|
+
const dir = join16(getProjectsRoot(), project.slug);
|
|
38796
38860
|
mkdirSync9(dir, { recursive: true });
|
|
38797
38861
|
const accountSlug = await getAccountSlug();
|
|
38798
38862
|
let agentGuid = "";
|
|
@@ -38888,7 +38952,26 @@ var agentCommand = new Command("agent").description("Manage agents").argument("[
|
|
|
38888
38952
|
return `${a.name}${active}${def}${model}`;
|
|
38889
38953
|
});
|
|
38890
38954
|
}));
|
|
38891
|
-
agentCommand.command("
|
|
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 () => {
|
|
38956
|
+
const res = await get("/agents/models");
|
|
38957
|
+
if (opts.json) {
|
|
38958
|
+
console.log(JSON.stringify(res.data));
|
|
38959
|
+
return;
|
|
38960
|
+
}
|
|
38961
|
+
const width = res.data.reduce((m, x) => Math.max(m, x.id.length), 0);
|
|
38962
|
+
for (const m of res.data) {
|
|
38963
|
+
const notes = [
|
|
38964
|
+
m.displayName,
|
|
38965
|
+
m.provider,
|
|
38966
|
+
`$${m.inputCostPerMTok}/$${m.outputCostPerMTok} per 1M tok`,
|
|
38967
|
+
`${Math.round(m.maxContextTokens / 1e3)}K ctx`
|
|
38968
|
+
];
|
|
38969
|
+
if (m.blurb) notes.push(m.blurb);
|
|
38970
|
+
if (m.isDefault) notes.push("default");
|
|
38971
|
+
console.log(`${m.id.padEnd(width)} ${muted(notes.join(" \xB7 "))}`);
|
|
38972
|
+
}
|
|
38973
|
+
}));
|
|
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 () => {
|
|
38892
38975
|
const body = { name };
|
|
38893
38976
|
if (opts.model) body.modelPreference = opts.model;
|
|
38894
38977
|
const res = await post("/agents", body);
|
|
@@ -38903,7 +38986,7 @@ agentCommand.command("create <name>").description("Create an agent").option("--m
|
|
|
38903
38986
|
if (opts.switch) console.log("Switched.");
|
|
38904
38987
|
}
|
|
38905
38988
|
}));
|
|
38906
|
-
agentCommand.command("set <field> <value>").description("Set a field (model, temp)").option("--json", "Output as JSON").action((field, value, opts) => run("Set", async () => {
|
|
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 () => {
|
|
38907
38990
|
const config = requireConfig();
|
|
38908
38991
|
const body = {};
|
|
38909
38992
|
if (field === "model") body.modelPreference = value;
|
|
@@ -39712,8 +39795,8 @@ storageCommand.command("retention").description("View or adjust your file versio
|
|
|
39712
39795
|
init_platform();
|
|
39713
39796
|
init_auth();
|
|
39714
39797
|
init_api();
|
|
39715
|
-
import { join as
|
|
39716
|
-
import { existsSync as
|
|
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";
|
|
39717
39800
|
import { homedir as homedir13 } from "os";
|
|
39718
39801
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
39719
39802
|
import { randomUUID } from "crypto";
|
|
@@ -39827,7 +39910,7 @@ init_colors();
|
|
|
39827
39910
|
|
|
39828
39911
|
// src/relay/installers.ts
|
|
39829
39912
|
import { homedir as homedir10, platform as osPlatform } from "os";
|
|
39830
|
-
import { join as
|
|
39913
|
+
import { join as join17 } from "path";
|
|
39831
39914
|
var UnsupportedPlatformError = class extends Error {
|
|
39832
39915
|
constructor(plat) {
|
|
39833
39916
|
super(`gipity relay install does not support ${plat}`);
|
|
@@ -39845,8 +39928,8 @@ function display(argvs) {
|
|
|
39845
39928
|
}
|
|
39846
39929
|
function launchdPlan(cliPath) {
|
|
39847
39930
|
const label2 = "ai.gipity.relay";
|
|
39848
|
-
const path5 =
|
|
39849
|
-
const logDir =
|
|
39931
|
+
const path5 = join17(homedir10(), "Library", "LaunchAgents", `${label2}.plist`);
|
|
39932
|
+
const logDir = join17(homedir10(), "Library", "Logs", "Gipity");
|
|
39850
39933
|
const uid = process.getuid?.() ?? 0;
|
|
39851
39934
|
const target = `gui/${uid}`;
|
|
39852
39935
|
const content = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -39870,8 +39953,8 @@ function launchdPlan(cliPath) {
|
|
|
39870
39953
|
<dict>
|
|
39871
39954
|
<key>SuccessfulExit</key><false/>
|
|
39872
39955
|
</dict>
|
|
39873
|
-
<key>StandardOutPath</key><string>${
|
|
39874
|
-
<key>StandardErrorPath</key><string>${
|
|
39956
|
+
<key>StandardOutPath</key><string>${join17(logDir, "relay.out.log")}</string>
|
|
39957
|
+
<key>StandardErrorPath</key><string>${join17(logDir, "relay.err.log")}</string>
|
|
39875
39958
|
<key>ProcessType</key><string>Background</string>
|
|
39876
39959
|
</dict>
|
|
39877
39960
|
</plist>
|
|
@@ -39894,7 +39977,7 @@ function launchdPlan(cliPath) {
|
|
|
39894
39977
|
}
|
|
39895
39978
|
function systemdUserPlan(cliPath) {
|
|
39896
39979
|
const unitName = "gipity-relay.service";
|
|
39897
|
-
const path5 =
|
|
39980
|
+
const path5 = join17(homedir10(), ".config", "systemd", "user", unitName);
|
|
39898
39981
|
const content = `[Unit]
|
|
39899
39982
|
Description=Gipity relay - local Claude Code control from the Gipity web CLI
|
|
39900
39983
|
After=network-online.target
|
|
@@ -39932,7 +40015,7 @@ WantedBy=default.target
|
|
|
39932
40015
|
}
|
|
39933
40016
|
function windowsTaskPlan(cliPath) {
|
|
39934
40017
|
const taskName = "GipityRelay";
|
|
39935
|
-
const path5 =
|
|
40018
|
+
const path5 = join17(homedir10(), "AppData", "Local", "Gipity", "relay-task.xml");
|
|
39936
40019
|
const runsViaNode = /\.[cm]?js$/i.test(cliPath);
|
|
39937
40020
|
const command = runsViaNode ? process.execPath : cliPath;
|
|
39938
40021
|
const argLine = runsViaNode ? `"${cliPath}" relay run` : "relay run";
|
|
@@ -39994,7 +40077,7 @@ function windowsTaskPlan(cliPath) {
|
|
|
39994
40077
|
init_platform();
|
|
39995
40078
|
init_api();
|
|
39996
40079
|
import { hostname as hostname3, userInfo, platform as osPlatform2 } from "os";
|
|
39997
|
-
import { resolve as resolve12, dirname as
|
|
40080
|
+
import { resolve as resolve12, dirname as dirname10 } from "path";
|
|
39998
40081
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
39999
40082
|
|
|
40000
40083
|
// src/relay/machine-id.ts
|
|
@@ -40104,7 +40187,7 @@ function startDaemon() {
|
|
|
40104
40187
|
function installAutostart(opts = {}) {
|
|
40105
40188
|
const stdio = opts.stdio ?? "ignore";
|
|
40106
40189
|
const plan2 = planFor({ cliPath: resolveCliPath() });
|
|
40107
|
-
mkdirSync10(
|
|
40190
|
+
mkdirSync10(dirname10(plan2.path), { recursive: true });
|
|
40108
40191
|
writeFileSync10(plan2.path, plan2.content);
|
|
40109
40192
|
let ok = true;
|
|
40110
40193
|
for (const argv2 of plan2.enableCmds) {
|
|
@@ -40238,12 +40321,12 @@ init_colors();
|
|
|
40238
40321
|
// src/banner.ts
|
|
40239
40322
|
init_colors();
|
|
40240
40323
|
import { homedir as homedir11 } from "os";
|
|
40241
|
-
import { sep as
|
|
40324
|
+
import { sep as sep5 } from "path";
|
|
40242
40325
|
function tildify(p) {
|
|
40243
40326
|
const home = homedir11();
|
|
40244
40327
|
if (!home) return p;
|
|
40245
40328
|
if (p === home) return "~";
|
|
40246
|
-
if (p.startsWith(home +
|
|
40329
|
+
if (p.startsWith(home + sep5)) return "~" + p.slice(home.length);
|
|
40247
40330
|
return p;
|
|
40248
40331
|
}
|
|
40249
40332
|
var AI_MODELS = [
|
|
@@ -40490,12 +40573,12 @@ init_claude_setup();
|
|
|
40490
40573
|
init_agents();
|
|
40491
40574
|
|
|
40492
40575
|
// src/prefs.ts
|
|
40493
|
-
import { existsSync as
|
|
40576
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
|
|
40494
40577
|
import { homedir as homedir12 } from "os";
|
|
40495
|
-
import { join as
|
|
40496
|
-
var PREFS_PATH =
|
|
40578
|
+
import { join as join18 } from "path";
|
|
40579
|
+
var PREFS_PATH = join18(homedir12(), ".gipity", "prefs.json");
|
|
40497
40580
|
function readPrefs() {
|
|
40498
|
-
if (!
|
|
40581
|
+
if (!existsSync14(PREFS_PATH)) return {};
|
|
40499
40582
|
try {
|
|
40500
40583
|
const parsed = JSON.parse(readFileSync17(PREFS_PATH, "utf-8"));
|
|
40501
40584
|
return {
|
|
@@ -40509,7 +40592,7 @@ function writePrefs(update) {
|
|
|
40509
40592
|
try {
|
|
40510
40593
|
const current = readPrefs();
|
|
40511
40594
|
const next = { ...current, ...update };
|
|
40512
|
-
mkdirSync11(
|
|
40595
|
+
mkdirSync11(join18(homedir12(), ".gipity"), { recursive: true });
|
|
40513
40596
|
writeFileSync11(PREFS_PATH, JSON.stringify(next, null, 2) + "\n");
|
|
40514
40597
|
} catch {
|
|
40515
40598
|
}
|
|
@@ -40517,18 +40600,18 @@ function writePrefs(update) {
|
|
|
40517
40600
|
|
|
40518
40601
|
// src/commands/build.ts
|
|
40519
40602
|
init_setup();
|
|
40520
|
-
var __clDir =
|
|
40603
|
+
var __clDir = dirname11(fileURLToPath2(import.meta.url));
|
|
40521
40604
|
function readOwnPkg(fromDir) {
|
|
40522
|
-
for (let d = fromDir; ; d =
|
|
40523
|
-
const p =
|
|
40524
|
-
if (
|
|
40605
|
+
for (let d = fromDir; ; d = dirname11(d)) {
|
|
40606
|
+
const p = join19(d, "package.json");
|
|
40607
|
+
if (existsSync15(p)) {
|
|
40525
40608
|
try {
|
|
40526
40609
|
const pkg2 = JSON.parse(readFileSync18(p, "utf-8"));
|
|
40527
40610
|
if (pkg2.name === "gipity") return pkg2;
|
|
40528
40611
|
} catch {
|
|
40529
40612
|
}
|
|
40530
40613
|
}
|
|
40531
|
-
if (
|
|
40614
|
+
if (dirname11(d) === d) return {};
|
|
40532
40615
|
}
|
|
40533
40616
|
}
|
|
40534
40617
|
var __clPkg = readOwnPkg(__clDir);
|
|
@@ -40577,7 +40660,7 @@ function localFsFallback(dir) {
|
|
|
40577
40660
|
let isDir = false;
|
|
40578
40661
|
let size = 0;
|
|
40579
40662
|
try {
|
|
40580
|
-
const st2 = statSync8(
|
|
40663
|
+
const st2 = statSync8(join19(d, name));
|
|
40581
40664
|
isDir = st2.isDirectory();
|
|
40582
40665
|
size = st2.isFile() ? st2.size : 0;
|
|
40583
40666
|
} catch {
|
|
@@ -40586,7 +40669,7 @@ function localFsFallback(dir) {
|
|
|
40586
40669
|
if (isDir) {
|
|
40587
40670
|
folderCount++;
|
|
40588
40671
|
if (depth === 0) topLevelEntries.push(`${name}/`);
|
|
40589
|
-
walk(
|
|
40672
|
+
walk(join19(d, name), depth + 1);
|
|
40590
40673
|
} else {
|
|
40591
40674
|
fileCount++;
|
|
40592
40675
|
totalBytes += size;
|
|
@@ -40619,8 +40702,8 @@ function hasStreamJsonFlag(args) {
|
|
|
40619
40702
|
}
|
|
40620
40703
|
function markFolderTrusted(dir) {
|
|
40621
40704
|
try {
|
|
40622
|
-
const file =
|
|
40623
|
-
const cfg =
|
|
40705
|
+
const file = join19(homedir13(), ".claude.json");
|
|
40706
|
+
const cfg = existsSync15(file) ? JSON.parse(readFileSync18(file, "utf-8")) : {};
|
|
40624
40707
|
if (typeof cfg !== "object" || cfg === null) return;
|
|
40625
40708
|
if (typeof cfg.projects !== "object" || cfg.projects === null) cfg.projects = {};
|
|
40626
40709
|
const entry = typeof cfg.projects[dir] === "object" && cfg.projects[dir] !== null ? cfg.projects[dir] : {};
|
|
@@ -40745,9 +40828,9 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40745
40828
|
let existing = getConfig();
|
|
40746
40829
|
let forceAdoptCwd = false;
|
|
40747
40830
|
if (existing && !opts.newProject && !opts.project && !nonInteractive) {
|
|
40748
|
-
const cwdHasConfig =
|
|
40831
|
+
const cwdHasConfig = existsSync15(resolve13(process.cwd(), ".gipity.json"));
|
|
40749
40832
|
if (!cwdHasConfig && isLikelyEmpty(process.cwd())) {
|
|
40750
|
-
const ancestorRoot =
|
|
40833
|
+
const ancestorRoot = dirname11(getConfigPath());
|
|
40751
40834
|
console.log(` ${bold("You are inside an existing Gipity project.")}
|
|
40752
40835
|
`);
|
|
40753
40836
|
console.log(` ${bold("1.")} Continue in ${brand(existing.projectSlug)} ${muted(`(rooted at ${formatCwdLabel(ancestorRoot)})`)}`);
|
|
@@ -40794,7 +40877,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40794
40877
|
}
|
|
40795
40878
|
project = found;
|
|
40796
40879
|
}
|
|
40797
|
-
const projectDir2 = opts.here ? process.cwd() :
|
|
40880
|
+
const projectDir2 = opts.here ? process.cwd() : join19(getProjectsRoot(), project.slug);
|
|
40798
40881
|
mkdirSync12(projectDir2, { recursive: true });
|
|
40799
40882
|
process.chdir(projectDir2);
|
|
40800
40883
|
clearConfigCache();
|
|
@@ -40837,7 +40920,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40837
40920
|
`);
|
|
40838
40921
|
setupProjectTools();
|
|
40839
40922
|
let doSync = true;
|
|
40840
|
-
const projectRoot =
|
|
40923
|
+
const projectRoot = dirname11(getConfigPath());
|
|
40841
40924
|
const scan = scanForAdoption(projectRoot);
|
|
40842
40925
|
if (scan.tier === "refuse" && !nonInteractive) {
|
|
40843
40926
|
const sizeStr = scan.truncated ? `>${formatBytes(ADOPT_THRESHOLDS.REFUSE_BYTES)}` : formatBytes(scan.bytes);
|
|
@@ -40918,7 +41001,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40918
41001
|
} else {
|
|
40919
41002
|
project = result.project;
|
|
40920
41003
|
isNewProject = result.kind === "create-new";
|
|
40921
|
-
const projectDir2 =
|
|
41004
|
+
const projectDir2 = join19(getProjectsRoot(), project.slug);
|
|
40922
41005
|
mkdirSync12(projectDir2, { recursive: true });
|
|
40923
41006
|
process.chdir(projectDir2);
|
|
40924
41007
|
clearConfigCache();
|
|
@@ -41306,8 +41389,8 @@ ${doneLine}
|
|
|
41306
41389
|
});
|
|
41307
41390
|
}
|
|
41308
41391
|
function flushHeadlessCapture(adapter, sessionId, convGuid) {
|
|
41309
|
-
const runner =
|
|
41310
|
-
if (!
|
|
41392
|
+
const runner = join19(__clDir, "..", "hooks", "capture-runner.js");
|
|
41393
|
+
if (!existsSync15(runner)) return;
|
|
41311
41394
|
const payload = JSON.stringify({ session_id: sessionId, cwd: process.cwd() });
|
|
41312
41395
|
const env = { ...process.env, GIPITY_CONVERSATION_GUID: convGuid };
|
|
41313
41396
|
for (const event of ["session-start", "stop"]) {
|
|
@@ -41435,8 +41518,8 @@ function formatNewProjectLabel(existingSlugs) {
|
|
|
41435
41518
|
const slug = suggestProjectName(existingSlugs);
|
|
41436
41519
|
const root = getProjectsRoot();
|
|
41437
41520
|
const home = homedir13();
|
|
41438
|
-
const display2 = root === home || root.startsWith(home +
|
|
41439
|
-
return `${display2}${
|
|
41521
|
+
const display2 = root === home || root.startsWith(home + sep6) ? "~" + root.slice(home.length) : root;
|
|
41522
|
+
return `${display2}${sep6}${slug}`;
|
|
41440
41523
|
}
|
|
41441
41524
|
async function confirmAdoptCwd(cwd) {
|
|
41442
41525
|
process.stdout.write(` ${muted("Scanning directory...")} `);
|
|
@@ -42152,7 +42235,7 @@ and its own error message), use the per-call log instead:
|
|
|
42152
42235
|
}
|
|
42153
42236
|
}
|
|
42154
42237
|
}));
|
|
42155
|
-
logsCommand.command("app").description("Unified recent activity for this app \u2014 JS errors, failed function calls, failed services, network failures. Designed for agents debugging a deployed app.").option("--since <window>", "Window: 5m / 10m / 30m / 1h / 6h / 24h / 7d", "10m").
|
|
42238
|
+
logsCommand.command("app").description("Unified recent activity for this app \u2014 JS errors, failed function calls, failed services, network failures. Designed for agents debugging a deployed app.").option("--since <window>", "Window: 5m / 10m / 30m / 1h / 6h / 24h / 7d", "10m").addOption(new Option("--severity <level>", "Severity filter").choices(["error", "warn", "network", "all"]).default("all")).option("--type <list>", "Comma-separated: errors,functions,services,traffic. Default excludes traffic (high volume).").option("--filter <pattern>", "Substring match against message / fn name / path (case-insensitive)").option("--limit <n>", "Max entries", "100").option("--json", "Output as JSON (parseable by agents / pipes)").addHelpText("after", `
|
|
42156
42239
|
Examples:
|
|
42157
42240
|
$ gipity logs app Last 10 min of errors + fn failures
|
|
42158
42241
|
$ gipity logs app --since 1h Last hour
|
|
@@ -42648,7 +42731,7 @@ recordsCommand.command("list").description("List record tables").option("--json"
|
|
|
42648
42731
|
(t) => `${bold(t.table_name)} ${muted(t.auth_level)} ${muted(`pk=${t.primary_key_column}`)} ${muted(`db=${t.database_name}`)}`
|
|
42649
42732
|
);
|
|
42650
42733
|
}));
|
|
42651
|
-
recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, etc.)").
|
|
42734
|
+
recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, etc.)").addOption(new Option("--auth <level>", "Auth level: public (anonymous writes), member (sign-in), or user").choices(["public", "member", "user"])).option("--searchable <bool>", "Enable full-text search (true/false)").option("--primary-key <col>", "Primary key column (default: id)").option("--soft-delete <col>", 'Soft-delete column (pass "none" to clear)').option("--json", "Output as JSON").action((table, opts) => run("Config", async () => {
|
|
42652
42735
|
const config = requireConfig();
|
|
42653
42736
|
const base = `/api/${config.projectGuid}/records/${table}/config`;
|
|
42654
42737
|
const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete;
|
|
@@ -42669,7 +42752,7 @@ recordsCommand.command("config <table>").description("Show or set a table's Reco
|
|
|
42669
42752
|
res.data
|
|
42670
42753
|
);
|
|
42671
42754
|
}));
|
|
42672
|
-
recordsCommand.command("query <table>").description("List records (full-text search, filter, sort, recycle bin)").option("-q, --q <text>", "Full-text search across the table's text columns (needs `--searchable true` on the table)").option("--filter <filter>", 'AND filter string
|
|
42755
|
+
recordsCommand.command("query <table>").description("List records (full-text search, filter, sort, recycle bin)").option("-q, --q <text>", "Full-text search across the table's text columns (needs `--searchable true` on the table)").option("--filter <filter>", 'AND filter string, "col:op:value" comma-joined. Ops: eq, neq, gt, gte, lt, lte, like, ilike, in (pipe-separated values), is_null, not_null. Full grammar: gipity skill read app-records').option("--any <filter>", 'OR filter group, same grammar and ops as --filter (e.g., "owner:eq:me,shared:eq:true")').option("--sort <sort>", 'Sort string (e.g., "created_at:desc")').option("--limit <n>", "Max rows", "20").option("--offset <n>", "Offset", "0").option("--fields <fields>", "Comma-separated column names").option("--include-deleted", "Include soft-deleted rows (owner/editor)").option("--only-deleted", "Only soft-deleted rows - the recycle bin (owner/editor)").option(ANON_FLAG, ANON_HELP).option("--json", "Output as JSON").action((table, opts) => run("Query", async () => {
|
|
42673
42756
|
const api = await recordsHttp(opts);
|
|
42674
42757
|
const params = new URLSearchParams();
|
|
42675
42758
|
if (opts.q) params.set("q", opts.q);
|
|
@@ -42839,9 +42922,10 @@ var SERVICES = [
|
|
|
42839
42922
|
{ name: "image", method: "POST", desc: "Generate an image ({ prompt, provider?, size? })" },
|
|
42840
42923
|
{ name: "image/models", method: "GET", desc: "List image providers/models" },
|
|
42841
42924
|
{ name: "tts", method: "POST", desc: "Text-to-speech ({ text, voice?, ... })" },
|
|
42842
|
-
{ name: "tts/voices", method: "GET", desc: "List TTS voices" },
|
|
42925
|
+
{ name: "tts/voices", method: "GET", desc: "List TTS voices (append ?provider=elevenlabs|openai|gemini)" },
|
|
42843
42926
|
{ name: "sound", method: "POST", desc: "Sound effect ({ text, duration_seconds? })" },
|
|
42844
42927
|
{ name: "music", method: "POST", desc: "Music generation ({ prompt, duration_seconds? })" },
|
|
42928
|
+
{ name: "music/models", method: "GET", desc: "List music models (ids for --model / model)" },
|
|
42845
42929
|
{ name: "video", method: "POST", desc: "Video generation ({ prompt, ... })" },
|
|
42846
42930
|
{ name: "location/ip", method: "POST", desc: "IP geolocation ({ ip? })" },
|
|
42847
42931
|
{ name: "location/geocode", method: "POST", desc: "Reverse geocode ({ lat, lon })" }
|
|
@@ -42877,8 +42961,9 @@ function anonBillingHint(name, err) {
|
|
|
42877
42961
|
}
|
|
42878
42962
|
serviceCommand.command("call <name> [body]").description("Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling; --anon calls it as a signed-out visitor instead.").option("-d, --data <json>", "JSON request body: inline JSON, @file to read a file, or @- / - for stdin (alternative to the positional [body])").option("--file <field=@path>", "Attach a file as { data, media_type } under <field> (the vision/media shape these services expect), repeatable, e.g. --file image=@receipt.png", (v7, acc) => (acc || []).concat(v7)).option("--anon", "Call as an anonymous visitor (the public path a signed-out user of your deployed app hits) instead of as your signed-in account").option("--get", "Issue a GET (for listing endpoints like llm/models, tts/voices)").option("--field <path>", "Print only this field of the result (dot path, e.g. choices.0.message.content)").option("--json", "Output compact JSON").action((name, bodyArg, opts) => run("Call", async () => {
|
|
42879
42963
|
const config = requireConfig();
|
|
42880
|
-
const
|
|
42881
|
-
const
|
|
42964
|
+
const [pathPart, query] = name.split("?", 2);
|
|
42965
|
+
const path5 = pathPart.split("/").map(encodeURIComponent).join("/");
|
|
42966
|
+
const url = `/api/${config.projectGuid}/services/${path5}${query ? `?${query}` : ""}`;
|
|
42882
42967
|
const body = resolveBody(bodyArg || opts.data, opts.file);
|
|
42883
42968
|
if (opts.anon) {
|
|
42884
42969
|
console.error(muted("Auth: anonymous visitor (the public path a signed-out user of your deployed app hits)"));
|
|
@@ -43422,11 +43507,11 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
|
|
|
43422
43507
|
}
|
|
43423
43508
|
}));
|
|
43424
43509
|
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) => {
|
|
43425
|
-
const { existsSync:
|
|
43426
|
-
const { resolve: resolve19, join:
|
|
43510
|
+
const { existsSync: existsSync25, statSync: statSync12 } = await import("node:fs");
|
|
43511
|
+
const { resolve: resolve19, join: join29 } = await import("node:path");
|
|
43427
43512
|
const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
43428
43513
|
const jobDir = resolve19(process.cwd(), "jobs", name);
|
|
43429
|
-
if (!
|
|
43514
|
+
if (!existsSync25(jobDir) || !statSync12(jobDir).isDirectory()) {
|
|
43430
43515
|
console.error(error(`jobs/${name}/ not found in current directory`));
|
|
43431
43516
|
process.exit(1);
|
|
43432
43517
|
}
|
|
@@ -43447,7 +43532,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43447
43532
|
},
|
|
43448
43533
|
{ file: "main.sh", runtime: "bash", entry: "bash" }
|
|
43449
43534
|
];
|
|
43450
|
-
const picked = variants.find((v7) =>
|
|
43535
|
+
const picked = variants.find((v7) => existsSync25(join29(jobDir, v7.file)));
|
|
43451
43536
|
if (!picked) {
|
|
43452
43537
|
console.error(error(`No main.py / main.js / main.sh found under jobs/${name}/`));
|
|
43453
43538
|
process.exit(1);
|
|
@@ -43472,7 +43557,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43472
43557
|
"-v",
|
|
43473
43558
|
`${jobDir}:/work`
|
|
43474
43559
|
];
|
|
43475
|
-
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd &&
|
|
43560
|
+
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd && existsSync25(join29(jobDir, picked.depsFile));
|
|
43476
43561
|
const handlerCmd = `${picked.entry} /work/${picked.file}`;
|
|
43477
43562
|
let shellCmd;
|
|
43478
43563
|
if (needsDeps && picked.installCmd) {
|
|
@@ -43622,7 +43707,7 @@ emailCommand.command("test").description("Send a test email through your app's e
|
|
|
43622
43707
|
console.log(muted(` ${r.to} \u2014 ${r.status}${r.reason ? `: ${r.reason}` : ""}`));
|
|
43623
43708
|
}
|
|
43624
43709
|
}));
|
|
43625
|
-
emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").
|
|
43710
|
+
emailCommand.command("log").description("Recent email() sends and skipped attempts from your app").addOption(new Option("--range <range>", "Time range").choices(["1h", "24h", "7d", "30d", "1y"]).default("7d")).option("--limit <n>", "Max rows", "50").option("--project <guid-or-slug>", "Target a specific project instead of cwd / Home").option("--json", "Output raw JSON").action((opts) => run("Email", async () => {
|
|
43626
43711
|
const { config } = await resolveProjectContext({ projectOverride: opts.project });
|
|
43627
43712
|
const res = await get(
|
|
43628
43713
|
`/account/logs/credits?operations=email_send,email_skip&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`
|
|
@@ -43651,18 +43736,106 @@ init_api();
|
|
|
43651
43736
|
init_config();
|
|
43652
43737
|
init_colors();
|
|
43653
43738
|
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync19 } from "fs";
|
|
43654
|
-
import { resolve as resolvePath2, dirname as
|
|
43739
|
+
import { resolve as resolvePath2, dirname as dirname12, relative as relative5, isAbsolute, basename as basename6 } from "path";
|
|
43655
43740
|
|
|
43656
43741
|
// src/provider-docs.ts
|
|
43657
|
-
var
|
|
43742
|
+
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`;
|
|
43743
|
+
var IMAGE_GEMINI_ASPECT_RATIO_IDS = [
|
|
43744
|
+
"1:1",
|
|
43745
|
+
"16:9",
|
|
43746
|
+
"9:16",
|
|
43747
|
+
"4:3",
|
|
43748
|
+
"3:4",
|
|
43749
|
+
"3:2",
|
|
43750
|
+
"2:3",
|
|
43751
|
+
"4:5",
|
|
43752
|
+
"5:4",
|
|
43753
|
+
"21:9"
|
|
43754
|
+
];
|
|
43755
|
+
var IMAGE_GEMINI_SIZE_IDS = [
|
|
43756
|
+
"512",
|
|
43757
|
+
"1K",
|
|
43758
|
+
"2K",
|
|
43759
|
+
"4K"
|
|
43760
|
+
];
|
|
43761
|
+
var IMAGE_MODELS_TABLE = ` openai gpt-image-2
|
|
43762
|
+
bfl flux-2-pro, flux-2-flex, flux-2-max, flux-2-klein-9b, flux-2-klein-4b
|
|
43763
|
+
gemini gemini-3.1-flash-lite-image, gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3-pro-image`;
|
|
43764
|
+
var IMAGE_PROVIDER_IDS = [
|
|
43765
|
+
"openai",
|
|
43766
|
+
"bfl",
|
|
43767
|
+
"gemini"
|
|
43768
|
+
];
|
|
43769
|
+
var IMAGE_QUALITY_IDS = [
|
|
43770
|
+
"low",
|
|
43771
|
+
"medium",
|
|
43772
|
+
"high",
|
|
43773
|
+
"auto"
|
|
43774
|
+
];
|
|
43775
|
+
var IMAGE_TIER_ALIASES_DOC = `fast (gemini/gemini-3.1-flash-lite-image), standard (openai/gpt-image-2), high (bfl/flux-2-pro), ultra (bfl/flux-2-max)`;
|
|
43776
|
+
var IMAGE_TIER_ALIAS_IDS = [
|
|
43777
|
+
"fast",
|
|
43778
|
+
"standard",
|
|
43779
|
+
"high",
|
|
43780
|
+
"ultra"
|
|
43781
|
+
];
|
|
43658
43782
|
var TTS_PROVIDER_DESCRIPTIONS = {
|
|
43659
|
-
"elevenlabs": `ElevenLabs (many voices
|
|
43783
|
+
"elevenlabs": `ElevenLabs (many premium voices)`,
|
|
43660
43784
|
"openai": `OpenAI (alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse)`,
|
|
43661
43785
|
"gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more). Multi-speaker (up to 2) and 60+ languages`
|
|
43662
43786
|
};
|
|
43663
|
-
var
|
|
43787
|
+
var TTS_PROVIDER_IDS = [
|
|
43788
|
+
"elevenlabs",
|
|
43789
|
+
"openai",
|
|
43790
|
+
"gemini"
|
|
43791
|
+
];
|
|
43792
|
+
var VIDEO_ASPECT_RATIOS = `16:9 (landscape), 9:16 (portrait), 1:1 (square)`;
|
|
43793
|
+
var VIDEO_ASPECT_RATIO_IDS = [
|
|
43794
|
+
"16:9",
|
|
43795
|
+
"9:16",
|
|
43796
|
+
"1:1"
|
|
43797
|
+
];
|
|
43798
|
+
var VIDEO_MODELS_TABLE = ` veo-3.1-generate-preview best quality, up to 4K, ~$0.40/sec
|
|
43799
|
+
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`;
|
|
43802
|
+
var VIDEO_MODEL_IDS = [
|
|
43803
|
+
"veo-3.1-generate-preview",
|
|
43804
|
+
"veo-3.1-fast-generate-preview",
|
|
43805
|
+
"veo-3.1-lite-generate-preview",
|
|
43806
|
+
"gemini-omni-flash-preview"
|
|
43807
|
+
];
|
|
43808
|
+
var VIDEO_RESOLUTION_IDS = [
|
|
43809
|
+
"720p",
|
|
43810
|
+
"1080p",
|
|
43811
|
+
"4k"
|
|
43812
|
+
];
|
|
43664
43813
|
|
|
43665
43814
|
// src/commands/generate.ts
|
|
43815
|
+
function printMetrics(metrics) {
|
|
43816
|
+
const rows = metrics.filter((m) => m !== null);
|
|
43817
|
+
const width = Math.max(...rows.map((m) => m.label.length));
|
|
43818
|
+
for (const m of rows) {
|
|
43819
|
+
console.log(` ${muted(`${m.label.padStart(width)}:`)} ${m.value}`);
|
|
43820
|
+
}
|
|
43821
|
+
}
|
|
43822
|
+
function fmtSeconds(s) {
|
|
43823
|
+
if (s >= 60) return `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
|
|
43824
|
+
return `${s < 10 ? Math.round(s * 10) / 10 : Math.round(s)}s`;
|
|
43825
|
+
}
|
|
43826
|
+
function generationMetrics(result, elapsedSeconds) {
|
|
43827
|
+
const speed = result.duration_seconds !== void 0 && elapsedSeconds > 0 ? result.duration_seconds / elapsedSeconds : void 0;
|
|
43828
|
+
return [
|
|
43829
|
+
result.duration_seconds !== void 0 ? { label: "duration", value: `${fmtSeconds(result.duration_seconds)} clip` } : null,
|
|
43830
|
+
{ label: "size", value: `${Math.round(result.size_bytes / 1024)}KB` },
|
|
43831
|
+
{ label: "time", value: fmtSeconds(elapsedSeconds) },
|
|
43832
|
+
speed !== void 0 ? { label: "speed", value: `${speed >= 1 ? Math.round(speed * 10) / 10 : Math.round(speed * 100) / 100}x realtime` } : null,
|
|
43833
|
+
result.credits_deducted !== void 0 ? { label: "credits", value: `${result.credits_deducted.toLocaleString("en-US")} (${result.remaining_balance.toLocaleString("en-US")} remaining)` } : null
|
|
43834
|
+
];
|
|
43835
|
+
}
|
|
43836
|
+
function jsonResult(result, elapsedSeconds, savedPath) {
|
|
43837
|
+
return JSON.stringify({ ...result, generation_seconds: Math.round(elapsedSeconds * 10) / 10, saved: savedPath });
|
|
43838
|
+
}
|
|
43666
43839
|
async function downloadFile(url, filename, explicit) {
|
|
43667
43840
|
const res = await fetch(url);
|
|
43668
43841
|
if (!res.ok) throw new Error(`Download failed: ${res.status}`);
|
|
@@ -43714,7 +43887,7 @@ function noteFormatMismatch(filename, buf) {
|
|
|
43714
43887
|
));
|
|
43715
43888
|
}
|
|
43716
43889
|
function ensureOutputDir(output) {
|
|
43717
|
-
const dir =
|
|
43890
|
+
const dir = dirname12(resolvePath2(output));
|
|
43718
43891
|
try {
|
|
43719
43892
|
mkdirSync13(dir, { recursive: true });
|
|
43720
43893
|
} catch (err) {
|
|
@@ -43724,7 +43897,7 @@ function ensureOutputDir(output) {
|
|
|
43724
43897
|
async function pushGenerated(savedPath) {
|
|
43725
43898
|
const configPath = getConfigPath();
|
|
43726
43899
|
if (!configPath) return;
|
|
43727
|
-
const rel2 = relative5(
|
|
43900
|
+
const rel2 = relative5(dirname12(configPath), savedPath);
|
|
43728
43901
|
if (rel2.startsWith("..") || isAbsolute(rel2)) return;
|
|
43729
43902
|
try {
|
|
43730
43903
|
await pushFile(savedPath);
|
|
@@ -43748,7 +43921,11 @@ function readInputImages(paths) {
|
|
|
43748
43921
|
});
|
|
43749
43922
|
}
|
|
43750
43923
|
var imageCommand = new Command("image").description("Generate an image from a text prompt, or edit existing images with --input").addHelpText("after", `
|
|
43751
|
-
Models:
|
|
43924
|
+
Models (one line per provider; pass an id with --model, the provider with --provider):
|
|
43925
|
+
${IMAGE_MODELS_TABLE}
|
|
43926
|
+
|
|
43927
|
+
Tier aliases (pass to --model instead of an id; each names a provider+model):
|
|
43928
|
+
${IMAGE_TIER_ALIASES_DOC}
|
|
43752
43929
|
|
|
43753
43930
|
Editing (--input): pass one or more source images and the prompt becomes an edit
|
|
43754
43931
|
instruction applied to them - "make it night time", "add a hat", "remove the car
|
|
@@ -43762,7 +43939,7 @@ Examples:
|
|
|
43762
43939
|
gipity generate image "landscape sunset" --provider gemini --aspect-ratio 16:9 --image-size 2K
|
|
43763
43940
|
gipity generate image "product photo" --provider openai --model gpt-image-2 --size 1536x1024 --quality high
|
|
43764
43941
|
gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png
|
|
43765
|
-
`).argument("<prompt>", "Text description of the image, or (with --input) the edit instruction to apply").option("--input <file>", "Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.", (v7, acc) => (acc || []).concat(v7)).
|
|
43942
|
+
`).argument("<prompt>", "Text description of the image, or (with --input) the edit instruction to apply").option("--input <file>", "Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.", (v7, acc) => (acc || []).concat(v7)).addOption(new Option("--provider <provider>", "Image provider (default: bfl)").choices(IMAGE_PROVIDER_IDS)).option("--model <model>", `Model id for the chosen provider, or a tier alias (${IMAGE_TIER_ALIAS_IDS.join(", ")}); see Models below`).option("--size <size>", 'Dimensions as WxH, e.g. "1024x1024" (OpenAI/BFL)').addOption(new Option("--quality <quality>", "Quality (gpt-image-2 only)").choices(IMAGE_QUALITY_IDS)).addOption(new Option("--aspect-ratio <ratio>", "Aspect ratio (Gemini only)").choices(IMAGE_GEMINI_ASPECT_RATIO_IDS)).addOption(new Option("--image-size <size>", "Output resolution (Gemini only)").choices(IMAGE_GEMINI_SIZE_IDS)).option("--seed <n>", "Deterministic seed (BFL only): reuse one seed to keep a set of images visually coherent", (v7) => parseInt(v7, 10)).option("-o, --output <file>", "Output path (default ./generated.png). For an image your app ships, write it into the source tree so it deploys, e.g. -o src/assets/images/hero.png; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
|
|
43766
43943
|
try {
|
|
43767
43944
|
const { config } = await resolveProjectContext();
|
|
43768
43945
|
if (opts.output) ensureOutputDir(opts.output);
|
|
@@ -43779,18 +43956,20 @@ Examples:
|
|
|
43779
43956
|
input_images: inputImages
|
|
43780
43957
|
});
|
|
43781
43958
|
const verb = inputImages ? "Editing image..." : "Generating image...";
|
|
43959
|
+
const started = Date.now();
|
|
43782
43960
|
const result = opts.json ? await doGenerate() : await withSpinner(verb, doGenerate, { done: null });
|
|
43961
|
+
const elapsed = (Date.now() - started) / 1e3;
|
|
43783
43962
|
const ext = result.content_type.includes("png") ? "png" : "jpg";
|
|
43784
43963
|
const filename = opts.output || `generated.${ext}`;
|
|
43785
43964
|
const savedPath = await downloadFile(result.url, filename, !!opts.output);
|
|
43786
43965
|
if (opts.json) {
|
|
43787
|
-
console.log(
|
|
43966
|
+
console.log(jsonResult(result, elapsed, savedPath));
|
|
43788
43967
|
} else {
|
|
43789
|
-
|
|
43790
|
-
|
|
43791
|
-
|
|
43792
|
-
|
|
43793
|
-
|
|
43968
|
+
console.log(muted(`Generated with ${result.provider}/${result.model}`));
|
|
43969
|
+
printMetrics([
|
|
43970
|
+
...generationMetrics(result, elapsed),
|
|
43971
|
+
result.seed !== void 0 ? { label: "seed", value: `${result.seed} ${muted(`(pass --seed ${result.seed} to keep the next image coherent)`)}` } : null
|
|
43972
|
+
]);
|
|
43794
43973
|
console.log(success(`Saved to ${savedPath}`));
|
|
43795
43974
|
}
|
|
43796
43975
|
} catch (err) {
|
|
@@ -43799,7 +43978,10 @@ Examples:
|
|
|
43799
43978
|
}
|
|
43800
43979
|
});
|
|
43801
43980
|
var videoCommand = new Command("video").description("Generate a short video (up to 8 seconds) from a text prompt using Google Veo").addHelpText("after", `
|
|
43802
|
-
Models:
|
|
43981
|
+
Models (default: veo-3.1-generate-preview):
|
|
43982
|
+
${VIDEO_MODELS_TABLE}
|
|
43983
|
+
|
|
43984
|
+
Aspect ratios: ${VIDEO_ASPECT_RATIOS}
|
|
43803
43985
|
|
|
43804
43986
|
Tips:
|
|
43805
43987
|
- Describe the scene, camera movement, lighting, and any dialogue
|
|
@@ -43810,7 +43992,8 @@ Examples:
|
|
|
43810
43992
|
gipity generate video "a bird flying over a mountain lake at sunset"
|
|
43811
43993
|
gipity generate video "close-up of coffee being poured" --model veo-3.1-fast-generate-preview
|
|
43812
43994
|
gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4
|
|
43813
|
-
|
|
43995
|
+
gipity generate video "a wave crashing" --duration 4 --model veo-3.1-lite-generate-preview
|
|
43996
|
+
`).argument("<prompt>", "Description of the video scene, action, camera movement, and dialogue").addOption(new Option("--model <model>", "Video model; see Models below for quality/price").choices(VIDEO_MODEL_IDS)).addOption(new Option("--aspect <ratio>", "Aspect ratio (landscape, portrait, square)").choices(VIDEO_ASPECT_RATIO_IDS)).addOption(new Option("--resolution <res>", "Video resolution").choices(VIDEO_RESOLUTION_IDS)).option("--duration <seconds>", "Clip length in seconds. Veo models: 4, 6, or 8 (8 required at 1080p/4K); omni-flash: 3-10. Default 8. Billing is per second, so shorter is cheaper.").option("-o, --output <file>", "Output path (default ./generated.mp4). For a clip your app ships, write it into the source tree so it deploys, e.g. -o src/assets/video/clip.mp4; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
|
|
43814
43997
|
try {
|
|
43815
43998
|
const { config } = await resolveProjectContext();
|
|
43816
43999
|
if (opts.output) ensureOutputDir(opts.output);
|
|
@@ -43818,16 +44001,19 @@ Examples:
|
|
|
43818
44001
|
prompt: prompt2,
|
|
43819
44002
|
model: opts.model,
|
|
43820
44003
|
aspect_ratio: opts.aspect,
|
|
43821
|
-
resolution: opts.resolution
|
|
44004
|
+
resolution: opts.resolution,
|
|
44005
|
+
duration_seconds: opts.duration ? Number(opts.duration) : void 0
|
|
43822
44006
|
});
|
|
44007
|
+
const started = Date.now();
|
|
43823
44008
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating video...", doGenerate, { done: null });
|
|
44009
|
+
const elapsed = (Date.now() - started) / 1e3;
|
|
43824
44010
|
const filename = opts.output || "generated.mp4";
|
|
43825
44011
|
const savedPath = await downloadFile(result.url, filename, !!opts.output);
|
|
43826
44012
|
if (opts.json) {
|
|
43827
|
-
console.log(
|
|
44013
|
+
console.log(jsonResult(result, elapsed, savedPath));
|
|
43828
44014
|
} else {
|
|
43829
|
-
|
|
43830
|
-
|
|
44015
|
+
console.log(muted(`Generated with ${result.provider}/${result.model}`));
|
|
44016
|
+
printMetrics(generationMetrics(result, elapsed));
|
|
43831
44017
|
console.log(success(`Saved to ${savedPath}`));
|
|
43832
44018
|
}
|
|
43833
44019
|
} catch (err) {
|
|
@@ -43836,7 +44022,13 @@ Examples:
|
|
|
43836
44022
|
}
|
|
43837
44023
|
});
|
|
43838
44024
|
var speechCommand = new Command("speech").description("Generate speech audio from text using text-to-speech").addHelpText("after", `
|
|
43839
|
-
Providers:
|
|
44025
|
+
Providers:
|
|
44026
|
+
${Object.entries(TTS_PROVIDER_DESCRIPTIONS).map(([k7, v7]) => ` ${k7.padEnd(10)} ${v7}`).join("\n")}
|
|
44027
|
+
|
|
44028
|
+
Voices: openai voices are the list above; the full Gemini list is below. ElevenLabs
|
|
44029
|
+
voice ids: gipity service call "tts/voices?provider=elevenlabs" --get
|
|
44030
|
+
|
|
44031
|
+
Gemini voices: ${GEMINI_TTS_VOICES_DOC}
|
|
43840
44032
|
|
|
43841
44033
|
Multi-speaker (--speakers, Gemini only): JSON array like
|
|
43842
44034
|
[{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]; format the
|
|
@@ -43847,7 +44039,7 @@ Examples:
|
|
|
43847
44039
|
gipity generate speech "\u3053\u3093\u306B\u3061\u306F\u4E16\u754C" --provider gemini --voice Kore --language ja-JP
|
|
43848
44040
|
gipity generate speech "Bonjour le monde" --provider gemini --language fr-FR
|
|
43849
44041
|
gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'
|
|
43850
|
-
`).argument("<text>", "Text to convert to speech (max 5000 characters)").
|
|
44042
|
+
`).argument("<text>", "Text to convert to speech (max 5000 characters)").addOption(new Option("--provider <provider>", "TTS provider (default: elevenlabs)").choices(TTS_PROVIDER_IDS)).option("--voice <voice>", "Voice ID or name (provider-specific; see Voices below)").option("--language <code>", "BCP-47 language code, e.g. ja-JP, es-ES (Gemini only, 60+ languages)").option("--speakers <json>", "Multi-speaker config as JSON array (Gemini only, up to 2 speakers)").option("-o, --output <file>", "Output path (default ./speech.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/sounds/intro.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (text, opts) => {
|
|
43851
44043
|
try {
|
|
43852
44044
|
const { config } = await resolveProjectContext();
|
|
43853
44045
|
if (opts.output) ensureOutputDir(opts.output);
|
|
@@ -43867,14 +44059,16 @@ Examples:
|
|
|
43867
44059
|
language: opts.language,
|
|
43868
44060
|
speakers
|
|
43869
44061
|
});
|
|
44062
|
+
const started = Date.now();
|
|
43870
44063
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating speech...", doGenerate, { done: null });
|
|
44064
|
+
const elapsed = (Date.now() - started) / 1e3;
|
|
43871
44065
|
const filename = opts.output || "speech.mp3";
|
|
43872
44066
|
const savedPath = await downloadFile(result.url, filename, !!opts.output);
|
|
43873
44067
|
if (opts.json) {
|
|
43874
|
-
console.log(
|
|
44068
|
+
console.log(jsonResult(result, elapsed, savedPath));
|
|
43875
44069
|
} else {
|
|
43876
|
-
|
|
43877
|
-
|
|
44070
|
+
console.log(muted(`Generated with ${result.provider}`));
|
|
44071
|
+
printMetrics(generationMetrics(result, elapsed));
|
|
43878
44072
|
console.log(success(`Saved to ${savedPath}`));
|
|
43879
44073
|
}
|
|
43880
44074
|
} catch (err) {
|
|
@@ -43896,7 +44090,7 @@ Examples:
|
|
|
43896
44090
|
gipity generate music "chill lo-fi beat for studying"
|
|
43897
44091
|
gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
|
|
43898
44092
|
gipity generate music "indie pop chorus" --vocals --duration 20
|
|
43899
|
-
`).argument("<prompt>", "Text description of the music to generate").option("--duration <seconds>", "Clip length in seconds (default 30; max depends on the model)", (v7) => parseInt(v7, 10)).option("--model <model>", "Music model id (default: platform default)").option("--vocals", "Allow vocals (default: instrumental only)").option("-o, --output <file>", "Output path (default ./music.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/audio/theme.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
|
|
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) => {
|
|
43900
44094
|
try {
|
|
43901
44095
|
const { config } = await resolveProjectContext();
|
|
43902
44096
|
if (opts.output) ensureOutputDir(opts.output);
|
|
@@ -43906,14 +44100,16 @@ Examples:
|
|
|
43906
44100
|
model: opts.model,
|
|
43907
44101
|
instrumental: !opts.vocals
|
|
43908
44102
|
});
|
|
44103
|
+
const started = Date.now();
|
|
43909
44104
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating music...", doGenerate, { done: null });
|
|
44105
|
+
const elapsed = (Date.now() - started) / 1e3;
|
|
43910
44106
|
const filename = opts.output || "music.mp3";
|
|
43911
44107
|
const savedPath = await downloadFile(result.url, filename, !!opts.output);
|
|
43912
44108
|
if (opts.json) {
|
|
43913
|
-
console.log(
|
|
44109
|
+
console.log(jsonResult(result, elapsed, savedPath));
|
|
43914
44110
|
} else {
|
|
43915
|
-
|
|
43916
|
-
|
|
44111
|
+
console.log(muted(`Generated with ${result.model}`));
|
|
44112
|
+
printMetrics(generationMetrics(result, elapsed));
|
|
43917
44113
|
console.log(success(`Saved to ${savedPath}`));
|
|
43918
44114
|
}
|
|
43919
44115
|
} catch (err) {
|
|
@@ -43944,14 +44140,16 @@ Examples:
|
|
|
43944
44140
|
duration_seconds: opts.duration,
|
|
43945
44141
|
prompt_influence: opts.influence
|
|
43946
44142
|
});
|
|
44143
|
+
const started = Date.now();
|
|
43947
44144
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating sound effect...", doGenerate, { done: null });
|
|
44145
|
+
const elapsed = (Date.now() - started) / 1e3;
|
|
43948
44146
|
const filename = opts.output || "sound.mp3";
|
|
43949
44147
|
const savedPath = await downloadFile(result.url, filename, !!opts.output);
|
|
43950
44148
|
if (opts.json) {
|
|
43951
|
-
console.log(
|
|
44149
|
+
console.log(jsonResult(result, elapsed, savedPath));
|
|
43952
44150
|
} else {
|
|
43953
|
-
|
|
43954
|
-
|
|
44151
|
+
console.log(muted("Generated sound effect"));
|
|
44152
|
+
printMetrics(generationMetrics(result, elapsed));
|
|
43955
44153
|
console.log(success(`Saved to ${savedPath}`));
|
|
43956
44154
|
}
|
|
43957
44155
|
} catch (err) {
|
|
@@ -43965,14 +44163,14 @@ var generateCommand = new Command("generate").description("Generate images, vide
|
|
|
43965
44163
|
init_api();
|
|
43966
44164
|
init_config();
|
|
43967
44165
|
init_colors();
|
|
43968
|
-
import { existsSync as
|
|
43969
|
-
import { join as
|
|
44166
|
+
import { existsSync as existsSync16, readFileSync as readFileSync20 } from "fs";
|
|
44167
|
+
import { join as join20 } from "path";
|
|
43970
44168
|
function readInstalledKitReadme(name) {
|
|
43971
44169
|
const root = getProjectRoot() ?? process.cwd();
|
|
43972
|
-
const kitDir =
|
|
43973
|
-
if (!
|
|
43974
|
-
const readme =
|
|
43975
|
-
return
|
|
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;
|
|
43976
44174
|
}
|
|
43977
44175
|
function slugify2(title) {
|
|
43978
44176
|
return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -44245,17 +44443,17 @@ var domainCommand = new Command("domain").description("Manage custom domains").a
|
|
|
44245
44443
|
}));
|
|
44246
44444
|
|
|
44247
44445
|
// src/commands/realtime.ts
|
|
44248
|
-
import { existsSync as
|
|
44249
|
-
import { dirname as
|
|
44446
|
+
import { existsSync as existsSync17 } from "fs";
|
|
44447
|
+
import { dirname as dirname13, resolve as resolve14 } from "path";
|
|
44250
44448
|
init_api();
|
|
44251
44449
|
init_config();
|
|
44252
44450
|
init_colors();
|
|
44253
44451
|
function hasDeployManifest() {
|
|
44254
44452
|
const cfgPath = getConfigPath();
|
|
44255
44453
|
if (!cfgPath) return false;
|
|
44256
|
-
return
|
|
44454
|
+
return existsSync17(resolve14(dirname13(cfgPath), "gipity.yaml"));
|
|
44257
44455
|
}
|
|
44258
|
-
var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").
|
|
44456
|
+
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 () => {
|
|
44259
44457
|
const config = requireConfig();
|
|
44260
44458
|
const base = `/projects/${config.projectGuid}/realtime-rooms`;
|
|
44261
44459
|
const sub = (action || "list").toLowerCase();
|
|
@@ -44662,21 +44860,21 @@ var locationCommand = new Command("location").description("Show location").argum
|
|
|
44662
44860
|
}));
|
|
44663
44861
|
|
|
44664
44862
|
// src/commands/doctor.ts
|
|
44665
|
-
import { existsSync as
|
|
44666
|
-
import { join as
|
|
44863
|
+
import { existsSync as existsSync19, readFileSync as readFileSync22, statSync as statSync9 } from "fs";
|
|
44864
|
+
import { join as join22, resolve as resolve15 } from "path";
|
|
44667
44865
|
import { homedir as homedir15 } from "os";
|
|
44668
44866
|
|
|
44669
44867
|
// src/updater/state.ts
|
|
44670
|
-
import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as
|
|
44671
|
-
import { join as
|
|
44868
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as existsSync18 } from "fs";
|
|
44869
|
+
import { join as join21 } from "path";
|
|
44672
44870
|
import { homedir as homedir14 } from "os";
|
|
44673
|
-
var GIPITY_DIR =
|
|
44674
|
-
var LOCAL_DIR =
|
|
44675
|
-
var LOCAL_PKG_DIR =
|
|
44676
|
-
var LOCAL_ENTRY =
|
|
44677
|
-
var STATE_FILE =
|
|
44678
|
-
var SETTINGS_FILE =
|
|
44679
|
-
var UPDATE_LOG =
|
|
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");
|
|
44680
44878
|
var DEFAULT_STATE = {
|
|
44681
44879
|
installedVersion: null,
|
|
44682
44880
|
lastCheckAt: 0,
|
|
@@ -44690,7 +44888,7 @@ function ensureDir() {
|
|
|
44690
44888
|
mkdirSync14(GIPITY_DIR, { recursive: true });
|
|
44691
44889
|
}
|
|
44692
44890
|
function readState() {
|
|
44693
|
-
if (!
|
|
44891
|
+
if (!existsSync18(STATE_FILE)) return { ...DEFAULT_STATE };
|
|
44694
44892
|
try {
|
|
44695
44893
|
return { ...DEFAULT_STATE, ...JSON.parse(readFileSync21(STATE_FILE, "utf-8")) };
|
|
44696
44894
|
} catch {
|
|
@@ -44702,7 +44900,7 @@ function writeState(state) {
|
|
|
44702
44900
|
writeFileSync14(STATE_FILE, JSON.stringify(state, null, 2));
|
|
44703
44901
|
}
|
|
44704
44902
|
function readSettings() {
|
|
44705
|
-
if (!
|
|
44903
|
+
if (!existsSync18(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
|
|
44706
44904
|
try {
|
|
44707
44905
|
return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync21(SETTINGS_FILE, "utf-8")) };
|
|
44708
44906
|
} catch {
|
|
@@ -44738,8 +44936,8 @@ function versionManagerNode(execPath, env = process.env, home = homedir15()) {
|
|
|
44738
44936
|
return null;
|
|
44739
44937
|
}
|
|
44740
44938
|
function localVersion() {
|
|
44741
|
-
const pkgPath =
|
|
44742
|
-
if (!
|
|
44939
|
+
const pkgPath = join22(LOCAL_PKG_DIR, "package.json");
|
|
44940
|
+
if (!existsSync19(pkgPath)) return null;
|
|
44743
44941
|
try {
|
|
44744
44942
|
return JSON.parse(readFileSync22(pkgPath, "utf-8")).version ?? null;
|
|
44745
44943
|
} catch {
|
|
@@ -44764,7 +44962,7 @@ function rel(t) {
|
|
|
44764
44962
|
}
|
|
44765
44963
|
function relayAutostartInstalled() {
|
|
44766
44964
|
try {
|
|
44767
|
-
return
|
|
44965
|
+
return existsSync19(planFor({ cliPath: resolveCliPath() }).path);
|
|
44768
44966
|
} catch (err) {
|
|
44769
44967
|
if (err instanceof UnsupportedPlatformError) return null;
|
|
44770
44968
|
return null;
|
|
@@ -44802,7 +45000,7 @@ function gatherEnv(opts = {}) {
|
|
|
44802
45000
|
const cli = {
|
|
44803
45001
|
shim_version: shimVersion(),
|
|
44804
45002
|
local_version: localVersion(),
|
|
44805
|
-
local_install_ok:
|
|
45003
|
+
local_install_ok: existsSync19(LOCAL_ENTRY),
|
|
44806
45004
|
auto_updates: !dis.disabled,
|
|
44807
45005
|
updates_disabled_reason: dis.disabled ? dis.reason ?? null : null,
|
|
44808
45006
|
last_check_at: updState.lastCheckAt,
|
|
@@ -44832,7 +45030,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44832
45030
|
console.log(`${muted("claude code ")} installed ${yn(env.claude.installed)} \xB7 authenticated ${yn(env.claude.authenticated)}`);
|
|
44833
45031
|
const autostartLabel = env.relay.autostart === null ? muted("n/a") : yn(env.relay.autostart);
|
|
44834
45032
|
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})`) : ""}`);
|
|
44835
|
-
if (
|
|
45033
|
+
if (existsSync19(resolve15(process.cwd(), ".codex", "hooks.json"))) {
|
|
44836
45034
|
console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
|
|
44837
45035
|
}
|
|
44838
45036
|
console.log(`${muted("ready ")} ${env.ready ? success("yes") : warning("no - run `gipity build` (or the desktop app) to finish setup")}`);
|
|
@@ -44840,7 +45038,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44840
45038
|
const settings = readSettings();
|
|
44841
45039
|
const dis = updatesDisabled();
|
|
44842
45040
|
const local = localVersion();
|
|
44843
|
-
const localOk =
|
|
45041
|
+
const localOk = existsSync19(LOCAL_ENTRY);
|
|
44844
45042
|
console.log("");
|
|
44845
45043
|
console.log(bold("CLI install"));
|
|
44846
45044
|
console.log(`${muted("shim version ")} ${shimVersion()}`);
|
|
@@ -44848,11 +45046,11 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44848
45046
|
console.log(`${muted("local install ")} ${LOCAL_PKG_DIR}`);
|
|
44849
45047
|
console.log("");
|
|
44850
45048
|
console.log(`${muted("auto-updates ")} ${dis.disabled ? warning(`disabled (${dis.reason})`) : success("enabled")}`);
|
|
44851
|
-
console.log(`${muted("settings file ")} ${
|
|
45049
|
+
console.log(`${muted("settings file ")} ${existsSync19(SETTINGS_FILE) ? SETTINGS_FILE : dim("(default)")} autoUpdates=${settings.autoUpdates}`);
|
|
44852
45050
|
console.log(`${muted("last check ")} ${rel(state.lastCheckAt)}`);
|
|
44853
45051
|
console.log(`${muted("last error ")} ${state.lastError ? error(state.lastError) : dim("none")}`);
|
|
44854
|
-
console.log(`${muted("state file ")} ${
|
|
44855
|
-
console.log(`${muted("update log ")} ${
|
|
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)")}`);
|
|
44856
45054
|
console.log("");
|
|
44857
45055
|
console.log(dim("Force an update with: gipity update"));
|
|
44858
45056
|
});
|
|
@@ -44861,10 +45059,10 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44861
45059
|
import { appendFileSync } from "fs";
|
|
44862
45060
|
|
|
44863
45061
|
// src/updater/install.ts
|
|
44864
|
-
import { existsSync as
|
|
44865
|
-
import { dirname as
|
|
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";
|
|
44866
45064
|
init_platform();
|
|
44867
|
-
var UPDATE_LOCK =
|
|
45065
|
+
var UPDATE_LOCK = join23(GIPITY_DIR, "update.lock");
|
|
44868
45066
|
var LOCK_STALE_MS2 = 10 * 60 * 1e3;
|
|
44869
45067
|
function npmInstallGipity(version) {
|
|
44870
45068
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
@@ -44873,7 +45071,7 @@ function npmInstallGipity(version) {
|
|
|
44873
45071
|
encoding: "utf-8"
|
|
44874
45072
|
});
|
|
44875
45073
|
return {
|
|
44876
|
-
ok: res.status === 0 &&
|
|
45074
|
+
ok: res.status === 0 && existsSync20(LOCAL_ENTRY),
|
|
44877
45075
|
status: res.status,
|
|
44878
45076
|
stderr: (res.stderr || "").toString(),
|
|
44879
45077
|
spawnError: res.error
|
|
@@ -44885,12 +45083,12 @@ function isWedged(stderr) {
|
|
|
44885
45083
|
}
|
|
44886
45084
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
44887
45085
|
mkdirSync15(dir, { recursive: true });
|
|
44888
|
-
rmSync2(
|
|
44889
|
-
rmSync2(
|
|
44890
|
-
writeFileSync15(
|
|
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));
|
|
44891
45089
|
}
|
|
44892
45090
|
function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
44893
|
-
mkdirSync15(
|
|
45091
|
+
mkdirSync15(dirname14(lockPath2), { recursive: true });
|
|
44894
45092
|
try {
|
|
44895
45093
|
writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
|
|
44896
45094
|
return true;
|
|
@@ -45031,7 +45229,7 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
|
|
|
45031
45229
|
console.log("");
|
|
45032
45230
|
if (result.updated) {
|
|
45033
45231
|
console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
|
|
45034
|
-
console.log(dim(
|
|
45232
|
+
console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
|
|
45035
45233
|
} else if (result.reason === "up-to-date") {
|
|
45036
45234
|
console.log(success("Already on the latest version."));
|
|
45037
45235
|
} else {
|
|
@@ -45047,17 +45245,17 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
|
|
|
45047
45245
|
init_api();
|
|
45048
45246
|
init_utils();
|
|
45049
45247
|
init_colors();
|
|
45050
|
-
import { existsSync as
|
|
45248
|
+
import { existsSync as existsSync23, readFileSync as readFileSync25, unlinkSync as unlinkSync8 } from "fs";
|
|
45051
45249
|
import { spawn as spawn2 } from "child_process";
|
|
45052
45250
|
|
|
45053
45251
|
// src/relay/daemon.ts
|
|
45054
45252
|
init_platform();
|
|
45055
45253
|
init_config();
|
|
45056
|
-
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync17, existsSync as
|
|
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";
|
|
45057
45255
|
import { stat, readFile } from "fs/promises";
|
|
45058
45256
|
import { createInterface as createInterface2 } from "readline";
|
|
45059
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";
|
|
45060
|
-
import { join as
|
|
45258
|
+
import { join as join26 } from "path";
|
|
45061
45259
|
init_setup();
|
|
45062
45260
|
init_auth();
|
|
45063
45261
|
init_api();
|
|
@@ -45684,11 +45882,11 @@ var DeltaAccumulator = class {
|
|
|
45684
45882
|
return [];
|
|
45685
45883
|
}
|
|
45686
45884
|
emitUpTo(messageId, idx, b7, closing) {
|
|
45687
|
-
const
|
|
45688
|
-
if (!closing && PEM_BEGIN.test(
|
|
45689
|
-
const tailBoundary = safeEmitBoundary(
|
|
45885
|
+
const tail2 = b7.raw.slice(b7.rawEmitted);
|
|
45886
|
+
if (!closing && PEM_BEGIN.test(tail2) && !PEM_END.test(tail2)) return [];
|
|
45887
|
+
const tailBoundary = safeEmitBoundary(tail2, closing);
|
|
45690
45888
|
if (tailBoundary <= 0) return [];
|
|
45691
|
-
const span =
|
|
45889
|
+
const span = tail2.slice(0, tailBoundary);
|
|
45692
45890
|
const boundary = b7.rawEmitted + tailBoundary;
|
|
45693
45891
|
b7.rawEmitted = boundary;
|
|
45694
45892
|
const scrubbed = redactString(span, this.getSecrets());
|
|
@@ -45816,7 +46014,7 @@ init_client_context();
|
|
|
45816
46014
|
init_agents();
|
|
45817
46015
|
import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as homedir16 } from "os";
|
|
45818
46016
|
import { statfsSync, readdirSync as readdirSync9 } from "fs";
|
|
45819
|
-
import { join as
|
|
46017
|
+
import { join as join24 } from "path";
|
|
45820
46018
|
var PROBE_TIMEOUT_MS = 4e3;
|
|
45821
46019
|
function parseVersion(out) {
|
|
45822
46020
|
const m = out.match(/\d+\.\d+(?:\.\d+)?(?:[-.\w]*)?/);
|
|
@@ -45883,7 +46081,7 @@ async function detectGpu() {
|
|
|
45883
46081
|
function diskUsage() {
|
|
45884
46082
|
try {
|
|
45885
46083
|
if (typeof statfsSync !== "function") return void 0;
|
|
45886
|
-
const st2 = statfsSync(
|
|
46084
|
+
const st2 = statfsSync(join24(homedir16(), "GipityProjects"), { bigint: false });
|
|
45887
46085
|
if (!st2 || !st2.bsize) return void 0;
|
|
45888
46086
|
return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
|
|
45889
46087
|
} catch {
|
|
@@ -45897,7 +46095,7 @@ function diskUsage() {
|
|
|
45897
46095
|
}
|
|
45898
46096
|
function localProjectCount() {
|
|
45899
46097
|
try {
|
|
45900
|
-
return readdirSync9(
|
|
46098
|
+
return readdirSync9(join24(homedir16(), "GipityProjects"), { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).length;
|
|
45901
46099
|
} catch {
|
|
45902
46100
|
return void 0;
|
|
45903
46101
|
}
|
|
@@ -45944,6 +46142,149 @@ function safe(fn) {
|
|
|
45944
46142
|
}
|
|
45945
46143
|
}
|
|
45946
46144
|
|
|
46145
|
+
// src/relay/agent-updates.ts
|
|
46146
|
+
init_agents();
|
|
46147
|
+
init_platform();
|
|
46148
|
+
var UPDATE_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_AGENT_UPDATE_TIMEOUT_MS || String(5 * 6e4), 10);
|
|
46149
|
+
var PROBE_TIMEOUT_MS2 = 4e3;
|
|
46150
|
+
var REGISTRY_TIMEOUT_MS = 1e4;
|
|
46151
|
+
var UPDATE_STUB = process.env.GIPITY_RELAY_AGENT_UPDATE_STUB;
|
|
46152
|
+
function stubAdapters(stub) {
|
|
46153
|
+
return [{
|
|
46154
|
+
source: "stub_agent",
|
|
46155
|
+
binary: stub,
|
|
46156
|
+
updatePlan: () => ({ argv: [stub, "update"], label: "stub" })
|
|
46157
|
+
}];
|
|
46158
|
+
}
|
|
46159
|
+
var inProgress = false;
|
|
46160
|
+
function agentUpdateInProgress() {
|
|
46161
|
+
return inProgress;
|
|
46162
|
+
}
|
|
46163
|
+
function execCapture(argv2, timeoutMs, signal) {
|
|
46164
|
+
return new Promise((resolve19) => {
|
|
46165
|
+
let output = "";
|
|
46166
|
+
let settled = false;
|
|
46167
|
+
const done = (ok) => {
|
|
46168
|
+
if (!settled) {
|
|
46169
|
+
settled = true;
|
|
46170
|
+
resolve19({ ok, output });
|
|
46171
|
+
}
|
|
46172
|
+
};
|
|
46173
|
+
let child;
|
|
46174
|
+
try {
|
|
46175
|
+
child = spawnCommand(resolveCommand(argv2[0]), argv2.slice(1), { stdio: ["ignore", "pipe", "pipe"] });
|
|
46176
|
+
} catch (err) {
|
|
46177
|
+
output = err?.message ?? "spawn failed";
|
|
46178
|
+
return done(false);
|
|
46179
|
+
}
|
|
46180
|
+
const kill = () => {
|
|
46181
|
+
try {
|
|
46182
|
+
child.kill("SIGKILL");
|
|
46183
|
+
} catch {
|
|
46184
|
+
}
|
|
46185
|
+
};
|
|
46186
|
+
const timer = setTimeout(() => {
|
|
46187
|
+
output += "\n[timed out]";
|
|
46188
|
+
kill();
|
|
46189
|
+
}, timeoutMs);
|
|
46190
|
+
signal?.addEventListener("abort", kill, { once: true });
|
|
46191
|
+
child.stdout?.on("data", (d) => {
|
|
46192
|
+
output += d.toString();
|
|
46193
|
+
});
|
|
46194
|
+
child.stderr?.on("data", (d) => {
|
|
46195
|
+
output += d.toString();
|
|
46196
|
+
});
|
|
46197
|
+
child.on("error", (err) => {
|
|
46198
|
+
clearTimeout(timer);
|
|
46199
|
+
output += `
|
|
46200
|
+
${err.message}`;
|
|
46201
|
+
done(false);
|
|
46202
|
+
});
|
|
46203
|
+
child.on("close", (code) => {
|
|
46204
|
+
clearTimeout(timer);
|
|
46205
|
+
done(code === 0);
|
|
46206
|
+
});
|
|
46207
|
+
});
|
|
46208
|
+
}
|
|
46209
|
+
async function defaultProbeVersion(binary) {
|
|
46210
|
+
const r = await execCapture([binary, "--version"], PROBE_TIMEOUT_MS2);
|
|
46211
|
+
return parseVersion(r.output);
|
|
46212
|
+
}
|
|
46213
|
+
async function defaultFetchLatest(pkg2) {
|
|
46214
|
+
try {
|
|
46215
|
+
const res = await fetch(`https://registry.npmjs.org/${pkg2}/latest`, {
|
|
46216
|
+
headers: { accept: "application/json" },
|
|
46217
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS)
|
|
46218
|
+
});
|
|
46219
|
+
if (!res.ok) return null;
|
|
46220
|
+
const json = await res.json();
|
|
46221
|
+
return typeof json.version === "string" ? json.version : null;
|
|
46222
|
+
} catch {
|
|
46223
|
+
return null;
|
|
46224
|
+
}
|
|
46225
|
+
}
|
|
46226
|
+
var tail = (s) => s.trim().slice(-300).replace(/\s+/g, " ");
|
|
46227
|
+
async function runAgentUpdates(opts, deps = {}) {
|
|
46228
|
+
const adapters = deps.adapters ?? (UPDATE_STUB ? stubAdapters(UPDATE_STUB) : AGENT_ADAPTERS);
|
|
46229
|
+
const exec = deps.exec ?? execCapture;
|
|
46230
|
+
const probe = deps.probeVersion ?? defaultProbeVersion;
|
|
46231
|
+
const fetchLatest = deps.fetchLatest ?? defaultFetchLatest;
|
|
46232
|
+
const results = [];
|
|
46233
|
+
inProgress = true;
|
|
46234
|
+
try {
|
|
46235
|
+
for (const adapter of adapters) {
|
|
46236
|
+
const source = adapter.source;
|
|
46237
|
+
if (opts.signal?.aborted) {
|
|
46238
|
+
results.push({ source, status: "skipped", detail: "daemon shutting down" });
|
|
46239
|
+
continue;
|
|
46240
|
+
}
|
|
46241
|
+
let plan2;
|
|
46242
|
+
try {
|
|
46243
|
+
plan2 = adapter.updatePlan?.();
|
|
46244
|
+
} catch {
|
|
46245
|
+
plan2 = null;
|
|
46246
|
+
}
|
|
46247
|
+
if (!plan2) {
|
|
46248
|
+
results.push({ source, status: "skipped", detail: "no unattended update path" });
|
|
46249
|
+
continue;
|
|
46250
|
+
}
|
|
46251
|
+
if (opts.busy?.()) {
|
|
46252
|
+
results.push({ source, status: "skipped", detail: "dispatch in flight" });
|
|
46253
|
+
continue;
|
|
46254
|
+
}
|
|
46255
|
+
const before = await probe(adapter.binary);
|
|
46256
|
+
if (plan2.pkg && before) {
|
|
46257
|
+
const latest = await fetchLatest(plan2.pkg);
|
|
46258
|
+
if (!latest) {
|
|
46259
|
+
results.push({ source, status: "skipped", from: before, detail: "registry check failed" });
|
|
46260
|
+
continue;
|
|
46261
|
+
}
|
|
46262
|
+
if (compareSemver(latest, before) <= 0) {
|
|
46263
|
+
results.push({ source, status: "current", from: before });
|
|
46264
|
+
opts.log("debug", `agent up-to-date: ${source} ${before}`);
|
|
46265
|
+
continue;
|
|
46266
|
+
}
|
|
46267
|
+
}
|
|
46268
|
+
opts.log("info", `agent update starting: ${source} via ${plan2.label}`, { from: before ?? "unknown" });
|
|
46269
|
+
const res = await exec(plan2.argv, UPDATE_TIMEOUT_MS, opts.signal);
|
|
46270
|
+
const after = await probe(adapter.binary);
|
|
46271
|
+
if (!res.ok) {
|
|
46272
|
+
results.push({ source, status: "failed", from: before, to: after, detail: tail(res.output) });
|
|
46273
|
+
opts.log("warn", `agent update failed: ${source}`, { detail: tail(res.output) });
|
|
46274
|
+
} else if (after && after !== before) {
|
|
46275
|
+
results.push({ source, status: "updated", from: before, to: after });
|
|
46276
|
+
opts.log("info", `agent updated: ${source} ${before ?? "unknown"} -> ${after}`);
|
|
46277
|
+
} else {
|
|
46278
|
+
results.push({ source, status: "current", from: before, to: after });
|
|
46279
|
+
opts.log("debug", `agent up-to-date: ${source} ${after ?? "unknown"}`);
|
|
46280
|
+
}
|
|
46281
|
+
}
|
|
46282
|
+
} finally {
|
|
46283
|
+
inProgress = false;
|
|
46284
|
+
}
|
|
46285
|
+
return results;
|
|
46286
|
+
}
|
|
46287
|
+
|
|
45947
46288
|
// src/relay/session-pool.ts
|
|
45948
46289
|
function userMessage(text) {
|
|
45949
46290
|
return {
|
|
@@ -46206,7 +46547,7 @@ var SessionPool = class {
|
|
|
46206
46547
|
init_config();
|
|
46207
46548
|
init_api();
|
|
46208
46549
|
init_agents();
|
|
46209
|
-
var RELAY_LOG_PATH =
|
|
46550
|
+
var RELAY_LOG_PATH = join26(homedir17(), ".gipity", "relay.log");
|
|
46210
46551
|
var HEARTBEAT_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_HEARTBEAT_MS || "60000", 10);
|
|
46211
46552
|
var DIAGNOSTICS_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_DIAGNOSTICS_MS || String(24 * 60 * 60 * 1e3), 10);
|
|
46212
46553
|
var LONG_POLL_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_POLL_TIMEOUT_MS || "35000", 10);
|
|
@@ -46306,7 +46647,7 @@ function lockLogPerms(dir, file) {
|
|
|
46306
46647
|
chmodSync3(dir, 448);
|
|
46307
46648
|
} catch {
|
|
46308
46649
|
}
|
|
46309
|
-
if (!
|
|
46650
|
+
if (!existsSync22(file)) {
|
|
46310
46651
|
try {
|
|
46311
46652
|
closeSync4(openSync4(file, "a", 384));
|
|
46312
46653
|
} catch {
|
|
@@ -46323,7 +46664,7 @@ function log2(level, msg, extra) {
|
|
|
46323
46664
|
const pretty = `${C7.dim(hhmmss())} ${badge(level)} ${C7.bold(msg)}${formatExtra(extra)}`;
|
|
46324
46665
|
process.stderr.write(pretty + "\n");
|
|
46325
46666
|
try {
|
|
46326
|
-
const dir =
|
|
46667
|
+
const dir = join26(homedir17(), ".gipity");
|
|
46327
46668
|
mkdirSync17(dir, { recursive: true });
|
|
46328
46669
|
lockLogPerms(dir, RELAY_LOG_PATH);
|
|
46329
46670
|
const json = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level, msg, ...extra ?? {} });
|
|
@@ -46403,14 +46744,41 @@ async function heartbeatLoop(ctx) {
|
|
|
46403
46744
|
let backoff = 0;
|
|
46404
46745
|
let sessionWarnLogged = false;
|
|
46405
46746
|
let lastDiagnosticsAt = 0;
|
|
46747
|
+
let lastAgentUpdateAt = 0;
|
|
46748
|
+
let agentUpdatePass = null;
|
|
46749
|
+
let diagnosticsRefreshNeeded = false;
|
|
46406
46750
|
while (!ctx.abort.signal.aborted) {
|
|
46407
46751
|
try {
|
|
46752
|
+
if (!agentUpdatePass && agentUpdatesEnabled() && Date.now() - lastAgentUpdateAt >= DIAGNOSTICS_INTERVAL_MS) {
|
|
46753
|
+
if (getRunningDispatchGuids().length > 0) {
|
|
46754
|
+
log2("debug", "agent updates deferred - dispatches in flight");
|
|
46755
|
+
} else {
|
|
46756
|
+
agentUpdatePass = runAgentUpdates({
|
|
46757
|
+
log: log2,
|
|
46758
|
+
busy: () => getRunningDispatchGuids().length > 0,
|
|
46759
|
+
signal: ctx.abort.signal
|
|
46760
|
+
}).then((results) => {
|
|
46761
|
+
lastAgentUpdateAt = Date.now();
|
|
46762
|
+
if (results.some((r7) => r7.status === "updated")) {
|
|
46763
|
+
diagnosticsRefreshNeeded = true;
|
|
46764
|
+
pokeHeartbeat();
|
|
46765
|
+
}
|
|
46766
|
+
}).catch((err) => {
|
|
46767
|
+
lastAgentUpdateAt = Date.now();
|
|
46768
|
+
log2("warn", "agent update pass failed", { err: err?.message });
|
|
46769
|
+
}).finally(() => {
|
|
46770
|
+
agentUpdatePass = null;
|
|
46771
|
+
});
|
|
46772
|
+
}
|
|
46773
|
+
}
|
|
46408
46774
|
let body = {};
|
|
46409
|
-
if (diagnosticsConsented() && Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS) {
|
|
46775
|
+
if (diagnosticsConsented() && (diagnosticsRefreshNeeded || Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS)) {
|
|
46776
|
+
diagnosticsRefreshNeeded = false;
|
|
46410
46777
|
try {
|
|
46411
46778
|
body = { diagnostics: await collectDiagnostics() };
|
|
46412
46779
|
lastDiagnosticsAt = Date.now();
|
|
46413
46780
|
} catch (err) {
|
|
46781
|
+
diagnosticsRefreshNeeded = true;
|
|
46414
46782
|
log2("debug", "diagnostics collection failed", { err: err?.message });
|
|
46415
46783
|
}
|
|
46416
46784
|
}
|
|
@@ -46509,6 +46877,10 @@ async function dispatchLoop(ctx, opts) {
|
|
|
46509
46877
|
}
|
|
46510
46878
|
await waitForSlot();
|
|
46511
46879
|
if (ctx.abort.signal.aborted) break;
|
|
46880
|
+
while (agentUpdateInProgress() && !ctx.abort.signal.aborted) {
|
|
46881
|
+
await sleep4(1e3, ctx.abort.signal);
|
|
46882
|
+
}
|
|
46883
|
+
if (ctx.abort.signal.aborted) break;
|
|
46512
46884
|
try {
|
|
46513
46885
|
const r = await deviceFetch("GET", "/remote-devices/next", void 0, LONG_POLL_TIMEOUT_MS, ctx.abort.signal);
|
|
46514
46886
|
if (r.status === 401) {
|
|
@@ -46724,7 +47096,7 @@ function isSafeSessionId(s) {
|
|
|
46724
47096
|
function transcriptPathFor(cwd, sessionId) {
|
|
46725
47097
|
if (!isSafeSessionId(sessionId)) return null;
|
|
46726
47098
|
const slug = cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
46727
|
-
return
|
|
47099
|
+
return join26(homedir17(), ".claude", "projects", slug, `${sessionId}.jsonl`);
|
|
46728
47100
|
}
|
|
46729
47101
|
function formatDuration(ms2) {
|
|
46730
47102
|
const totalSec = ms2 / 1e3;
|
|
@@ -46936,8 +47308,8 @@ async function handleDispatch(claimed) {
|
|
|
46936
47308
|
}
|
|
46937
47309
|
}
|
|
46938
47310
|
const stderrNote = stderrTail ? `: ${stderrTail.slice(0, 300)}` : "";
|
|
46939
|
-
const
|
|
46940
|
-
pushSystem(`Claude Code ${
|
|
47311
|
+
const tail2 = runtimeLimit ? `stopped after ${dur} (runtime limit)` : killed ? `cancelled (${dur})` : spawnErr ? `failed (${dur}: ${spawnErr})` : exitCode === 0 ? `finished (${dur})` : `failed (${dur}, exit ${exitCode}${stderrNote})`;
|
|
47312
|
+
pushSystem(`Claude Code ${tail2}`);
|
|
46941
47313
|
await flushQueue();
|
|
46942
47314
|
const metrics = startupMs !== void 0 ? { startup_ms: startupMs } : void 0;
|
|
46943
47315
|
if (runtimeLimit) {
|
|
@@ -46994,8 +47366,8 @@ async function handleNonClaudeDispatch(adapter, d, cwd, queue, pushSystem, flush
|
|
|
46994
47366
|
}
|
|
46995
47367
|
}
|
|
46996
47368
|
const stderrNote = stderrTail ? `: ${stderrTail.slice(0, 300)}` : "";
|
|
46997
|
-
const
|
|
46998
|
-
pushSystem(`${adapter.displayName} ${
|
|
47369
|
+
const tail2 = runtimeLimit ? `stopped after ${dur} (runtime limit)` : killed ? `cancelled (${dur})` : spawnErr ? `failed (${dur}: ${spawnErr})` : exitCode === 0 ? `finished (${dur})` : `failed (${dur}, exit ${exitCode}${stderrNote})`;
|
|
47370
|
+
pushSystem(`${adapter.displayName} ${tail2}`);
|
|
46999
47371
|
await flushQueue();
|
|
47000
47372
|
if (runtimeLimit) {
|
|
47001
47373
|
await ack(d.short_guid, "error", `${adapter.displayName} stopped after ${dur} (runtime limit)`);
|
|
@@ -47178,9 +47550,9 @@ async function resolveCwdForProject(d) {
|
|
|
47178
47550
|
throw new Error(`Invalid project slug: ${JSON.stringify(d.project_slug)}`);
|
|
47179
47551
|
}
|
|
47180
47552
|
const root = getProjectsRoot();
|
|
47181
|
-
const path5 =
|
|
47182
|
-
const configPath =
|
|
47183
|
-
if (
|
|
47553
|
+
const path5 = join26(root, d.project_slug);
|
|
47554
|
+
const configPath = join26(path5, ".gipity.json");
|
|
47555
|
+
if (existsSync22(configPath)) {
|
|
47184
47556
|
try {
|
|
47185
47557
|
const cfg = JSON.parse(readFileSync24(configPath, "utf-8"));
|
|
47186
47558
|
if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
|
|
@@ -47317,7 +47689,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
|
|
|
47317
47689
|
} catch {
|
|
47318
47690
|
}
|
|
47319
47691
|
try {
|
|
47320
|
-
unlinkSync7(
|
|
47692
|
+
unlinkSync7(join26(cwd, ".gipity", "sync.lock"));
|
|
47321
47693
|
} catch {
|
|
47322
47694
|
}
|
|
47323
47695
|
finish(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s`)));
|
|
@@ -47754,7 +48126,7 @@ relayCommand.command("run").description("Run the background service").option("-v
|
|
|
47754
48126
|
});
|
|
47755
48127
|
relayCommand.command("stop").description("Stop the background service").option("--force", "Force-stop if it doesn't exit cleanly within 5s").action(async (opts) => {
|
|
47756
48128
|
const pidPath = getDaemonPidPath();
|
|
47757
|
-
if (!
|
|
48129
|
+
if (!existsSync23(pidPath)) {
|
|
47758
48130
|
console.log(muted("Background service isn't running."));
|
|
47759
48131
|
return;
|
|
47760
48132
|
}
|
|
@@ -47840,6 +48212,30 @@ relayCommand.command("diagnostics [state]").description("View or set sharing of
|
|
|
47840
48212
|
setDiagnosticsConsent(on2);
|
|
47841
48213
|
console.log(on2 ? `${success("Diagnostics sharing on.")} ${muted("Reported on the next daily heartbeat.")}` : `${success("Diagnostics sharing off.")} ${muted("No host/version data will be sent.")}`);
|
|
47842
48214
|
});
|
|
48215
|
+
relayCommand.command("updates [state]").description("View or set daily auto-update of installed coding agents (on|off)").action((arg) => {
|
|
48216
|
+
if (arg === void 0) {
|
|
48217
|
+
const stored = getAgentUpdatesPref();
|
|
48218
|
+
const effective = agentUpdatesEnabled();
|
|
48219
|
+
const label2 = stored === void 0 ? "on (default, not yet chosen)" : stored ? "on" : "off";
|
|
48220
|
+
console.log(`Agent auto-updates: ${effective ? success(label2) : muted(label2)}`);
|
|
48221
|
+
if (!effective && stored !== false) {
|
|
48222
|
+
console.log(muted(" (overridden off by DISABLE_AUTOUPDATER / GIPITY_RELAY_AGENT_UPDATES / CI)"));
|
|
48223
|
+
}
|
|
48224
|
+
console.log(muted(" Once a day, while idle, the relay brings its coding agents (Claude Code, Codex) to the latest release."));
|
|
48225
|
+
console.log(muted(" Upgrades appear in `gipity relay log` and in the device diagnostics on the web."));
|
|
48226
|
+
console.log(muted(" Set with `gipity relay updates on` / `gipity relay updates off`."));
|
|
48227
|
+
return;
|
|
48228
|
+
}
|
|
48229
|
+
const on2 = /^(on|true|yes|1|enable)$/i.test(arg);
|
|
48230
|
+
const off = /^(off|false|no|0|disable)$/i.test(arg);
|
|
48231
|
+
if (!on2 && !off) {
|
|
48232
|
+
console.log(error("Expected 'on' or 'off'."));
|
|
48233
|
+
process.exitCode = 1;
|
|
48234
|
+
return;
|
|
48235
|
+
}
|
|
48236
|
+
setAgentUpdatesPref(on2);
|
|
48237
|
+
console.log(on2 ? `${success("Agent auto-updates on.")} ${muted("Runs on the relay daemon's next daily maintenance tick.")}` : `${success("Agent auto-updates off.")} ${muted("Installed agents only change when you update them yourself.")}`);
|
|
48238
|
+
});
|
|
47843
48239
|
relayCommand.command("rename <new-name>").description("Rename this device").action(async (newName) => {
|
|
47844
48240
|
const device = requirePaired2();
|
|
47845
48241
|
const name = newName.trim();
|
|
@@ -47882,7 +48278,7 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
47882
48278
|
} catch {
|
|
47883
48279
|
}
|
|
47884
48280
|
const pidPath = getDaemonPidPath();
|
|
47885
|
-
if (
|
|
48281
|
+
if (existsSync23(pidPath)) {
|
|
47886
48282
|
const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
|
|
47887
48283
|
if (pid && !isNaN(pid)) {
|
|
47888
48284
|
try {
|
|
@@ -47896,15 +48292,15 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
47896
48292
|
});
|
|
47897
48293
|
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) => {
|
|
47898
48294
|
const path5 = RELAY_LOG_PATH;
|
|
47899
|
-
if (!
|
|
48295
|
+
if (!existsSync23(path5)) {
|
|
47900
48296
|
console.log(muted("No log file yet. Start the service with `gipity relay run` (or install it)."));
|
|
47901
48297
|
return;
|
|
47902
48298
|
}
|
|
47903
48299
|
const lines = parseInt(opts.lines, 10) || 100;
|
|
47904
48300
|
try {
|
|
47905
48301
|
const all = readFileSync25(path5, "utf-8").split("\n");
|
|
47906
|
-
const
|
|
47907
|
-
process.stdout.write(
|
|
48302
|
+
const tail2 = all.slice(-lines - 1).join("\n");
|
|
48303
|
+
process.stdout.write(tail2);
|
|
47908
48304
|
} catch (err) {
|
|
47909
48305
|
console.error(error(`Could not read log: ${err?.message || err}`));
|
|
47910
48306
|
process.exit(1);
|
|
@@ -47973,17 +48369,17 @@ init_api();
|
|
|
47973
48369
|
init_auth();
|
|
47974
48370
|
init_utils();
|
|
47975
48371
|
init_colors();
|
|
47976
|
-
import { existsSync as
|
|
48372
|
+
import { existsSync as existsSync24, rmSync as rmSync4, unlinkSync as unlinkSync9, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "fs";
|
|
47977
48373
|
import { homedir as homedir18, platform as osPlatform4 } from "os";
|
|
47978
|
-
import { join as
|
|
48374
|
+
import { join as join27, resolve as resolve17 } from "path";
|
|
47979
48375
|
init_agents();
|
|
47980
48376
|
function removeInstallerPathLines() {
|
|
47981
48377
|
if (osPlatform4() === "win32") return [];
|
|
47982
48378
|
const marker = "# Added by the Gipity installer";
|
|
47983
48379
|
const touched = [];
|
|
47984
48380
|
for (const name of [".bashrc", ".zshrc", ".profile"]) {
|
|
47985
|
-
const rc2 =
|
|
47986
|
-
if (!
|
|
48381
|
+
const rc2 = join27(homedir18(), name);
|
|
48382
|
+
if (!existsSync24(rc2)) continue;
|
|
47987
48383
|
let text;
|
|
47988
48384
|
try {
|
|
47989
48385
|
text = readFileSync26(rc2, "utf-8");
|
|
@@ -48042,7 +48438,7 @@ function removeServiceUnit() {
|
|
|
48042
48438
|
const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio: "ignore" });
|
|
48043
48439
|
if (r.status !== 0) allOk = false;
|
|
48044
48440
|
}
|
|
48045
|
-
if (
|
|
48441
|
+
if (existsSync24(plan2.path)) {
|
|
48046
48442
|
try {
|
|
48047
48443
|
unlinkSync9(plan2.path);
|
|
48048
48444
|
} catch {
|
|
@@ -48065,9 +48461,9 @@ async function revokeDeviceBestEffort() {
|
|
|
48065
48461
|
}
|
|
48066
48462
|
var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
|
|
48067
48463
|
const autoYes = opts.yes || getAutoConfirm();
|
|
48068
|
-
const gipityDir =
|
|
48069
|
-
const launcherBin =
|
|
48070
|
-
const installedViaLauncher =
|
|
48464
|
+
const gipityDir = join27(homedir18(), ".gipity");
|
|
48465
|
+
const launcherBin = join27(gipityDir, "launcher", "bin", "gipity");
|
|
48466
|
+
const installedViaLauncher = existsSync24(launcherBin);
|
|
48071
48467
|
console.log(`${bold("Gipity uninstall")} - this will:`);
|
|
48072
48468
|
console.log(`\u2022 Stop the running relay daemon (if any)`);
|
|
48073
48469
|
console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
|
|
@@ -48108,7 +48504,7 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
|
|
|
48108
48504
|
if (!anyAgentIntegration) {
|
|
48109
48505
|
console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
|
|
48110
48506
|
}
|
|
48111
|
-
if (
|
|
48507
|
+
if (existsSync24(gipityDir)) {
|
|
48112
48508
|
try {
|
|
48113
48509
|
rmSync4(gipityDir, { recursive: true, force: true });
|
|
48114
48510
|
console.log(`${success(`Removed ${gipityDir}/`)}`);
|
|
@@ -48150,7 +48546,7 @@ function keyToIndex(key) {
|
|
|
48150
48546
|
return code >= 0 && code < 26 ? code : -1;
|
|
48151
48547
|
}
|
|
48152
48548
|
var approvalCommand = new Command("approval").description("Manage approvals");
|
|
48153
|
-
approvalCommand.command("list").description("List pending approvals").
|
|
48549
|
+
approvalCommand.command("list").description("List pending approvals").addOption(new Option("--status <status>", "Filter by status").choices(["pending", "approved", "denied", "cancelled", "expired", "all"]).default("pending")).option("--json", "Output as JSON").action((opts) => run("List", async () => {
|
|
48154
48550
|
const res = await get(`/approvals?status=${encodeURIComponent(opts.status)}`);
|
|
48155
48551
|
printList(
|
|
48156
48552
|
res.data,
|
|
@@ -48159,7 +48555,7 @@ approvalCommand.command("list").description("List pending approvals").option("--
|
|
|
48159
48555
|
(a) => `${a.guid} ${a.title} ${muted(`[${a.status}] ${timeAgo(a.created_at)}`)}`
|
|
48160
48556
|
);
|
|
48161
48557
|
}));
|
|
48162
|
-
approvalCommand.command("create <title...>").description("Create a pending approval").option("--description <text>", "Detailed context").
|
|
48558
|
+
approvalCommand.command("create <title...>").description("Create a pending approval").option("--description <text>", "Detailed context").addOption(new Option("--type <type>", "Approval type").choices(["yes_no", "choice", "text"]).default("yes_no")).option("--choices <a,b,c>", "Comma-separated options (for --type choice)").option("--prompt <text>", "Custom prompt shown to the user").option("--expires-in <minutes>", "Minutes until expiry (default: 10080 = 7d)").option("--json", "Output as JSON").action((titleParts, opts) => run("Create", async () => {
|
|
48163
48559
|
const body = { title: titleParts.join(" ") };
|
|
48164
48560
|
if (opts.description) body.description = opts.description;
|
|
48165
48561
|
if (opts.type) body.response_type = opts.type;
|
|
@@ -48636,7 +49032,7 @@ function collectRealFlags(argv2, program3) {
|
|
|
48636
49032
|
|
|
48637
49033
|
// src/trace.ts
|
|
48638
49034
|
import { openSync as openSync5, writeSync, mkdirSync as mkdirSync18 } from "fs";
|
|
48639
|
-
import { join as
|
|
49035
|
+
import { join as join28 } from "path";
|
|
48640
49036
|
import { homedir as homedir19 } from "os";
|
|
48641
49037
|
var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
|
|
48642
49038
|
function installOutputTrace(label2) {
|
|
@@ -48648,10 +49044,10 @@ function installOutputTrace(label2) {
|
|
|
48648
49044
|
existing.emit({ event: "reenter", label: label2 });
|
|
48649
49045
|
return;
|
|
48650
49046
|
}
|
|
48651
|
-
const dir =
|
|
49047
|
+
const dir = join28(process.env.GIPITY_DIR || join28(homedir19(), ".gipity"), "trace");
|
|
48652
49048
|
mkdirSync18(dir, { recursive: true });
|
|
48653
49049
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
|
|
48654
|
-
const fd2 = openSync5(
|
|
49050
|
+
const fd2 = openSync5(join28(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
|
|
48655
49051
|
const emit = (rec) => {
|
|
48656
49052
|
try {
|
|
48657
49053
|
writeSync(fd2, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
|
|
@@ -48686,7 +49082,7 @@ function installOutputTrace(label2) {
|
|
|
48686
49082
|
|
|
48687
49083
|
// src/index.ts
|
|
48688
49084
|
installOutputTrace("index");
|
|
48689
|
-
var __dirname =
|
|
49085
|
+
var __dirname = dirname15(fileURLToPath3(import.meta.url));
|
|
48690
49086
|
var pkg = JSON.parse(readFileSync28(resolve18(__dirname, "../package.json"), "utf-8"));
|
|
48691
49087
|
function versionLabel() {
|
|
48692
49088
|
const base = `v${pkg.version}`;
|