gipity 1.1.9 → 1.1.10
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/generate.js +3 -0
- package/dist/commands/relay.js +30 -0
- package/dist/commands/update.js +1 -1
- package/dist/index.js +541 -277
- 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
|
}
|
|
@@ -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
|
}
|
|
@@ -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 = "";
|
|
@@ -39712,8 +39776,8 @@ storageCommand.command("retention").description("View or adjust your file versio
|
|
|
39712
39776
|
init_platform();
|
|
39713
39777
|
init_auth();
|
|
39714
39778
|
init_api();
|
|
39715
|
-
import { join as
|
|
39716
|
-
import { existsSync as
|
|
39779
|
+
import { join as join19, dirname as dirname11, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
|
|
39780
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync12, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
|
|
39717
39781
|
import { homedir as homedir13 } from "os";
|
|
39718
39782
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
39719
39783
|
import { randomUUID } from "crypto";
|
|
@@ -39827,7 +39891,7 @@ init_colors();
|
|
|
39827
39891
|
|
|
39828
39892
|
// src/relay/installers.ts
|
|
39829
39893
|
import { homedir as homedir10, platform as osPlatform } from "os";
|
|
39830
|
-
import { join as
|
|
39894
|
+
import { join as join17 } from "path";
|
|
39831
39895
|
var UnsupportedPlatformError = class extends Error {
|
|
39832
39896
|
constructor(plat) {
|
|
39833
39897
|
super(`gipity relay install does not support ${plat}`);
|
|
@@ -39845,8 +39909,8 @@ function display(argvs) {
|
|
|
39845
39909
|
}
|
|
39846
39910
|
function launchdPlan(cliPath) {
|
|
39847
39911
|
const label2 = "ai.gipity.relay";
|
|
39848
|
-
const path5 =
|
|
39849
|
-
const logDir =
|
|
39912
|
+
const path5 = join17(homedir10(), "Library", "LaunchAgents", `${label2}.plist`);
|
|
39913
|
+
const logDir = join17(homedir10(), "Library", "Logs", "Gipity");
|
|
39850
39914
|
const uid = process.getuid?.() ?? 0;
|
|
39851
39915
|
const target = `gui/${uid}`;
|
|
39852
39916
|
const content = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -39870,8 +39934,8 @@ function launchdPlan(cliPath) {
|
|
|
39870
39934
|
<dict>
|
|
39871
39935
|
<key>SuccessfulExit</key><false/>
|
|
39872
39936
|
</dict>
|
|
39873
|
-
<key>StandardOutPath</key><string>${
|
|
39874
|
-
<key>StandardErrorPath</key><string>${
|
|
39937
|
+
<key>StandardOutPath</key><string>${join17(logDir, "relay.out.log")}</string>
|
|
39938
|
+
<key>StandardErrorPath</key><string>${join17(logDir, "relay.err.log")}</string>
|
|
39875
39939
|
<key>ProcessType</key><string>Background</string>
|
|
39876
39940
|
</dict>
|
|
39877
39941
|
</plist>
|
|
@@ -39894,7 +39958,7 @@ function launchdPlan(cliPath) {
|
|
|
39894
39958
|
}
|
|
39895
39959
|
function systemdUserPlan(cliPath) {
|
|
39896
39960
|
const unitName = "gipity-relay.service";
|
|
39897
|
-
const path5 =
|
|
39961
|
+
const path5 = join17(homedir10(), ".config", "systemd", "user", unitName);
|
|
39898
39962
|
const content = `[Unit]
|
|
39899
39963
|
Description=Gipity relay - local Claude Code control from the Gipity web CLI
|
|
39900
39964
|
After=network-online.target
|
|
@@ -39932,7 +39996,7 @@ WantedBy=default.target
|
|
|
39932
39996
|
}
|
|
39933
39997
|
function windowsTaskPlan(cliPath) {
|
|
39934
39998
|
const taskName = "GipityRelay";
|
|
39935
|
-
const path5 =
|
|
39999
|
+
const path5 = join17(homedir10(), "AppData", "Local", "Gipity", "relay-task.xml");
|
|
39936
40000
|
const runsViaNode = /\.[cm]?js$/i.test(cliPath);
|
|
39937
40001
|
const command = runsViaNode ? process.execPath : cliPath;
|
|
39938
40002
|
const argLine = runsViaNode ? `"${cliPath}" relay run` : "relay run";
|
|
@@ -39994,7 +40058,7 @@ function windowsTaskPlan(cliPath) {
|
|
|
39994
40058
|
init_platform();
|
|
39995
40059
|
init_api();
|
|
39996
40060
|
import { hostname as hostname3, userInfo, platform as osPlatform2 } from "os";
|
|
39997
|
-
import { resolve as resolve12, dirname as
|
|
40061
|
+
import { resolve as resolve12, dirname as dirname10 } from "path";
|
|
39998
40062
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
39999
40063
|
|
|
40000
40064
|
// src/relay/machine-id.ts
|
|
@@ -40104,7 +40168,7 @@ function startDaemon() {
|
|
|
40104
40168
|
function installAutostart(opts = {}) {
|
|
40105
40169
|
const stdio = opts.stdio ?? "ignore";
|
|
40106
40170
|
const plan2 = planFor({ cliPath: resolveCliPath() });
|
|
40107
|
-
mkdirSync10(
|
|
40171
|
+
mkdirSync10(dirname10(plan2.path), { recursive: true });
|
|
40108
40172
|
writeFileSync10(plan2.path, plan2.content);
|
|
40109
40173
|
let ok = true;
|
|
40110
40174
|
for (const argv2 of plan2.enableCmds) {
|
|
@@ -40238,12 +40302,12 @@ init_colors();
|
|
|
40238
40302
|
// src/banner.ts
|
|
40239
40303
|
init_colors();
|
|
40240
40304
|
import { homedir as homedir11 } from "os";
|
|
40241
|
-
import { sep as
|
|
40305
|
+
import { sep as sep5 } from "path";
|
|
40242
40306
|
function tildify(p) {
|
|
40243
40307
|
const home = homedir11();
|
|
40244
40308
|
if (!home) return p;
|
|
40245
40309
|
if (p === home) return "~";
|
|
40246
|
-
if (p.startsWith(home +
|
|
40310
|
+
if (p.startsWith(home + sep5)) return "~" + p.slice(home.length);
|
|
40247
40311
|
return p;
|
|
40248
40312
|
}
|
|
40249
40313
|
var AI_MODELS = [
|
|
@@ -40490,12 +40554,12 @@ init_claude_setup();
|
|
|
40490
40554
|
init_agents();
|
|
40491
40555
|
|
|
40492
40556
|
// src/prefs.ts
|
|
40493
|
-
import { existsSync as
|
|
40557
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
|
|
40494
40558
|
import { homedir as homedir12 } from "os";
|
|
40495
|
-
import { join as
|
|
40496
|
-
var PREFS_PATH =
|
|
40559
|
+
import { join as join18 } from "path";
|
|
40560
|
+
var PREFS_PATH = join18(homedir12(), ".gipity", "prefs.json");
|
|
40497
40561
|
function readPrefs() {
|
|
40498
|
-
if (!
|
|
40562
|
+
if (!existsSync14(PREFS_PATH)) return {};
|
|
40499
40563
|
try {
|
|
40500
40564
|
const parsed = JSON.parse(readFileSync17(PREFS_PATH, "utf-8"));
|
|
40501
40565
|
return {
|
|
@@ -40509,7 +40573,7 @@ function writePrefs(update) {
|
|
|
40509
40573
|
try {
|
|
40510
40574
|
const current = readPrefs();
|
|
40511
40575
|
const next = { ...current, ...update };
|
|
40512
|
-
mkdirSync11(
|
|
40576
|
+
mkdirSync11(join18(homedir12(), ".gipity"), { recursive: true });
|
|
40513
40577
|
writeFileSync11(PREFS_PATH, JSON.stringify(next, null, 2) + "\n");
|
|
40514
40578
|
} catch {
|
|
40515
40579
|
}
|
|
@@ -40517,18 +40581,18 @@ function writePrefs(update) {
|
|
|
40517
40581
|
|
|
40518
40582
|
// src/commands/build.ts
|
|
40519
40583
|
init_setup();
|
|
40520
|
-
var __clDir =
|
|
40584
|
+
var __clDir = dirname11(fileURLToPath2(import.meta.url));
|
|
40521
40585
|
function readOwnPkg(fromDir) {
|
|
40522
|
-
for (let d = fromDir; ; d =
|
|
40523
|
-
const p =
|
|
40524
|
-
if (
|
|
40586
|
+
for (let d = fromDir; ; d = dirname11(d)) {
|
|
40587
|
+
const p = join19(d, "package.json");
|
|
40588
|
+
if (existsSync15(p)) {
|
|
40525
40589
|
try {
|
|
40526
40590
|
const pkg2 = JSON.parse(readFileSync18(p, "utf-8"));
|
|
40527
40591
|
if (pkg2.name === "gipity") return pkg2;
|
|
40528
40592
|
} catch {
|
|
40529
40593
|
}
|
|
40530
40594
|
}
|
|
40531
|
-
if (
|
|
40595
|
+
if (dirname11(d) === d) return {};
|
|
40532
40596
|
}
|
|
40533
40597
|
}
|
|
40534
40598
|
var __clPkg = readOwnPkg(__clDir);
|
|
@@ -40577,7 +40641,7 @@ function localFsFallback(dir) {
|
|
|
40577
40641
|
let isDir = false;
|
|
40578
40642
|
let size = 0;
|
|
40579
40643
|
try {
|
|
40580
|
-
const st2 = statSync8(
|
|
40644
|
+
const st2 = statSync8(join19(d, name));
|
|
40581
40645
|
isDir = st2.isDirectory();
|
|
40582
40646
|
size = st2.isFile() ? st2.size : 0;
|
|
40583
40647
|
} catch {
|
|
@@ -40586,7 +40650,7 @@ function localFsFallback(dir) {
|
|
|
40586
40650
|
if (isDir) {
|
|
40587
40651
|
folderCount++;
|
|
40588
40652
|
if (depth === 0) topLevelEntries.push(`${name}/`);
|
|
40589
|
-
walk(
|
|
40653
|
+
walk(join19(d, name), depth + 1);
|
|
40590
40654
|
} else {
|
|
40591
40655
|
fileCount++;
|
|
40592
40656
|
totalBytes += size;
|
|
@@ -40619,8 +40683,8 @@ function hasStreamJsonFlag(args) {
|
|
|
40619
40683
|
}
|
|
40620
40684
|
function markFolderTrusted(dir) {
|
|
40621
40685
|
try {
|
|
40622
|
-
const file =
|
|
40623
|
-
const cfg =
|
|
40686
|
+
const file = join19(homedir13(), ".claude.json");
|
|
40687
|
+
const cfg = existsSync15(file) ? JSON.parse(readFileSync18(file, "utf-8")) : {};
|
|
40624
40688
|
if (typeof cfg !== "object" || cfg === null) return;
|
|
40625
40689
|
if (typeof cfg.projects !== "object" || cfg.projects === null) cfg.projects = {};
|
|
40626
40690
|
const entry = typeof cfg.projects[dir] === "object" && cfg.projects[dir] !== null ? cfg.projects[dir] : {};
|
|
@@ -40745,9 +40809,9 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40745
40809
|
let existing = getConfig();
|
|
40746
40810
|
let forceAdoptCwd = false;
|
|
40747
40811
|
if (existing && !opts.newProject && !opts.project && !nonInteractive) {
|
|
40748
|
-
const cwdHasConfig =
|
|
40812
|
+
const cwdHasConfig = existsSync15(resolve13(process.cwd(), ".gipity.json"));
|
|
40749
40813
|
if (!cwdHasConfig && isLikelyEmpty(process.cwd())) {
|
|
40750
|
-
const ancestorRoot =
|
|
40814
|
+
const ancestorRoot = dirname11(getConfigPath());
|
|
40751
40815
|
console.log(` ${bold("You are inside an existing Gipity project.")}
|
|
40752
40816
|
`);
|
|
40753
40817
|
console.log(` ${bold("1.")} Continue in ${brand(existing.projectSlug)} ${muted(`(rooted at ${formatCwdLabel(ancestorRoot)})`)}`);
|
|
@@ -40794,7 +40858,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40794
40858
|
}
|
|
40795
40859
|
project = found;
|
|
40796
40860
|
}
|
|
40797
|
-
const projectDir2 = opts.here ? process.cwd() :
|
|
40861
|
+
const projectDir2 = opts.here ? process.cwd() : join19(getProjectsRoot(), project.slug);
|
|
40798
40862
|
mkdirSync12(projectDir2, { recursive: true });
|
|
40799
40863
|
process.chdir(projectDir2);
|
|
40800
40864
|
clearConfigCache();
|
|
@@ -40837,7 +40901,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40837
40901
|
`);
|
|
40838
40902
|
setupProjectTools();
|
|
40839
40903
|
let doSync = true;
|
|
40840
|
-
const projectRoot =
|
|
40904
|
+
const projectRoot = dirname11(getConfigPath());
|
|
40841
40905
|
const scan = scanForAdoption(projectRoot);
|
|
40842
40906
|
if (scan.tier === "refuse" && !nonInteractive) {
|
|
40843
40907
|
const sizeStr = scan.truncated ? `>${formatBytes(ADOPT_THRESHOLDS.REFUSE_BYTES)}` : formatBytes(scan.bytes);
|
|
@@ -40918,7 +40982,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40918
40982
|
} else {
|
|
40919
40983
|
project = result.project;
|
|
40920
40984
|
isNewProject = result.kind === "create-new";
|
|
40921
|
-
const projectDir2 =
|
|
40985
|
+
const projectDir2 = join19(getProjectsRoot(), project.slug);
|
|
40922
40986
|
mkdirSync12(projectDir2, { recursive: true });
|
|
40923
40987
|
process.chdir(projectDir2);
|
|
40924
40988
|
clearConfigCache();
|
|
@@ -41306,8 +41370,8 @@ ${doneLine}
|
|
|
41306
41370
|
});
|
|
41307
41371
|
}
|
|
41308
41372
|
function flushHeadlessCapture(adapter, sessionId, convGuid) {
|
|
41309
|
-
const runner =
|
|
41310
|
-
if (!
|
|
41373
|
+
const runner = join19(__clDir, "..", "hooks", "capture-runner.js");
|
|
41374
|
+
if (!existsSync15(runner)) return;
|
|
41311
41375
|
const payload = JSON.stringify({ session_id: sessionId, cwd: process.cwd() });
|
|
41312
41376
|
const env = { ...process.env, GIPITY_CONVERSATION_GUID: convGuid };
|
|
41313
41377
|
for (const event of ["session-start", "stop"]) {
|
|
@@ -41435,8 +41499,8 @@ function formatNewProjectLabel(existingSlugs) {
|
|
|
41435
41499
|
const slug = suggestProjectName(existingSlugs);
|
|
41436
41500
|
const root = getProjectsRoot();
|
|
41437
41501
|
const home = homedir13();
|
|
41438
|
-
const display2 = root === home || root.startsWith(home +
|
|
41439
|
-
return `${display2}${
|
|
41502
|
+
const display2 = root === home || root.startsWith(home + sep6) ? "~" + root.slice(home.length) : root;
|
|
41503
|
+
return `${display2}${sep6}${slug}`;
|
|
41440
41504
|
}
|
|
41441
41505
|
async function confirmAdoptCwd(cwd) {
|
|
41442
41506
|
process.stdout.write(` ${muted("Scanning directory...")} `);
|
|
@@ -43422,11 +43486,11 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
|
|
|
43422
43486
|
}
|
|
43423
43487
|
}));
|
|
43424
43488
|
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:
|
|
43489
|
+
const { existsSync: existsSync25, statSync: statSync12 } = await import("node:fs");
|
|
43490
|
+
const { resolve: resolve19, join: join29 } = await import("node:path");
|
|
43427
43491
|
const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
43428
43492
|
const jobDir = resolve19(process.cwd(), "jobs", name);
|
|
43429
|
-
if (!
|
|
43493
|
+
if (!existsSync25(jobDir) || !statSync12(jobDir).isDirectory()) {
|
|
43430
43494
|
console.error(error(`jobs/${name}/ not found in current directory`));
|
|
43431
43495
|
process.exit(1);
|
|
43432
43496
|
}
|
|
@@ -43447,7 +43511,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43447
43511
|
},
|
|
43448
43512
|
{ file: "main.sh", runtime: "bash", entry: "bash" }
|
|
43449
43513
|
];
|
|
43450
|
-
const picked = variants.find((v7) =>
|
|
43514
|
+
const picked = variants.find((v7) => existsSync25(join29(jobDir, v7.file)));
|
|
43451
43515
|
if (!picked) {
|
|
43452
43516
|
console.error(error(`No main.py / main.js / main.sh found under jobs/${name}/`));
|
|
43453
43517
|
process.exit(1);
|
|
@@ -43472,7 +43536,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43472
43536
|
"-v",
|
|
43473
43537
|
`${jobDir}:/work`
|
|
43474
43538
|
];
|
|
43475
|
-
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd &&
|
|
43539
|
+
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd && existsSync25(join29(jobDir, picked.depsFile));
|
|
43476
43540
|
const handlerCmd = `${picked.entry} /work/${picked.file}`;
|
|
43477
43541
|
let shellCmd;
|
|
43478
43542
|
if (needsDeps && picked.installCmd) {
|
|
@@ -43651,7 +43715,7 @@ init_api();
|
|
|
43651
43715
|
init_config();
|
|
43652
43716
|
init_colors();
|
|
43653
43717
|
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync13, readFileSync as readFileSync19 } from "fs";
|
|
43654
|
-
import { resolve as resolvePath2, dirname as
|
|
43718
|
+
import { resolve as resolvePath2, dirname as dirname12, relative as relative5, isAbsolute, basename as basename6 } from "path";
|
|
43655
43719
|
|
|
43656
43720
|
// src/provider-docs.ts
|
|
43657
43721
|
var IMAGE_MODELS_DOC = `openai: gpt-image-2. bfl: flux-2-pro, flux-2-flex, flux-2-max, flux-2-klein-9b, flux-2-klein-4b. gemini: gemini-3.1-flash-lite-image, gemini-2.5-flash-image, gemini-3.1-flash-image, gemini-3-pro-image`;
|
|
@@ -43714,7 +43778,7 @@ function noteFormatMismatch(filename, buf) {
|
|
|
43714
43778
|
));
|
|
43715
43779
|
}
|
|
43716
43780
|
function ensureOutputDir(output) {
|
|
43717
|
-
const dir =
|
|
43781
|
+
const dir = dirname12(resolvePath2(output));
|
|
43718
43782
|
try {
|
|
43719
43783
|
mkdirSync13(dir, { recursive: true });
|
|
43720
43784
|
} catch (err) {
|
|
@@ -43724,7 +43788,7 @@ function ensureOutputDir(output) {
|
|
|
43724
43788
|
async function pushGenerated(savedPath) {
|
|
43725
43789
|
const configPath = getConfigPath();
|
|
43726
43790
|
if (!configPath) return;
|
|
43727
|
-
const rel2 = relative5(
|
|
43791
|
+
const rel2 = relative5(dirname12(configPath), savedPath);
|
|
43728
43792
|
if (rel2.startsWith("..") || isAbsolute(rel2)) return;
|
|
43729
43793
|
try {
|
|
43730
43794
|
await pushFile(savedPath);
|
|
@@ -43810,7 +43874,8 @@ Examples:
|
|
|
43810
43874
|
gipity generate video "a bird flying over a mountain lake at sunset"
|
|
43811
43875
|
gipity generate video "close-up of coffee being poured" --model veo-3.1-fast-generate-preview
|
|
43812
43876
|
gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4
|
|
43813
|
-
|
|
43877
|
+
gipity generate video "a wave crashing" --duration 4 --model veo-3.1-lite-generate-preview
|
|
43878
|
+
`).argument("<prompt>", "Description of the video scene, action, camera movement, and dialogue").option("--model <model>", "Veo model: veo-3.1-generate-preview (quality), veo-3.1-fast-generate-preview (speed), veo-3.1-lite-generate-preview (budget)").option("--aspect <ratio>", "Aspect ratio: 16:9 (landscape), 9:16 (portrait), 1:1 (square)").option("--resolution <res>", "Video resolution: 720p, 1080p, 4k").option("--duration <seconds>", "Clip length in seconds. Veo models: 4, 6, or 8 (8 required at 1080p/4K); omni-flash: 3-10. Default 8. Billing is per second, so shorter is cheaper.").option("-o, --output <file>", "Output path (default ./generated.mp4). For a clip your app ships, write it into the source tree so it deploys, e.g. -o src/assets/video/clip.mp4; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
|
|
43814
43879
|
try {
|
|
43815
43880
|
const { config } = await resolveProjectContext();
|
|
43816
43881
|
if (opts.output) ensureOutputDir(opts.output);
|
|
@@ -43818,7 +43883,8 @@ Examples:
|
|
|
43818
43883
|
prompt: prompt2,
|
|
43819
43884
|
model: opts.model,
|
|
43820
43885
|
aspect_ratio: opts.aspect,
|
|
43821
|
-
resolution: opts.resolution
|
|
43886
|
+
resolution: opts.resolution,
|
|
43887
|
+
duration_seconds: opts.duration ? Number(opts.duration) : void 0
|
|
43822
43888
|
});
|
|
43823
43889
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating video...", doGenerate, { done: null });
|
|
43824
43890
|
const filename = opts.output || "generated.mp4";
|
|
@@ -43965,14 +44031,14 @@ var generateCommand = new Command("generate").description("Generate images, vide
|
|
|
43965
44031
|
init_api();
|
|
43966
44032
|
init_config();
|
|
43967
44033
|
init_colors();
|
|
43968
|
-
import { existsSync as
|
|
43969
|
-
import { join as
|
|
44034
|
+
import { existsSync as existsSync16, readFileSync as readFileSync20 } from "fs";
|
|
44035
|
+
import { join as join20 } from "path";
|
|
43970
44036
|
function readInstalledKitReadme(name) {
|
|
43971
44037
|
const root = getProjectRoot() ?? process.cwd();
|
|
43972
|
-
const kitDir =
|
|
43973
|
-
if (!
|
|
43974
|
-
const readme =
|
|
43975
|
-
return
|
|
44038
|
+
const kitDir = join20(root, "src", "packages", name);
|
|
44039
|
+
if (!existsSync16(join20(kitDir, "package.json"))) return null;
|
|
44040
|
+
const readme = join20(kitDir, "README.md");
|
|
44041
|
+
return existsSync16(readme) ? readFileSync20(readme, "utf-8") : null;
|
|
43976
44042
|
}
|
|
43977
44043
|
function slugify2(title) {
|
|
43978
44044
|
return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -44245,15 +44311,15 @@ var domainCommand = new Command("domain").description("Manage custom domains").a
|
|
|
44245
44311
|
}));
|
|
44246
44312
|
|
|
44247
44313
|
// src/commands/realtime.ts
|
|
44248
|
-
import { existsSync as
|
|
44249
|
-
import { dirname as
|
|
44314
|
+
import { existsSync as existsSync17 } from "fs";
|
|
44315
|
+
import { dirname as dirname13, resolve as resolve14 } from "path";
|
|
44250
44316
|
init_api();
|
|
44251
44317
|
init_config();
|
|
44252
44318
|
init_colors();
|
|
44253
44319
|
function hasDeployManifest() {
|
|
44254
44320
|
const cfgPath = getConfigPath();
|
|
44255
44321
|
if (!cfgPath) return false;
|
|
44256
|
-
return
|
|
44322
|
+
return existsSync17(resolve14(dirname13(cfgPath), "gipity.yaml"));
|
|
44257
44323
|
}
|
|
44258
44324
|
var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").option("--type <type>", "room type for create: state | relay", "state").option("--auth <level>", "auth level for create: public | user", "public").option("--max-clients <n>", "max clients for create (1-200)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
|
|
44259
44325
|
const config = requireConfig();
|
|
@@ -44662,21 +44728,21 @@ var locationCommand = new Command("location").description("Show location").argum
|
|
|
44662
44728
|
}));
|
|
44663
44729
|
|
|
44664
44730
|
// src/commands/doctor.ts
|
|
44665
|
-
import { existsSync as
|
|
44666
|
-
import { join as
|
|
44731
|
+
import { existsSync as existsSync19, readFileSync as readFileSync22, statSync as statSync9 } from "fs";
|
|
44732
|
+
import { join as join22, resolve as resolve15 } from "path";
|
|
44667
44733
|
import { homedir as homedir15 } from "os";
|
|
44668
44734
|
|
|
44669
44735
|
// src/updater/state.ts
|
|
44670
|
-
import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as
|
|
44671
|
-
import { join as
|
|
44736
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync14, existsSync as existsSync18 } from "fs";
|
|
44737
|
+
import { join as join21 } from "path";
|
|
44672
44738
|
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 =
|
|
44739
|
+
var GIPITY_DIR = join21(homedir14(), ".gipity");
|
|
44740
|
+
var LOCAL_DIR = join21(GIPITY_DIR, "local");
|
|
44741
|
+
var LOCAL_PKG_DIR = join21(LOCAL_DIR, "node_modules", "gipity");
|
|
44742
|
+
var LOCAL_ENTRY = join21(LOCAL_PKG_DIR, "dist", "index.js");
|
|
44743
|
+
var STATE_FILE = join21(GIPITY_DIR, "update-state.json");
|
|
44744
|
+
var SETTINGS_FILE = join21(GIPITY_DIR, "settings.json");
|
|
44745
|
+
var UPDATE_LOG = join21(GIPITY_DIR, "update.log");
|
|
44680
44746
|
var DEFAULT_STATE = {
|
|
44681
44747
|
installedVersion: null,
|
|
44682
44748
|
lastCheckAt: 0,
|
|
@@ -44690,7 +44756,7 @@ function ensureDir() {
|
|
|
44690
44756
|
mkdirSync14(GIPITY_DIR, { recursive: true });
|
|
44691
44757
|
}
|
|
44692
44758
|
function readState() {
|
|
44693
|
-
if (!
|
|
44759
|
+
if (!existsSync18(STATE_FILE)) return { ...DEFAULT_STATE };
|
|
44694
44760
|
try {
|
|
44695
44761
|
return { ...DEFAULT_STATE, ...JSON.parse(readFileSync21(STATE_FILE, "utf-8")) };
|
|
44696
44762
|
} catch {
|
|
@@ -44702,7 +44768,7 @@ function writeState(state) {
|
|
|
44702
44768
|
writeFileSync14(STATE_FILE, JSON.stringify(state, null, 2));
|
|
44703
44769
|
}
|
|
44704
44770
|
function readSettings() {
|
|
44705
|
-
if (!
|
|
44771
|
+
if (!existsSync18(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
|
|
44706
44772
|
try {
|
|
44707
44773
|
return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync21(SETTINGS_FILE, "utf-8")) };
|
|
44708
44774
|
} catch {
|
|
@@ -44738,8 +44804,8 @@ function versionManagerNode(execPath, env = process.env, home = homedir15()) {
|
|
|
44738
44804
|
return null;
|
|
44739
44805
|
}
|
|
44740
44806
|
function localVersion() {
|
|
44741
|
-
const pkgPath =
|
|
44742
|
-
if (!
|
|
44807
|
+
const pkgPath = join22(LOCAL_PKG_DIR, "package.json");
|
|
44808
|
+
if (!existsSync19(pkgPath)) return null;
|
|
44743
44809
|
try {
|
|
44744
44810
|
return JSON.parse(readFileSync22(pkgPath, "utf-8")).version ?? null;
|
|
44745
44811
|
} catch {
|
|
@@ -44764,7 +44830,7 @@ function rel(t) {
|
|
|
44764
44830
|
}
|
|
44765
44831
|
function relayAutostartInstalled() {
|
|
44766
44832
|
try {
|
|
44767
|
-
return
|
|
44833
|
+
return existsSync19(planFor({ cliPath: resolveCliPath() }).path);
|
|
44768
44834
|
} catch (err) {
|
|
44769
44835
|
if (err instanceof UnsupportedPlatformError) return null;
|
|
44770
44836
|
return null;
|
|
@@ -44802,7 +44868,7 @@ function gatherEnv(opts = {}) {
|
|
|
44802
44868
|
const cli = {
|
|
44803
44869
|
shim_version: shimVersion(),
|
|
44804
44870
|
local_version: localVersion(),
|
|
44805
|
-
local_install_ok:
|
|
44871
|
+
local_install_ok: existsSync19(LOCAL_ENTRY),
|
|
44806
44872
|
auto_updates: !dis.disabled,
|
|
44807
44873
|
updates_disabled_reason: dis.disabled ? dis.reason ?? null : null,
|
|
44808
44874
|
last_check_at: updState.lastCheckAt,
|
|
@@ -44832,7 +44898,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44832
44898
|
console.log(`${muted("claude code ")} installed ${yn(env.claude.installed)} \xB7 authenticated ${yn(env.claude.authenticated)}`);
|
|
44833
44899
|
const autostartLabel = env.relay.autostart === null ? muted("n/a") : yn(env.relay.autostart);
|
|
44834
44900
|
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 (
|
|
44901
|
+
if (existsSync19(resolve15(process.cwd(), ".codex", "hooks.json"))) {
|
|
44836
44902
|
console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
|
|
44837
44903
|
}
|
|
44838
44904
|
console.log(`${muted("ready ")} ${env.ready ? success("yes") : warning("no - run `gipity build` (or the desktop app) to finish setup")}`);
|
|
@@ -44840,7 +44906,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44840
44906
|
const settings = readSettings();
|
|
44841
44907
|
const dis = updatesDisabled();
|
|
44842
44908
|
const local = localVersion();
|
|
44843
|
-
const localOk =
|
|
44909
|
+
const localOk = existsSync19(LOCAL_ENTRY);
|
|
44844
44910
|
console.log("");
|
|
44845
44911
|
console.log(bold("CLI install"));
|
|
44846
44912
|
console.log(`${muted("shim version ")} ${shimVersion()}`);
|
|
@@ -44848,11 +44914,11 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44848
44914
|
console.log(`${muted("local install ")} ${LOCAL_PKG_DIR}`);
|
|
44849
44915
|
console.log("");
|
|
44850
44916
|
console.log(`${muted("auto-updates ")} ${dis.disabled ? warning(`disabled (${dis.reason})`) : success("enabled")}`);
|
|
44851
|
-
console.log(`${muted("settings file ")} ${
|
|
44917
|
+
console.log(`${muted("settings file ")} ${existsSync19(SETTINGS_FILE) ? SETTINGS_FILE : dim("(default)")} autoUpdates=${settings.autoUpdates}`);
|
|
44852
44918
|
console.log(`${muted("last check ")} ${rel(state.lastCheckAt)}`);
|
|
44853
44919
|
console.log(`${muted("last error ")} ${state.lastError ? error(state.lastError) : dim("none")}`);
|
|
44854
|
-
console.log(`${muted("state file ")} ${
|
|
44855
|
-
console.log(`${muted("update log ")} ${
|
|
44920
|
+
console.log(`${muted("state file ")} ${existsSync19(STATE_FILE) ? STATE_FILE : dim("(none yet)")}`);
|
|
44921
|
+
console.log(`${muted("update log ")} ${existsSync19(UPDATE_LOG) ? `${UPDATE_LOG} (${statSync9(UPDATE_LOG).size} bytes)` : dim("(none yet)")}`);
|
|
44856
44922
|
console.log("");
|
|
44857
44923
|
console.log(dim("Force an update with: gipity update"));
|
|
44858
44924
|
});
|
|
@@ -44861,10 +44927,10 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
44861
44927
|
import { appendFileSync } from "fs";
|
|
44862
44928
|
|
|
44863
44929
|
// src/updater/install.ts
|
|
44864
|
-
import { existsSync as
|
|
44865
|
-
import { dirname as
|
|
44930
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync5, writeFileSync as writeFileSync15 } from "fs";
|
|
44931
|
+
import { dirname as dirname14, join as join23 } from "path";
|
|
44866
44932
|
init_platform();
|
|
44867
|
-
var UPDATE_LOCK =
|
|
44933
|
+
var UPDATE_LOCK = join23(GIPITY_DIR, "update.lock");
|
|
44868
44934
|
var LOCK_STALE_MS2 = 10 * 60 * 1e3;
|
|
44869
44935
|
function npmInstallGipity(version) {
|
|
44870
44936
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
@@ -44873,7 +44939,7 @@ function npmInstallGipity(version) {
|
|
|
44873
44939
|
encoding: "utf-8"
|
|
44874
44940
|
});
|
|
44875
44941
|
return {
|
|
44876
|
-
ok: res.status === 0 &&
|
|
44942
|
+
ok: res.status === 0 && existsSync20(LOCAL_ENTRY),
|
|
44877
44943
|
status: res.status,
|
|
44878
44944
|
stderr: (res.stderr || "").toString(),
|
|
44879
44945
|
spawnError: res.error
|
|
@@ -44885,12 +44951,12 @@ function isWedged(stderr) {
|
|
|
44885
44951
|
}
|
|
44886
44952
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
44887
44953
|
mkdirSync15(dir, { recursive: true });
|
|
44888
|
-
rmSync2(
|
|
44889
|
-
rmSync2(
|
|
44890
|
-
writeFileSync15(
|
|
44954
|
+
rmSync2(join23(dir, "node_modules"), { recursive: true, force: true });
|
|
44955
|
+
rmSync2(join23(dir, "package-lock.json"), { force: true });
|
|
44956
|
+
writeFileSync15(join23(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
44891
44957
|
}
|
|
44892
44958
|
function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
44893
|
-
mkdirSync15(
|
|
44959
|
+
mkdirSync15(dirname14(lockPath2), { recursive: true });
|
|
44894
44960
|
try {
|
|
44895
44961
|
writeFileSync15(lockPath2, String(process.pid), { flag: "wx" });
|
|
44896
44962
|
return true;
|
|
@@ -45031,7 +45097,7 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
|
|
|
45031
45097
|
console.log("");
|
|
45032
45098
|
if (result.updated) {
|
|
45033
45099
|
console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
|
|
45034
|
-
console.log(dim(
|
|
45100
|
+
console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
|
|
45035
45101
|
} else if (result.reason === "up-to-date") {
|
|
45036
45102
|
console.log(success("Already on the latest version."));
|
|
45037
45103
|
} else {
|
|
@@ -45047,17 +45113,17 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
|
|
|
45047
45113
|
init_api();
|
|
45048
45114
|
init_utils();
|
|
45049
45115
|
init_colors();
|
|
45050
|
-
import { existsSync as
|
|
45116
|
+
import { existsSync as existsSync23, readFileSync as readFileSync25, unlinkSync as unlinkSync8 } from "fs";
|
|
45051
45117
|
import { spawn as spawn2 } from "child_process";
|
|
45052
45118
|
|
|
45053
45119
|
// src/relay/daemon.ts
|
|
45054
45120
|
init_platform();
|
|
45055
45121
|
init_config();
|
|
45056
|
-
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync17, existsSync as
|
|
45122
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync17, existsSync as existsSync22, readFileSync as readFileSync24, writeFileSync as writeFileSync16, chmodSync as chmodSync3, closeSync as closeSync4, openSync as openSync4, unlinkSync as unlinkSync7 } from "fs";
|
|
45057
45123
|
import { stat, readFile } from "fs/promises";
|
|
45058
45124
|
import { createInterface as createInterface2 } from "readline";
|
|
45059
45125
|
import { homedir as homedir17, hostname as hostname5, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
|
|
45060
|
-
import { join as
|
|
45126
|
+
import { join as join26 } from "path";
|
|
45061
45127
|
init_setup();
|
|
45062
45128
|
init_auth();
|
|
45063
45129
|
init_api();
|
|
@@ -45684,11 +45750,11 @@ var DeltaAccumulator = class {
|
|
|
45684
45750
|
return [];
|
|
45685
45751
|
}
|
|
45686
45752
|
emitUpTo(messageId, idx, b7, closing) {
|
|
45687
|
-
const
|
|
45688
|
-
if (!closing && PEM_BEGIN.test(
|
|
45689
|
-
const tailBoundary = safeEmitBoundary(
|
|
45753
|
+
const tail2 = b7.raw.slice(b7.rawEmitted);
|
|
45754
|
+
if (!closing && PEM_BEGIN.test(tail2) && !PEM_END.test(tail2)) return [];
|
|
45755
|
+
const tailBoundary = safeEmitBoundary(tail2, closing);
|
|
45690
45756
|
if (tailBoundary <= 0) return [];
|
|
45691
|
-
const span =
|
|
45757
|
+
const span = tail2.slice(0, tailBoundary);
|
|
45692
45758
|
const boundary = b7.rawEmitted + tailBoundary;
|
|
45693
45759
|
b7.rawEmitted = boundary;
|
|
45694
45760
|
const scrubbed = redactString(span, this.getSecrets());
|
|
@@ -45816,7 +45882,7 @@ init_client_context();
|
|
|
45816
45882
|
init_agents();
|
|
45817
45883
|
import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as homedir16 } from "os";
|
|
45818
45884
|
import { statfsSync, readdirSync as readdirSync9 } from "fs";
|
|
45819
|
-
import { join as
|
|
45885
|
+
import { join as join24 } from "path";
|
|
45820
45886
|
var PROBE_TIMEOUT_MS = 4e3;
|
|
45821
45887
|
function parseVersion(out) {
|
|
45822
45888
|
const m = out.match(/\d+\.\d+(?:\.\d+)?(?:[-.\w]*)?/);
|
|
@@ -45883,7 +45949,7 @@ async function detectGpu() {
|
|
|
45883
45949
|
function diskUsage() {
|
|
45884
45950
|
try {
|
|
45885
45951
|
if (typeof statfsSync !== "function") return void 0;
|
|
45886
|
-
const st2 = statfsSync(
|
|
45952
|
+
const st2 = statfsSync(join24(homedir16(), "GipityProjects"), { bigint: false });
|
|
45887
45953
|
if (!st2 || !st2.bsize) return void 0;
|
|
45888
45954
|
return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
|
|
45889
45955
|
} catch {
|
|
@@ -45897,7 +45963,7 @@ function diskUsage() {
|
|
|
45897
45963
|
}
|
|
45898
45964
|
function localProjectCount() {
|
|
45899
45965
|
try {
|
|
45900
|
-
return readdirSync9(
|
|
45966
|
+
return readdirSync9(join24(homedir16(), "GipityProjects"), { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).length;
|
|
45901
45967
|
} catch {
|
|
45902
45968
|
return void 0;
|
|
45903
45969
|
}
|
|
@@ -45944,6 +46010,149 @@ function safe(fn) {
|
|
|
45944
46010
|
}
|
|
45945
46011
|
}
|
|
45946
46012
|
|
|
46013
|
+
// src/relay/agent-updates.ts
|
|
46014
|
+
init_agents();
|
|
46015
|
+
init_platform();
|
|
46016
|
+
var UPDATE_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_AGENT_UPDATE_TIMEOUT_MS || String(5 * 6e4), 10);
|
|
46017
|
+
var PROBE_TIMEOUT_MS2 = 4e3;
|
|
46018
|
+
var REGISTRY_TIMEOUT_MS = 1e4;
|
|
46019
|
+
var UPDATE_STUB = process.env.GIPITY_RELAY_AGENT_UPDATE_STUB;
|
|
46020
|
+
function stubAdapters(stub) {
|
|
46021
|
+
return [{
|
|
46022
|
+
source: "stub_agent",
|
|
46023
|
+
binary: stub,
|
|
46024
|
+
updatePlan: () => ({ argv: [stub, "update"], label: "stub" })
|
|
46025
|
+
}];
|
|
46026
|
+
}
|
|
46027
|
+
var inProgress = false;
|
|
46028
|
+
function agentUpdateInProgress() {
|
|
46029
|
+
return inProgress;
|
|
46030
|
+
}
|
|
46031
|
+
function execCapture(argv2, timeoutMs, signal) {
|
|
46032
|
+
return new Promise((resolve19) => {
|
|
46033
|
+
let output = "";
|
|
46034
|
+
let settled = false;
|
|
46035
|
+
const done = (ok) => {
|
|
46036
|
+
if (!settled) {
|
|
46037
|
+
settled = true;
|
|
46038
|
+
resolve19({ ok, output });
|
|
46039
|
+
}
|
|
46040
|
+
};
|
|
46041
|
+
let child;
|
|
46042
|
+
try {
|
|
46043
|
+
child = spawnCommand(resolveCommand(argv2[0]), argv2.slice(1), { stdio: ["ignore", "pipe", "pipe"] });
|
|
46044
|
+
} catch (err) {
|
|
46045
|
+
output = err?.message ?? "spawn failed";
|
|
46046
|
+
return done(false);
|
|
46047
|
+
}
|
|
46048
|
+
const kill = () => {
|
|
46049
|
+
try {
|
|
46050
|
+
child.kill("SIGKILL");
|
|
46051
|
+
} catch {
|
|
46052
|
+
}
|
|
46053
|
+
};
|
|
46054
|
+
const timer = setTimeout(() => {
|
|
46055
|
+
output += "\n[timed out]";
|
|
46056
|
+
kill();
|
|
46057
|
+
}, timeoutMs);
|
|
46058
|
+
signal?.addEventListener("abort", kill, { once: true });
|
|
46059
|
+
child.stdout?.on("data", (d) => {
|
|
46060
|
+
output += d.toString();
|
|
46061
|
+
});
|
|
46062
|
+
child.stderr?.on("data", (d) => {
|
|
46063
|
+
output += d.toString();
|
|
46064
|
+
});
|
|
46065
|
+
child.on("error", (err) => {
|
|
46066
|
+
clearTimeout(timer);
|
|
46067
|
+
output += `
|
|
46068
|
+
${err.message}`;
|
|
46069
|
+
done(false);
|
|
46070
|
+
});
|
|
46071
|
+
child.on("close", (code) => {
|
|
46072
|
+
clearTimeout(timer);
|
|
46073
|
+
done(code === 0);
|
|
46074
|
+
});
|
|
46075
|
+
});
|
|
46076
|
+
}
|
|
46077
|
+
async function defaultProbeVersion(binary) {
|
|
46078
|
+
const r = await execCapture([binary, "--version"], PROBE_TIMEOUT_MS2);
|
|
46079
|
+
return parseVersion(r.output);
|
|
46080
|
+
}
|
|
46081
|
+
async function defaultFetchLatest(pkg2) {
|
|
46082
|
+
try {
|
|
46083
|
+
const res = await fetch(`https://registry.npmjs.org/${pkg2}/latest`, {
|
|
46084
|
+
headers: { accept: "application/json" },
|
|
46085
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS)
|
|
46086
|
+
});
|
|
46087
|
+
if (!res.ok) return null;
|
|
46088
|
+
const json = await res.json();
|
|
46089
|
+
return typeof json.version === "string" ? json.version : null;
|
|
46090
|
+
} catch {
|
|
46091
|
+
return null;
|
|
46092
|
+
}
|
|
46093
|
+
}
|
|
46094
|
+
var tail = (s) => s.trim().slice(-300).replace(/\s+/g, " ");
|
|
46095
|
+
async function runAgentUpdates(opts, deps = {}) {
|
|
46096
|
+
const adapters = deps.adapters ?? (UPDATE_STUB ? stubAdapters(UPDATE_STUB) : AGENT_ADAPTERS);
|
|
46097
|
+
const exec = deps.exec ?? execCapture;
|
|
46098
|
+
const probe = deps.probeVersion ?? defaultProbeVersion;
|
|
46099
|
+
const fetchLatest = deps.fetchLatest ?? defaultFetchLatest;
|
|
46100
|
+
const results = [];
|
|
46101
|
+
inProgress = true;
|
|
46102
|
+
try {
|
|
46103
|
+
for (const adapter of adapters) {
|
|
46104
|
+
const source = adapter.source;
|
|
46105
|
+
if (opts.signal?.aborted) {
|
|
46106
|
+
results.push({ source, status: "skipped", detail: "daemon shutting down" });
|
|
46107
|
+
continue;
|
|
46108
|
+
}
|
|
46109
|
+
let plan2;
|
|
46110
|
+
try {
|
|
46111
|
+
plan2 = adapter.updatePlan?.();
|
|
46112
|
+
} catch {
|
|
46113
|
+
plan2 = null;
|
|
46114
|
+
}
|
|
46115
|
+
if (!plan2) {
|
|
46116
|
+
results.push({ source, status: "skipped", detail: "no unattended update path" });
|
|
46117
|
+
continue;
|
|
46118
|
+
}
|
|
46119
|
+
if (opts.busy?.()) {
|
|
46120
|
+
results.push({ source, status: "skipped", detail: "dispatch in flight" });
|
|
46121
|
+
continue;
|
|
46122
|
+
}
|
|
46123
|
+
const before = await probe(adapter.binary);
|
|
46124
|
+
if (plan2.pkg && before) {
|
|
46125
|
+
const latest = await fetchLatest(plan2.pkg);
|
|
46126
|
+
if (!latest) {
|
|
46127
|
+
results.push({ source, status: "skipped", from: before, detail: "registry check failed" });
|
|
46128
|
+
continue;
|
|
46129
|
+
}
|
|
46130
|
+
if (compareSemver(latest, before) <= 0) {
|
|
46131
|
+
results.push({ source, status: "current", from: before });
|
|
46132
|
+
opts.log("debug", `agent up-to-date: ${source} ${before}`);
|
|
46133
|
+
continue;
|
|
46134
|
+
}
|
|
46135
|
+
}
|
|
46136
|
+
opts.log("info", `agent update starting: ${source} via ${plan2.label}`, { from: before ?? "unknown" });
|
|
46137
|
+
const res = await exec(plan2.argv, UPDATE_TIMEOUT_MS, opts.signal);
|
|
46138
|
+
const after = await probe(adapter.binary);
|
|
46139
|
+
if (!res.ok) {
|
|
46140
|
+
results.push({ source, status: "failed", from: before, to: after, detail: tail(res.output) });
|
|
46141
|
+
opts.log("warn", `agent update failed: ${source}`, { detail: tail(res.output) });
|
|
46142
|
+
} else if (after && after !== before) {
|
|
46143
|
+
results.push({ source, status: "updated", from: before, to: after });
|
|
46144
|
+
opts.log("info", `agent updated: ${source} ${before ?? "unknown"} -> ${after}`);
|
|
46145
|
+
} else {
|
|
46146
|
+
results.push({ source, status: "current", from: before, to: after });
|
|
46147
|
+
opts.log("debug", `agent up-to-date: ${source} ${after ?? "unknown"}`);
|
|
46148
|
+
}
|
|
46149
|
+
}
|
|
46150
|
+
} finally {
|
|
46151
|
+
inProgress = false;
|
|
46152
|
+
}
|
|
46153
|
+
return results;
|
|
46154
|
+
}
|
|
46155
|
+
|
|
45947
46156
|
// src/relay/session-pool.ts
|
|
45948
46157
|
function userMessage(text) {
|
|
45949
46158
|
return {
|
|
@@ -46206,7 +46415,7 @@ var SessionPool = class {
|
|
|
46206
46415
|
init_config();
|
|
46207
46416
|
init_api();
|
|
46208
46417
|
init_agents();
|
|
46209
|
-
var RELAY_LOG_PATH =
|
|
46418
|
+
var RELAY_LOG_PATH = join26(homedir17(), ".gipity", "relay.log");
|
|
46210
46419
|
var HEARTBEAT_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_HEARTBEAT_MS || "60000", 10);
|
|
46211
46420
|
var DIAGNOSTICS_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_DIAGNOSTICS_MS || String(24 * 60 * 60 * 1e3), 10);
|
|
46212
46421
|
var LONG_POLL_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_POLL_TIMEOUT_MS || "35000", 10);
|
|
@@ -46306,7 +46515,7 @@ function lockLogPerms(dir, file) {
|
|
|
46306
46515
|
chmodSync3(dir, 448);
|
|
46307
46516
|
} catch {
|
|
46308
46517
|
}
|
|
46309
|
-
if (!
|
|
46518
|
+
if (!existsSync22(file)) {
|
|
46310
46519
|
try {
|
|
46311
46520
|
closeSync4(openSync4(file, "a", 384));
|
|
46312
46521
|
} catch {
|
|
@@ -46323,7 +46532,7 @@ function log2(level, msg, extra) {
|
|
|
46323
46532
|
const pretty = `${C7.dim(hhmmss())} ${badge(level)} ${C7.bold(msg)}${formatExtra(extra)}`;
|
|
46324
46533
|
process.stderr.write(pretty + "\n");
|
|
46325
46534
|
try {
|
|
46326
|
-
const dir =
|
|
46535
|
+
const dir = join26(homedir17(), ".gipity");
|
|
46327
46536
|
mkdirSync17(dir, { recursive: true });
|
|
46328
46537
|
lockLogPerms(dir, RELAY_LOG_PATH);
|
|
46329
46538
|
const json = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level, msg, ...extra ?? {} });
|
|
@@ -46403,14 +46612,41 @@ async function heartbeatLoop(ctx) {
|
|
|
46403
46612
|
let backoff = 0;
|
|
46404
46613
|
let sessionWarnLogged = false;
|
|
46405
46614
|
let lastDiagnosticsAt = 0;
|
|
46615
|
+
let lastAgentUpdateAt = 0;
|
|
46616
|
+
let agentUpdatePass = null;
|
|
46617
|
+
let diagnosticsRefreshNeeded = false;
|
|
46406
46618
|
while (!ctx.abort.signal.aborted) {
|
|
46407
46619
|
try {
|
|
46620
|
+
if (!agentUpdatePass && agentUpdatesEnabled() && Date.now() - lastAgentUpdateAt >= DIAGNOSTICS_INTERVAL_MS) {
|
|
46621
|
+
if (getRunningDispatchGuids().length > 0) {
|
|
46622
|
+
log2("debug", "agent updates deferred - dispatches in flight");
|
|
46623
|
+
} else {
|
|
46624
|
+
agentUpdatePass = runAgentUpdates({
|
|
46625
|
+
log: log2,
|
|
46626
|
+
busy: () => getRunningDispatchGuids().length > 0,
|
|
46627
|
+
signal: ctx.abort.signal
|
|
46628
|
+
}).then((results) => {
|
|
46629
|
+
lastAgentUpdateAt = Date.now();
|
|
46630
|
+
if (results.some((r7) => r7.status === "updated")) {
|
|
46631
|
+
diagnosticsRefreshNeeded = true;
|
|
46632
|
+
pokeHeartbeat();
|
|
46633
|
+
}
|
|
46634
|
+
}).catch((err) => {
|
|
46635
|
+
lastAgentUpdateAt = Date.now();
|
|
46636
|
+
log2("warn", "agent update pass failed", { err: err?.message });
|
|
46637
|
+
}).finally(() => {
|
|
46638
|
+
agentUpdatePass = null;
|
|
46639
|
+
});
|
|
46640
|
+
}
|
|
46641
|
+
}
|
|
46408
46642
|
let body = {};
|
|
46409
|
-
if (diagnosticsConsented() && Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS) {
|
|
46643
|
+
if (diagnosticsConsented() && (diagnosticsRefreshNeeded || Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS)) {
|
|
46644
|
+
diagnosticsRefreshNeeded = false;
|
|
46410
46645
|
try {
|
|
46411
46646
|
body = { diagnostics: await collectDiagnostics() };
|
|
46412
46647
|
lastDiagnosticsAt = Date.now();
|
|
46413
46648
|
} catch (err) {
|
|
46649
|
+
diagnosticsRefreshNeeded = true;
|
|
46414
46650
|
log2("debug", "diagnostics collection failed", { err: err?.message });
|
|
46415
46651
|
}
|
|
46416
46652
|
}
|
|
@@ -46509,6 +46745,10 @@ async function dispatchLoop(ctx, opts) {
|
|
|
46509
46745
|
}
|
|
46510
46746
|
await waitForSlot();
|
|
46511
46747
|
if (ctx.abort.signal.aborted) break;
|
|
46748
|
+
while (agentUpdateInProgress() && !ctx.abort.signal.aborted) {
|
|
46749
|
+
await sleep4(1e3, ctx.abort.signal);
|
|
46750
|
+
}
|
|
46751
|
+
if (ctx.abort.signal.aborted) break;
|
|
46512
46752
|
try {
|
|
46513
46753
|
const r = await deviceFetch("GET", "/remote-devices/next", void 0, LONG_POLL_TIMEOUT_MS, ctx.abort.signal);
|
|
46514
46754
|
if (r.status === 401) {
|
|
@@ -46724,7 +46964,7 @@ function isSafeSessionId(s) {
|
|
|
46724
46964
|
function transcriptPathFor(cwd, sessionId) {
|
|
46725
46965
|
if (!isSafeSessionId(sessionId)) return null;
|
|
46726
46966
|
const slug = cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
46727
|
-
return
|
|
46967
|
+
return join26(homedir17(), ".claude", "projects", slug, `${sessionId}.jsonl`);
|
|
46728
46968
|
}
|
|
46729
46969
|
function formatDuration(ms2) {
|
|
46730
46970
|
const totalSec = ms2 / 1e3;
|
|
@@ -46936,8 +47176,8 @@ async function handleDispatch(claimed) {
|
|
|
46936
47176
|
}
|
|
46937
47177
|
}
|
|
46938
47178
|
const stderrNote = stderrTail ? `: ${stderrTail.slice(0, 300)}` : "";
|
|
46939
|
-
const
|
|
46940
|
-
pushSystem(`Claude Code ${
|
|
47179
|
+
const tail2 = runtimeLimit ? `stopped after ${dur} (runtime limit)` : killed ? `cancelled (${dur})` : spawnErr ? `failed (${dur}: ${spawnErr})` : exitCode === 0 ? `finished (${dur})` : `failed (${dur}, exit ${exitCode}${stderrNote})`;
|
|
47180
|
+
pushSystem(`Claude Code ${tail2}`);
|
|
46941
47181
|
await flushQueue();
|
|
46942
47182
|
const metrics = startupMs !== void 0 ? { startup_ms: startupMs } : void 0;
|
|
46943
47183
|
if (runtimeLimit) {
|
|
@@ -46994,8 +47234,8 @@ async function handleNonClaudeDispatch(adapter, d, cwd, queue, pushSystem, flush
|
|
|
46994
47234
|
}
|
|
46995
47235
|
}
|
|
46996
47236
|
const stderrNote = stderrTail ? `: ${stderrTail.slice(0, 300)}` : "";
|
|
46997
|
-
const
|
|
46998
|
-
pushSystem(`${adapter.displayName} ${
|
|
47237
|
+
const tail2 = runtimeLimit ? `stopped after ${dur} (runtime limit)` : killed ? `cancelled (${dur})` : spawnErr ? `failed (${dur}: ${spawnErr})` : exitCode === 0 ? `finished (${dur})` : `failed (${dur}, exit ${exitCode}${stderrNote})`;
|
|
47238
|
+
pushSystem(`${adapter.displayName} ${tail2}`);
|
|
46999
47239
|
await flushQueue();
|
|
47000
47240
|
if (runtimeLimit) {
|
|
47001
47241
|
await ack(d.short_guid, "error", `${adapter.displayName} stopped after ${dur} (runtime limit)`);
|
|
@@ -47178,9 +47418,9 @@ async function resolveCwdForProject(d) {
|
|
|
47178
47418
|
throw new Error(`Invalid project slug: ${JSON.stringify(d.project_slug)}`);
|
|
47179
47419
|
}
|
|
47180
47420
|
const root = getProjectsRoot();
|
|
47181
|
-
const path5 =
|
|
47182
|
-
const configPath =
|
|
47183
|
-
if (
|
|
47421
|
+
const path5 = join26(root, d.project_slug);
|
|
47422
|
+
const configPath = join26(path5, ".gipity.json");
|
|
47423
|
+
if (existsSync22(configPath)) {
|
|
47184
47424
|
try {
|
|
47185
47425
|
const cfg = JSON.parse(readFileSync24(configPath, "utf-8"));
|
|
47186
47426
|
if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
|
|
@@ -47317,7 +47557,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
|
|
|
47317
47557
|
} catch {
|
|
47318
47558
|
}
|
|
47319
47559
|
try {
|
|
47320
|
-
unlinkSync7(
|
|
47560
|
+
unlinkSync7(join26(cwd, ".gipity", "sync.lock"));
|
|
47321
47561
|
} catch {
|
|
47322
47562
|
}
|
|
47323
47563
|
finish(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s`)));
|
|
@@ -47754,7 +47994,7 @@ relayCommand.command("run").description("Run the background service").option("-v
|
|
|
47754
47994
|
});
|
|
47755
47995
|
relayCommand.command("stop").description("Stop the background service").option("--force", "Force-stop if it doesn't exit cleanly within 5s").action(async (opts) => {
|
|
47756
47996
|
const pidPath = getDaemonPidPath();
|
|
47757
|
-
if (!
|
|
47997
|
+
if (!existsSync23(pidPath)) {
|
|
47758
47998
|
console.log(muted("Background service isn't running."));
|
|
47759
47999
|
return;
|
|
47760
48000
|
}
|
|
@@ -47840,6 +48080,30 @@ relayCommand.command("diagnostics [state]").description("View or set sharing of
|
|
|
47840
48080
|
setDiagnosticsConsent(on2);
|
|
47841
48081
|
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
48082
|
});
|
|
48083
|
+
relayCommand.command("updates [state]").description("View or set daily auto-update of installed coding agents (on|off)").action((arg) => {
|
|
48084
|
+
if (arg === void 0) {
|
|
48085
|
+
const stored = getAgentUpdatesPref();
|
|
48086
|
+
const effective = agentUpdatesEnabled();
|
|
48087
|
+
const label2 = stored === void 0 ? "on (default, not yet chosen)" : stored ? "on" : "off";
|
|
48088
|
+
console.log(`Agent auto-updates: ${effective ? success(label2) : muted(label2)}`);
|
|
48089
|
+
if (!effective && stored !== false) {
|
|
48090
|
+
console.log(muted(" (overridden off by DISABLE_AUTOUPDATER / GIPITY_RELAY_AGENT_UPDATES / CI)"));
|
|
48091
|
+
}
|
|
48092
|
+
console.log(muted(" Once a day, while idle, the relay brings its coding agents (Claude Code, Codex) to the latest release."));
|
|
48093
|
+
console.log(muted(" Upgrades appear in `gipity relay log` and in the device diagnostics on the web."));
|
|
48094
|
+
console.log(muted(" Set with `gipity relay updates on` / `gipity relay updates off`."));
|
|
48095
|
+
return;
|
|
48096
|
+
}
|
|
48097
|
+
const on2 = /^(on|true|yes|1|enable)$/i.test(arg);
|
|
48098
|
+
const off = /^(off|false|no|0|disable)$/i.test(arg);
|
|
48099
|
+
if (!on2 && !off) {
|
|
48100
|
+
console.log(error("Expected 'on' or 'off'."));
|
|
48101
|
+
process.exitCode = 1;
|
|
48102
|
+
return;
|
|
48103
|
+
}
|
|
48104
|
+
setAgentUpdatesPref(on2);
|
|
48105
|
+
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.")}`);
|
|
48106
|
+
});
|
|
47843
48107
|
relayCommand.command("rename <new-name>").description("Rename this device").action(async (newName) => {
|
|
47844
48108
|
const device = requirePaired2();
|
|
47845
48109
|
const name = newName.trim();
|
|
@@ -47882,7 +48146,7 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
47882
48146
|
} catch {
|
|
47883
48147
|
}
|
|
47884
48148
|
const pidPath = getDaemonPidPath();
|
|
47885
|
-
if (
|
|
48149
|
+
if (existsSync23(pidPath)) {
|
|
47886
48150
|
const pid = parseInt(readFileSync25(pidPath, "utf-8").trim(), 10);
|
|
47887
48151
|
if (pid && !isNaN(pid)) {
|
|
47888
48152
|
try {
|
|
@@ -47896,15 +48160,15 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
47896
48160
|
});
|
|
47897
48161
|
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
48162
|
const path5 = RELAY_LOG_PATH;
|
|
47899
|
-
if (!
|
|
48163
|
+
if (!existsSync23(path5)) {
|
|
47900
48164
|
console.log(muted("No log file yet. Start the service with `gipity relay run` (or install it)."));
|
|
47901
48165
|
return;
|
|
47902
48166
|
}
|
|
47903
48167
|
const lines = parseInt(opts.lines, 10) || 100;
|
|
47904
48168
|
try {
|
|
47905
48169
|
const all = readFileSync25(path5, "utf-8").split("\n");
|
|
47906
|
-
const
|
|
47907
|
-
process.stdout.write(
|
|
48170
|
+
const tail2 = all.slice(-lines - 1).join("\n");
|
|
48171
|
+
process.stdout.write(tail2);
|
|
47908
48172
|
} catch (err) {
|
|
47909
48173
|
console.error(error(`Could not read log: ${err?.message || err}`));
|
|
47910
48174
|
process.exit(1);
|
|
@@ -47973,17 +48237,17 @@ init_api();
|
|
|
47973
48237
|
init_auth();
|
|
47974
48238
|
init_utils();
|
|
47975
48239
|
init_colors();
|
|
47976
|
-
import { existsSync as
|
|
48240
|
+
import { existsSync as existsSync24, rmSync as rmSync4, unlinkSync as unlinkSync9, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "fs";
|
|
47977
48241
|
import { homedir as homedir18, platform as osPlatform4 } from "os";
|
|
47978
|
-
import { join as
|
|
48242
|
+
import { join as join27, resolve as resolve17 } from "path";
|
|
47979
48243
|
init_agents();
|
|
47980
48244
|
function removeInstallerPathLines() {
|
|
47981
48245
|
if (osPlatform4() === "win32") return [];
|
|
47982
48246
|
const marker = "# Added by the Gipity installer";
|
|
47983
48247
|
const touched = [];
|
|
47984
48248
|
for (const name of [".bashrc", ".zshrc", ".profile"]) {
|
|
47985
|
-
const rc2 =
|
|
47986
|
-
if (!
|
|
48249
|
+
const rc2 = join27(homedir18(), name);
|
|
48250
|
+
if (!existsSync24(rc2)) continue;
|
|
47987
48251
|
let text;
|
|
47988
48252
|
try {
|
|
47989
48253
|
text = readFileSync26(rc2, "utf-8");
|
|
@@ -48042,7 +48306,7 @@ function removeServiceUnit() {
|
|
|
48042
48306
|
const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio: "ignore" });
|
|
48043
48307
|
if (r.status !== 0) allOk = false;
|
|
48044
48308
|
}
|
|
48045
|
-
if (
|
|
48309
|
+
if (existsSync24(plan2.path)) {
|
|
48046
48310
|
try {
|
|
48047
48311
|
unlinkSync9(plan2.path);
|
|
48048
48312
|
} catch {
|
|
@@ -48065,9 +48329,9 @@ async function revokeDeviceBestEffort() {
|
|
|
48065
48329
|
}
|
|
48066
48330
|
var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
|
|
48067
48331
|
const autoYes = opts.yes || getAutoConfirm();
|
|
48068
|
-
const gipityDir =
|
|
48069
|
-
const launcherBin =
|
|
48070
|
-
const installedViaLauncher =
|
|
48332
|
+
const gipityDir = join27(homedir18(), ".gipity");
|
|
48333
|
+
const launcherBin = join27(gipityDir, "launcher", "bin", "gipity");
|
|
48334
|
+
const installedViaLauncher = existsSync24(launcherBin);
|
|
48071
48335
|
console.log(`${bold("Gipity uninstall")} - this will:`);
|
|
48072
48336
|
console.log(`\u2022 Stop the running relay daemon (if any)`);
|
|
48073
48337
|
console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
|
|
@@ -48108,7 +48372,7 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
|
|
|
48108
48372
|
if (!anyAgentIntegration) {
|
|
48109
48373
|
console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
|
|
48110
48374
|
}
|
|
48111
|
-
if (
|
|
48375
|
+
if (existsSync24(gipityDir)) {
|
|
48112
48376
|
try {
|
|
48113
48377
|
rmSync4(gipityDir, { recursive: true, force: true });
|
|
48114
48378
|
console.log(`${success(`Removed ${gipityDir}/`)}`);
|
|
@@ -48636,7 +48900,7 @@ function collectRealFlags(argv2, program3) {
|
|
|
48636
48900
|
|
|
48637
48901
|
// src/trace.ts
|
|
48638
48902
|
import { openSync as openSync5, writeSync, mkdirSync as mkdirSync18 } from "fs";
|
|
48639
|
-
import { join as
|
|
48903
|
+
import { join as join28 } from "path";
|
|
48640
48904
|
import { homedir as homedir19 } from "os";
|
|
48641
48905
|
var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
|
|
48642
48906
|
function installOutputTrace(label2) {
|
|
@@ -48648,10 +48912,10 @@ function installOutputTrace(label2) {
|
|
|
48648
48912
|
existing.emit({ event: "reenter", label: label2 });
|
|
48649
48913
|
return;
|
|
48650
48914
|
}
|
|
48651
|
-
const dir =
|
|
48915
|
+
const dir = join28(process.env.GIPITY_DIR || join28(homedir19(), ".gipity"), "trace");
|
|
48652
48916
|
mkdirSync18(dir, { recursive: true });
|
|
48653
48917
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
|
|
48654
|
-
const fd2 = openSync5(
|
|
48918
|
+
const fd2 = openSync5(join28(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
|
|
48655
48919
|
const emit = (rec) => {
|
|
48656
48920
|
try {
|
|
48657
48921
|
writeSync(fd2, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
|
|
@@ -48686,7 +48950,7 @@ function installOutputTrace(label2) {
|
|
|
48686
48950
|
|
|
48687
48951
|
// src/index.ts
|
|
48688
48952
|
installOutputTrace("index");
|
|
48689
|
-
var __dirname =
|
|
48953
|
+
var __dirname = dirname15(fileURLToPath3(import.meta.url));
|
|
48690
48954
|
var pkg = JSON.parse(readFileSync28(resolve18(__dirname, "../package.json"), "utf-8"));
|
|
48691
48955
|
function versionLabel() {
|
|
48692
48956
|
const base = `v${pkg.version}`;
|