gipity 1.1.11 → 1.1.13
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/README.md +3 -3
- package/dist/adopt-cwd.js +5 -6
- package/dist/agents/index.js +2 -0
- package/dist/agents/opencode.js +143 -0
- package/dist/api.js +14 -5
- package/dist/capture/sources/claude-code.js +23 -0
- package/dist/capture/sources/codex.js +30 -1
- package/dist/capture/sources/opencode.js +156 -0
- package/dist/commands/agent.js +14 -4
- package/dist/commands/build.js +13 -5
- package/dist/commands/generate.js +23 -8
- package/dist/commands/service.js +7 -2
- package/dist/hooks/capture-runner.js +94 -4
- package/dist/index.js +983 -552
- package/dist/knowledge.js +2 -2
- package/dist/opencode-setup.js +178 -0
- package/dist/provider-docs.js +6 -8
- package/dist/relay/setup.js +10 -1
- package/dist/setup.js +38 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6765,6 +6765,10 @@ function parseTranscript(content, afterUuid) {
|
|
|
6765
6765
|
let lastUuid = afterUuid;
|
|
6766
6766
|
const out = [];
|
|
6767
6767
|
const toolNames = /* @__PURE__ */ new Map();
|
|
6768
|
+
const countedUsage = /* @__PURE__ */ new Set();
|
|
6769
|
+
let tokensIn = 0;
|
|
6770
|
+
let tokensOut = 0;
|
|
6771
|
+
const num = (v7) => typeof v7 === "number" && v7 > 0 ? v7 : 0;
|
|
6768
6772
|
for (const raw of content.split("\n")) {
|
|
6769
6773
|
const line = raw.trim();
|
|
6770
6774
|
if (!line) continue;
|
|
@@ -6785,6 +6789,16 @@ function parseTranscript(content, afterUuid) {
|
|
|
6785
6789
|
if (parsed?.uuid === afterUuid) seenWatermark = true;
|
|
6786
6790
|
continue;
|
|
6787
6791
|
}
|
|
6792
|
+
if (parsed?.type === "assistant" && parsed?.isSidechain !== true) {
|
|
6793
|
+
const m = parsed.message;
|
|
6794
|
+
const u = m?.usage;
|
|
6795
|
+
const key = typeof m?.id === "string" && m.id ? m.id : parsed.uuid;
|
|
6796
|
+
if (u && typeof key === "string" && !countedUsage.has(key)) {
|
|
6797
|
+
countedUsage.add(key);
|
|
6798
|
+
tokensIn += num(u.input_tokens) + num(u.cache_read_input_tokens) + num(u.cache_creation_input_tokens);
|
|
6799
|
+
tokensOut += num(u.output_tokens);
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6788
6802
|
const entries = transcriptLineToEntries(parsed, toolNames);
|
|
6789
6803
|
if (entries.length) {
|
|
6790
6804
|
for (const e of entries) out.push(e);
|
|
@@ -6796,7 +6810,8 @@ function parseTranscript(content, afterUuid) {
|
|
|
6796
6810
|
return {
|
|
6797
6811
|
entries: out,
|
|
6798
6812
|
lastUuid,
|
|
6799
|
-
foundWatermark: seenWatermark
|
|
6813
|
+
foundWatermark: seenWatermark,
|
|
6814
|
+
usage: { tokensIn, tokensOut }
|
|
6800
6815
|
};
|
|
6801
6816
|
}
|
|
6802
6817
|
var init_claude_code = __esm({
|
|
@@ -6905,7 +6920,7 @@ Prefer the cheapest option that works - CLI and sandbox are instant and free, ap
|
|
|
6905
6920
|
3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime, location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` or \`gipity chat\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it.
|
|
6906
6921
|
4. Delegate to Gip (\`gipity chat "<task>"\`) - only when the work genuinely needs agent reasoning or a tool not in the CLI, sandbox, or app services. Required for: Twitter/X search, Gmail, calendar, push notifications, video understanding, audio source isolation, cross-model second opinions, multi-step orchestration. Don't use \`gipity chat\` for anything the sandbox can do - it's slower and burns tokens.
|
|
6907
6922
|
|
|
6908
|
-
You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Grok, and
|
|
6923
|
+
You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Grok, Codex, and opencode) auto-sync them to Gipity. Don't run \`npm install\`, \`npm start\`, \`node\`, or \`python\` locally; there is no local runtime. Code runs in the Gipity sandbox.
|
|
6909
6924
|
|
|
6910
6925
|
## Use first-party services before reaching outside
|
|
6911
6926
|
|
|
@@ -6997,7 +7012,7 @@ Every tool call returns its full output with that call. There is no output buffe
|
|
|
6997
7012
|
|
|
6998
7013
|
This directory is the app root - it holds \`.gipity.json\` (and \`gipity.yaml\` for backends) and is already your cwd, so run app commands here. Don't \`cd\` to a git root (\`git rev-parse --show-toplevel\`): when the app is nested in a larger repo that resolves outside the app.
|
|
6999
7014
|
|
|
7000
|
-
Write files locally - Gipity's editor hooks (installed into Claude Code, Grok, and
|
|
7015
|
+
Write files locally - Gipity's editor hooks (installed into Claude Code, Grok, Codex, and opencode by \`gipity init\`) auto-push every save to Gipity and auto-pull remote changes (images, audio from \`gipity chat\`) before each turn. Use \`gipity sync\` if things get out of sync (or if the hooks aren't installed - \`gipity status --repair-hooks\` re-enables them). Deletes are safe - use \`rollback\` with a datetime to undo, or \`file_version_restore\` for individual files.
|
|
7001
7016
|
|
|
7002
7017
|
To keep local-only material (research clones, scratch data, vendored references) in the project directory without syncing or deploying it, list it in a \`.gipityignore\` at the project root - gitignore-style, one pattern per line, \`#\` comments. Ignored paths are invisible to sync in both directions; anything that already synced before being ignored stays on the server until you delete it.
|
|
7003
7018
|
|
|
@@ -7067,10 +7082,145 @@ If any step fails, fix it before claiming done - do not report success on a brok
|
|
|
7067
7082
|
}
|
|
7068
7083
|
});
|
|
7069
7084
|
|
|
7085
|
+
// src/opencode-setup.ts
|
|
7086
|
+
import { execSync as execSync4 } from "child_process";
|
|
7087
|
+
import { copyFileSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2, chmodSync as chmodSync2 } from "fs";
|
|
7088
|
+
import { homedir as homedir3, hostname } from "os";
|
|
7089
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
7090
|
+
function opencodeConfigDir() {
|
|
7091
|
+
const base = process.env.XDG_CONFIG_HOME || join5(homedir3(), ".config");
|
|
7092
|
+
return join5(base, "opencode");
|
|
7093
|
+
}
|
|
7094
|
+
function opencodePluginDest() {
|
|
7095
|
+
return join5(opencodeConfigDir(), "plugins", "gipity.js");
|
|
7096
|
+
}
|
|
7097
|
+
function stagedPluginPath() {
|
|
7098
|
+
return join5(AGENT_HOOKS_DIR, "opencode-plugin.mjs");
|
|
7099
|
+
}
|
|
7100
|
+
function isOpencodeInstalled() {
|
|
7101
|
+
const cmd = process.platform === "win32" ? "where opencode" : "which opencode";
|
|
7102
|
+
try {
|
|
7103
|
+
execSync4(cmd, { stdio: "ignore", windowsHide: true });
|
|
7104
|
+
return true;
|
|
7105
|
+
} catch {
|
|
7106
|
+
return false;
|
|
7107
|
+
}
|
|
7108
|
+
}
|
|
7109
|
+
function ensureOpencodeInstalled(opts = {}) {
|
|
7110
|
+
if (isOpencodeInstalled()) return true;
|
|
7111
|
+
try {
|
|
7112
|
+
execSync4(`npm install -g ${OPENCODE_PACKAGE}`, {
|
|
7113
|
+
stdio: opts.quiet ? "ignore" : "inherit",
|
|
7114
|
+
windowsHide: true
|
|
7115
|
+
});
|
|
7116
|
+
} catch {
|
|
7117
|
+
}
|
|
7118
|
+
return isOpencodeInstalled();
|
|
7119
|
+
}
|
|
7120
|
+
function ensureOpencodePluginInstalled() {
|
|
7121
|
+
const src = stagedPluginPath();
|
|
7122
|
+
if (!existsSync4(src)) {
|
|
7123
|
+
const installed = existsSync4(opencodePluginDest());
|
|
7124
|
+
if (!installed) {
|
|
7125
|
+
console.warn(
|
|
7126
|
+
"Gipity opencode plugin is not staged (skills install incomplete?) - session capture is off. Re-run `gipity init` with network access to fix."
|
|
7127
|
+
);
|
|
7128
|
+
}
|
|
7129
|
+
return installed;
|
|
7130
|
+
}
|
|
7131
|
+
const dest = opencodePluginDest();
|
|
7132
|
+
try {
|
|
7133
|
+
if (existsSync4(dest) && readFileSync3(dest, "utf-8") === readFileSync3(src, "utf-8")) return true;
|
|
7134
|
+
mkdirSync2(join5(opencodeConfigDir(), "plugins"), { recursive: true });
|
|
7135
|
+
copyFileSync(src, dest);
|
|
7136
|
+
console.log("Installed the Gipity plugin for opencode (models + session capture).");
|
|
7137
|
+
return true;
|
|
7138
|
+
} catch {
|
|
7139
|
+
return existsSync4(dest);
|
|
7140
|
+
}
|
|
7141
|
+
}
|
|
7142
|
+
function opencodePluginState() {
|
|
7143
|
+
const src = stagedPluginPath();
|
|
7144
|
+
const dest = opencodePluginDest();
|
|
7145
|
+
try {
|
|
7146
|
+
return { current: existsSync4(dest) && (!existsSync4(src) || readFileSync3(dest, "utf-8") === readFileSync3(src, "utf-8")) };
|
|
7147
|
+
} catch {
|
|
7148
|
+
return { current: false };
|
|
7149
|
+
}
|
|
7150
|
+
}
|
|
7151
|
+
function removeOpencodePlugin() {
|
|
7152
|
+
const dest = opencodePluginDest();
|
|
7153
|
+
if (!existsSync4(dest)) return false;
|
|
7154
|
+
try {
|
|
7155
|
+
unlinkSync2(dest);
|
|
7156
|
+
} catch {
|
|
7157
|
+
return false;
|
|
7158
|
+
}
|
|
7159
|
+
return true;
|
|
7160
|
+
}
|
|
7161
|
+
function readOpencodeModelToken() {
|
|
7162
|
+
try {
|
|
7163
|
+
const parsed = JSON.parse(readFileSync3(OPENCODE_TOKEN_FILE, "utf-8"));
|
|
7164
|
+
return typeof parsed?.token === "string" && parsed.token ? parsed : null;
|
|
7165
|
+
} catch {
|
|
7166
|
+
return null;
|
|
7167
|
+
}
|
|
7168
|
+
}
|
|
7169
|
+
async function ensureOpencodeModelToken() {
|
|
7170
|
+
const existing = readOpencodeModelToken();
|
|
7171
|
+
if (existing) {
|
|
7172
|
+
try {
|
|
7173
|
+
const res = await fetch(`${resolveApiBase()}/users/me`, {
|
|
7174
|
+
headers: { Authorization: `Bearer ${existing.token}` }
|
|
7175
|
+
});
|
|
7176
|
+
if (res.status !== 401) return existing.token;
|
|
7177
|
+
} catch {
|
|
7178
|
+
return existing.token;
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
if (!getAuth()) return null;
|
|
7182
|
+
try {
|
|
7183
|
+
const res = await post(
|
|
7184
|
+
"/auth/agent-tokens",
|
|
7185
|
+
{ name: `opencode models on ${hostname()}`, expiresInDays: MODEL_TOKEN_EXPIRY_DAYS }
|
|
7186
|
+
);
|
|
7187
|
+
const stored = {
|
|
7188
|
+
token: res.data.token,
|
|
7189
|
+
guid: res.data.shortGuid,
|
|
7190
|
+
mintedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7191
|
+
};
|
|
7192
|
+
mkdirSync2(dirname2(OPENCODE_TOKEN_FILE), { recursive: true, mode: 448 });
|
|
7193
|
+
writeFileSync2(OPENCODE_TOKEN_FILE, JSON.stringify(stored, null, 2), { mode: 384 });
|
|
7194
|
+
try {
|
|
7195
|
+
chmodSync2(OPENCODE_TOKEN_FILE, 384);
|
|
7196
|
+
} catch {
|
|
7197
|
+
}
|
|
7198
|
+
return stored.token;
|
|
7199
|
+
} catch {
|
|
7200
|
+
return null;
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
var OPENCODE_PACKAGE, OPENCODE_TOKEN_FILE, MODEL_TOKEN_EXPIRY_DAYS;
|
|
7204
|
+
var init_opencode_setup = __esm({
|
|
7205
|
+
"src/opencode-setup.ts"() {
|
|
7206
|
+
"use strict";
|
|
7207
|
+
init_setup();
|
|
7208
|
+
init_api();
|
|
7209
|
+
init_auth();
|
|
7210
|
+
init_config();
|
|
7211
|
+
OPENCODE_PACKAGE = "opencode-ai";
|
|
7212
|
+
OPENCODE_TOKEN_FILE = join5(
|
|
7213
|
+
process.env.GIPITY_DIR || join5(homedir3(), ".gipity"),
|
|
7214
|
+
"opencode-token.json"
|
|
7215
|
+
);
|
|
7216
|
+
MODEL_TOKEN_EXPIRY_DAYS = 90;
|
|
7217
|
+
}
|
|
7218
|
+
});
|
|
7219
|
+
|
|
7070
7220
|
// src/setup.ts
|
|
7071
|
-
import { resolve, join as
|
|
7072
|
-
import { homedir as
|
|
7073
|
-
import { existsSync as
|
|
7221
|
+
import { resolve, join as join6, dirname as dirname3 } from "path";
|
|
7222
|
+
import { homedir as homedir4, tmpdir } from "os";
|
|
7223
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readFileSync as readFileSync4, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
|
|
7074
7224
|
function isSyncIgnored(name) {
|
|
7075
7225
|
if (name.startsWith(".")) return true;
|
|
7076
7226
|
if (DEFAULT_SYNC_IGNORE.includes(name)) return true;
|
|
@@ -7107,16 +7257,16 @@ function stripGipityHooks(settings) {
|
|
|
7107
7257
|
return changed;
|
|
7108
7258
|
}
|
|
7109
7259
|
function readSettingsFile(path5) {
|
|
7110
|
-
if (!
|
|
7260
|
+
if (!existsSync5(path5)) return {};
|
|
7111
7261
|
try {
|
|
7112
|
-
return JSON.parse(
|
|
7262
|
+
return JSON.parse(readFileSync4(path5, "utf-8"));
|
|
7113
7263
|
} catch {
|
|
7114
7264
|
return {};
|
|
7115
7265
|
}
|
|
7116
7266
|
}
|
|
7117
7267
|
function ensureGipityPlugin(force = false) {
|
|
7118
|
-
const claudeDir =
|
|
7119
|
-
const settingsPath =
|
|
7268
|
+
const claudeDir = join6(homedir4(), ".claude");
|
|
7269
|
+
const settingsPath = join6(claudeDir, "settings.json");
|
|
7120
7270
|
const settings = readSettingsFile(settingsPath);
|
|
7121
7271
|
let changed = stripGipityHooks(settings);
|
|
7122
7272
|
const marketplaces = settings.extraKnownMarketplaces ?? (settings.extraKnownMarketplaces = {});
|
|
@@ -7133,8 +7283,8 @@ function ensureGipityPlugin(force = false) {
|
|
|
7133
7283
|
changed = true;
|
|
7134
7284
|
}
|
|
7135
7285
|
if (!changed) return;
|
|
7136
|
-
|
|
7137
|
-
|
|
7286
|
+
mkdirSync3(claudeDir, { recursive: true });
|
|
7287
|
+
writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
7138
7288
|
}
|
|
7139
7289
|
function versionGte(have, want) {
|
|
7140
7290
|
const h = have.split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -7148,8 +7298,8 @@ function versionGte(have, want) {
|
|
|
7148
7298
|
}
|
|
7149
7299
|
function userScopeInstallState() {
|
|
7150
7300
|
try {
|
|
7151
|
-
const p =
|
|
7152
|
-
const data = JSON.parse(
|
|
7301
|
+
const p = join6(homedir4(), ".claude", "plugins", "installed_plugins.json");
|
|
7302
|
+
const data = JSON.parse(readFileSync4(p, "utf-8"));
|
|
7153
7303
|
const entries = data?.plugins?.[GIPITY_PLUGIN_ID];
|
|
7154
7304
|
if (!Array.isArray(entries)) return { exists: false, current: false };
|
|
7155
7305
|
const userEntries = entries.filter((e) => e?.scope === "user");
|
|
@@ -7164,11 +7314,11 @@ function userScopeInstallState() {
|
|
|
7164
7314
|
}
|
|
7165
7315
|
}
|
|
7166
7316
|
function removeGipityPluginConfig() {
|
|
7167
|
-
const settingsPath =
|
|
7168
|
-
if (!
|
|
7317
|
+
const settingsPath = join6(homedir4(), ".claude", "settings.json");
|
|
7318
|
+
if (!existsSync5(settingsPath)) return false;
|
|
7169
7319
|
let settings;
|
|
7170
7320
|
try {
|
|
7171
|
-
settings = JSON.parse(
|
|
7321
|
+
settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
|
|
7172
7322
|
} catch {
|
|
7173
7323
|
return false;
|
|
7174
7324
|
}
|
|
@@ -7183,7 +7333,7 @@ function removeGipityPluginConfig() {
|
|
|
7183
7333
|
if (Object.keys(settings.extraKnownMarketplaces).length === 0) delete settings.extraKnownMarketplaces;
|
|
7184
7334
|
changed = true;
|
|
7185
7335
|
}
|
|
7186
|
-
if (changed)
|
|
7336
|
+
if (changed) writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
7187
7337
|
return changed;
|
|
7188
7338
|
}
|
|
7189
7339
|
function binaryOnPath(bin) {
|
|
@@ -7209,8 +7359,8 @@ function ensureGipityPluginInstalled() {
|
|
|
7209
7359
|
}
|
|
7210
7360
|
function grokInstallState() {
|
|
7211
7361
|
try {
|
|
7212
|
-
const p =
|
|
7213
|
-
const data = JSON.parse(
|
|
7362
|
+
const p = join6(homedir4(), ".grok", "installed-plugins", "registry.json");
|
|
7363
|
+
const data = JSON.parse(readFileSync4(p, "utf-8"));
|
|
7214
7364
|
const versions = [];
|
|
7215
7365
|
for (const repo of Object.values(data?.repos ?? {})) {
|
|
7216
7366
|
const v7 = repo?.plugins?.gipity?.version;
|
|
@@ -7245,7 +7395,7 @@ function removeGrokPlugin() {
|
|
|
7245
7395
|
}
|
|
7246
7396
|
function skillsManifestState(manifestPath) {
|
|
7247
7397
|
try {
|
|
7248
|
-
const m = JSON.parse(
|
|
7398
|
+
const m = JSON.parse(readFileSync4(manifestPath, "utf-8"));
|
|
7249
7399
|
return {
|
|
7250
7400
|
current: typeof m?.version === "string" && versionGte(m.version, GIPITY_PLUGIN_VERSION),
|
|
7251
7401
|
skills: Array.isArray(m?.skills) ? m.skills : []
|
|
@@ -7264,7 +7414,7 @@ function removeManifestSkills(skillsDir, manifestPath) {
|
|
|
7264
7414
|
const { skills } = skillsManifestState(manifestPath);
|
|
7265
7415
|
for (const name of skills) {
|
|
7266
7416
|
try {
|
|
7267
|
-
rmSync(
|
|
7417
|
+
rmSync(join6(skillsDir, name), { recursive: true, force: true });
|
|
7268
7418
|
} catch {
|
|
7269
7419
|
}
|
|
7270
7420
|
}
|
|
@@ -7278,38 +7428,38 @@ function removeAgySkills() {
|
|
|
7278
7428
|
}
|
|
7279
7429
|
function installSkillsAndHooks(skillsDir, manifestPath, harnessLabel) {
|
|
7280
7430
|
if (!binaryOnPath("git")) return;
|
|
7281
|
-
const tmp = mkdtempSync(
|
|
7431
|
+
const tmp = mkdtempSync(join6(tmpdir(), "gipity-skills-"));
|
|
7282
7432
|
try {
|
|
7283
7433
|
const clone = spawnSyncCommand(
|
|
7284
7434
|
resolveCommand("git"),
|
|
7285
|
-
["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`,
|
|
7435
|
+
["clone", "--depth", "1", `https://github.com/${GIPITY_MARKETPLACE_REPO}.git`, join6(tmp, "repo")],
|
|
7286
7436
|
{ stdio: "ignore", timeout: 12e4 }
|
|
7287
7437
|
);
|
|
7288
7438
|
if (clone.status !== 0) return;
|
|
7289
|
-
const repo =
|
|
7439
|
+
const repo = join6(tmp, "repo");
|
|
7290
7440
|
let version = GIPITY_PLUGIN_VERSION;
|
|
7291
7441
|
try {
|
|
7292
|
-
const manifest = JSON.parse(
|
|
7442
|
+
const manifest = JSON.parse(readFileSync4(join6(repo, ".claude-plugin", "plugin.json"), "utf-8"));
|
|
7293
7443
|
if (typeof manifest?.version === "string") version = manifest.version;
|
|
7294
7444
|
} catch {
|
|
7295
7445
|
}
|
|
7296
|
-
const skillsSrc =
|
|
7446
|
+
const skillsSrc = join6(repo, "skills");
|
|
7297
7447
|
const names = [];
|
|
7298
7448
|
for (const entry of readdirSync2(skillsSrc, { withFileTypes: true })) {
|
|
7299
7449
|
if (!entry.isDirectory()) continue;
|
|
7300
|
-
if (!
|
|
7301
|
-
|
|
7302
|
-
cpSync(
|
|
7450
|
+
if (!existsSync5(join6(skillsSrc, entry.name, "SKILL.md"))) continue;
|
|
7451
|
+
mkdirSync3(skillsDir, { recursive: true });
|
|
7452
|
+
cpSync(join6(skillsSrc, entry.name), join6(skillsDir, entry.name), {
|
|
7303
7453
|
recursive: true,
|
|
7304
7454
|
force: true
|
|
7305
7455
|
});
|
|
7306
7456
|
names.push(entry.name);
|
|
7307
7457
|
}
|
|
7308
|
-
|
|
7309
|
-
for (const script of readdirSync2(
|
|
7310
|
-
cpSync(
|
|
7458
|
+
mkdirSync3(AGENT_HOOKS_DIR, { recursive: true });
|
|
7459
|
+
for (const script of readdirSync2(join6(repo, "hooks", "scripts"))) {
|
|
7460
|
+
cpSync(join6(repo, "hooks", "scripts", script), join6(AGENT_HOOKS_DIR, script), { force: true });
|
|
7311
7461
|
}
|
|
7312
|
-
|
|
7462
|
+
writeFileSync3(manifestPath, JSON.stringify({ version, skills: names }, null, 2) + "\n");
|
|
7313
7463
|
console.log(`Installed ${names.length} Gipity skills for ${harnessLabel} (${skillsDir}).`);
|
|
7314
7464
|
} catch {
|
|
7315
7465
|
} finally {
|
|
@@ -7327,8 +7477,8 @@ function ensureAgySkillsInstalled() {
|
|
|
7327
7477
|
installSkillsAndHooks(AGY_SKILLS_DIR, AGY_SKILLS_MANIFEST, "Antigravity");
|
|
7328
7478
|
}
|
|
7329
7479
|
function applyCodexHooks(existing) {
|
|
7330
|
-
const launcher =
|
|
7331
|
-
const cmd = (script, ...args) => [`sh "${launcher}" "${
|
|
7480
|
+
const launcher = join6(AGENT_HOOKS_DIR, "launch.sh");
|
|
7481
|
+
const cmd = (script, ...args) => [`sh "${launcher}" "${join6(AGENT_HOOKS_DIR, script)}"`, ...args].join(" ");
|
|
7332
7482
|
const wanted = [
|
|
7333
7483
|
{ event: "PostToolUse", matcher: "Edit|Write", command: cmd("sync-push.cjs"), timeout: 30 },
|
|
7334
7484
|
{ event: "UserPromptSubmit", command: cmd("sync-pull.cjs"), timeout: 300 },
|
|
@@ -7365,13 +7515,13 @@ function applyCodexHooks(existing) {
|
|
|
7365
7515
|
function setupCodexHooks() {
|
|
7366
7516
|
if (process.platform === "win32") return;
|
|
7367
7517
|
const cwd = resolve(process.cwd());
|
|
7368
|
-
if (cwd === resolve(
|
|
7369
|
-
const path5 =
|
|
7370
|
-
const existing =
|
|
7518
|
+
if (cwd === resolve(homedir4())) return;
|
|
7519
|
+
const path5 = join6(cwd, ".codex", "hooks.json");
|
|
7520
|
+
const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
|
|
7371
7521
|
const next = applyCodexHooks(existing);
|
|
7372
7522
|
if (next === null) return;
|
|
7373
|
-
|
|
7374
|
-
|
|
7523
|
+
mkdirSync3(dirname3(path5), { recursive: true });
|
|
7524
|
+
writeFileSync3(path5, next);
|
|
7375
7525
|
if (existing === null) {
|
|
7376
7526
|
console.log("Wrote Codex sync + session-capture hooks (.codex/hooks.json) - approve them once with /hooks inside Codex.");
|
|
7377
7527
|
} else {
|
|
@@ -7383,9 +7533,19 @@ function setupCodexIntegration() {
|
|
|
7383
7533
|
ensureAgentSkillsInstalled();
|
|
7384
7534
|
setupCodexHooks();
|
|
7385
7535
|
}
|
|
7536
|
+
function ensureOpencodeSkillsInstalled() {
|
|
7537
|
+
if (agentSkillsState().current && existsSync5(stagedPluginPath())) return;
|
|
7538
|
+
if (!binaryOnPath("opencode")) return;
|
|
7539
|
+
installSkillsAndHooks(AGENTS_SKILLS_DIR, AGENT_SKILLS_MANIFEST, "opencode");
|
|
7540
|
+
}
|
|
7541
|
+
function setupOpencodeIntegration() {
|
|
7542
|
+
if (!binaryOnPath("opencode")) return;
|
|
7543
|
+
ensureOpencodeSkillsInstalled();
|
|
7544
|
+
ensureOpencodePluginInstalled();
|
|
7545
|
+
}
|
|
7386
7546
|
function applyAgyHooks(existing) {
|
|
7387
|
-
const wrapper =
|
|
7388
|
-
const launcher =
|
|
7547
|
+
const wrapper = join6(AGENT_HOOKS_DIR, "agy-hooks.cjs");
|
|
7548
|
+
const launcher = join6(AGENT_HOOKS_DIR, "launch.sh");
|
|
7389
7549
|
const wrapCmd = (event) => `sh "${launcher}" "${wrapper}" ${event}`;
|
|
7390
7550
|
const block = {
|
|
7391
7551
|
PostToolUse: [
|
|
@@ -7415,15 +7575,15 @@ function applyAgyHooks(existing) {
|
|
|
7415
7575
|
function setupAgyHooks() {
|
|
7416
7576
|
if (process.platform === "win32") return;
|
|
7417
7577
|
const cwd = resolve(process.cwd());
|
|
7418
|
-
if (cwd === resolve(
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
const path5 =
|
|
7422
|
-
const existing =
|
|
7578
|
+
if (cwd === resolve(homedir4())) return;
|
|
7579
|
+
mkdirSync3(AGENT_HOOKS_DIR, { recursive: true });
|
|
7580
|
+
writeFileSync3(join6(AGENT_HOOKS_DIR, "agy-hooks.cjs"), AGY_HOOKS_SCRIPT);
|
|
7581
|
+
const path5 = join6(cwd, ".agents", "hooks.json");
|
|
7582
|
+
const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
|
|
7423
7583
|
const next = applyAgyHooks(existing);
|
|
7424
7584
|
if (next === null) return;
|
|
7425
|
-
|
|
7426
|
-
|
|
7585
|
+
mkdirSync3(dirname3(path5), { recursive: true });
|
|
7586
|
+
writeFileSync3(path5, next);
|
|
7427
7587
|
console.log(existing === null ? "Wrote Antigravity sync + session-capture hooks (.agents/hooks.json)." : "Updated Antigravity hooks (.agents/hooks.json).");
|
|
7428
7588
|
}
|
|
7429
7589
|
function setupAgyIntegration() {
|
|
@@ -7434,10 +7594,10 @@ function setupAgyIntegration() {
|
|
|
7434
7594
|
function setupClaudeHooks() {
|
|
7435
7595
|
ensureGipityPlugin();
|
|
7436
7596
|
const cwd = resolve(process.cwd());
|
|
7437
|
-
if (cwd === resolve(
|
|
7438
|
-
const claudeDir =
|
|
7439
|
-
|
|
7440
|
-
const settingsPath =
|
|
7597
|
+
if (cwd === resolve(homedir4())) return;
|
|
7598
|
+
const claudeDir = join6(cwd, ".claude");
|
|
7599
|
+
mkdirSync3(claudeDir, { recursive: true });
|
|
7600
|
+
const settingsPath = join6(claudeDir, "settings.json");
|
|
7441
7601
|
const settings = readSettingsFile(settingsPath);
|
|
7442
7602
|
stripGipityHooks(settings);
|
|
7443
7603
|
const perms = settings.permissions || {};
|
|
@@ -7448,7 +7608,7 @@ function setupClaudeHooks() {
|
|
|
7448
7608
|
}
|
|
7449
7609
|
}
|
|
7450
7610
|
settings.permissions = perms;
|
|
7451
|
-
|
|
7611
|
+
writeFileSync3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
7452
7612
|
}
|
|
7453
7613
|
function renderManagedBlock(apiBase2) {
|
|
7454
7614
|
let body = [SKILLS_CONTENT, BUILD_VS_NON_BUILD_RULE, DEFINITION_OF_DONE].join("\n\n");
|
|
@@ -7481,11 +7641,11 @@ function applySkillsBlock(existing, apiBase2 = DEFAULT_API_BASE) {
|
|
|
7481
7641
|
}
|
|
7482
7642
|
function writeSkillsFile(relPath, wrap) {
|
|
7483
7643
|
const path5 = resolve(process.cwd(), relPath);
|
|
7484
|
-
|
|
7485
|
-
const existing =
|
|
7644
|
+
mkdirSync3(dirname3(path5), { recursive: true });
|
|
7645
|
+
const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
|
|
7486
7646
|
const baseNext = applySkillsBlock(existing, resolveApiBase());
|
|
7487
7647
|
const next = wrap && existing === null ? wrap(baseNext) : baseNext;
|
|
7488
|
-
if (next !== existing)
|
|
7648
|
+
if (next !== existing) writeFileSync3(path5, next);
|
|
7489
7649
|
}
|
|
7490
7650
|
function setupClaudeMd() {
|
|
7491
7651
|
writeSkillsFile(PRIMER_FILES.claude);
|
|
@@ -7525,9 +7685,9 @@ function applyAiderConf(existing) {
|
|
|
7525
7685
|
function setupAiderMd() {
|
|
7526
7686
|
writeSkillsFile(PRIMER_FILES.aider);
|
|
7527
7687
|
const path5 = resolve(process.cwd(), AIDER_CONF_FILE);
|
|
7528
|
-
const existing =
|
|
7688
|
+
const existing = existsSync5(path5) ? readFileSync4(path5, "utf-8") : null;
|
|
7529
7689
|
const next = applyAiderConf(existing);
|
|
7530
|
-
if (next !== null)
|
|
7690
|
+
if (next !== null) writeFileSync3(path5, next);
|
|
7531
7691
|
}
|
|
7532
7692
|
function setupGeminiMd() {
|
|
7533
7693
|
writeSkillsFile(PRIMER_FILES.gemini);
|
|
@@ -7556,16 +7716,16 @@ function setupProjectTools(tools = DEFAULT_TOOLS) {
|
|
|
7556
7716
|
function setupGitignore() {
|
|
7557
7717
|
const gitignorePath = resolve(process.cwd(), ".gitignore");
|
|
7558
7718
|
const entries = [".gipity/", ".gipity.json", ...SCRATCH_IGNORE];
|
|
7559
|
-
if (
|
|
7560
|
-
let content =
|
|
7719
|
+
if (existsSync5(gitignorePath)) {
|
|
7720
|
+
let content = readFileSync4(gitignorePath, "utf-8");
|
|
7561
7721
|
const lines = content.split(/\r?\n/);
|
|
7562
7722
|
const toAdd = entries.filter((e) => !lines.includes(e));
|
|
7563
7723
|
if (toAdd.length > 0) {
|
|
7564
7724
|
content = content.trimEnd() + "\n" + toAdd.join("\n") + "\n";
|
|
7565
|
-
|
|
7725
|
+
writeFileSync3(gitignorePath, content);
|
|
7566
7726
|
}
|
|
7567
7727
|
} else {
|
|
7568
|
-
|
|
7728
|
+
writeFileSync3(gitignorePath, entries.join("\n") + "\n");
|
|
7569
7729
|
}
|
|
7570
7730
|
}
|
|
7571
7731
|
function slugify(name) {
|
|
@@ -7582,6 +7742,7 @@ var init_setup = __esm({
|
|
|
7582
7742
|
init_platform();
|
|
7583
7743
|
init_knowledge();
|
|
7584
7744
|
init_config();
|
|
7745
|
+
init_opencode_setup();
|
|
7585
7746
|
PRIMER_FILES = {
|
|
7586
7747
|
claude: "CLAUDE.md",
|
|
7587
7748
|
codex: "AGENTS.md",
|
|
@@ -7589,6 +7750,8 @@ var init_setup = __esm({
|
|
|
7589
7750
|
// Grok Build reads the AGENTS.md family (and CLAUDE.md) natively
|
|
7590
7751
|
agy: "AGENTS.md",
|
|
7591
7752
|
// Antigravity reads the same AGENTS.md/GEMINI.md rules family natively
|
|
7753
|
+
opencode: "AGENTS.md",
|
|
7754
|
+
// opencode reads AGENTS.md (and CLAUDE.md) natively
|
|
7592
7755
|
aider: "AGENTS.md",
|
|
7593
7756
|
// shares the Codex primer; aider is pointed at it via .aider.conf.yml
|
|
7594
7757
|
gemini: "GEMINI.md",
|
|
@@ -7659,12 +7822,12 @@ var init_setup = __esm({
|
|
|
7659
7822
|
GIPITY_MARKETPLACE_NAME = "gipity";
|
|
7660
7823
|
GIPITY_MARKETPLACE_REPO = "GipityAI/skills";
|
|
7661
7824
|
LEGACY_MARKETPLACE_REPO = "GipityAI/claude-plugin";
|
|
7662
|
-
GIPITY_PLUGIN_VERSION = "0.
|
|
7663
|
-
AGENTS_SKILLS_DIR =
|
|
7664
|
-
AGENT_HOOKS_DIR =
|
|
7665
|
-
AGENT_SKILLS_MANIFEST =
|
|
7666
|
-
AGY_SKILLS_DIR =
|
|
7667
|
-
AGY_SKILLS_MANIFEST =
|
|
7825
|
+
GIPITY_PLUGIN_VERSION = "0.8.0";
|
|
7826
|
+
AGENTS_SKILLS_DIR = join6(homedir4(), ".agents", "skills");
|
|
7827
|
+
AGENT_HOOKS_DIR = join6(homedir4(), ".gipity", "agent-hooks");
|
|
7828
|
+
AGENT_SKILLS_MANIFEST = join6(homedir4(), ".gipity", "agent-skills.json");
|
|
7829
|
+
AGY_SKILLS_DIR = join6(homedir4(), ".gemini", "config", "skills");
|
|
7830
|
+
AGY_SKILLS_MANIFEST = join6(homedir4(), ".gipity", "agy-skills.json");
|
|
7668
7831
|
AGY_HOOKS_SCRIPT = `#!/usr/bin/env node
|
|
7669
7832
|
'use strict';
|
|
7670
7833
|
const { spawnSync } = require('child_process');
|
|
@@ -7725,6 +7888,7 @@ main();
|
|
|
7725
7888
|
{ key: "codex", label: "OpenAI Codex (AGENTS.md + skills + sync hooks)", setup: setupAgentsMd, integrate: setupCodexIntegration },
|
|
7726
7889
|
{ key: "grok", label: "Grok Build (AGENTS.md + Gipity plugin)", setup: setupAgentsMd, integrate: ensureGrokPluginInstalled },
|
|
7727
7890
|
{ key: "agy", label: "Antigravity (AGENTS.md + skills + sync hooks)", setup: setupAgentsMd, integrate: setupAgyIntegration },
|
|
7891
|
+
{ key: "opencode", label: "opencode (AGENTS.md + skills + Gipity plugin)", setup: setupAgentsMd, integrate: setupOpencodeIntegration },
|
|
7728
7892
|
{ key: "aider", label: "Aider (AGENTS.md + .aider.conf.yml)", setup: setupAiderMd, optIn: true },
|
|
7729
7893
|
{ key: "gemini", label: "Gemini CLI (GEMINI.md)", setup: setupGeminiMd },
|
|
7730
7894
|
{ key: "copilot", label: "GitHub Copilot (.github/copilot-instructions.md)", setup: setupCopilotMd },
|
|
@@ -7905,6 +8069,12 @@ function lineToEntries(parsed, sessionId, idx, toolNames) {
|
|
|
7905
8069
|
}
|
|
7906
8070
|
return [];
|
|
7907
8071
|
}
|
|
8072
|
+
function tokenTotals(payload) {
|
|
8073
|
+
const t = payload?.info?.total_token_usage;
|
|
8074
|
+
if (!t || typeof t !== "object") return null;
|
|
8075
|
+
const num = (v7) => typeof v7 === "number" && v7 > 0 ? v7 : 0;
|
|
8076
|
+
return { input: num(t.input_tokens), output: num(t.output_tokens) };
|
|
8077
|
+
}
|
|
7908
8078
|
function parseTranscript2(content, afterUuid) {
|
|
7909
8079
|
const lines = content.split("\n");
|
|
7910
8080
|
let sessionId = "";
|
|
@@ -7926,6 +8096,8 @@ function parseTranscript2(content, afterUuid) {
|
|
|
7926
8096
|
const out = [];
|
|
7927
8097
|
const toolNames = /* @__PURE__ */ new Map();
|
|
7928
8098
|
let lastIdx = startAfter;
|
|
8099
|
+
let baseUsage = null;
|
|
8100
|
+
let lastUsage = null;
|
|
7929
8101
|
for (let i = 0; i < lines.length; i++) {
|
|
7930
8102
|
const line = lines[i].trim();
|
|
7931
8103
|
if (!line) continue;
|
|
@@ -7935,13 +8107,16 @@ function parseTranscript2(content, afterUuid) {
|
|
|
7935
8107
|
} catch {
|
|
7936
8108
|
continue;
|
|
7937
8109
|
}
|
|
8110
|
+
const isTokenCount = parsed?.type === "event_msg" && parsed?.payload?.type === "token_count";
|
|
7938
8111
|
if (startAfter !== null && i <= startAfter) {
|
|
7939
8112
|
const p = parsed?.payload;
|
|
7940
8113
|
if (parsed?.type === "response_item" && p && (p.type === "custom_tool_call" || p.type === "function_call") && typeof p.call_id === "string") {
|
|
7941
8114
|
toolNames.set(p.call_id, typeof p.name === "string" && p.name ? p.name : "tool");
|
|
7942
8115
|
}
|
|
8116
|
+
if (isTokenCount) baseUsage = tokenTotals(parsed.payload) ?? baseUsage;
|
|
7943
8117
|
continue;
|
|
7944
8118
|
}
|
|
8119
|
+
if (isTokenCount) lastUsage = tokenTotals(parsed.payload) ?? lastUsage;
|
|
7945
8120
|
const entries = lineToEntries(parsed, sessionId, i, toolNames);
|
|
7946
8121
|
for (const e of entries) out.push(e);
|
|
7947
8122
|
lastIdx = i;
|
|
@@ -7949,7 +8124,11 @@ function parseTranscript2(content, afterUuid) {
|
|
|
7949
8124
|
return {
|
|
7950
8125
|
entries: out,
|
|
7951
8126
|
lastUuid: lastIdx === null ? afterUuid : positional(sessionId, lastIdx),
|
|
7952
|
-
foundWatermark
|
|
8127
|
+
foundWatermark,
|
|
8128
|
+
usage: lastUsage === null ? { tokensIn: 0, tokensOut: 0 } : {
|
|
8129
|
+
tokensIn: Math.max(0, lastUsage.input - (baseUsage?.input ?? 0)),
|
|
8130
|
+
tokensOut: Math.max(0, lastUsage.output - (baseUsage?.output ?? 0))
|
|
8131
|
+
}
|
|
7953
8132
|
};
|
|
7954
8133
|
}
|
|
7955
8134
|
var init_codex = __esm({
|
|
@@ -8160,8 +8339,8 @@ var init_grok = __esm({
|
|
|
8160
8339
|
});
|
|
8161
8340
|
|
|
8162
8341
|
// src/agents/grok.ts
|
|
8163
|
-
import { homedir as
|
|
8164
|
-
import { join as
|
|
8342
|
+
import { homedir as homedir5 } from "os";
|
|
8343
|
+
import { join as join7 } from "path";
|
|
8165
8344
|
var grokAdapter;
|
|
8166
8345
|
var init_grok2 = __esm({
|
|
8167
8346
|
"src/agents/grok.ts"() {
|
|
@@ -8219,7 +8398,7 @@ var init_grok2 = __esm({
|
|
|
8219
8398
|
resolveTranscriptPath: (hook) => {
|
|
8220
8399
|
if (!hook.session_id) return null;
|
|
8221
8400
|
const cwd = hook.cwd ?? process.cwd();
|
|
8222
|
-
return
|
|
8401
|
+
return join7(homedir5(), ".grok", "sessions", encodeURIComponent(cwd), hook.session_id, "chat_history.jsonl");
|
|
8223
8402
|
}
|
|
8224
8403
|
},
|
|
8225
8404
|
setup: {
|
|
@@ -8424,6 +8603,231 @@ var init_agy2 = __esm({
|
|
|
8424
8603
|
}
|
|
8425
8604
|
});
|
|
8426
8605
|
|
|
8606
|
+
// src/capture/sources/opencode.ts
|
|
8607
|
+
function toIso(ms2) {
|
|
8608
|
+
return typeof ms2 === "number" && ms2 > 0 ? new Date(ms2).toISOString() : void 0;
|
|
8609
|
+
}
|
|
8610
|
+
function joinTextParts(parts) {
|
|
8611
|
+
const out = [];
|
|
8612
|
+
for (const p of parts) {
|
|
8613
|
+
if (p?.type === "text" && typeof p.text === "string" && !p.synthetic && !p.ignored) {
|
|
8614
|
+
out.push(p.text);
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
return out.join("\n");
|
|
8618
|
+
}
|
|
8619
|
+
function messageToEntries(info2, parts) {
|
|
8620
|
+
if (!info2 || typeof info2.id !== "string") return [];
|
|
8621
|
+
const ts2 = toIso(info2?.time?.created);
|
|
8622
|
+
if (info2.role === "user") {
|
|
8623
|
+
const prompt2 = joinTextParts(parts);
|
|
8624
|
+
if (!prompt2) return [];
|
|
8625
|
+
return [{ kind: "prompt", prompt: prompt2, source_uuid: info2.id, ...ts2 ? { ts: ts2 } : {} }];
|
|
8626
|
+
}
|
|
8627
|
+
if (info2.role === "assistant") {
|
|
8628
|
+
const out = [];
|
|
8629
|
+
const text = joinTextParts(parts);
|
|
8630
|
+
const toolParts = parts.filter((p) => p?.type === "tool" && typeof p.callID === "string" && p.callID);
|
|
8631
|
+
if (text || toolParts.length) {
|
|
8632
|
+
out.push({
|
|
8633
|
+
kind: "assistant",
|
|
8634
|
+
text,
|
|
8635
|
+
blocks: text ? [{ type: "text", text }] : [],
|
|
8636
|
+
...typeof info2?.tokens?.input === "number" ? { input_tokens: info2.tokens.input } : {},
|
|
8637
|
+
...typeof info2?.tokens?.output === "number" ? { output_tokens: info2.tokens.output } : {},
|
|
8638
|
+
...typeof info2.modelID === "string" ? { model: info2.modelID } : {},
|
|
8639
|
+
...typeof info2.finish === "string" ? { stop_reason: info2.finish } : {},
|
|
8640
|
+
source_uuid: info2.id,
|
|
8641
|
+
...ts2 ? { ts: ts2 } : {}
|
|
8642
|
+
});
|
|
8643
|
+
}
|
|
8644
|
+
for (const p of toolParts) {
|
|
8645
|
+
const toolName = typeof p.tool === "string" && p.tool ? p.tool : "tool";
|
|
8646
|
+
out.push({
|
|
8647
|
+
kind: "tool_use",
|
|
8648
|
+
tool_use_id: p.callID,
|
|
8649
|
+
tool_name: toolName,
|
|
8650
|
+
tool_input: p?.state?.input ?? null,
|
|
8651
|
+
source_uuid: p.callID
|
|
8652
|
+
});
|
|
8653
|
+
const status = p?.state?.status;
|
|
8654
|
+
if (status === "completed" || status === "error") {
|
|
8655
|
+
out.push({
|
|
8656
|
+
kind: "tool_result",
|
|
8657
|
+
tool_use_id: p.callID,
|
|
8658
|
+
tool_name: toolName,
|
|
8659
|
+
content: status === "error" ? p.state.error ?? "" : p.state.output ?? "",
|
|
8660
|
+
...status === "error" ? { is_error: true } : {},
|
|
8661
|
+
source_uuid: `${p.callID}#out`
|
|
8662
|
+
});
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
return out;
|
|
8666
|
+
}
|
|
8667
|
+
return [];
|
|
8668
|
+
}
|
|
8669
|
+
function parseTranscript5(content, afterUuid) {
|
|
8670
|
+
const lines = content.split("\n");
|
|
8671
|
+
let watermarkLine = -1;
|
|
8672
|
+
if (afterUuid) {
|
|
8673
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8674
|
+
const line = lines[i].trim();
|
|
8675
|
+
if (!line) continue;
|
|
8676
|
+
try {
|
|
8677
|
+
if (JSON.parse(line)?.info?.id === afterUuid) {
|
|
8678
|
+
watermarkLine = i;
|
|
8679
|
+
break;
|
|
8680
|
+
}
|
|
8681
|
+
} catch {
|
|
8682
|
+
}
|
|
8683
|
+
}
|
|
8684
|
+
}
|
|
8685
|
+
const foundWatermark = afterUuid === null || watermarkLine !== -1;
|
|
8686
|
+
const out = [];
|
|
8687
|
+
let lastUuid = foundWatermark ? afterUuid : null;
|
|
8688
|
+
let tokensIn = 0;
|
|
8689
|
+
let tokensOut = 0;
|
|
8690
|
+
const num = (v7) => typeof v7 === "number" && v7 > 0 ? v7 : 0;
|
|
8691
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8692
|
+
if (watermarkLine !== -1 && i <= watermarkLine) continue;
|
|
8693
|
+
const line = lines[i].trim();
|
|
8694
|
+
if (!line) continue;
|
|
8695
|
+
let parsed;
|
|
8696
|
+
try {
|
|
8697
|
+
parsed = JSON.parse(line);
|
|
8698
|
+
} catch {
|
|
8699
|
+
continue;
|
|
8700
|
+
}
|
|
8701
|
+
const info2 = parsed?.info;
|
|
8702
|
+
const entries = messageToEntries(info2, Array.isArray(parsed?.parts) ? parsed.parts : []);
|
|
8703
|
+
if (!entries.length) continue;
|
|
8704
|
+
if (info2?.role === "assistant" && info2?.tokens) {
|
|
8705
|
+
tokensIn += num(info2.tokens.input) + num(info2.tokens.cache?.read) + num(info2.tokens.cache?.write);
|
|
8706
|
+
tokensOut += num(info2.tokens.output);
|
|
8707
|
+
}
|
|
8708
|
+
for (const e of entries) out.push(e);
|
|
8709
|
+
if (typeof info2?.id === "string") lastUuid = info2.id;
|
|
8710
|
+
}
|
|
8711
|
+
return { entries: out, lastUuid, foundWatermark, usage: { tokensIn, tokensOut } };
|
|
8712
|
+
}
|
|
8713
|
+
var init_opencode = __esm({
|
|
8714
|
+
"src/capture/sources/opencode.ts"() {
|
|
8715
|
+
"use strict";
|
|
8716
|
+
}
|
|
8717
|
+
});
|
|
8718
|
+
|
|
8719
|
+
// src/agents/opencode.ts
|
|
8720
|
+
import { homedir as homedir6 } from "os";
|
|
8721
|
+
import { join as join8 } from "path";
|
|
8722
|
+
function toOpencodeModel(model) {
|
|
8723
|
+
const head = model.split("/", 1)[0];
|
|
8724
|
+
return OPENCODE_NATIVE_PROVIDERS.has(head) ? model : `gipity/${model}`;
|
|
8725
|
+
}
|
|
8726
|
+
var OPENCODE_NATIVE_PROVIDERS, opencodeAdapter;
|
|
8727
|
+
var init_opencode2 = __esm({
|
|
8728
|
+
"src/agents/opencode.ts"() {
|
|
8729
|
+
"use strict";
|
|
8730
|
+
init_types();
|
|
8731
|
+
init_self_update();
|
|
8732
|
+
init_opencode();
|
|
8733
|
+
init_opencode_setup();
|
|
8734
|
+
init_setup();
|
|
8735
|
+
OPENCODE_NATIVE_PROVIDERS = /* @__PURE__ */ new Set([
|
|
8736
|
+
"gipity",
|
|
8737
|
+
"anthropic",
|
|
8738
|
+
"openai",
|
|
8739
|
+
"google",
|
|
8740
|
+
"openrouter",
|
|
8741
|
+
"xai",
|
|
8742
|
+
"groq",
|
|
8743
|
+
"mistral",
|
|
8744
|
+
"azure",
|
|
8745
|
+
"amazon-bedrock",
|
|
8746
|
+
"github-copilot",
|
|
8747
|
+
"opencode"
|
|
8748
|
+
]);
|
|
8749
|
+
opencodeAdapter = {
|
|
8750
|
+
key: "opencode",
|
|
8751
|
+
source: "opencode",
|
|
8752
|
+
harness: "opencode",
|
|
8753
|
+
displayName: "opencode",
|
|
8754
|
+
providerName: "Anomaly",
|
|
8755
|
+
binary: "opencode",
|
|
8756
|
+
buildInteractiveArgs({ resume, model }) {
|
|
8757
|
+
const args = [];
|
|
8758
|
+
if (model) args.push("--model", toOpencodeModel(model));
|
|
8759
|
+
if (resume) args.push("--session", resume);
|
|
8760
|
+
return args;
|
|
8761
|
+
},
|
|
8762
|
+
buildHeadlessArgs({ message, resume, model, bypassApprovals, jsonStream }) {
|
|
8763
|
+
const args = ["run", message];
|
|
8764
|
+
if (model) args.push("--model", toOpencodeModel(model));
|
|
8765
|
+
if (resume) args.push("--session", resume);
|
|
8766
|
+
if (bypassApprovals) args.push("--auto");
|
|
8767
|
+
if (jsonStream) args.push("--format", "json");
|
|
8768
|
+
return args;
|
|
8769
|
+
},
|
|
8770
|
+
sessionIdFromStreamEvent(event) {
|
|
8771
|
+
const fromProps = event?.properties?.sessionID;
|
|
8772
|
+
if (typeof fromProps === "string" && fromProps) return fromProps;
|
|
8773
|
+
const fromInfo = event?.properties?.info?.id;
|
|
8774
|
+
if (typeof fromInfo === "string" && fromInfo.startsWith("ses")) return fromInfo;
|
|
8775
|
+
return null;
|
|
8776
|
+
},
|
|
8777
|
+
hooksSupportedOnPlatform() {
|
|
8778
|
+
return true;
|
|
8779
|
+
},
|
|
8780
|
+
daemonStreamCapture: false,
|
|
8781
|
+
ensureInstalled() {
|
|
8782
|
+
return ensureOpencodeInstalled();
|
|
8783
|
+
},
|
|
8784
|
+
// Plain literal, not `npm install -g ${OPENCODE_PACKAGE}`: this module sits
|
|
8785
|
+
// in an import cycle (opencode.ts -> opencode-setup.ts -> setup.ts -> ...
|
|
8786
|
+
// -> agents/index.ts -> opencode.ts), so a module-eval read of an imported
|
|
8787
|
+
// binding hits the TDZ when the cycle is entered from setup.ts's side.
|
|
8788
|
+
// Function bodies (updatePlan below) read the live binding safely.
|
|
8789
|
+
installHint: "npm install -g opencode-ai (or: curl -fsSL https://opencode.ai/install | bash)",
|
|
8790
|
+
updatePlan() {
|
|
8791
|
+
return planForInstall(whichFirst("opencode"), OPENCODE_PACKAGE, ["opencode", "upgrade"]);
|
|
8792
|
+
},
|
|
8793
|
+
async prepareLaunch() {
|
|
8794
|
+
await ensureOpencodeModelToken();
|
|
8795
|
+
},
|
|
8796
|
+
detectEnv() {
|
|
8797
|
+
if (!hasEnvPrefix("OPENCODE")) return null;
|
|
8798
|
+
return { harness: "opencode", harnessSession: process.env.OPENCODE_SESSION_ID };
|
|
8799
|
+
},
|
|
8800
|
+
capture: {
|
|
8801
|
+
hookKey: "opencode",
|
|
8802
|
+
parse: (content, afterUuid) => parseTranscript5(content, afterUuid),
|
|
8803
|
+
// The plugin writes the transcript at a derivable path, so a hook payload
|
|
8804
|
+
// without transcript_path still resolves.
|
|
8805
|
+
resolveTranscriptPath: (hook) => {
|
|
8806
|
+
if (!hook.session_id) return null;
|
|
8807
|
+
const gipityDir = process.env.GIPITY_DIR || join8(homedir6(), ".gipity");
|
|
8808
|
+
return join8(gipityDir, "opencode", "transcripts", `${hook.session_id}.jsonl`);
|
|
8809
|
+
}
|
|
8810
|
+
},
|
|
8811
|
+
setup: {
|
|
8812
|
+
state: () => opencodePluginState(),
|
|
8813
|
+
install: () => {
|
|
8814
|
+
ensureOpencodeSkillsInstalled();
|
|
8815
|
+
ensureOpencodePluginInstalled();
|
|
8816
|
+
},
|
|
8817
|
+
uninstall: () => {
|
|
8818
|
+
const removedPlugin = removeOpencodePlugin();
|
|
8819
|
+
const n = removeAgentSkills();
|
|
8820
|
+
if (!removedPlugin && !n) return null;
|
|
8821
|
+
const parts = [];
|
|
8822
|
+
if (removedPlugin) parts.push("Gipity plugin removed from opencode.");
|
|
8823
|
+
if (n) parts.push(`Removed ${n} Gipity skills from ~/.agents/skills.`);
|
|
8824
|
+
return parts.join(" ");
|
|
8825
|
+
}
|
|
8826
|
+
}
|
|
8827
|
+
};
|
|
8828
|
+
}
|
|
8829
|
+
});
|
|
8830
|
+
|
|
8427
8831
|
// src/agents/index.ts
|
|
8428
8832
|
function getAdapter(key) {
|
|
8429
8833
|
const found = AGENT_ADAPTERS.find((a) => a.key === key);
|
|
@@ -8443,24 +8847,26 @@ var init_agents = __esm({
|
|
|
8443
8847
|
init_codex2();
|
|
8444
8848
|
init_grok2();
|
|
8445
8849
|
init_agy2();
|
|
8850
|
+
init_opencode2();
|
|
8446
8851
|
AGENT_ADAPTERS = [
|
|
8447
8852
|
claudeCodeAdapter,
|
|
8448
8853
|
codexAdapter,
|
|
8449
8854
|
grokAdapter,
|
|
8450
|
-
agyAdapter
|
|
8855
|
+
agyAdapter,
|
|
8856
|
+
opencodeAdapter
|
|
8451
8857
|
];
|
|
8452
8858
|
AGENT_KEYS = AGENT_ADAPTERS.map((a) => a.key);
|
|
8453
8859
|
}
|
|
8454
8860
|
});
|
|
8455
8861
|
|
|
8456
8862
|
// src/client-context.ts
|
|
8457
|
-
import { readFileSync as
|
|
8458
|
-
import { resolve as resolve2, dirname as
|
|
8863
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
8864
|
+
import { resolve as resolve2, dirname as dirname4 } from "path";
|
|
8459
8865
|
import { fileURLToPath } from "url";
|
|
8460
8866
|
function cliVersion() {
|
|
8461
8867
|
try {
|
|
8462
|
-
const dir =
|
|
8463
|
-
const pkg2 = JSON.parse(
|
|
8868
|
+
const dir = dirname4(fileURLToPath(import.meta.url));
|
|
8869
|
+
const pkg2 = JSON.parse(readFileSync5(resolve2(dir, "../package.json"), "utf-8"));
|
|
8464
8870
|
return typeof pkg2.version === "string" ? pkg2.version : "unknown";
|
|
8465
8871
|
} catch {
|
|
8466
8872
|
return "unknown";
|
|
@@ -8521,6 +8927,7 @@ var init_client_context = __esm({
|
|
|
8521
8927
|
var api_exports = {};
|
|
8522
8928
|
__export(api_exports, {
|
|
8523
8929
|
ApiError: () => ApiError,
|
|
8930
|
+
LONG_REQUEST_TIMEOUT_MS: () => LONG_REQUEST_TIMEOUT_MS,
|
|
8524
8931
|
del: () => del,
|
|
8525
8932
|
download: () => download,
|
|
8526
8933
|
downloadStream: () => downloadStream,
|
|
@@ -8588,16 +8995,16 @@ async function getAuthHeader() {
|
|
|
8588
8995
|
const headers = await getHeaders();
|
|
8589
8996
|
return headers.Authorization;
|
|
8590
8997
|
}
|
|
8591
|
-
async function request(method, path5, body, retrying = false) {
|
|
8998
|
+
async function request(method, path5, body, retrying = false, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
8592
8999
|
const headers = await getHeaders();
|
|
8593
9000
|
const url = `${baseUrl()}${path5}`;
|
|
8594
9001
|
const res = await fetchWithTimeout(url, {
|
|
8595
9002
|
method,
|
|
8596
9003
|
headers,
|
|
8597
9004
|
body: body ? JSON.stringify(body) : void 0
|
|
8598
|
-
},
|
|
9005
|
+
}, timeoutMs, `${method} ${path5}`);
|
|
8599
9006
|
if (await shouldRetryAfter401(res.status, retrying)) {
|
|
8600
|
-
return request(method, path5, body, true);
|
|
9007
|
+
return request(method, path5, body, true, timeoutMs);
|
|
8601
9008
|
}
|
|
8602
9009
|
if (!res.ok) {
|
|
8603
9010
|
const json = await res.json().catch(() => ({ error: { code: "UNKNOWN", message: res.statusText } }));
|
|
@@ -8609,8 +9016,8 @@ async function request(method, path5, body, retrying = false) {
|
|
|
8609
9016
|
function get(path5) {
|
|
8610
9017
|
return request("GET", path5);
|
|
8611
9018
|
}
|
|
8612
|
-
function post(path5, body) {
|
|
8613
|
-
return request("POST", path5, body);
|
|
9019
|
+
function post(path5, body, opts) {
|
|
9020
|
+
return request("POST", path5, body, false, opts?.timeoutMs);
|
|
8614
9021
|
}
|
|
8615
9022
|
async function postForTarEntries(path5, body, retried = false) {
|
|
8616
9023
|
const headers = await getHeaders();
|
|
@@ -8816,7 +9223,7 @@ async function mintAppToken(projectGuid2) {
|
|
|
8816
9223
|
return void 0;
|
|
8817
9224
|
}
|
|
8818
9225
|
}
|
|
8819
|
-
var tar, ApiError, REQUEST_TIMEOUT_MS, DOWNLOAD_HEADER_TIMEOUT_MS, PUT_TIMEOUT_FLOOR_MS, PUT_MIN_BYTES_PER_SEC, accountSlugCache;
|
|
9226
|
+
var tar, ApiError, REQUEST_TIMEOUT_MS, DOWNLOAD_HEADER_TIMEOUT_MS, LONG_REQUEST_TIMEOUT_MS, PUT_TIMEOUT_FLOOR_MS, PUT_MIN_BYTES_PER_SEC, accountSlugCache;
|
|
8820
9227
|
var init_api = __esm({
|
|
8821
9228
|
"src/api.ts"() {
|
|
8822
9229
|
"use strict";
|
|
@@ -8838,6 +9245,7 @@ var init_api = __esm({
|
|
|
8838
9245
|
};
|
|
8839
9246
|
REQUEST_TIMEOUT_MS = 6e4;
|
|
8840
9247
|
DOWNLOAD_HEADER_TIMEOUT_MS = 3e4;
|
|
9248
|
+
LONG_REQUEST_TIMEOUT_MS = 31e4;
|
|
8841
9249
|
PUT_TIMEOUT_FLOOR_MS = 12e4;
|
|
8842
9250
|
PUT_MIN_BYTES_PER_SEC = 256 * 1024;
|
|
8843
9251
|
accountSlugCache = null;
|
|
@@ -8863,8 +9271,8 @@ __export(config_exports, {
|
|
|
8863
9271
|
setApiBaseOverride: () => setApiBaseOverride,
|
|
8864
9272
|
shouldIgnore: () => shouldIgnore
|
|
8865
9273
|
});
|
|
8866
|
-
import { readFileSync as
|
|
8867
|
-
import { dirname as
|
|
9274
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6 } from "fs";
|
|
9275
|
+
import { dirname as dirname5, resolve as resolve3 } from "path";
|
|
8868
9276
|
function setApiBaseOverride(url) {
|
|
8869
9277
|
apiBaseOverride = url;
|
|
8870
9278
|
}
|
|
@@ -8873,9 +9281,9 @@ function getApiBaseOverride() {
|
|
|
8873
9281
|
}
|
|
8874
9282
|
function isAllowedApiHost(url) {
|
|
8875
9283
|
try {
|
|
8876
|
-
const { protocol, hostname:
|
|
9284
|
+
const { protocol, hostname: hostname7 } = new URL(url);
|
|
8877
9285
|
if (protocol !== "https:") return false;
|
|
8878
|
-
return
|
|
9286
|
+
return hostname7 === "gipity.ai" || hostname7.endsWith(".gipity.ai");
|
|
8879
9287
|
} catch {
|
|
8880
9288
|
return false;
|
|
8881
9289
|
}
|
|
@@ -8901,7 +9309,7 @@ function findConfigPath() {
|
|
|
8901
9309
|
let dir = process.cwd();
|
|
8902
9310
|
while (true) {
|
|
8903
9311
|
const candidate = resolve3(dir, CONFIG_FILE);
|
|
8904
|
-
if (
|
|
9312
|
+
if (existsSync6(candidate)) return candidate;
|
|
8905
9313
|
const parent = resolve3(dir, "..");
|
|
8906
9314
|
if (parent === dir) return null;
|
|
8907
9315
|
dir = parent;
|
|
@@ -8914,14 +9322,14 @@ function getConfigPath() {
|
|
|
8914
9322
|
}
|
|
8915
9323
|
function getProjectRoot() {
|
|
8916
9324
|
const path5 = getConfigPath();
|
|
8917
|
-
return path5 ?
|
|
9325
|
+
return path5 ? dirname5(path5) : null;
|
|
8918
9326
|
}
|
|
8919
9327
|
function getConfig() {
|
|
8920
9328
|
if (cached3) return cached3;
|
|
8921
9329
|
const path5 = getConfigPath();
|
|
8922
9330
|
if (!path5) return null;
|
|
8923
9331
|
try {
|
|
8924
|
-
cached3 = JSON.parse(
|
|
9332
|
+
cached3 = JSON.parse(readFileSync6(path5, "utf-8"));
|
|
8925
9333
|
return cached3;
|
|
8926
9334
|
} catch {
|
|
8927
9335
|
return null;
|
|
@@ -9009,13 +9417,13 @@ function saveConfig(data) {
|
|
|
9009
9417
|
"saveConfig: no .gipity.json found to update. Use saveConfigAt(dir, \u2026) to create a new project config."
|
|
9010
9418
|
);
|
|
9011
9419
|
}
|
|
9012
|
-
|
|
9420
|
+
writeFileSync4(path5, JSON.stringify(data, null, 2) + "\n");
|
|
9013
9421
|
cached3 = data;
|
|
9014
9422
|
cachedPath = path5;
|
|
9015
9423
|
}
|
|
9016
9424
|
function saveConfigAt(dir, data) {
|
|
9017
9425
|
const path5 = resolve3(dir, CONFIG_FILE);
|
|
9018
|
-
|
|
9426
|
+
writeFileSync4(path5, JSON.stringify(data, null, 2) + "\n");
|
|
9019
9427
|
cached3 = data;
|
|
9020
9428
|
cachedPath = path5;
|
|
9021
9429
|
}
|
|
@@ -33750,9 +34158,9 @@ var {
|
|
|
33750
34158
|
// src/index.ts
|
|
33751
34159
|
init_config();
|
|
33752
34160
|
init_utils();
|
|
33753
|
-
import { readFileSync as
|
|
34161
|
+
import { readFileSync as readFileSync29 } from "fs";
|
|
33754
34162
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
33755
|
-
import { dirname as
|
|
34163
|
+
import { dirname as dirname16, resolve as resolve18 } from "path";
|
|
33756
34164
|
|
|
33757
34165
|
// src/helpers/output.ts
|
|
33758
34166
|
var frameOpen = false;
|
|
@@ -33836,14 +34244,14 @@ init_colors();
|
|
|
33836
34244
|
|
|
33837
34245
|
// src/bug-queue.ts
|
|
33838
34246
|
init_api();
|
|
33839
|
-
import { existsSync as
|
|
33840
|
-
import { join as
|
|
33841
|
-
import { homedir as
|
|
33842
|
-
var QUEUE_DIR =
|
|
34247
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync5, unlinkSync as unlinkSync3 } from "fs";
|
|
34248
|
+
import { join as join9 } from "path";
|
|
34249
|
+
import { homedir as homedir7 } from "os";
|
|
34250
|
+
var QUEUE_DIR = join9(process.env.GIPITY_DIR || join9(homedir7(), ".gipity"), "bug-queue");
|
|
33843
34251
|
function queueBugReport(report) {
|
|
33844
|
-
|
|
33845
|
-
const file =
|
|
33846
|
-
|
|
34252
|
+
mkdirSync4(QUEUE_DIR, { recursive: true, mode: 448 });
|
|
34253
|
+
const file = join9(QUEUE_DIR, `${Date.now()}-${Math.random().toString(36).slice(2, 8)}.json`);
|
|
34254
|
+
writeFileSync5(file, JSON.stringify(report, null, 2), { mode: 384 });
|
|
33847
34255
|
}
|
|
33848
34256
|
function isRetryableFailure(err) {
|
|
33849
34257
|
if (err?.name === "ApiError") {
|
|
@@ -33852,17 +34260,17 @@ function isRetryableFailure(err) {
|
|
|
33852
34260
|
return typeof err?.statusCode !== "number";
|
|
33853
34261
|
}
|
|
33854
34262
|
async function flushBugQueue() {
|
|
33855
|
-
if (!
|
|
34263
|
+
if (!existsSync7(QUEUE_DIR)) return 0;
|
|
33856
34264
|
let delivered = 0;
|
|
33857
34265
|
for (const file of readdirSync3(QUEUE_DIR)) {
|
|
33858
34266
|
if (!file.endsWith(".json")) continue;
|
|
33859
|
-
const path5 =
|
|
34267
|
+
const path5 = join9(QUEUE_DIR, file);
|
|
33860
34268
|
let report;
|
|
33861
34269
|
try {
|
|
33862
|
-
report = JSON.parse(
|
|
34270
|
+
report = JSON.parse(readFileSync7(path5, "utf-8"));
|
|
33863
34271
|
} catch {
|
|
33864
34272
|
try {
|
|
33865
|
-
|
|
34273
|
+
unlinkSync3(path5);
|
|
33866
34274
|
} catch {
|
|
33867
34275
|
}
|
|
33868
34276
|
continue;
|
|
@@ -33874,7 +34282,7 @@ async function flushBugQueue() {
|
|
|
33874
34282
|
summary: report.summary,
|
|
33875
34283
|
detail: report.detail
|
|
33876
34284
|
});
|
|
33877
|
-
|
|
34285
|
+
unlinkSync3(path5);
|
|
33878
34286
|
delivered++;
|
|
33879
34287
|
} catch {
|
|
33880
34288
|
}
|
|
@@ -34043,9 +34451,9 @@ function run(label2, action) {
|
|
|
34043
34451
|
init_api();
|
|
34044
34452
|
init_config();
|
|
34045
34453
|
init_utils();
|
|
34046
|
-
import { writeFileSync as
|
|
34047
|
-
import { join as
|
|
34048
|
-
import { hostname } from "os";
|
|
34454
|
+
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, statSync as statSync2, lstatSync, unlinkSync as unlinkSync4, readdirSync as readdirSync4, rmdirSync, readFileSync as readFileSync8, renameSync, openSync as openSync2, closeSync as closeSync2, utimesSync, realpathSync as realpathSync3 } from "fs";
|
|
34455
|
+
import { join as join10, relative, dirname as dirname6, extname as extname2, resolve as resolve4, sep as sep2 } from "path";
|
|
34456
|
+
import { hostname as hostname2 } from "os";
|
|
34049
34457
|
import { createHash as createHash2 } from "crypto";
|
|
34050
34458
|
|
|
34051
34459
|
// src/upload.ts
|
|
@@ -34295,15 +34703,15 @@ var BULK_DELETE_FRACTION = 0.25;
|
|
|
34295
34703
|
var DOWNLOAD_IDLE_MS = 3e4;
|
|
34296
34704
|
function syncStatePath() {
|
|
34297
34705
|
const configPath = getConfigPath();
|
|
34298
|
-
return
|
|
34706
|
+
return join10(dirname6(configPath), ".gipity", "sync-state.json");
|
|
34299
34707
|
}
|
|
34300
34708
|
function lockPath() {
|
|
34301
34709
|
const configPath = getConfigPath();
|
|
34302
|
-
return
|
|
34710
|
+
return join10(dirname6(configPath), ".gipity", "sync.lock");
|
|
34303
34711
|
}
|
|
34304
34712
|
function projectDir() {
|
|
34305
34713
|
const configPath = getConfigPath();
|
|
34306
|
-
return
|
|
34714
|
+
return dirname6(configPath);
|
|
34307
34715
|
}
|
|
34308
34716
|
var LOCK_WAIT_MS2 = 3e4;
|
|
34309
34717
|
var LOCK_POLL_MS2 = 500;
|
|
@@ -34313,7 +34721,7 @@ function isLockReclaimable(path5, now = Date.now()) {
|
|
|
34313
34721
|
let raw;
|
|
34314
34722
|
let mtimeMs;
|
|
34315
34723
|
try {
|
|
34316
|
-
raw =
|
|
34724
|
+
raw = readFileSync8(path5, "utf-8").trim();
|
|
34317
34725
|
mtimeMs = statSync2(path5).mtimeMs;
|
|
34318
34726
|
} catch {
|
|
34319
34727
|
return false;
|
|
@@ -34329,7 +34737,7 @@ function isLockReclaimable(path5, now = Date.now()) {
|
|
|
34329
34737
|
}
|
|
34330
34738
|
async function acquireLock(progress) {
|
|
34331
34739
|
const path5 = lockPath();
|
|
34332
|
-
|
|
34740
|
+
mkdirSync5(dirname6(path5), { recursive: true });
|
|
34333
34741
|
const start = Date.now();
|
|
34334
34742
|
let waitSpinner = null;
|
|
34335
34743
|
const settleWait = (ok) => {
|
|
@@ -34341,7 +34749,7 @@ async function acquireLock(progress) {
|
|
|
34341
34749
|
while (true) {
|
|
34342
34750
|
try {
|
|
34343
34751
|
const fd2 = openSync2(path5, "wx");
|
|
34344
|
-
|
|
34752
|
+
writeFileSync6(fd2, String(process.pid));
|
|
34345
34753
|
closeSync2(fd2);
|
|
34346
34754
|
const beat = setInterval(() => {
|
|
34347
34755
|
try {
|
|
@@ -34354,14 +34762,14 @@ async function acquireLock(progress) {
|
|
|
34354
34762
|
return () => {
|
|
34355
34763
|
clearInterval(beat);
|
|
34356
34764
|
try {
|
|
34357
|
-
|
|
34765
|
+
unlinkSync4(path5);
|
|
34358
34766
|
} catch {
|
|
34359
34767
|
}
|
|
34360
34768
|
};
|
|
34361
34769
|
} catch {
|
|
34362
34770
|
if (isLockReclaimable(path5)) {
|
|
34363
34771
|
try {
|
|
34364
|
-
|
|
34772
|
+
unlinkSync4(path5);
|
|
34365
34773
|
} catch {
|
|
34366
34774
|
}
|
|
34367
34775
|
continue;
|
|
@@ -34381,9 +34789,9 @@ async function acquireLock(progress) {
|
|
|
34381
34789
|
}
|
|
34382
34790
|
function readBaseline(projectGuid2) {
|
|
34383
34791
|
const path5 = syncStatePath();
|
|
34384
|
-
if (!
|
|
34792
|
+
if (!existsSync8(path5)) return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
|
|
34385
34793
|
try {
|
|
34386
|
-
const parsed = JSON.parse(
|
|
34794
|
+
const parsed = JSON.parse(readFileSync8(path5, "utf-8"));
|
|
34387
34795
|
if (parsed.projectGuid !== projectGuid2) {
|
|
34388
34796
|
return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
|
|
34389
34797
|
}
|
|
@@ -34399,8 +34807,8 @@ function readBaseline(projectGuid2) {
|
|
|
34399
34807
|
}
|
|
34400
34808
|
function writeBaseline(b7) {
|
|
34401
34809
|
const path5 = syncStatePath();
|
|
34402
|
-
|
|
34403
|
-
|
|
34810
|
+
mkdirSync5(dirname6(path5), { recursive: true });
|
|
34811
|
+
writeFileSync6(path5, JSON.stringify(b7, null, 2));
|
|
34404
34812
|
}
|
|
34405
34813
|
function walkLocal(root, ignorePatterns, baseline) {
|
|
34406
34814
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -34412,11 +34820,11 @@ function walkLocal(root, ignorePatterns, baseline) {
|
|
|
34412
34820
|
return;
|
|
34413
34821
|
}
|
|
34414
34822
|
for (const entry of entries) {
|
|
34415
|
-
const full =
|
|
34823
|
+
const full = join10(dir, entry.name);
|
|
34416
34824
|
const rel2 = relative(root, full).replace(/\\/g, "/");
|
|
34417
34825
|
if (shouldIgnore(rel2, ignorePatterns)) continue;
|
|
34418
34826
|
if (entry.isDirectory()) {
|
|
34419
|
-
if (
|
|
34827
|
+
if (existsSync8(join10(full, CONFIG_FILE2))) continue;
|
|
34420
34828
|
walk(full);
|
|
34421
34829
|
} else if (entry.isFile()) {
|
|
34422
34830
|
try {
|
|
@@ -34439,7 +34847,7 @@ async function ensureLocalHashes(root, local, paths) {
|
|
|
34439
34847
|
const info2 = local.get(path5);
|
|
34440
34848
|
if (!info2 || info2.sha256) continue;
|
|
34441
34849
|
try {
|
|
34442
|
-
const { sha256 } = await hashFile(
|
|
34850
|
+
const { sha256 } = await hashFile(join10(root, path5));
|
|
34443
34851
|
info2.sha256 = sha256;
|
|
34444
34852
|
} catch {
|
|
34445
34853
|
}
|
|
@@ -34457,7 +34865,7 @@ function resolveInRoot(root, relPath) {
|
|
|
34457
34865
|
try {
|
|
34458
34866
|
const rootReal = realpathSync3(rootResolved);
|
|
34459
34867
|
let ancestor = full;
|
|
34460
|
-
while (!
|
|
34868
|
+
while (!existsSync8(ancestor) && dirname6(ancestor) !== ancestor) ancestor = dirname6(ancestor);
|
|
34461
34869
|
const ancestorReal = realpathSync3(ancestor);
|
|
34462
34870
|
if (ancestorReal !== rootReal && !ancestorReal.startsWith(rootReal + sep2)) {
|
|
34463
34871
|
throw new Error(`Refusing path outside project root (symlink escape): ${relPath}`);
|
|
@@ -34576,7 +34984,7 @@ function classifyRemote(info2, base) {
|
|
|
34576
34984
|
}
|
|
34577
34985
|
function conflictedCopyName(path5) {
|
|
34578
34986
|
const ts2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:T]/g, "-").replace(/\..+$/, "");
|
|
34579
|
-
const host =
|
|
34987
|
+
const host = hostname2().replace(/[^A-Za-z0-9._-]/g, "_");
|
|
34580
34988
|
const ext = extname2(path5);
|
|
34581
34989
|
const base = ext ? path5.slice(0, -ext.length) : path5;
|
|
34582
34990
|
return `${base} (conflict from ${host} ${ts2})${ext}`;
|
|
@@ -34746,9 +35154,9 @@ Plan deletes ${totalDeletes} files (${Math.round(fraction * 100)}% of the tree).
|
|
|
34746
35154
|
}
|
|
34747
35155
|
var GIPITY_IGNORE_FILE = ".gipityignore";
|
|
34748
35156
|
function readGipityIgnore(root) {
|
|
34749
|
-
const path5 =
|
|
34750
|
-
if (!
|
|
34751
|
-
return
|
|
35157
|
+
const path5 = join10(root, GIPITY_IGNORE_FILE);
|
|
35158
|
+
if (!existsSync8(path5)) return [];
|
|
35159
|
+
return readFileSync8(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
|
|
34752
35160
|
}
|
|
34753
35161
|
function effectiveIgnore(root, configIgnore) {
|
|
34754
35162
|
const base = configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE;
|
|
@@ -34934,8 +35342,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34934
35342
|
return;
|
|
34935
35343
|
}
|
|
34936
35344
|
if (currentBytes) {
|
|
34937
|
-
|
|
34938
|
-
|
|
35345
|
+
mkdirSync5(dirname6(full), { recursive: true });
|
|
35346
|
+
writeFileSync6(full, currentBytes);
|
|
34939
35347
|
const stat2 = statSync2(full);
|
|
34940
35348
|
baseline.files[a.path] = {
|
|
34941
35349
|
size: stat2.size,
|
|
@@ -34978,7 +35386,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34978
35386
|
errors.push(e.message);
|
|
34979
35387
|
continue;
|
|
34980
35388
|
}
|
|
34981
|
-
if (
|
|
35389
|
+
if (existsSync8(full)) {
|
|
34982
35390
|
const scanSha = local.get(a.path)?.sha256 ?? baseline.files[a.path]?.sha256;
|
|
34983
35391
|
const remoteSha = remote.get(a.path)?.sha256 ?? void 0;
|
|
34984
35392
|
let currentSha;
|
|
@@ -34991,8 +35399,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
34991
35399
|
continue;
|
|
34992
35400
|
}
|
|
34993
35401
|
}
|
|
34994
|
-
|
|
34995
|
-
|
|
35402
|
+
mkdirSync5(dirname6(full), { recursive: true });
|
|
35403
|
+
writeFileSync6(full, buf);
|
|
34996
35404
|
const stat2 = statSync2(full);
|
|
34997
35405
|
local.set(a.path, { size: stat2.size, mtime: stat2.mtime.toISOString(), sha256: void 0 });
|
|
34998
35406
|
baseline.files[a.path] = {
|
|
@@ -35014,7 +35422,7 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35014
35422
|
continue;
|
|
35015
35423
|
}
|
|
35016
35424
|
try {
|
|
35017
|
-
|
|
35425
|
+
mkdirSync5(dirname6(renamed), { recursive: true });
|
|
35018
35426
|
renameSync(full, renamed);
|
|
35019
35427
|
} catch (err) {
|
|
35020
35428
|
errors.push(`Could not rename ${a.path} \u2192 ${a.renamedLocalTo}: ${err.message}`);
|
|
@@ -35022,8 +35430,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35022
35430
|
}
|
|
35023
35431
|
const buf = downloadedBytes.get(a.path);
|
|
35024
35432
|
if (buf) {
|
|
35025
|
-
|
|
35026
|
-
|
|
35433
|
+
mkdirSync5(dirname6(full), { recursive: true });
|
|
35434
|
+
writeFileSync6(full, buf);
|
|
35027
35435
|
const stat2 = statSync2(full);
|
|
35028
35436
|
baseline.files[a.path] = {
|
|
35029
35437
|
size: stat2.size,
|
|
@@ -35204,13 +35612,13 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35204
35612
|
continue;
|
|
35205
35613
|
}
|
|
35206
35614
|
try {
|
|
35207
|
-
|
|
35208
|
-
dirsTouchedByDelete.add(
|
|
35615
|
+
unlinkSync4(full);
|
|
35616
|
+
dirsTouchedByDelete.add(dirname6(full));
|
|
35209
35617
|
delete baseline.files[a.path];
|
|
35210
35618
|
applied++;
|
|
35211
35619
|
} catch (err) {
|
|
35212
35620
|
if (err.code === "ENOENT") {
|
|
35213
|
-
dirsTouchedByDelete.add(
|
|
35621
|
+
dirsTouchedByDelete.add(dirname6(full));
|
|
35214
35622
|
delete baseline.files[a.path];
|
|
35215
35623
|
applied++;
|
|
35216
35624
|
} else {
|
|
@@ -35229,8 +35637,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35229
35637
|
const buf = await fetchOne(config.projectGuid, a.path);
|
|
35230
35638
|
if (!buf) throw new Error("remote bytes unavailable");
|
|
35231
35639
|
const full = resolveInRoot(root, a.path);
|
|
35232
|
-
|
|
35233
|
-
|
|
35640
|
+
mkdirSync5(dirname6(full), { recursive: true });
|
|
35641
|
+
writeFileSync6(full, buf);
|
|
35234
35642
|
const stat2 = statSync2(full);
|
|
35235
35643
|
const { sha256 } = await hashFile(full);
|
|
35236
35644
|
const current = typeof err.data?.current_server_version === "number" ? err.data.current_server_version : null;
|
|
@@ -35295,7 +35703,7 @@ function cleanupEmptyDirs(root, emptiedDirs) {
|
|
|
35295
35703
|
} catch {
|
|
35296
35704
|
break;
|
|
35297
35705
|
}
|
|
35298
|
-
dir =
|
|
35706
|
+
dir = dirname6(dir);
|
|
35299
35707
|
}
|
|
35300
35708
|
}
|
|
35301
35709
|
}
|
|
@@ -35509,11 +35917,11 @@ async function syncBeforeAction(opts) {
|
|
|
35509
35917
|
}
|
|
35510
35918
|
|
|
35511
35919
|
// src/helpers/body.ts
|
|
35512
|
-
import { readFileSync as
|
|
35920
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
35513
35921
|
function readStdin() {
|
|
35514
35922
|
if (process.stdin.isTTY) return "";
|
|
35515
35923
|
try {
|
|
35516
|
-
return
|
|
35924
|
+
return readFileSync9(0, "utf-8");
|
|
35517
35925
|
} catch {
|
|
35518
35926
|
return "";
|
|
35519
35927
|
}
|
|
@@ -35529,7 +35937,7 @@ function readFileField(spec) {
|
|
|
35529
35937
|
if (!field) throw new Error(`Invalid --file '${spec}': missing field name before '='.`);
|
|
35530
35938
|
if (!path5) throw new Error(`Invalid --file '${spec}': missing file path after '='.`);
|
|
35531
35939
|
try {
|
|
35532
|
-
return [field, { data:
|
|
35940
|
+
return [field, { data: readFileSync9(path5).toString("base64"), media_type: guessMime(path5) }];
|
|
35533
35941
|
} catch (e) {
|
|
35534
35942
|
throw new Error(`Cannot read --file '${path5}': ${e.message}`);
|
|
35535
35943
|
}
|
|
@@ -35560,7 +35968,7 @@ function resolveJsonBody(raw) {
|
|
|
35560
35968
|
} else if (raw.startsWith("@")) {
|
|
35561
35969
|
const path5 = raw.slice(1);
|
|
35562
35970
|
try {
|
|
35563
|
-
source =
|
|
35971
|
+
source = readFileSync9(path5, "utf-8");
|
|
35564
35972
|
} catch (e) {
|
|
35565
35973
|
throw new Error(`Cannot read body file '${path5}': ${e.message}`);
|
|
35566
35974
|
}
|
|
@@ -35717,15 +36125,15 @@ init_setup();
|
|
|
35717
36125
|
init_agents();
|
|
35718
36126
|
init_colors();
|
|
35719
36127
|
init_utils();
|
|
35720
|
-
import { basename as basename2, resolve as resolve7, dirname as
|
|
36128
|
+
import { basename as basename2, resolve as resolve7, dirname as dirname7 } from "path";
|
|
35721
36129
|
import { existsSync as existsSync10, readFileSync as readFileSync11 } from "fs";
|
|
35722
36130
|
|
|
35723
36131
|
// src/adopt-cwd.ts
|
|
35724
36132
|
init_api();
|
|
35725
36133
|
init_setup();
|
|
35726
36134
|
import { readdirSync as readdirSync6, statSync as statSync4 } from "fs";
|
|
35727
|
-
import { join as
|
|
35728
|
-
import { homedir as
|
|
36135
|
+
import { join as join13, resolve as resolve6, sep as sep3, parse as parsePath } from "path";
|
|
36136
|
+
import { homedir as homedir9 } from "os";
|
|
35729
36137
|
|
|
35730
36138
|
// src/project-setup.ts
|
|
35731
36139
|
init_config();
|
|
@@ -35734,7 +36142,7 @@ init_setup();
|
|
|
35734
36142
|
// src/template-vars.ts
|
|
35735
36143
|
init_setup();
|
|
35736
36144
|
import { promises as fs, readdirSync as readdirSync5, statSync as statSync3 } from "fs";
|
|
35737
|
-
import { join as
|
|
36145
|
+
import { join as join11, relative as relative2, extname as extname3 } from "path";
|
|
35738
36146
|
var SUBSTITUTABLE_EXTS = /* @__PURE__ */ new Set([
|
|
35739
36147
|
".html",
|
|
35740
36148
|
".htm",
|
|
@@ -35883,7 +36291,7 @@ function* walkTextFiles(root) {
|
|
|
35883
36291
|
}
|
|
35884
36292
|
for (const entry of entries) {
|
|
35885
36293
|
if (isSyncIgnored(entry.name)) continue;
|
|
35886
|
-
const full =
|
|
36294
|
+
const full = join11(dir, entry.name);
|
|
35887
36295
|
if (entry.isDirectory()) {
|
|
35888
36296
|
stack.push(full);
|
|
35889
36297
|
} else if (entry.isFile()) {
|
|
@@ -35905,7 +36313,7 @@ async function substituteDir(dir, vars) {
|
|
|
35905
36313
|
for (const rel2 of walkTextFiles(dir)) {
|
|
35906
36314
|
const ext = extname3(rel2).toLowerCase();
|
|
35907
36315
|
if (!SUBSTITUTABLE_EXTS.has(ext)) continue;
|
|
35908
|
-
const abs =
|
|
36316
|
+
const abs = join11(dir, rel2);
|
|
35909
36317
|
let content;
|
|
35910
36318
|
try {
|
|
35911
36319
|
content = await fs.readFile(abs, "utf-8");
|
|
@@ -35973,184 +36381,25 @@ async function finalizeLocalProject(opts) {
|
|
|
35973
36381
|
}
|
|
35974
36382
|
|
|
35975
36383
|
// src/relay/paths.ts
|
|
35976
|
-
import { existsSync as
|
|
35977
|
-
import { homedir as
|
|
35978
|
-
import { join as
|
|
36384
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
|
|
36385
|
+
import { homedir as homedir8 } from "os";
|
|
36386
|
+
import { join as join12, resolve as resolve5 } from "path";
|
|
35979
36387
|
function getProjectsRoot() {
|
|
35980
|
-
const settingsPath =
|
|
35981
|
-
const defaultDir =
|
|
36388
|
+
const settingsPath = join12(homedir8(), ".gipity", "settings.json");
|
|
36389
|
+
const defaultDir = join12(homedir8(), "GipityProjects");
|
|
35982
36390
|
try {
|
|
35983
|
-
if (
|
|
35984
|
-
const settings = JSON.parse(
|
|
36391
|
+
if (existsSync9(settingsPath)) {
|
|
36392
|
+
const settings = JSON.parse(readFileSync10(settingsPath, "utf-8"));
|
|
35985
36393
|
if (settings.projectsDir) return resolve5(settings.projectsDir);
|
|
35986
36394
|
} else {
|
|
35987
|
-
|
|
35988
|
-
|
|
36395
|
+
mkdirSync6(join12(homedir8(), ".gipity"), { recursive: true });
|
|
36396
|
+
writeFileSync7(settingsPath, JSON.stringify({ projectsDir: defaultDir }, null, 2) + "\n");
|
|
35989
36397
|
}
|
|
35990
36398
|
} catch {
|
|
35991
36399
|
}
|
|
35992
36400
|
return defaultDir;
|
|
35993
36401
|
}
|
|
35994
36402
|
|
|
35995
|
-
// src/relay/state.ts
|
|
35996
|
-
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync9, chmodSync as chmodSync2, unlinkSync as unlinkSync4 } from "fs";
|
|
35997
|
-
import { join as join11 } from "path";
|
|
35998
|
-
import { homedir as homedir7 } from "os";
|
|
35999
|
-
var RELAY_DIR = process.env.GIPITY_DIR || join11(homedir7(), ".gipity");
|
|
36000
|
-
var RELAY_FILE = join11(RELAY_DIR, "relay.json");
|
|
36001
|
-
var FILE_MODE = 384;
|
|
36002
|
-
function emptyState() {
|
|
36003
|
-
return { device: null, paused: false };
|
|
36004
|
-
}
|
|
36005
|
-
function loadState() {
|
|
36006
|
-
if (!existsSync9(RELAY_FILE)) return emptyState();
|
|
36007
|
-
try {
|
|
36008
|
-
const raw = JSON.parse(readFileSync10(RELAY_FILE, "utf-8"));
|
|
36009
|
-
return {
|
|
36010
|
-
device: raw.device ?? null,
|
|
36011
|
-
paused: Boolean(raw.paused),
|
|
36012
|
-
relay_enabled: typeof raw.relay_enabled === "boolean" ? raw.relay_enabled : void 0,
|
|
36013
|
-
onboard_shown: Boolean(raw.onboard_shown),
|
|
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,
|
|
36016
|
-
agent_token: typeof raw.agent_token === "string" ? raw.agent_token : null,
|
|
36017
|
-
agent_token_guid: typeof raw.agent_token_guid === "string" ? raw.agent_token_guid : null
|
|
36018
|
-
};
|
|
36019
|
-
} catch {
|
|
36020
|
-
return emptyState();
|
|
36021
|
-
}
|
|
36022
|
-
}
|
|
36023
|
-
function saveState(state) {
|
|
36024
|
-
mkdirSync6(RELAY_DIR, { recursive: true });
|
|
36025
|
-
writeFileSync7(RELAY_FILE, JSON.stringify(state, null, 2) + "\n", { mode: FILE_MODE });
|
|
36026
|
-
try {
|
|
36027
|
-
chmodSync2(RELAY_FILE, FILE_MODE);
|
|
36028
|
-
} catch {
|
|
36029
|
-
}
|
|
36030
|
-
}
|
|
36031
|
-
function mutate(fn) {
|
|
36032
|
-
const s = loadState();
|
|
36033
|
-
fn(s);
|
|
36034
|
-
saveState(s);
|
|
36035
|
-
}
|
|
36036
|
-
function getDevice() {
|
|
36037
|
-
return loadState().device;
|
|
36038
|
-
}
|
|
36039
|
-
function setDevice(device) {
|
|
36040
|
-
mutate((s) => {
|
|
36041
|
-
s.device = device;
|
|
36042
|
-
});
|
|
36043
|
-
}
|
|
36044
|
-
function clearDevice() {
|
|
36045
|
-
mutate((s) => {
|
|
36046
|
-
s.device = null;
|
|
36047
|
-
s.paused = false;
|
|
36048
|
-
s.agent_token = null;
|
|
36049
|
-
s.agent_token_guid = null;
|
|
36050
|
-
});
|
|
36051
|
-
}
|
|
36052
|
-
function getAgentToken() {
|
|
36053
|
-
const s = loadState();
|
|
36054
|
-
return s.agent_token ? { token: s.agent_token, guid: s.agent_token_guid ?? null } : null;
|
|
36055
|
-
}
|
|
36056
|
-
function setAgentToken(token, guid) {
|
|
36057
|
-
mutate((s) => {
|
|
36058
|
-
s.agent_token = token;
|
|
36059
|
-
s.agent_token_guid = guid;
|
|
36060
|
-
});
|
|
36061
|
-
}
|
|
36062
|
-
function isPaused() {
|
|
36063
|
-
return loadState().paused;
|
|
36064
|
-
}
|
|
36065
|
-
function setPaused(paused) {
|
|
36066
|
-
mutate((s) => {
|
|
36067
|
-
s.paused = paused;
|
|
36068
|
-
});
|
|
36069
|
-
}
|
|
36070
|
-
function getRelayEnabled() {
|
|
36071
|
-
return loadState().relay_enabled;
|
|
36072
|
-
}
|
|
36073
|
-
function isRelayEnabled() {
|
|
36074
|
-
return loadState().relay_enabled === true;
|
|
36075
|
-
}
|
|
36076
|
-
function setRelayEnabled(enabled) {
|
|
36077
|
-
mutate((s) => {
|
|
36078
|
-
s.relay_enabled = enabled;
|
|
36079
|
-
});
|
|
36080
|
-
}
|
|
36081
|
-
function getDiagnosticsConsent() {
|
|
36082
|
-
return loadState().diagnostics_consent;
|
|
36083
|
-
}
|
|
36084
|
-
function setDiagnosticsConsent(consent) {
|
|
36085
|
-
mutate((s) => {
|
|
36086
|
-
s.diagnostics_consent = consent;
|
|
36087
|
-
});
|
|
36088
|
-
}
|
|
36089
|
-
function diagnosticsConsented() {
|
|
36090
|
-
const env = process.env.GIPITY_NO_DIAGNOSTICS ?? process.env.DO_NOT_TRACK;
|
|
36091
|
-
if (env && env !== "0" && env.toLowerCase() !== "false") return false;
|
|
36092
|
-
return loadState().diagnostics_consent !== false;
|
|
36093
|
-
}
|
|
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");
|
|
36111
|
-
function getDaemonPidPath() {
|
|
36112
|
-
return RELAY_PID_FILE;
|
|
36113
|
-
}
|
|
36114
|
-
function writeDaemonPid(pid) {
|
|
36115
|
-
mkdirSync6(RELAY_DIR, { recursive: true });
|
|
36116
|
-
writeFileSync7(RELAY_PID_FILE, String(pid), { flag: "wx" });
|
|
36117
|
-
}
|
|
36118
|
-
function clearDaemonPid() {
|
|
36119
|
-
try {
|
|
36120
|
-
unlinkSync4(RELAY_PID_FILE);
|
|
36121
|
-
} catch {
|
|
36122
|
-
}
|
|
36123
|
-
}
|
|
36124
|
-
function isDaemonRunning() {
|
|
36125
|
-
if (!existsSync9(RELAY_PID_FILE)) return false;
|
|
36126
|
-
try {
|
|
36127
|
-
const raw = readFileSync10(RELAY_PID_FILE, "utf-8").trim();
|
|
36128
|
-
const pid = parseInt(raw, 10);
|
|
36129
|
-
if (!pid || isNaN(pid)) {
|
|
36130
|
-
try {
|
|
36131
|
-
unlinkSync4(RELAY_PID_FILE);
|
|
36132
|
-
} catch {
|
|
36133
|
-
}
|
|
36134
|
-
return false;
|
|
36135
|
-
}
|
|
36136
|
-
if (pid === process.pid) {
|
|
36137
|
-
try {
|
|
36138
|
-
unlinkSync4(RELAY_PID_FILE);
|
|
36139
|
-
} catch {
|
|
36140
|
-
}
|
|
36141
|
-
return false;
|
|
36142
|
-
}
|
|
36143
|
-
process.kill(pid, 0);
|
|
36144
|
-
return true;
|
|
36145
|
-
} catch {
|
|
36146
|
-
try {
|
|
36147
|
-
unlinkSync4(RELAY_PID_FILE);
|
|
36148
|
-
} catch {
|
|
36149
|
-
}
|
|
36150
|
-
return false;
|
|
36151
|
-
}
|
|
36152
|
-
}
|
|
36153
|
-
|
|
36154
36403
|
// src/adopt-cwd.ts
|
|
36155
36404
|
var EASY_FILES = 200;
|
|
36156
36405
|
var EASY_BYTES = 100 * 1024 * 1024;
|
|
@@ -36171,7 +36420,7 @@ function scanForAdoption(cwd) {
|
|
|
36171
36420
|
for (const name of entries) {
|
|
36172
36421
|
if (truncated) return;
|
|
36173
36422
|
if (isSyncIgnored(name)) continue;
|
|
36174
|
-
const full =
|
|
36423
|
+
const full = join13(dir, name);
|
|
36175
36424
|
let st2;
|
|
36176
36425
|
try {
|
|
36177
36426
|
st2 = statSync4(full);
|
|
@@ -36208,7 +36457,7 @@ function isLikelyEmpty(cwd) {
|
|
|
36208
36457
|
}
|
|
36209
36458
|
function canAdoptCwd(cwd) {
|
|
36210
36459
|
const norm = resolve6(cwd);
|
|
36211
|
-
const home = resolve6(
|
|
36460
|
+
const home = resolve6(homedir9());
|
|
36212
36461
|
const blocked = /* @__PURE__ */ new Set([
|
|
36213
36462
|
sep3,
|
|
36214
36463
|
home,
|
|
@@ -36245,10 +36494,10 @@ function countGitRepoChildren(dir) {
|
|
|
36245
36494
|
let count = 0;
|
|
36246
36495
|
for (const name of entries.slice(0, 50)) {
|
|
36247
36496
|
if (name.startsWith(".")) continue;
|
|
36248
|
-
const child =
|
|
36497
|
+
const child = join13(dir, name);
|
|
36249
36498
|
try {
|
|
36250
36499
|
if (!statSync4(child).isDirectory()) continue;
|
|
36251
|
-
const gitPath =
|
|
36500
|
+
const gitPath = join13(child, ".git");
|
|
36252
36501
|
if (statSync4(gitPath)) count++;
|
|
36253
36502
|
} catch {
|
|
36254
36503
|
}
|
|
@@ -36258,7 +36507,7 @@ function countGitRepoChildren(dir) {
|
|
|
36258
36507
|
}
|
|
36259
36508
|
function formatCwdLabel(cwd) {
|
|
36260
36509
|
const norm = resolve6(cwd);
|
|
36261
|
-
const home = resolve6(
|
|
36510
|
+
const home = resolve6(homedir9());
|
|
36262
36511
|
if (norm === home) return "~";
|
|
36263
36512
|
if (norm.startsWith(home + sep3)) {
|
|
36264
36513
|
const tail2 = norm.slice(home.length + 1).split(sep3);
|
|
@@ -36285,15 +36534,10 @@ async function adoptCurrentDir(opts) {
|
|
|
36285
36534
|
}
|
|
36286
36535
|
let isNew = false;
|
|
36287
36536
|
if (!project) {
|
|
36288
|
-
const device = getDevice();
|
|
36289
36537
|
const body = {
|
|
36290
36538
|
name: opts.projectName,
|
|
36291
36539
|
slug: opts.projectSlug
|
|
36292
36540
|
};
|
|
36293
|
-
if (device) {
|
|
36294
|
-
body.autoChat = "claude_code";
|
|
36295
|
-
body.deviceGuid = device.guid;
|
|
36296
|
-
}
|
|
36297
36541
|
try {
|
|
36298
36542
|
const res = await post("/projects", body);
|
|
36299
36543
|
project = res.data;
|
|
@@ -36419,7 +36663,7 @@ Working with an existing Gipity project:
|
|
|
36419
36663
|
}
|
|
36420
36664
|
const ancestorConfigPath = getConfigPath();
|
|
36421
36665
|
if (ancestorConfigPath) {
|
|
36422
|
-
console.log(muted(`Note: ${formatCwdLabel(
|
|
36666
|
+
console.log(muted(`Note: ${formatCwdLabel(dirname7(ancestorConfigPath))} is already a Gipity project.`));
|
|
36423
36667
|
const ok = await confirm(
|
|
36424
36668
|
`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`,
|
|
36425
36669
|
{ default: "no" }
|
|
@@ -36507,10 +36751,10 @@ init_config();
|
|
|
36507
36751
|
init_colors();
|
|
36508
36752
|
init_setup();
|
|
36509
36753
|
import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
|
|
36510
|
-
import { join as
|
|
36511
|
-
import { homedir as
|
|
36754
|
+
import { join as join14, resolve as resolve8 } from "path";
|
|
36755
|
+
import { homedir as homedir10 } from "os";
|
|
36512
36756
|
function checkGipityPlugin() {
|
|
36513
|
-
const path5 =
|
|
36757
|
+
const path5 = join14(homedir10(), ".claude", "settings.json");
|
|
36514
36758
|
let settings = {};
|
|
36515
36759
|
if (existsSync11(path5)) {
|
|
36516
36760
|
try {
|
|
@@ -36631,7 +36875,7 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
|
|
|
36631
36875
|
});
|
|
36632
36876
|
|
|
36633
36877
|
// src/commands/sync.ts
|
|
36634
|
-
import { dirname as
|
|
36878
|
+
import { dirname as dirname8 } from "node:path";
|
|
36635
36879
|
init_colors();
|
|
36636
36880
|
init_utils();
|
|
36637
36881
|
init_config();
|
|
@@ -36649,7 +36893,7 @@ ${result.applied} action${result.applied > 1 ? "s" : ""} applied.`);
|
|
|
36649
36893
|
}
|
|
36650
36894
|
if (isWsl()) {
|
|
36651
36895
|
const configPath = getConfigPath();
|
|
36652
|
-
const twin = configPath ? findWindowsTwinProject(
|
|
36896
|
+
const twin = configPath ? findWindowsTwinProject(dirname8(configPath)) : null;
|
|
36653
36897
|
if (twin) {
|
|
36654
36898
|
console.log(muted(
|
|
36655
36899
|
`
|
|
@@ -36800,7 +37044,7 @@ function dropCheckpoint(projectGuid2, database) {
|
|
|
36800
37044
|
init_api();
|
|
36801
37045
|
init_config();
|
|
36802
37046
|
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
|
|
37047
|
+
import { basename as basename4, resolve as resolve10, relative as relative3, join as join15 } from "node:path";
|
|
36804
37048
|
var FIND_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", ".gipity", "dist", "build", ".next", "coverage"]);
|
|
36805
37049
|
function findByBasename(root, name, limit = 3) {
|
|
36806
37050
|
const hits = [];
|
|
@@ -36817,9 +37061,9 @@ function findByBasename(root, name, limit = 3) {
|
|
|
36817
37061
|
}
|
|
36818
37062
|
for (const e of entries) {
|
|
36819
37063
|
if (e.isDirectory()) {
|
|
36820
|
-
if (!FIND_SKIP.has(e.name)) queue.push(
|
|
37064
|
+
if (!FIND_SKIP.has(e.name)) queue.push(join15(dir, e.name));
|
|
36821
37065
|
} else if (e.name === name && hits.length < limit) {
|
|
36822
|
-
hits.push(
|
|
37066
|
+
hits.push(join15(dir, e.name));
|
|
36823
37067
|
}
|
|
36824
37068
|
}
|
|
36825
37069
|
}
|
|
@@ -37398,7 +37642,7 @@ init_auth();
|
|
|
37398
37642
|
init_colors();
|
|
37399
37643
|
init_utils();
|
|
37400
37644
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
37401
|
-
import { dirname as
|
|
37645
|
+
import { dirname as dirname9, extname as extname4, join as join16, resolve as resolvePath } from "path";
|
|
37402
37646
|
var DEVICE_PRESETS = {
|
|
37403
37647
|
default: { width: 1280, height: 720 },
|
|
37404
37648
|
desktop: { width: 1920, height: 1080 },
|
|
@@ -37462,7 +37706,7 @@ function dimSuffix(vp2) {
|
|
|
37462
37706
|
}
|
|
37463
37707
|
function defaultScreenshotDir() {
|
|
37464
37708
|
const root = getProjectRoot();
|
|
37465
|
-
return
|
|
37709
|
+
return join16(root ?? ".", "screenshots");
|
|
37466
37710
|
}
|
|
37467
37711
|
function timestampSlug(d = /* @__PURE__ */ new Date()) {
|
|
37468
37712
|
const p = (n) => String(n).padStart(2, "0");
|
|
@@ -37674,8 +37918,8 @@ var pageScreenshotCommand = new Command("screenshot").description("Screenshot a
|
|
|
37674
37918
|
return stemPath(opts.output, suffix);
|
|
37675
37919
|
};
|
|
37676
37920
|
for (let i = 0; i < pngs.length; i++) {
|
|
37677
|
-
const target = opts.output ? outputPath(i) :
|
|
37678
|
-
mkdirSync7(
|
|
37921
|
+
const target = opts.output ? outputPath(i) : join16(dir, names[i] ?? shotName(meta.screenshots[i].viewport));
|
|
37922
|
+
mkdirSync7(dirname9(target), { recursive: true });
|
|
37679
37923
|
writeFileSync8(target, pngs[i].buffer);
|
|
37680
37924
|
savedFiles.push(resolvePath(target));
|
|
37681
37925
|
}
|
|
@@ -38319,7 +38563,7 @@ init_api();
|
|
|
38319
38563
|
init_config();
|
|
38320
38564
|
init_setup();
|
|
38321
38565
|
import { readFileSync as readFileSync15, existsSync as existsSync13, statSync as statSync7, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9 } from "fs";
|
|
38322
|
-
import { dirname as
|
|
38566
|
+
import { dirname as dirname10, extname as extname5, relative as relative4, resolve as resolve11, sep as sep4 } from "path";
|
|
38323
38567
|
init_colors();
|
|
38324
38568
|
var LANG_MAP = {
|
|
38325
38569
|
js: "javascript",
|
|
@@ -38457,7 +38701,7 @@ function isWriteTarget(code, p) {
|
|
|
38457
38701
|
function resolveRelativeCwd() {
|
|
38458
38702
|
const configPath = getConfigPath();
|
|
38459
38703
|
if (!configPath) return void 0;
|
|
38460
|
-
const projectRoot =
|
|
38704
|
+
const projectRoot = dirname10(configPath);
|
|
38461
38705
|
const rel2 = relative4(projectRoot, process.cwd());
|
|
38462
38706
|
if (!rel2 || rel2.startsWith("..")) return void 0;
|
|
38463
38707
|
return rel2.split(/[\\/]/).filter(Boolean).join("/");
|
|
@@ -38624,7 +38868,7 @@ GCC/Rust).
|
|
|
38624
38868
|
const rel2 = f.path.replace(/\\/g, "/");
|
|
38625
38869
|
const abs = resolve11(base, rel2);
|
|
38626
38870
|
if (abs !== base && !abs.startsWith(base + sep4)) continue;
|
|
38627
|
-
mkdirSync8(
|
|
38871
|
+
mkdirSync8(dirname10(abs), { recursive: true });
|
|
38628
38872
|
writeFileSync9(abs, Buffer.from(f.contentBase64, "base64"));
|
|
38629
38873
|
scratchWritten.push(rel2);
|
|
38630
38874
|
}
|
|
@@ -38800,8 +39044,169 @@ init_config();
|
|
|
38800
39044
|
init_setup();
|
|
38801
39045
|
init_colors();
|
|
38802
39046
|
init_utils();
|
|
38803
|
-
import { join as
|
|
38804
|
-
import { mkdirSync as
|
|
39047
|
+
import { join as join18 } from "path";
|
|
39048
|
+
import { mkdirSync as mkdirSync10 } from "fs";
|
|
39049
|
+
|
|
39050
|
+
// src/relay/state.ts
|
|
39051
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9, existsSync as existsSync14, chmodSync as chmodSync3, unlinkSync as unlinkSync5 } from "fs";
|
|
39052
|
+
import { join as join17 } from "path";
|
|
39053
|
+
import { homedir as homedir11 } from "os";
|
|
39054
|
+
var RELAY_DIR = process.env.GIPITY_DIR || join17(homedir11(), ".gipity");
|
|
39055
|
+
var RELAY_FILE = join17(RELAY_DIR, "relay.json");
|
|
39056
|
+
var FILE_MODE = 384;
|
|
39057
|
+
function emptyState() {
|
|
39058
|
+
return { device: null, paused: false };
|
|
39059
|
+
}
|
|
39060
|
+
function loadState() {
|
|
39061
|
+
if (!existsSync14(RELAY_FILE)) return emptyState();
|
|
39062
|
+
try {
|
|
39063
|
+
const raw = JSON.parse(readFileSync16(RELAY_FILE, "utf-8"));
|
|
39064
|
+
return {
|
|
39065
|
+
device: raw.device ?? null,
|
|
39066
|
+
paused: Boolean(raw.paused),
|
|
39067
|
+
relay_enabled: typeof raw.relay_enabled === "boolean" ? raw.relay_enabled : void 0,
|
|
39068
|
+
onboard_shown: Boolean(raw.onboard_shown),
|
|
39069
|
+
diagnostics_consent: typeof raw.diagnostics_consent === "boolean" ? raw.diagnostics_consent : void 0,
|
|
39070
|
+
agent_updates: typeof raw.agent_updates === "boolean" ? raw.agent_updates : void 0,
|
|
39071
|
+
agent_token: typeof raw.agent_token === "string" ? raw.agent_token : null,
|
|
39072
|
+
agent_token_guid: typeof raw.agent_token_guid === "string" ? raw.agent_token_guid : null
|
|
39073
|
+
};
|
|
39074
|
+
} catch {
|
|
39075
|
+
return emptyState();
|
|
39076
|
+
}
|
|
39077
|
+
}
|
|
39078
|
+
function saveState(state) {
|
|
39079
|
+
mkdirSync9(RELAY_DIR, { recursive: true });
|
|
39080
|
+
writeFileSync10(RELAY_FILE, JSON.stringify(state, null, 2) + "\n", { mode: FILE_MODE });
|
|
39081
|
+
try {
|
|
39082
|
+
chmodSync3(RELAY_FILE, FILE_MODE);
|
|
39083
|
+
} catch {
|
|
39084
|
+
}
|
|
39085
|
+
}
|
|
39086
|
+
function mutate(fn) {
|
|
39087
|
+
const s = loadState();
|
|
39088
|
+
fn(s);
|
|
39089
|
+
saveState(s);
|
|
39090
|
+
}
|
|
39091
|
+
function getDevice() {
|
|
39092
|
+
return loadState().device;
|
|
39093
|
+
}
|
|
39094
|
+
function setDevice(device) {
|
|
39095
|
+
mutate((s) => {
|
|
39096
|
+
s.device = device;
|
|
39097
|
+
});
|
|
39098
|
+
}
|
|
39099
|
+
function clearDevice() {
|
|
39100
|
+
mutate((s) => {
|
|
39101
|
+
s.device = null;
|
|
39102
|
+
s.paused = false;
|
|
39103
|
+
s.agent_token = null;
|
|
39104
|
+
s.agent_token_guid = null;
|
|
39105
|
+
});
|
|
39106
|
+
}
|
|
39107
|
+
function getAgentToken() {
|
|
39108
|
+
const s = loadState();
|
|
39109
|
+
return s.agent_token ? { token: s.agent_token, guid: s.agent_token_guid ?? null } : null;
|
|
39110
|
+
}
|
|
39111
|
+
function setAgentToken(token, guid) {
|
|
39112
|
+
mutate((s) => {
|
|
39113
|
+
s.agent_token = token;
|
|
39114
|
+
s.agent_token_guid = guid;
|
|
39115
|
+
});
|
|
39116
|
+
}
|
|
39117
|
+
function isPaused() {
|
|
39118
|
+
return loadState().paused;
|
|
39119
|
+
}
|
|
39120
|
+
function setPaused(paused) {
|
|
39121
|
+
mutate((s) => {
|
|
39122
|
+
s.paused = paused;
|
|
39123
|
+
});
|
|
39124
|
+
}
|
|
39125
|
+
function getRelayEnabled() {
|
|
39126
|
+
return loadState().relay_enabled;
|
|
39127
|
+
}
|
|
39128
|
+
function isRelayEnabled() {
|
|
39129
|
+
return loadState().relay_enabled === true;
|
|
39130
|
+
}
|
|
39131
|
+
function setRelayEnabled(enabled) {
|
|
39132
|
+
mutate((s) => {
|
|
39133
|
+
s.relay_enabled = enabled;
|
|
39134
|
+
});
|
|
39135
|
+
}
|
|
39136
|
+
function getDiagnosticsConsent() {
|
|
39137
|
+
return loadState().diagnostics_consent;
|
|
39138
|
+
}
|
|
39139
|
+
function setDiagnosticsConsent(consent) {
|
|
39140
|
+
mutate((s) => {
|
|
39141
|
+
s.diagnostics_consent = consent;
|
|
39142
|
+
});
|
|
39143
|
+
}
|
|
39144
|
+
function diagnosticsConsented() {
|
|
39145
|
+
const env = process.env.GIPITY_NO_DIAGNOSTICS ?? process.env.DO_NOT_TRACK;
|
|
39146
|
+
if (env && env !== "0" && env.toLowerCase() !== "false") return false;
|
|
39147
|
+
return loadState().diagnostics_consent !== false;
|
|
39148
|
+
}
|
|
39149
|
+
function getAgentUpdatesPref() {
|
|
39150
|
+
return loadState().agent_updates;
|
|
39151
|
+
}
|
|
39152
|
+
function setAgentUpdatesPref(on2) {
|
|
39153
|
+
mutate((s) => {
|
|
39154
|
+
s.agent_updates = on2;
|
|
39155
|
+
});
|
|
39156
|
+
}
|
|
39157
|
+
function agentUpdatesEnabled() {
|
|
39158
|
+
if (process.env.DISABLE_AUTOUPDATER === "1") return false;
|
|
39159
|
+
const env = (process.env.GIPITY_RELAY_AGENT_UPDATES || "").toLowerCase();
|
|
39160
|
+
if (["0", "off", "false", "no"].includes(env)) return false;
|
|
39161
|
+
if (["1", "on", "true", "yes"].includes(env)) return true;
|
|
39162
|
+
if (process.env.CI || process.env.NODE_ENV === "test") return false;
|
|
39163
|
+
return loadState().agent_updates !== false;
|
|
39164
|
+
}
|
|
39165
|
+
var RELAY_PID_FILE = join17(RELAY_DIR, "relay.pid");
|
|
39166
|
+
function getDaemonPidPath() {
|
|
39167
|
+
return RELAY_PID_FILE;
|
|
39168
|
+
}
|
|
39169
|
+
function writeDaemonPid(pid) {
|
|
39170
|
+
mkdirSync9(RELAY_DIR, { recursive: true });
|
|
39171
|
+
writeFileSync10(RELAY_PID_FILE, String(pid), { flag: "wx" });
|
|
39172
|
+
}
|
|
39173
|
+
function clearDaemonPid() {
|
|
39174
|
+
try {
|
|
39175
|
+
unlinkSync5(RELAY_PID_FILE);
|
|
39176
|
+
} catch {
|
|
39177
|
+
}
|
|
39178
|
+
}
|
|
39179
|
+
function isDaemonRunning() {
|
|
39180
|
+
if (!existsSync14(RELAY_PID_FILE)) return false;
|
|
39181
|
+
try {
|
|
39182
|
+
const raw = readFileSync16(RELAY_PID_FILE, "utf-8").trim();
|
|
39183
|
+
const pid = parseInt(raw, 10);
|
|
39184
|
+
if (!pid || isNaN(pid)) {
|
|
39185
|
+
try {
|
|
39186
|
+
unlinkSync5(RELAY_PID_FILE);
|
|
39187
|
+
} catch {
|
|
39188
|
+
}
|
|
39189
|
+
return false;
|
|
39190
|
+
}
|
|
39191
|
+
if (pid === process.pid) {
|
|
39192
|
+
try {
|
|
39193
|
+
unlinkSync5(RELAY_PID_FILE);
|
|
39194
|
+
} catch {
|
|
39195
|
+
}
|
|
39196
|
+
return false;
|
|
39197
|
+
}
|
|
39198
|
+
process.kill(pid, 0);
|
|
39199
|
+
return true;
|
|
39200
|
+
} catch {
|
|
39201
|
+
try {
|
|
39202
|
+
unlinkSync5(RELAY_PID_FILE);
|
|
39203
|
+
} catch {
|
|
39204
|
+
}
|
|
39205
|
+
return false;
|
|
39206
|
+
}
|
|
39207
|
+
}
|
|
39208
|
+
|
|
39209
|
+
// src/commands/project.ts
|
|
38805
39210
|
var projectCommand = new Command("project").description("Manage projects").argument("[name]", "Switch to project by name/slug").option("--json", "Output as JSON").action((name, opts) => run("Project", async () => {
|
|
38806
39211
|
const config = requireConfig();
|
|
38807
39212
|
if (name) {
|
|
@@ -38856,8 +39261,8 @@ projectCommand.command("create <name>").description("Create a project").option("
|
|
|
38856
39261
|
}
|
|
38857
39262
|
const res = await post("/projects", body);
|
|
38858
39263
|
const project = res.data;
|
|
38859
|
-
const dir =
|
|
38860
|
-
|
|
39264
|
+
const dir = join18(getProjectsRoot(), project.slug);
|
|
39265
|
+
mkdirSync10(dir, { recursive: true });
|
|
38861
39266
|
const accountSlug = await getAccountSlug();
|
|
38862
39267
|
let agentGuid = "";
|
|
38863
39268
|
try {
|
|
@@ -38952,10 +39357,10 @@ var agentCommand = new Command("agent").description("Manage agents").argument("[
|
|
|
38952
39357
|
return `${a.name}${active}${def}${model}`;
|
|
38953
39358
|
});
|
|
38954
39359
|
}));
|
|
38955
|
-
agentCommand.command("models").description("List the LLM models an agent can use (ids for `agent create --model` and `agent set model`)").option("--json", "Output as JSON").action((opts) => run("Models", async () => {
|
|
39360
|
+
agentCommand.command("models").description("List the LLM models an agent can use (ids and tier aliases for `agent create --model` and `agent set model`)").option("--json", "Output as JSON").action((opts) => run("Models", async () => {
|
|
38956
39361
|
const res = await get("/agents/models");
|
|
38957
39362
|
if (opts.json) {
|
|
38958
|
-
console.log(JSON.stringify(res.data));
|
|
39363
|
+
console.log(JSON.stringify({ models: res.data, aliases: res.aliases ?? {} }));
|
|
38959
39364
|
return;
|
|
38960
39365
|
}
|
|
38961
39366
|
const width = res.data.reduce((m, x) => Math.max(m, x.id.length), 0);
|
|
@@ -38970,8 +39375,16 @@ agentCommand.command("models").description("List the LLM models an agent can use
|
|
|
38970
39375
|
if (m.isDefault) notes.push("default");
|
|
38971
39376
|
console.log(`${m.id.padEnd(width)} ${muted(notes.join(" \xB7 "))}`);
|
|
38972
39377
|
}
|
|
39378
|
+
if (res.aliases && Object.keys(res.aliases).length > 0) {
|
|
39379
|
+
console.log("");
|
|
39380
|
+
console.log("Tier aliases (an agent set to one follows the platform model rotations):");
|
|
39381
|
+
const aw = Object.keys(res.aliases).reduce((m, k7) => Math.max(m, k7.length), 0);
|
|
39382
|
+
for (const [alias, id2] of Object.entries(res.aliases)) {
|
|
39383
|
+
console.log(`${alias.padEnd(aw)} ${muted(`-> ${id2}`)}`);
|
|
39384
|
+
}
|
|
39385
|
+
}
|
|
38973
39386
|
}));
|
|
38974
|
-
agentCommand.command("create <name>").description("Create an agent").option("--model <model>", "Model
|
|
39387
|
+
agentCommand.command("create <name>").description("Create an agent").option("--model <model>", "Model id (pins that model) or tier alias like gipity-default/opus (follows rotations) - see `gipity agent models`. Default: gipity-default").option("--switch", "Switch to new agent after creation").option("--json", "Output as JSON").action((name, opts) => run("Create", async () => {
|
|
38975
39388
|
const body = { name };
|
|
38976
39389
|
if (opts.model) body.modelPreference = opts.model;
|
|
38977
39390
|
const res = await post("/agents", body);
|
|
@@ -38986,7 +39399,7 @@ agentCommand.command("create <name>").description("Create an agent").option("--m
|
|
|
38986
39399
|
if (opts.switch) console.log("Switched.");
|
|
38987
39400
|
}
|
|
38988
39401
|
}));
|
|
38989
|
-
agentCommand.command("set <field> <value>").description("Set a field (model, temp). Model ids: `gipity agent models`").option("--json", "Output as JSON").action((field, value, opts) => run("Set", async () => {
|
|
39402
|
+
agentCommand.command("set <field> <value>").description("Set a field (model, temp). Model ids + tier aliases: `gipity agent models`").option("--json", "Output as JSON").action((field, value, opts) => run("Set", async () => {
|
|
38990
39403
|
const config = requireConfig();
|
|
38991
39404
|
const body = {};
|
|
38992
39405
|
if (field === "model") body.modelPreference = value;
|
|
@@ -39795,9 +40208,9 @@ storageCommand.command("retention").description("View or adjust your file versio
|
|
|
39795
40208
|
init_platform();
|
|
39796
40209
|
init_auth();
|
|
39797
40210
|
init_api();
|
|
39798
|
-
import { join as
|
|
39799
|
-
import { existsSync as
|
|
39800
|
-
import { homedir as
|
|
40211
|
+
import { join as join21, dirname as dirname12, resolve as resolve13, basename as basename5, sep as sep6 } from "path";
|
|
40212
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync19, writeFileSync as writeFileSync13, renameSync as renameSync2, readdirSync as readdirSync8, statSync as statSync8 } from "fs";
|
|
40213
|
+
import { homedir as homedir15 } from "os";
|
|
39801
40214
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
39802
40215
|
import { randomUUID } from "crypto";
|
|
39803
40216
|
init_config();
|
|
@@ -39909,8 +40322,8 @@ init_utils();
|
|
|
39909
40322
|
init_colors();
|
|
39910
40323
|
|
|
39911
40324
|
// src/relay/installers.ts
|
|
39912
|
-
import { homedir as
|
|
39913
|
-
import { join as
|
|
40325
|
+
import { homedir as homedir12, platform as osPlatform } from "os";
|
|
40326
|
+
import { join as join19 } from "path";
|
|
39914
40327
|
var UnsupportedPlatformError = class extends Error {
|
|
39915
40328
|
constructor(plat) {
|
|
39916
40329
|
super(`gipity relay install does not support ${plat}`);
|
|
@@ -39928,8 +40341,8 @@ function display(argvs) {
|
|
|
39928
40341
|
}
|
|
39929
40342
|
function launchdPlan(cliPath) {
|
|
39930
40343
|
const label2 = "ai.gipity.relay";
|
|
39931
|
-
const path5 =
|
|
39932
|
-
const logDir =
|
|
40344
|
+
const path5 = join19(homedir12(), "Library", "LaunchAgents", `${label2}.plist`);
|
|
40345
|
+
const logDir = join19(homedir12(), "Library", "Logs", "Gipity");
|
|
39933
40346
|
const uid = process.getuid?.() ?? 0;
|
|
39934
40347
|
const target = `gui/${uid}`;
|
|
39935
40348
|
const content = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -39953,8 +40366,8 @@ function launchdPlan(cliPath) {
|
|
|
39953
40366
|
<dict>
|
|
39954
40367
|
<key>SuccessfulExit</key><false/>
|
|
39955
40368
|
</dict>
|
|
39956
|
-
<key>StandardOutPath</key><string>${
|
|
39957
|
-
<key>StandardErrorPath</key><string>${
|
|
40369
|
+
<key>StandardOutPath</key><string>${join19(logDir, "relay.out.log")}</string>
|
|
40370
|
+
<key>StandardErrorPath</key><string>${join19(logDir, "relay.err.log")}</string>
|
|
39958
40371
|
<key>ProcessType</key><string>Background</string>
|
|
39959
40372
|
</dict>
|
|
39960
40373
|
</plist>
|
|
@@ -39977,7 +40390,7 @@ function launchdPlan(cliPath) {
|
|
|
39977
40390
|
}
|
|
39978
40391
|
function systemdUserPlan(cliPath) {
|
|
39979
40392
|
const unitName = "gipity-relay.service";
|
|
39980
|
-
const path5 =
|
|
40393
|
+
const path5 = join19(homedir12(), ".config", "systemd", "user", unitName);
|
|
39981
40394
|
const content = `[Unit]
|
|
39982
40395
|
Description=Gipity relay - local Claude Code control from the Gipity web CLI
|
|
39983
40396
|
After=network-online.target
|
|
@@ -40015,7 +40428,7 @@ WantedBy=default.target
|
|
|
40015
40428
|
}
|
|
40016
40429
|
function windowsTaskPlan(cliPath) {
|
|
40017
40430
|
const taskName = "GipityRelay";
|
|
40018
|
-
const path5 =
|
|
40431
|
+
const path5 = join19(homedir12(), "AppData", "Local", "Gipity", "relay-task.xml");
|
|
40019
40432
|
const runsViaNode = /\.[cm]?js$/i.test(cliPath);
|
|
40020
40433
|
const command = runsViaNode ? process.execPath : cliPath;
|
|
40021
40434
|
const argLine = runsViaNode ? `"${cliPath}" relay run` : "relay run";
|
|
@@ -40076,15 +40489,15 @@ function windowsTaskPlan(cliPath) {
|
|
|
40076
40489
|
// src/relay/setup.ts
|
|
40077
40490
|
init_platform();
|
|
40078
40491
|
init_api();
|
|
40079
|
-
import { hostname as
|
|
40080
|
-
import { resolve as resolve12, dirname as
|
|
40081
|
-
import { mkdirSync as
|
|
40492
|
+
import { hostname as hostname4, userInfo, platform as osPlatform2 } from "os";
|
|
40493
|
+
import { resolve as resolve12, dirname as dirname11 } from "path";
|
|
40494
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
40082
40495
|
|
|
40083
40496
|
// src/relay/machine-id.ts
|
|
40084
40497
|
import { createHash as createHash3 } from "crypto";
|
|
40085
40498
|
import { execFileSync } from "child_process";
|
|
40086
|
-
import { readFileSync as
|
|
40087
|
-
import { hostname as
|
|
40499
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
40500
|
+
import { hostname as hostname3, platform, arch } from "os";
|
|
40088
40501
|
function rawMachineId() {
|
|
40089
40502
|
const override = process.env.GIPITY_RELAY_MACHINE_ID?.trim();
|
|
40090
40503
|
if (override) return `override:${override}`;
|
|
@@ -40092,7 +40505,7 @@ function rawMachineId() {
|
|
|
40092
40505
|
if (platform() === "linux") {
|
|
40093
40506
|
for (const path5 of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
40094
40507
|
try {
|
|
40095
|
-
const id2 =
|
|
40508
|
+
const id2 = readFileSync17(path5, "utf-8").trim();
|
|
40096
40509
|
if (id2) return `linux:${id2}`;
|
|
40097
40510
|
} catch {
|
|
40098
40511
|
}
|
|
@@ -40112,7 +40525,7 @@ function rawMachineId() {
|
|
|
40112
40525
|
}
|
|
40113
40526
|
} catch {
|
|
40114
40527
|
}
|
|
40115
|
-
return `fallback:${
|
|
40528
|
+
return `fallback:${hostname3()}:${platform()}:${arch()}`;
|
|
40116
40529
|
}
|
|
40117
40530
|
function getMachineId() {
|
|
40118
40531
|
return createHash3("sha256").update(rawMachineId()).digest("hex");
|
|
@@ -40135,7 +40548,7 @@ function friendlyDeviceName() {
|
|
|
40135
40548
|
const owner = user.charAt(0).toUpperCase() + user.slice(1);
|
|
40136
40549
|
return `${owner}'s ${kind}`;
|
|
40137
40550
|
}
|
|
40138
|
-
const host = (
|
|
40551
|
+
const host = (hostname4() || "").trim();
|
|
40139
40552
|
return host || `My ${kind}`;
|
|
40140
40553
|
}
|
|
40141
40554
|
function resolveCliPath() {
|
|
@@ -40160,7 +40573,15 @@ async function pairDevice(opts = {}) {
|
|
|
40160
40573
|
throw new Error("Device name must be 1\u2013100 non-whitespace characters.");
|
|
40161
40574
|
}
|
|
40162
40575
|
const plat = mapPlatform(osPlatform2());
|
|
40163
|
-
const
|
|
40576
|
+
const deviceKind = process.env.GIPITY_DEVICE_KIND;
|
|
40577
|
+
const agentKind = process.env.GIPITY_AGENT_KIND;
|
|
40578
|
+
const res = await post("/remote-devices", {
|
|
40579
|
+
name,
|
|
40580
|
+
platform: plat,
|
|
40581
|
+
machine_id: getMachineId(),
|
|
40582
|
+
...deviceKind ? { device_kind: deviceKind } : {},
|
|
40583
|
+
...agentKind ? { agent_kind: agentKind } : {}
|
|
40584
|
+
});
|
|
40164
40585
|
setDevice({
|
|
40165
40586
|
guid: res.data.short_guid,
|
|
40166
40587
|
name,
|
|
@@ -40187,8 +40608,8 @@ function startDaemon() {
|
|
|
40187
40608
|
function installAutostart(opts = {}) {
|
|
40188
40609
|
const stdio = opts.stdio ?? "ignore";
|
|
40189
40610
|
const plan2 = planFor({ cliPath: resolveCliPath() });
|
|
40190
|
-
|
|
40191
|
-
|
|
40611
|
+
mkdirSync11(dirname11(plan2.path), { recursive: true });
|
|
40612
|
+
writeFileSync11(plan2.path, plan2.content);
|
|
40192
40613
|
let ok = true;
|
|
40193
40614
|
for (const argv2 of plan2.enableCmds) {
|
|
40194
40615
|
const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio });
|
|
@@ -40320,10 +40741,10 @@ init_colors();
|
|
|
40320
40741
|
|
|
40321
40742
|
// src/banner.ts
|
|
40322
40743
|
init_colors();
|
|
40323
|
-
import { homedir as
|
|
40744
|
+
import { homedir as homedir13 } from "os";
|
|
40324
40745
|
import { sep as sep5 } from "path";
|
|
40325
40746
|
function tildify(p) {
|
|
40326
|
-
const home =
|
|
40747
|
+
const home = homedir13();
|
|
40327
40748
|
if (!home) return p;
|
|
40328
40749
|
if (p === home) return "~";
|
|
40329
40750
|
if (p.startsWith(home + sep5)) return "~" + p.slice(home.length);
|
|
@@ -40573,14 +40994,14 @@ init_claude_setup();
|
|
|
40573
40994
|
init_agents();
|
|
40574
40995
|
|
|
40575
40996
|
// src/prefs.ts
|
|
40576
|
-
import { existsSync as
|
|
40577
|
-
import { homedir as
|
|
40578
|
-
import { join as
|
|
40579
|
-
var PREFS_PATH =
|
|
40997
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
|
|
40998
|
+
import { homedir as homedir14 } from "os";
|
|
40999
|
+
import { join as join20 } from "path";
|
|
41000
|
+
var PREFS_PATH = join20(homedir14(), ".gipity", "prefs.json");
|
|
40580
41001
|
function readPrefs() {
|
|
40581
|
-
if (!
|
|
41002
|
+
if (!existsSync15(PREFS_PATH)) return {};
|
|
40582
41003
|
try {
|
|
40583
|
-
const parsed = JSON.parse(
|
|
41004
|
+
const parsed = JSON.parse(readFileSync18(PREFS_PATH, "utf-8"));
|
|
40584
41005
|
return {
|
|
40585
41006
|
lastAgent: typeof parsed.lastAgent === "string" ? parsed.lastAgent : void 0
|
|
40586
41007
|
};
|
|
@@ -40592,26 +41013,26 @@ function writePrefs(update) {
|
|
|
40592
41013
|
try {
|
|
40593
41014
|
const current = readPrefs();
|
|
40594
41015
|
const next = { ...current, ...update };
|
|
40595
|
-
|
|
40596
|
-
|
|
41016
|
+
mkdirSync12(join20(homedir14(), ".gipity"), { recursive: true });
|
|
41017
|
+
writeFileSync12(PREFS_PATH, JSON.stringify(next, null, 2) + "\n");
|
|
40597
41018
|
} catch {
|
|
40598
41019
|
}
|
|
40599
41020
|
}
|
|
40600
41021
|
|
|
40601
41022
|
// src/commands/build.ts
|
|
40602
41023
|
init_setup();
|
|
40603
|
-
var __clDir =
|
|
41024
|
+
var __clDir = dirname12(fileURLToPath2(import.meta.url));
|
|
40604
41025
|
function readOwnPkg(fromDir) {
|
|
40605
|
-
for (let d = fromDir; ; d =
|
|
40606
|
-
const p =
|
|
40607
|
-
if (
|
|
41026
|
+
for (let d = fromDir; ; d = dirname12(d)) {
|
|
41027
|
+
const p = join21(d, "package.json");
|
|
41028
|
+
if (existsSync16(p)) {
|
|
40608
41029
|
try {
|
|
40609
|
-
const pkg2 = JSON.parse(
|
|
41030
|
+
const pkg2 = JSON.parse(readFileSync19(p, "utf-8"));
|
|
40610
41031
|
if (pkg2.name === "gipity") return pkg2;
|
|
40611
41032
|
} catch {
|
|
40612
41033
|
}
|
|
40613
41034
|
}
|
|
40614
|
-
if (
|
|
41035
|
+
if (dirname12(d) === d) return {};
|
|
40615
41036
|
}
|
|
40616
41037
|
}
|
|
40617
41038
|
var __clPkg = readOwnPkg(__clDir);
|
|
@@ -40660,7 +41081,7 @@ function localFsFallback(dir) {
|
|
|
40660
41081
|
let isDir = false;
|
|
40661
41082
|
let size = 0;
|
|
40662
41083
|
try {
|
|
40663
|
-
const st2 = statSync8(
|
|
41084
|
+
const st2 = statSync8(join21(d, name));
|
|
40664
41085
|
isDir = st2.isDirectory();
|
|
40665
41086
|
size = st2.isFile() ? st2.size : 0;
|
|
40666
41087
|
} catch {
|
|
@@ -40669,7 +41090,7 @@ function localFsFallback(dir) {
|
|
|
40669
41090
|
if (isDir) {
|
|
40670
41091
|
folderCount++;
|
|
40671
41092
|
if (depth === 0) topLevelEntries.push(`${name}/`);
|
|
40672
|
-
walk(
|
|
41093
|
+
walk(join21(d, name), depth + 1);
|
|
40673
41094
|
} else {
|
|
40674
41095
|
fileCount++;
|
|
40675
41096
|
totalBytes += size;
|
|
@@ -40702,8 +41123,8 @@ function hasStreamJsonFlag(args) {
|
|
|
40702
41123
|
}
|
|
40703
41124
|
function markFolderTrusted(dir) {
|
|
40704
41125
|
try {
|
|
40705
|
-
const file =
|
|
40706
|
-
const cfg =
|
|
41126
|
+
const file = join21(homedir15(), ".claude.json");
|
|
41127
|
+
const cfg = existsSync16(file) ? JSON.parse(readFileSync19(file, "utf-8")) : {};
|
|
40707
41128
|
if (typeof cfg !== "object" || cfg === null) return;
|
|
40708
41129
|
if (typeof cfg.projects !== "object" || cfg.projects === null) cfg.projects = {};
|
|
40709
41130
|
const entry = typeof cfg.projects[dir] === "object" && cfg.projects[dir] !== null ? cfg.projects[dir] : {};
|
|
@@ -40711,7 +41132,7 @@ function markFolderTrusted(dir) {
|
|
|
40711
41132
|
entry.hasTrustDialogAccepted = true;
|
|
40712
41133
|
cfg.projects[dir] = entry;
|
|
40713
41134
|
const tmp = `${file}.gipity-tmp`;
|
|
40714
|
-
|
|
41135
|
+
writeFileSync13(tmp, JSON.stringify(cfg, null, 2));
|
|
40715
41136
|
renameSync2(tmp, file);
|
|
40716
41137
|
} catch {
|
|
40717
41138
|
}
|
|
@@ -40828,9 +41249,9 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40828
41249
|
let existing = getConfig();
|
|
40829
41250
|
let forceAdoptCwd = false;
|
|
40830
41251
|
if (existing && !opts.newProject && !opts.project && !nonInteractive) {
|
|
40831
|
-
const cwdHasConfig =
|
|
41252
|
+
const cwdHasConfig = existsSync16(resolve13(process.cwd(), ".gipity.json"));
|
|
40832
41253
|
if (!cwdHasConfig && isLikelyEmpty(process.cwd())) {
|
|
40833
|
-
const ancestorRoot =
|
|
41254
|
+
const ancestorRoot = dirname12(getConfigPath());
|
|
40834
41255
|
console.log(` ${bold("You are inside an existing Gipity project.")}
|
|
40835
41256
|
`);
|
|
40836
41257
|
console.log(` ${bold("1.")} Continue in ${brand(existing.projectSlug)} ${muted(`(rooted at ${formatCwdLabel(ancestorRoot)})`)}`);
|
|
@@ -40877,8 +41298,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40877
41298
|
}
|
|
40878
41299
|
project = found;
|
|
40879
41300
|
}
|
|
40880
|
-
const projectDir2 = opts.here ? process.cwd() :
|
|
40881
|
-
|
|
41301
|
+
const projectDir2 = opts.here ? process.cwd() : join21(getProjectsRoot(), project.slug);
|
|
41302
|
+
mkdirSync13(projectDir2, { recursive: true });
|
|
40882
41303
|
process.chdir(projectDir2);
|
|
40883
41304
|
clearConfigCache();
|
|
40884
41305
|
let agentGuid = "";
|
|
@@ -40920,7 +41341,7 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
40920
41341
|
`);
|
|
40921
41342
|
setupProjectTools();
|
|
40922
41343
|
let doSync = true;
|
|
40923
|
-
const projectRoot =
|
|
41344
|
+
const projectRoot = dirname12(getConfigPath());
|
|
40924
41345
|
const scan = scanForAdoption(projectRoot);
|
|
40925
41346
|
if (scan.tier === "refuse" && !nonInteractive) {
|
|
40926
41347
|
const sizeStr = scan.truncated ? `>${formatBytes(ADOPT_THRESHOLDS.REFUSE_BYTES)}` : formatBytes(scan.bytes);
|
|
@@ -41001,8 +41422,8 @@ async function runLaunch(cmdName, cmdCfg, opts) {
|
|
|
41001
41422
|
} else {
|
|
41002
41423
|
project = result.project;
|
|
41003
41424
|
isNewProject = result.kind === "create-new";
|
|
41004
|
-
const projectDir2 =
|
|
41005
|
-
|
|
41425
|
+
const projectDir2 = join21(getProjectsRoot(), project.slug);
|
|
41426
|
+
mkdirSync13(projectDir2, { recursive: true });
|
|
41006
41427
|
process.chdir(projectDir2);
|
|
41007
41428
|
clearConfigCache();
|
|
41008
41429
|
try {
|
|
@@ -41358,6 +41779,12 @@ Sending to ${adapter.displayName}: ${message}
|
|
|
41358
41779
|
}
|
|
41359
41780
|
console.log("");
|
|
41360
41781
|
}
|
|
41782
|
+
if (adapter.prepareLaunch) {
|
|
41783
|
+
try {
|
|
41784
|
+
await adapter.prepareLaunch();
|
|
41785
|
+
} catch {
|
|
41786
|
+
}
|
|
41787
|
+
}
|
|
41361
41788
|
const childEnv2 = { ...process.env };
|
|
41362
41789
|
if (convGuid) childEnv2.GIPITY_CONVERSATION_GUID = convGuid;
|
|
41363
41790
|
const agentCmd = resolveCommand(adapter.binary);
|
|
@@ -41389,8 +41816,8 @@ ${doneLine}
|
|
|
41389
41816
|
});
|
|
41390
41817
|
}
|
|
41391
41818
|
function flushHeadlessCapture(adapter, sessionId, convGuid) {
|
|
41392
|
-
const runner =
|
|
41393
|
-
if (!
|
|
41819
|
+
const runner = join21(__clDir, "..", "hooks", "capture-runner.js");
|
|
41820
|
+
if (!existsSync16(runner)) return;
|
|
41394
41821
|
const payload = JSON.stringify({ session_id: sessionId, cwd: process.cwd() });
|
|
41395
41822
|
const env = { ...process.env, GIPITY_CONVERSATION_GUID: convGuid };
|
|
41396
41823
|
for (const event of ["session-start", "stop"]) {
|
|
@@ -41517,7 +41944,7 @@ async function browseProjects(all, opts = {}) {
|
|
|
41517
41944
|
function formatNewProjectLabel(existingSlugs) {
|
|
41518
41945
|
const slug = suggestProjectName(existingSlugs);
|
|
41519
41946
|
const root = getProjectsRoot();
|
|
41520
|
-
const home =
|
|
41947
|
+
const home = homedir15();
|
|
41521
41948
|
const display2 = root === home || root.startsWith(home + sep6) ? "~" + root.slice(home.length) : root;
|
|
41522
41949
|
return `${display2}${sep6}${slug}`;
|
|
41523
41950
|
}
|
|
@@ -41567,12 +41994,7 @@ async function createNewProject(existingSlugs, preset) {
|
|
|
41567
41994
|
continue;
|
|
41568
41995
|
}
|
|
41569
41996
|
try {
|
|
41570
|
-
const device = getDevice();
|
|
41571
41997
|
const body = { name: projectName, slug: projectSlug };
|
|
41572
|
-
if (device) {
|
|
41573
|
-
body.autoChat = "claude_code";
|
|
41574
|
-
body.deviceGuid = device.guid;
|
|
41575
|
-
}
|
|
41576
41998
|
const res = await post("/projects", body);
|
|
41577
41999
|
console.log(` ${info(`Creating "${projectName}"...`)} ${success("Created.")}`);
|
|
41578
42000
|
return res.data;
|
|
@@ -42982,7 +43404,7 @@ serviceCommand.command("call <name> [body]").description("Call an app service by
|
|
|
42982
43404
|
}
|
|
42983
43405
|
res = await publicRequest(opts.get ? "GET" : "POST", url, opts.get ? void 0 : body, headers);
|
|
42984
43406
|
} else {
|
|
42985
|
-
res = opts.get ? await get(url) : await post(url, body);
|
|
43407
|
+
res = opts.get ? await get(url) : await post(url, body, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
42986
43408
|
}
|
|
42987
43409
|
} catch (err) {
|
|
42988
43410
|
const hint = opts.anon ? anonBillingHint(name, err) : null;
|
|
@@ -43507,11 +43929,11 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
|
|
|
43507
43929
|
}
|
|
43508
43930
|
}));
|
|
43509
43931
|
jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").action(async (name, opts) => {
|
|
43510
|
-
const { existsSync:
|
|
43511
|
-
const { resolve: resolve19, join:
|
|
43932
|
+
const { existsSync: existsSync26, statSync: statSync12 } = await import("node:fs");
|
|
43933
|
+
const { resolve: resolve19, join: join31 } = await import("node:path");
|
|
43512
43934
|
const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
43513
43935
|
const jobDir = resolve19(process.cwd(), "jobs", name);
|
|
43514
|
-
if (!
|
|
43936
|
+
if (!existsSync26(jobDir) || !statSync12(jobDir).isDirectory()) {
|
|
43515
43937
|
console.error(error(`jobs/${name}/ not found in current directory`));
|
|
43516
43938
|
process.exit(1);
|
|
43517
43939
|
}
|
|
@@ -43532,7 +43954,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43532
43954
|
},
|
|
43533
43955
|
{ file: "main.sh", runtime: "bash", entry: "bash" }
|
|
43534
43956
|
];
|
|
43535
|
-
const picked = variants.find((v7) =>
|
|
43957
|
+
const picked = variants.find((v7) => existsSync26(join31(jobDir, v7.file)));
|
|
43536
43958
|
if (!picked) {
|
|
43537
43959
|
console.error(error(`No main.py / main.js / main.sh found under jobs/${name}/`));
|
|
43538
43960
|
process.exit(1);
|
|
@@ -43557,7 +43979,7 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
43557
43979
|
"-v",
|
|
43558
43980
|
`${jobDir}:/work`
|
|
43559
43981
|
];
|
|
43560
|
-
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd &&
|
|
43982
|
+
const needsDeps = opts.deps !== false && picked.depsFile && picked.installCmd && existsSync26(join31(jobDir, picked.depsFile));
|
|
43561
43983
|
const handlerCmd = `${picked.entry} /work/${picked.file}`;
|
|
43562
43984
|
let shellCmd;
|
|
43563
43985
|
if (needsDeps && picked.installCmd) {
|
|
@@ -43735,8 +44157,8 @@ emailCommand.command("log").description("Recent email() sends and skipped attemp
|
|
|
43735
44157
|
init_api();
|
|
43736
44158
|
init_config();
|
|
43737
44159
|
init_colors();
|
|
43738
|
-
import { mkdirSync as
|
|
43739
|
-
import { resolve as resolvePath2, dirname as
|
|
44160
|
+
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync14, readFileSync as readFileSync20 } from "fs";
|
|
44161
|
+
import { resolve as resolvePath2, dirname as dirname13, relative as relative5, isAbsolute, basename as basename6 } from "path";
|
|
43740
44162
|
|
|
43741
44163
|
// src/provider-docs.ts
|
|
43742
44164
|
var GEMINI_TTS_VOICES_DOC = `Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat`;
|
|
@@ -43797,13 +44219,11 @@ var VIDEO_ASPECT_RATIO_IDS = [
|
|
|
43797
44219
|
];
|
|
43798
44220
|
var VIDEO_MODELS_TABLE = ` veo-3.1-generate-preview best quality, up to 4K, ~$0.40/sec
|
|
43799
44221
|
veo-3.1-fast-generate-preview faster, ~$0.10/sec
|
|
43800
|
-
veo-3.1-lite-generate-preview budget, ~$0.05/sec
|
|
43801
|
-
gemini-omni-flash-preview 3-10s @ 720p, conversational editing, ~$0.10/sec`;
|
|
44222
|
+
veo-3.1-lite-generate-preview budget, ~$0.05/sec`;
|
|
43802
44223
|
var VIDEO_MODEL_IDS = [
|
|
43803
44224
|
"veo-3.1-generate-preview",
|
|
43804
44225
|
"veo-3.1-fast-generate-preview",
|
|
43805
|
-
"veo-3.1-lite-generate-preview"
|
|
43806
|
-
"gemini-omni-flash-preview"
|
|
44226
|
+
"veo-3.1-lite-generate-preview"
|
|
43807
44227
|
];
|
|
43808
44228
|
var VIDEO_RESOLUTION_IDS = [
|
|
43809
44229
|
"720p",
|
|
@@ -43843,7 +44263,7 @@ async function downloadFile(url, filename, explicit) {
|
|
|
43843
44263
|
const outPath = explicit ? filename : correctExtension(filename, buffer);
|
|
43844
44264
|
if (explicit) noteFormatMismatch(filename, buffer);
|
|
43845
44265
|
ensureOutputDir(outPath);
|
|
43846
|
-
|
|
44266
|
+
writeFileSync14(outPath, buffer);
|
|
43847
44267
|
const savedPath = resolvePath2(outPath);
|
|
43848
44268
|
await pushGenerated(savedPath);
|
|
43849
44269
|
return savedPath;
|
|
@@ -43887,9 +44307,9 @@ function noteFormatMismatch(filename, buf) {
|
|
|
43887
44307
|
));
|
|
43888
44308
|
}
|
|
43889
44309
|
function ensureOutputDir(output) {
|
|
43890
|
-
const dir =
|
|
44310
|
+
const dir = dirname13(resolvePath2(output));
|
|
43891
44311
|
try {
|
|
43892
|
-
|
|
44312
|
+
mkdirSync14(dir, { recursive: true });
|
|
43893
44313
|
} catch (err) {
|
|
43894
44314
|
throw new Error(`can't create the output directory ${dir} (${err.code || err.message}). Pick a different -o path.`);
|
|
43895
44315
|
}
|
|
@@ -43897,7 +44317,7 @@ function ensureOutputDir(output) {
|
|
|
43897
44317
|
async function pushGenerated(savedPath) {
|
|
43898
44318
|
const configPath = getConfigPath();
|
|
43899
44319
|
if (!configPath) return;
|
|
43900
|
-
const rel2 = relative5(
|
|
44320
|
+
const rel2 = relative5(dirname13(configPath), savedPath);
|
|
43901
44321
|
if (rel2.startsWith("..") || isAbsolute(rel2)) return;
|
|
43902
44322
|
try {
|
|
43903
44323
|
await pushFile(savedPath);
|
|
@@ -43909,7 +44329,7 @@ function readInputImages(paths) {
|
|
|
43909
44329
|
return paths.map((p) => {
|
|
43910
44330
|
let buf;
|
|
43911
44331
|
try {
|
|
43912
|
-
buf =
|
|
44332
|
+
buf = readFileSync20(p);
|
|
43913
44333
|
} catch (e) {
|
|
43914
44334
|
throw new Error(`can't read --input image ${p} (${e.code || e.message}).`);
|
|
43915
44335
|
}
|
|
@@ -43954,7 +44374,7 @@ Examples:
|
|
|
43954
44374
|
image_size: opts.imageSize,
|
|
43955
44375
|
seed: Number.isFinite(opts.seed) ? opts.seed : void 0,
|
|
43956
44376
|
input_images: inputImages
|
|
43957
|
-
});
|
|
44377
|
+
}, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
43958
44378
|
const verb = inputImages ? "Editing image..." : "Generating image...";
|
|
43959
44379
|
const started = Date.now();
|
|
43960
44380
|
const result = opts.json ? await doGenerate() : await withSpinner(verb, doGenerate, { done: null });
|
|
@@ -44003,7 +44423,7 @@ Examples:
|
|
|
44003
44423
|
aspect_ratio: opts.aspect,
|
|
44004
44424
|
resolution: opts.resolution,
|
|
44005
44425
|
duration_seconds: opts.duration ? Number(opts.duration) : void 0
|
|
44006
|
-
});
|
|
44426
|
+
}, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
44007
44427
|
const started = Date.now();
|
|
44008
44428
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating video...", doGenerate, { done: null });
|
|
44009
44429
|
const elapsed = (Date.now() - started) / 1e3;
|
|
@@ -44058,7 +44478,7 @@ Examples:
|
|
|
44058
44478
|
voice: opts.voice,
|
|
44059
44479
|
language: opts.language,
|
|
44060
44480
|
speakers
|
|
44061
|
-
});
|
|
44481
|
+
}, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
44062
44482
|
const started = Date.now();
|
|
44063
44483
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating speech...", doGenerate, { done: null });
|
|
44064
44484
|
const elapsed = (Date.now() - started) / 1e3;
|
|
@@ -44083,23 +44503,34 @@ default; pass --model <id> only if you want a specific one (see the catalog with
|
|
|
44083
44503
|
|
|
44084
44504
|
Tips:
|
|
44085
44505
|
- Describe genre, mood, instruments, and tempo (e.g. "upbeat lo-fi hip hop with mellow piano")
|
|
44086
|
-
- Music is instrumental by default; pass --vocals to allow singing
|
|
44506
|
+
- Music is instrumental by default; pass --vocals to allow singing, or --lyrics /
|
|
44507
|
+
--lyrics-file to have the vocalist sing YOUR exact words (section tags like
|
|
44508
|
+
[Verse] / [Chorus] are understood; keep the prompt to style only)
|
|
44509
|
+
- With lyrics, size --duration to the words (roughly 10s per short section)
|
|
44087
44510
|
- Longer clips cost more; the max length depends on the model
|
|
44088
44511
|
|
|
44089
44512
|
Examples:
|
|
44090
44513
|
gipity generate music "chill lo-fi beat for studying"
|
|
44091
44514
|
gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
|
|
44092
44515
|
gipity generate music "indie pop chorus" --vocals --duration 20
|
|
44093
|
-
|
|
44516
|
+
gipity generate music "80s synth-pop, female vocals" --lyrics-file lyrics.txt --duration 120 -o song.mp3
|
|
44517
|
+
`).argument("<prompt>", "Text description of the music to generate").option("--duration <seconds>", "Clip length in seconds (default 30; max depends on the model)", (v7) => parseInt(v7, 10)).option("--model <model>", "Music model id (default: platform default; list ids: gipity service call music/models --get)").option("--vocals", "Allow vocals (default: instrumental only)").option("--lyrics <text>", "Exact lyrics to sing (implies vocals; only lyrics-capable models)").option("--lyrics-file <file>", "Read the exact lyrics to sing from a file (implies vocals)").option("-o, --output <file>", "Output path (default ./music.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/audio/theme.mp3; the cwd default is fine for one-off generation.").option("--json", "Output as JSON").action(async (prompt2, opts) => {
|
|
44094
44518
|
try {
|
|
44095
44519
|
const { config } = await resolveProjectContext();
|
|
44096
44520
|
if (opts.output) ensureOutputDir(opts.output);
|
|
44521
|
+
if (opts.lyrics && opts.lyricsFile) {
|
|
44522
|
+
console.error(error("Pass --lyrics or --lyrics-file, not both."));
|
|
44523
|
+
process.exit(1);
|
|
44524
|
+
}
|
|
44525
|
+
const lyrics = opts.lyricsFile ? readFileSync20(opts.lyricsFile, "utf8").trim() : opts.lyrics;
|
|
44097
44526
|
const doGenerate = () => post(`/projects/${config.projectGuid}/generate/music`, {
|
|
44098
44527
|
prompt: prompt2,
|
|
44099
44528
|
duration_seconds: opts.duration,
|
|
44100
44529
|
model: opts.model,
|
|
44101
|
-
instrumental
|
|
44102
|
-
|
|
44530
|
+
// Lyrics imply vocals; otherwise instrumental unless --vocals.
|
|
44531
|
+
instrumental: lyrics ? false : !opts.vocals,
|
|
44532
|
+
lyrics: lyrics || void 0
|
|
44533
|
+
}, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
44103
44534
|
const started = Date.now();
|
|
44104
44535
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating music...", doGenerate, { done: null });
|
|
44105
44536
|
const elapsed = (Date.now() - started) / 1e3;
|
|
@@ -44139,7 +44570,7 @@ Examples:
|
|
|
44139
44570
|
text,
|
|
44140
44571
|
duration_seconds: opts.duration,
|
|
44141
44572
|
prompt_influence: opts.influence
|
|
44142
|
-
});
|
|
44573
|
+
}, { timeoutMs: LONG_REQUEST_TIMEOUT_MS });
|
|
44143
44574
|
const started = Date.now();
|
|
44144
44575
|
const result = opts.json ? await doGenerate() : await withSpinner("Generating sound effect...", doGenerate, { done: null });
|
|
44145
44576
|
const elapsed = (Date.now() - started) / 1e3;
|
|
@@ -44163,14 +44594,14 @@ var generateCommand = new Command("generate").description("Generate images, vide
|
|
|
44163
44594
|
init_api();
|
|
44164
44595
|
init_config();
|
|
44165
44596
|
init_colors();
|
|
44166
|
-
import { existsSync as
|
|
44167
|
-
import { join as
|
|
44597
|
+
import { existsSync as existsSync17, readFileSync as readFileSync21 } from "fs";
|
|
44598
|
+
import { join as join22 } from "path";
|
|
44168
44599
|
function readInstalledKitReadme(name) {
|
|
44169
44600
|
const root = getProjectRoot() ?? process.cwd();
|
|
44170
|
-
const kitDir =
|
|
44171
|
-
if (!
|
|
44172
|
-
const readme =
|
|
44173
|
-
return
|
|
44601
|
+
const kitDir = join22(root, "src", "packages", name);
|
|
44602
|
+
if (!existsSync17(join22(kitDir, "package.json"))) return null;
|
|
44603
|
+
const readme = join22(kitDir, "README.md");
|
|
44604
|
+
return existsSync17(readme) ? readFileSync21(readme, "utf-8") : null;
|
|
44174
44605
|
}
|
|
44175
44606
|
function slugify2(title) {
|
|
44176
44607
|
return title.toLowerCase().replace(/[`*_]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -44443,15 +44874,15 @@ var domainCommand = new Command("domain").description("Manage custom domains").a
|
|
|
44443
44874
|
}));
|
|
44444
44875
|
|
|
44445
44876
|
// src/commands/realtime.ts
|
|
44446
|
-
import { existsSync as
|
|
44447
|
-
import { dirname as
|
|
44877
|
+
import { existsSync as existsSync18 } from "fs";
|
|
44878
|
+
import { dirname as dirname14, resolve as resolve14 } from "path";
|
|
44448
44879
|
init_api();
|
|
44449
44880
|
init_config();
|
|
44450
44881
|
init_colors();
|
|
44451
44882
|
function hasDeployManifest() {
|
|
44452
44883
|
const cfgPath = getConfigPath();
|
|
44453
44884
|
if (!cfgPath) return false;
|
|
44454
|
-
return
|
|
44885
|
+
return existsSync18(resolve14(dirname14(cfgPath), "gipity.yaml"));
|
|
44455
44886
|
}
|
|
44456
44887
|
var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").addOption(new Option("--type <type>", "Room type for create").choices(["state", "relay"]).default("state")).addOption(new Option("--auth <level>", "Auth level for create").choices(["public", "user"]).default("public")).option("--max-clients <n>", "max clients for create (1-200)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
|
|
44457
44888
|
const config = requireConfig();
|
|
@@ -44860,21 +45291,21 @@ var locationCommand = new Command("location").description("Show location").argum
|
|
|
44860
45291
|
}));
|
|
44861
45292
|
|
|
44862
45293
|
// src/commands/doctor.ts
|
|
44863
|
-
import { existsSync as
|
|
44864
|
-
import { join as
|
|
44865
|
-
import { homedir as
|
|
45294
|
+
import { existsSync as existsSync20, readFileSync as readFileSync23, statSync as statSync9 } from "fs";
|
|
45295
|
+
import { join as join24, resolve as resolve15 } from "path";
|
|
45296
|
+
import { homedir as homedir17 } from "os";
|
|
44866
45297
|
|
|
44867
45298
|
// src/updater/state.ts
|
|
44868
|
-
import { readFileSync as
|
|
44869
|
-
import { join as
|
|
44870
|
-
import { homedir as
|
|
44871
|
-
var GIPITY_DIR =
|
|
44872
|
-
var LOCAL_DIR =
|
|
44873
|
-
var LOCAL_PKG_DIR =
|
|
44874
|
-
var LOCAL_ENTRY =
|
|
44875
|
-
var STATE_FILE =
|
|
44876
|
-
var SETTINGS_FILE =
|
|
44877
|
-
var UPDATE_LOG =
|
|
45299
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, mkdirSync as mkdirSync15, existsSync as existsSync19 } from "fs";
|
|
45300
|
+
import { join as join23 } from "path";
|
|
45301
|
+
import { homedir as homedir16 } from "os";
|
|
45302
|
+
var GIPITY_DIR = join23(homedir16(), ".gipity");
|
|
45303
|
+
var LOCAL_DIR = join23(GIPITY_DIR, "local");
|
|
45304
|
+
var LOCAL_PKG_DIR = join23(LOCAL_DIR, "node_modules", "gipity");
|
|
45305
|
+
var LOCAL_ENTRY = join23(LOCAL_PKG_DIR, "dist", "index.js");
|
|
45306
|
+
var STATE_FILE = join23(GIPITY_DIR, "update-state.json");
|
|
45307
|
+
var SETTINGS_FILE = join23(GIPITY_DIR, "settings.json");
|
|
45308
|
+
var UPDATE_LOG = join23(GIPITY_DIR, "update.log");
|
|
44878
45309
|
var DEFAULT_STATE = {
|
|
44879
45310
|
installedVersion: null,
|
|
44880
45311
|
lastCheckAt: 0,
|
|
@@ -44885,24 +45316,24 @@ var DEFAULT_SETTINGS = {
|
|
|
44885
45316
|
autoUpdates: true
|
|
44886
45317
|
};
|
|
44887
45318
|
function ensureDir() {
|
|
44888
|
-
|
|
45319
|
+
mkdirSync15(GIPITY_DIR, { recursive: true });
|
|
44889
45320
|
}
|
|
44890
45321
|
function readState() {
|
|
44891
|
-
if (!
|
|
45322
|
+
if (!existsSync19(STATE_FILE)) return { ...DEFAULT_STATE };
|
|
44892
45323
|
try {
|
|
44893
|
-
return { ...DEFAULT_STATE, ...JSON.parse(
|
|
45324
|
+
return { ...DEFAULT_STATE, ...JSON.parse(readFileSync22(STATE_FILE, "utf-8")) };
|
|
44894
45325
|
} catch {
|
|
44895
45326
|
return { ...DEFAULT_STATE };
|
|
44896
45327
|
}
|
|
44897
45328
|
}
|
|
44898
45329
|
function writeState(state) {
|
|
44899
45330
|
ensureDir();
|
|
44900
|
-
|
|
45331
|
+
writeFileSync15(STATE_FILE, JSON.stringify(state, null, 2));
|
|
44901
45332
|
}
|
|
44902
45333
|
function readSettings() {
|
|
44903
|
-
if (!
|
|
45334
|
+
if (!existsSync19(SETTINGS_FILE)) return { ...DEFAULT_SETTINGS };
|
|
44904
45335
|
try {
|
|
44905
|
-
return { ...DEFAULT_SETTINGS, ...JSON.parse(
|
|
45336
|
+
return { ...DEFAULT_SETTINGS, ...JSON.parse(readFileSync22(SETTINGS_FILE, "utf-8")) };
|
|
44906
45337
|
} catch {
|
|
44907
45338
|
return { ...DEFAULT_SETTINGS };
|
|
44908
45339
|
}
|
|
@@ -44919,7 +45350,7 @@ init_colors();
|
|
|
44919
45350
|
init_auth();
|
|
44920
45351
|
init_claude_setup();
|
|
44921
45352
|
var NODE_MIN_MAJOR = 18;
|
|
44922
|
-
function versionManagerNode(execPath, env = process.env, home =
|
|
45353
|
+
function versionManagerNode(execPath, env = process.env, home = homedir17()) {
|
|
44923
45354
|
const norm = (s) => s.replace(/\\/g, "/").replace(/\/+$/, "") + "/";
|
|
44924
45355
|
const p = norm(execPath);
|
|
44925
45356
|
const h = norm(home);
|
|
@@ -44936,10 +45367,10 @@ function versionManagerNode(execPath, env = process.env, home = homedir15()) {
|
|
|
44936
45367
|
return null;
|
|
44937
45368
|
}
|
|
44938
45369
|
function localVersion() {
|
|
44939
|
-
const pkgPath =
|
|
44940
|
-
if (!
|
|
45370
|
+
const pkgPath = join24(LOCAL_PKG_DIR, "package.json");
|
|
45371
|
+
if (!existsSync20(pkgPath)) return null;
|
|
44941
45372
|
try {
|
|
44942
|
-
return JSON.parse(
|
|
45373
|
+
return JSON.parse(readFileSync23(pkgPath, "utf-8")).version ?? null;
|
|
44943
45374
|
} catch {
|
|
44944
45375
|
return null;
|
|
44945
45376
|
}
|
|
@@ -44947,7 +45378,7 @@ function localVersion() {
|
|
|
44947
45378
|
function shimVersion() {
|
|
44948
45379
|
try {
|
|
44949
45380
|
const url = new URL("../../package.json", import.meta.url);
|
|
44950
|
-
return JSON.parse(
|
|
45381
|
+
return JSON.parse(readFileSync23(url, "utf-8")).version;
|
|
44951
45382
|
} catch {
|
|
44952
45383
|
return "unknown";
|
|
44953
45384
|
}
|
|
@@ -44962,7 +45393,7 @@ function rel(t) {
|
|
|
44962
45393
|
}
|
|
44963
45394
|
function relayAutostartInstalled() {
|
|
44964
45395
|
try {
|
|
44965
|
-
return
|
|
45396
|
+
return existsSync20(planFor({ cliPath: resolveCliPath() }).path);
|
|
44966
45397
|
} catch (err) {
|
|
44967
45398
|
if (err instanceof UnsupportedPlatformError) return null;
|
|
44968
45399
|
return null;
|
|
@@ -45000,7 +45431,7 @@ function gatherEnv(opts = {}) {
|
|
|
45000
45431
|
const cli = {
|
|
45001
45432
|
shim_version: shimVersion(),
|
|
45002
45433
|
local_version: localVersion(),
|
|
45003
|
-
local_install_ok:
|
|
45434
|
+
local_install_ok: existsSync20(LOCAL_ENTRY),
|
|
45004
45435
|
auto_updates: !dis.disabled,
|
|
45005
45436
|
updates_disabled_reason: dis.disabled ? dis.reason ?? null : null,
|
|
45006
45437
|
last_check_at: updState.lastCheckAt,
|
|
@@ -45030,7 +45461,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
45030
45461
|
console.log(`${muted("claude code ")} installed ${yn(env.claude.installed)} \xB7 authenticated ${yn(env.claude.authenticated)}`);
|
|
45031
45462
|
const autostartLabel = env.relay.autostart === null ? muted("n/a") : yn(env.relay.autostart);
|
|
45032
45463
|
console.log(`${muted("relay ")} paired ${yn(env.relay.paired)} \xB7 running ${yn(env.relay.running)} \xB7 autostart ${autostartLabel}${env.relay.paused ? warning(" \xB7 paused") : ""}${env.relay.device ? muted(` (${env.relay.device.name})`) : ""}`);
|
|
45033
|
-
if (
|
|
45464
|
+
if (existsSync20(resolve15(process.cwd(), ".codex", "hooks.json"))) {
|
|
45034
45465
|
console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
|
|
45035
45466
|
}
|
|
45036
45467
|
console.log(`${muted("ready ")} ${env.ready ? success("yes") : warning("no - run `gipity build` (or the desktop app) to finish setup")}`);
|
|
@@ -45038,7 +45469,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
45038
45469
|
const settings = readSettings();
|
|
45039
45470
|
const dis = updatesDisabled();
|
|
45040
45471
|
const local = localVersion();
|
|
45041
|
-
const localOk =
|
|
45472
|
+
const localOk = existsSync20(LOCAL_ENTRY);
|
|
45042
45473
|
console.log("");
|
|
45043
45474
|
console.log(bold("CLI install"));
|
|
45044
45475
|
console.log(`${muted("shim version ")} ${shimVersion()}`);
|
|
@@ -45046,11 +45477,11 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
45046
45477
|
console.log(`${muted("local install ")} ${LOCAL_PKG_DIR}`);
|
|
45047
45478
|
console.log("");
|
|
45048
45479
|
console.log(`${muted("auto-updates ")} ${dis.disabled ? warning(`disabled (${dis.reason})`) : success("enabled")}`);
|
|
45049
|
-
console.log(`${muted("settings file ")} ${
|
|
45480
|
+
console.log(`${muted("settings file ")} ${existsSync20(SETTINGS_FILE) ? SETTINGS_FILE : dim("(default)")} autoUpdates=${settings.autoUpdates}`);
|
|
45050
45481
|
console.log(`${muted("last check ")} ${rel(state.lastCheckAt)}`);
|
|
45051
45482
|
console.log(`${muted("last error ")} ${state.lastError ? error(state.lastError) : dim("none")}`);
|
|
45052
|
-
console.log(`${muted("state file ")} ${
|
|
45053
|
-
console.log(`${muted("update log ")} ${
|
|
45483
|
+
console.log(`${muted("state file ")} ${existsSync20(STATE_FILE) ? STATE_FILE : dim("(none yet)")}`);
|
|
45484
|
+
console.log(`${muted("update log ")} ${existsSync20(UPDATE_LOG) ? `${UPDATE_LOG} (${statSync9(UPDATE_LOG).size} bytes)` : dim("(none yet)")}`);
|
|
45054
45485
|
console.log("");
|
|
45055
45486
|
console.log(dim("Force an update with: gipity update"));
|
|
45056
45487
|
});
|
|
@@ -45059,10 +45490,10 @@ var doctorCommand = new Command("doctor").description("Check install + environme
|
|
|
45059
45490
|
import { appendFileSync } from "fs";
|
|
45060
45491
|
|
|
45061
45492
|
// src/updater/install.ts
|
|
45062
|
-
import { existsSync as
|
|
45063
|
-
import { dirname as
|
|
45493
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync16, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync16 } from "fs";
|
|
45494
|
+
import { dirname as dirname15, join as join25 } from "path";
|
|
45064
45495
|
init_platform();
|
|
45065
|
-
var UPDATE_LOCK =
|
|
45496
|
+
var UPDATE_LOCK = join25(GIPITY_DIR, "update.lock");
|
|
45066
45497
|
var LOCK_STALE_MS2 = 10 * 60 * 1e3;
|
|
45067
45498
|
function npmInstallGipity(version) {
|
|
45068
45499
|
const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
|
|
@@ -45071,7 +45502,7 @@ function npmInstallGipity(version) {
|
|
|
45071
45502
|
encoding: "utf-8"
|
|
45072
45503
|
});
|
|
45073
45504
|
return {
|
|
45074
|
-
ok: res.status === 0 &&
|
|
45505
|
+
ok: res.status === 0 && existsSync21(LOCAL_ENTRY),
|
|
45075
45506
|
status: res.status,
|
|
45076
45507
|
stderr: (res.stderr || "").toString(),
|
|
45077
45508
|
spawnError: res.error
|
|
@@ -45082,21 +45513,21 @@ function isWedged(stderr) {
|
|
|
45082
45513
|
return WEDGE_CODES.test(stderr);
|
|
45083
45514
|
}
|
|
45084
45515
|
function resetLocalTree(dir = LOCAL_DIR) {
|
|
45085
|
-
|
|
45086
|
-
rmSync2(
|
|
45087
|
-
rmSync2(
|
|
45088
|
-
|
|
45516
|
+
mkdirSync16(dir, { recursive: true });
|
|
45517
|
+
rmSync2(join25(dir, "node_modules"), { recursive: true, force: true });
|
|
45518
|
+
rmSync2(join25(dir, "package-lock.json"), { force: true });
|
|
45519
|
+
writeFileSync16(join25(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
|
|
45089
45520
|
}
|
|
45090
45521
|
function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
45091
|
-
|
|
45522
|
+
mkdirSync16(dirname15(lockPath2), { recursive: true });
|
|
45092
45523
|
try {
|
|
45093
|
-
|
|
45524
|
+
writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
|
|
45094
45525
|
return true;
|
|
45095
45526
|
} catch {
|
|
45096
45527
|
try {
|
|
45097
45528
|
if (Date.now() - statSync10(lockPath2).mtimeMs > LOCK_STALE_MS2) {
|
|
45098
|
-
|
|
45099
|
-
|
|
45529
|
+
unlinkSync6(lockPath2);
|
|
45530
|
+
writeFileSync16(lockPath2, String(process.pid), { flag: "wx" });
|
|
45100
45531
|
return true;
|
|
45101
45532
|
}
|
|
45102
45533
|
} catch {
|
|
@@ -45106,7 +45537,7 @@ function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
|
45106
45537
|
}
|
|
45107
45538
|
function releaseUpdateLock(lockPath2 = UPDATE_LOCK) {
|
|
45108
45539
|
try {
|
|
45109
|
-
|
|
45540
|
+
unlinkSync6(lockPath2);
|
|
45110
45541
|
} catch {
|
|
45111
45542
|
}
|
|
45112
45543
|
}
|
|
@@ -45245,17 +45676,17 @@ var updateCommand = new Command("update").description("Update the CLI").action(a
|
|
|
45245
45676
|
init_api();
|
|
45246
45677
|
init_utils();
|
|
45247
45678
|
init_colors();
|
|
45248
|
-
import { existsSync as
|
|
45679
|
+
import { existsSync as existsSync24, readFileSync as readFileSync26, unlinkSync as unlinkSync9 } from "fs";
|
|
45249
45680
|
import { spawn as spawn2 } from "child_process";
|
|
45250
45681
|
|
|
45251
45682
|
// src/relay/daemon.ts
|
|
45252
45683
|
init_platform();
|
|
45253
45684
|
init_config();
|
|
45254
|
-
import { appendFileSync as appendFileSync3, mkdirSync as
|
|
45685
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync18, existsSync as existsSync23, readFileSync as readFileSync25, writeFileSync as writeFileSync17, chmodSync as chmodSync4, closeSync as closeSync4, openSync as openSync4, unlinkSync as unlinkSync8 } from "fs";
|
|
45255
45686
|
import { stat, readFile } from "fs/promises";
|
|
45256
45687
|
import { createInterface as createInterface2 } from "readline";
|
|
45257
|
-
import { homedir as
|
|
45258
|
-
import { join as
|
|
45688
|
+
import { homedir as homedir19, hostname as hostname6, platform as osPlatform3, loadavg as loadavg2, freemem as freemem2, totalmem as totalmem2, cpus as cpus2 } from "os";
|
|
45689
|
+
import { join as join28 } from "path";
|
|
45259
45690
|
init_setup();
|
|
45260
45691
|
init_auth();
|
|
45261
45692
|
init_api();
|
|
@@ -45967,7 +46398,7 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
45967
46398
|
// src/relay/agent-token.ts
|
|
45968
46399
|
init_api();
|
|
45969
46400
|
init_config();
|
|
45970
|
-
import { hostname as
|
|
46401
|
+
import { hostname as hostname5 } from "os";
|
|
45971
46402
|
var RELAY_AGENT_TOKEN_EXPIRY_DAYS = 60;
|
|
45972
46403
|
async function tokenValid(token) {
|
|
45973
46404
|
try {
|
|
@@ -45986,7 +46417,7 @@ async function ensureRelayAgentToken() {
|
|
|
45986
46417
|
setAgentToken(null, null);
|
|
45987
46418
|
}
|
|
45988
46419
|
try {
|
|
45989
|
-
const name = `Relay on ${getDevice()?.name ??
|
|
46420
|
+
const name = `Relay on ${getDevice()?.name ?? hostname5()}`;
|
|
45990
46421
|
const res = await post(
|
|
45991
46422
|
"/auth/agent-tokens",
|
|
45992
46423
|
{ name, expiresInDays: RELAY_AGENT_TOKEN_EXPIRY_DAYS }
|
|
@@ -46012,9 +46443,9 @@ async function revokeRelayAgentToken() {
|
|
|
46012
46443
|
init_platform();
|
|
46013
46444
|
init_client_context();
|
|
46014
46445
|
init_agents();
|
|
46015
|
-
import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as
|
|
46446
|
+
import { cpus, freemem, totalmem, loadavg, release, uptime, homedir as homedir18 } from "os";
|
|
46016
46447
|
import { statfsSync, readdirSync as readdirSync9 } from "fs";
|
|
46017
|
-
import { join as
|
|
46448
|
+
import { join as join26 } from "path";
|
|
46018
46449
|
var PROBE_TIMEOUT_MS = 4e3;
|
|
46019
46450
|
function parseVersion(out) {
|
|
46020
46451
|
const m = out.match(/\d+\.\d+(?:\.\d+)?(?:[-.\w]*)?/);
|
|
@@ -46081,12 +46512,12 @@ async function detectGpu() {
|
|
|
46081
46512
|
function diskUsage() {
|
|
46082
46513
|
try {
|
|
46083
46514
|
if (typeof statfsSync !== "function") return void 0;
|
|
46084
|
-
const st2 = statfsSync(
|
|
46515
|
+
const st2 = statfsSync(join26(homedir18(), "GipityProjects"), { bigint: false });
|
|
46085
46516
|
if (!st2 || !st2.bsize) return void 0;
|
|
46086
46517
|
return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
|
|
46087
46518
|
} catch {
|
|
46088
46519
|
try {
|
|
46089
|
-
const st2 = statfsSync(
|
|
46520
|
+
const st2 = statfsSync(homedir18(), { bigint: false });
|
|
46090
46521
|
return { total: st2.bsize * st2.blocks, free: st2.bsize * st2.bavail };
|
|
46091
46522
|
} catch {
|
|
46092
46523
|
return void 0;
|
|
@@ -46095,7 +46526,7 @@ function diskUsage() {
|
|
|
46095
46526
|
}
|
|
46096
46527
|
function localProjectCount() {
|
|
46097
46528
|
try {
|
|
46098
|
-
return readdirSync9(
|
|
46529
|
+
return readdirSync9(join26(homedir18(), "GipityProjects"), { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).length;
|
|
46099
46530
|
} catch {
|
|
46100
46531
|
return void 0;
|
|
46101
46532
|
}
|
|
@@ -46547,7 +46978,7 @@ var SessionPool = class {
|
|
|
46547
46978
|
init_config();
|
|
46548
46979
|
init_api();
|
|
46549
46980
|
init_agents();
|
|
46550
|
-
var RELAY_LOG_PATH =
|
|
46981
|
+
var RELAY_LOG_PATH = join28(homedir19(), ".gipity", "relay.log");
|
|
46551
46982
|
var HEARTBEAT_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_HEARTBEAT_MS || "60000", 10);
|
|
46552
46983
|
var DIAGNOSTICS_INTERVAL_MS = parseInt(process.env.GIPITY_RELAY_DIAGNOSTICS_MS || String(24 * 60 * 60 * 1e3), 10);
|
|
46553
46984
|
var LONG_POLL_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_POLL_TIMEOUT_MS || "35000", 10);
|
|
@@ -46574,7 +47005,7 @@ function mapPlatform2(p) {
|
|
|
46574
47005
|
return "linux";
|
|
46575
47006
|
}
|
|
46576
47007
|
async function registerDevice() {
|
|
46577
|
-
const name = (
|
|
47008
|
+
const name = (hostname6() || "my-pc").trim().slice(0, 100) || "my-pc";
|
|
46578
47009
|
const res = await post("/remote-devices", { name, platform: mapPlatform2(osPlatform3()), machine_id: getMachineId() });
|
|
46579
47010
|
const device = {
|
|
46580
47011
|
guid: res.data.short_guid,
|
|
@@ -46644,17 +47075,17 @@ var permsLocked = false;
|
|
|
46644
47075
|
function lockLogPerms(dir, file) {
|
|
46645
47076
|
if (permsLocked) return;
|
|
46646
47077
|
try {
|
|
46647
|
-
|
|
47078
|
+
chmodSync4(dir, 448);
|
|
46648
47079
|
} catch {
|
|
46649
47080
|
}
|
|
46650
|
-
if (!
|
|
47081
|
+
if (!existsSync23(file)) {
|
|
46651
47082
|
try {
|
|
46652
47083
|
closeSync4(openSync4(file, "a", 384));
|
|
46653
47084
|
} catch {
|
|
46654
47085
|
}
|
|
46655
47086
|
}
|
|
46656
47087
|
try {
|
|
46657
|
-
|
|
47088
|
+
chmodSync4(file, 384);
|
|
46658
47089
|
} catch {
|
|
46659
47090
|
}
|
|
46660
47091
|
permsLocked = true;
|
|
@@ -46664,8 +47095,8 @@ function log2(level, msg, extra) {
|
|
|
46664
47095
|
const pretty = `${C7.dim(hhmmss())} ${badge(level)} ${C7.bold(msg)}${formatExtra(extra)}`;
|
|
46665
47096
|
process.stderr.write(pretty + "\n");
|
|
46666
47097
|
try {
|
|
46667
|
-
const dir =
|
|
46668
|
-
|
|
47098
|
+
const dir = join28(homedir19(), ".gipity");
|
|
47099
|
+
mkdirSync18(dir, { recursive: true });
|
|
46669
47100
|
lockLogPerms(dir, RELAY_LOG_PATH);
|
|
46670
47101
|
const json = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), level, msg, ...extra ?? {} });
|
|
46671
47102
|
appendFileSync3(RELAY_LOG_PATH, json + "\n");
|
|
@@ -47096,7 +47527,7 @@ function isSafeSessionId(s) {
|
|
|
47096
47527
|
function transcriptPathFor(cwd, sessionId) {
|
|
47097
47528
|
if (!isSafeSessionId(sessionId)) return null;
|
|
47098
47529
|
const slug = cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
47099
|
-
return
|
|
47530
|
+
return join28(homedir19(), ".claude", "projects", slug, `${sessionId}.jsonl`);
|
|
47100
47531
|
}
|
|
47101
47532
|
function formatDuration(ms2) {
|
|
47102
47533
|
const totalSec = ms2 / 1e3;
|
|
@@ -47550,11 +47981,11 @@ async function resolveCwdForProject(d) {
|
|
|
47550
47981
|
throw new Error(`Invalid project slug: ${JSON.stringify(d.project_slug)}`);
|
|
47551
47982
|
}
|
|
47552
47983
|
const root = getProjectsRoot();
|
|
47553
|
-
const path5 =
|
|
47554
|
-
const configPath =
|
|
47555
|
-
if (
|
|
47984
|
+
const path5 = join28(root, d.project_slug);
|
|
47985
|
+
const configPath = join28(path5, ".gipity.json");
|
|
47986
|
+
if (existsSync23(configPath)) {
|
|
47556
47987
|
try {
|
|
47557
|
-
const cfg = JSON.parse(
|
|
47988
|
+
const cfg = JSON.parse(readFileSync25(configPath, "utf-8"));
|
|
47558
47989
|
if (cfg.projectGuid === d.project_guid) return { cwd: path5, bootstrapped: false };
|
|
47559
47990
|
log2("warn", "project dir exists but guid mismatch - using it anyway", {
|
|
47560
47991
|
path: path5,
|
|
@@ -47566,9 +47997,9 @@ async function resolveCwdForProject(d) {
|
|
|
47566
47997
|
}
|
|
47567
47998
|
}
|
|
47568
47999
|
log2("info", "bootstrapping new project dir", { slug: d.project_slug, path: path5 });
|
|
47569
|
-
|
|
48000
|
+
mkdirSync18(path5, { recursive: true });
|
|
47570
48001
|
const apiBase2 = getApiBaseOverride() || DEFAULT_API_BASE;
|
|
47571
|
-
|
|
48002
|
+
writeFileSync17(configPath, JSON.stringify({
|
|
47572
48003
|
projectGuid: d.project_guid,
|
|
47573
48004
|
projectSlug: d.project_slug,
|
|
47574
48005
|
accountSlug: d.account_slug,
|
|
@@ -47689,7 +48120,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
|
|
|
47689
48120
|
} catch {
|
|
47690
48121
|
}
|
|
47691
48122
|
try {
|
|
47692
|
-
|
|
48123
|
+
unlinkSync8(join28(cwd, ".gipity", "sync.lock"));
|
|
47693
48124
|
} catch {
|
|
47694
48125
|
}
|
|
47695
48126
|
finish(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s`)));
|
|
@@ -48126,11 +48557,11 @@ relayCommand.command("run").description("Run the background service").option("-v
|
|
|
48126
48557
|
});
|
|
48127
48558
|
relayCommand.command("stop").description("Stop the background service").option("--force", "Force-stop if it doesn't exit cleanly within 5s").action(async (opts) => {
|
|
48128
48559
|
const pidPath = getDaemonPidPath();
|
|
48129
|
-
if (!
|
|
48560
|
+
if (!existsSync24(pidPath)) {
|
|
48130
48561
|
console.log(muted("Background service isn't running."));
|
|
48131
48562
|
return;
|
|
48132
48563
|
}
|
|
48133
|
-
const pid = parseInt(
|
|
48564
|
+
const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
|
|
48134
48565
|
if (!pid || isNaN(pid)) {
|
|
48135
48566
|
console.error(error("PID file is empty or malformed."));
|
|
48136
48567
|
process.exit(1);
|
|
@@ -48141,7 +48572,7 @@ relayCommand.command("stop").description("Stop the background service").option("
|
|
|
48141
48572
|
if (err?.code === "ESRCH") {
|
|
48142
48573
|
console.log(muted(`PID ${pid} not running - cleaning up stale PID file.`));
|
|
48143
48574
|
try {
|
|
48144
|
-
|
|
48575
|
+
unlinkSync9(pidPath);
|
|
48145
48576
|
} catch {
|
|
48146
48577
|
}
|
|
48147
48578
|
return;
|
|
@@ -48278,8 +48709,8 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
48278
48709
|
} catch {
|
|
48279
48710
|
}
|
|
48280
48711
|
const pidPath = getDaemonPidPath();
|
|
48281
|
-
if (
|
|
48282
|
-
const pid = parseInt(
|
|
48712
|
+
if (existsSync24(pidPath)) {
|
|
48713
|
+
const pid = parseInt(readFileSync26(pidPath, "utf-8").trim(), 10);
|
|
48283
48714
|
if (pid && !isNaN(pid)) {
|
|
48284
48715
|
try {
|
|
48285
48716
|
process.kill(pid, "SIGTERM");
|
|
@@ -48292,13 +48723,13 @@ relayCommand.command("revoke").description("Revoke and forget this device").acti
|
|
|
48292
48723
|
});
|
|
48293
48724
|
relayCommand.command("log").description("Tail the service log").option("-n, --lines <n>", "How many lines to print (default 100)", "100").option("-f, --follow", "Follow the log like `tail -f`").action((opts) => {
|
|
48294
48725
|
const path5 = RELAY_LOG_PATH;
|
|
48295
|
-
if (!
|
|
48726
|
+
if (!existsSync24(path5)) {
|
|
48296
48727
|
console.log(muted("No log file yet. Start the service with `gipity relay run` (or install it)."));
|
|
48297
48728
|
return;
|
|
48298
48729
|
}
|
|
48299
48730
|
const lines = parseInt(opts.lines, 10) || 100;
|
|
48300
48731
|
try {
|
|
48301
|
-
const all =
|
|
48732
|
+
const all = readFileSync26(path5, "utf-8").split("\n");
|
|
48302
48733
|
const tail2 = all.slice(-lines - 1).join("\n");
|
|
48303
48734
|
process.stdout.write(tail2);
|
|
48304
48735
|
} catch (err) {
|
|
@@ -48369,20 +48800,20 @@ init_api();
|
|
|
48369
48800
|
init_auth();
|
|
48370
48801
|
init_utils();
|
|
48371
48802
|
init_colors();
|
|
48372
|
-
import { existsSync as
|
|
48373
|
-
import { homedir as
|
|
48374
|
-
import { join as
|
|
48803
|
+
import { existsSync as existsSync25, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "fs";
|
|
48804
|
+
import { homedir as homedir20, platform as osPlatform4 } from "os";
|
|
48805
|
+
import { join as join29, resolve as resolve17 } from "path";
|
|
48375
48806
|
init_agents();
|
|
48376
48807
|
function removeInstallerPathLines() {
|
|
48377
48808
|
if (osPlatform4() === "win32") return [];
|
|
48378
48809
|
const marker = "# Added by the Gipity installer";
|
|
48379
48810
|
const touched = [];
|
|
48380
48811
|
for (const name of [".bashrc", ".zshrc", ".profile"]) {
|
|
48381
|
-
const rc2 =
|
|
48382
|
-
if (!
|
|
48812
|
+
const rc2 = join29(homedir20(), name);
|
|
48813
|
+
if (!existsSync25(rc2)) continue;
|
|
48383
48814
|
let text;
|
|
48384
48815
|
try {
|
|
48385
|
-
text =
|
|
48816
|
+
text = readFileSync27(rc2, "utf-8");
|
|
48386
48817
|
} catch {
|
|
48387
48818
|
continue;
|
|
48388
48819
|
}
|
|
@@ -48392,7 +48823,7 @@ function removeInstallerPathLines() {
|
|
|
48392
48823
|
);
|
|
48393
48824
|
if (kept.length === lines.length) continue;
|
|
48394
48825
|
try {
|
|
48395
|
-
|
|
48826
|
+
writeFileSync18(rc2, kept.join("\n"));
|
|
48396
48827
|
touched.push(rc2);
|
|
48397
48828
|
} catch {
|
|
48398
48829
|
}
|
|
@@ -48400,7 +48831,7 @@ function removeInstallerPathLines() {
|
|
|
48400
48831
|
return touched;
|
|
48401
48832
|
}
|
|
48402
48833
|
function tildify2(p) {
|
|
48403
|
-
const home =
|
|
48834
|
+
const home = homedir20();
|
|
48404
48835
|
return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
|
|
48405
48836
|
}
|
|
48406
48837
|
function resolveCliPath2() {
|
|
@@ -48438,9 +48869,9 @@ function removeServiceUnit() {
|
|
|
48438
48869
|
const r = spawnSyncCommand(argv2[0], argv2.slice(1), { stdio: "ignore" });
|
|
48439
48870
|
if (r.status !== 0) allOk = false;
|
|
48440
48871
|
}
|
|
48441
|
-
if (
|
|
48872
|
+
if (existsSync25(plan2.path)) {
|
|
48442
48873
|
try {
|
|
48443
|
-
|
|
48874
|
+
unlinkSync10(plan2.path);
|
|
48444
48875
|
} catch {
|
|
48445
48876
|
}
|
|
48446
48877
|
}
|
|
@@ -48461,9 +48892,9 @@ async function revokeDeviceBestEffort() {
|
|
|
48461
48892
|
}
|
|
48462
48893
|
var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
|
|
48463
48894
|
const autoYes = opts.yes || getAutoConfirm();
|
|
48464
|
-
const gipityDir =
|
|
48465
|
-
const launcherBin =
|
|
48466
|
-
const installedViaLauncher =
|
|
48895
|
+
const gipityDir = join29(homedir20(), ".gipity");
|
|
48896
|
+
const launcherBin = join29(gipityDir, "launcher", "bin", "gipity");
|
|
48897
|
+
const installedViaLauncher = existsSync25(launcherBin);
|
|
48467
48898
|
console.log(`${bold("Gipity uninstall")} - this will:`);
|
|
48468
48899
|
console.log(`\u2022 Stop the running relay daemon (if any)`);
|
|
48469
48900
|
console.log(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
|
|
@@ -48504,7 +48935,7 @@ var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").
|
|
|
48504
48935
|
if (!anyAgentIntegration) {
|
|
48505
48936
|
console.log(`${muted("No Gipity entries in any detected coding agent.")}`);
|
|
48506
48937
|
}
|
|
48507
|
-
if (
|
|
48938
|
+
if (existsSync25(gipityDir)) {
|
|
48508
48939
|
try {
|
|
48509
48940
|
rmSync4(gipityDir, { recursive: true, force: true });
|
|
48510
48941
|
console.log(`${success(`Removed ${gipityDir}/`)}`);
|
|
@@ -48667,7 +49098,7 @@ gmailCommand.command("reply").description("Reply to a Gmail thread. Get thread-i
|
|
|
48667
49098
|
}));
|
|
48668
49099
|
|
|
48669
49100
|
// src/commands/text.ts
|
|
48670
|
-
import { readFileSync as
|
|
49101
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
48671
49102
|
init_colors();
|
|
48672
49103
|
|
|
48673
49104
|
// src/helpers/text-analysis.ts
|
|
@@ -48822,10 +49253,10 @@ function areAnagrams(a, b7) {
|
|
|
48822
49253
|
|
|
48823
49254
|
// src/commands/text.ts
|
|
48824
49255
|
function resolveInput(args, opts) {
|
|
48825
|
-
if (opts.file) return
|
|
49256
|
+
if (opts.file) return readFileSync28(opts.file, "utf-8");
|
|
48826
49257
|
if (args.length) return args.join(" ");
|
|
48827
49258
|
try {
|
|
48828
|
-
return
|
|
49259
|
+
return readFileSync28(0, "utf-8");
|
|
48829
49260
|
} catch {
|
|
48830
49261
|
return "";
|
|
48831
49262
|
}
|
|
@@ -49031,9 +49462,9 @@ function collectRealFlags(argv2, program3) {
|
|
|
49031
49462
|
}
|
|
49032
49463
|
|
|
49033
49464
|
// src/trace.ts
|
|
49034
|
-
import { openSync as openSync5, writeSync, mkdirSync as
|
|
49035
|
-
import { join as
|
|
49036
|
-
import { homedir as
|
|
49465
|
+
import { openSync as openSync5, writeSync, mkdirSync as mkdirSync19 } from "fs";
|
|
49466
|
+
import { join as join30 } from "path";
|
|
49467
|
+
import { homedir as homedir21 } from "os";
|
|
49037
49468
|
var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
|
|
49038
49469
|
function installOutputTrace(label2) {
|
|
49039
49470
|
if (process.env.GIPITY_TRACE_OUTPUT !== "1") return;
|
|
@@ -49044,10 +49475,10 @@ function installOutputTrace(label2) {
|
|
|
49044
49475
|
existing.emit({ event: "reenter", label: label2 });
|
|
49045
49476
|
return;
|
|
49046
49477
|
}
|
|
49047
|
-
const dir =
|
|
49048
|
-
|
|
49478
|
+
const dir = join30(process.env.GIPITY_DIR || join30(homedir21(), ".gipity"), "trace");
|
|
49479
|
+
mkdirSync19(dir, { recursive: true });
|
|
49049
49480
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
|
|
49050
|
-
const fd2 = openSync5(
|
|
49481
|
+
const fd2 = openSync5(join30(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
|
|
49051
49482
|
const emit = (rec) => {
|
|
49052
49483
|
try {
|
|
49053
49484
|
writeSync(fd2, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
|
|
@@ -49082,12 +49513,12 @@ function installOutputTrace(label2) {
|
|
|
49082
49513
|
|
|
49083
49514
|
// src/index.ts
|
|
49084
49515
|
installOutputTrace("index");
|
|
49085
|
-
var __dirname =
|
|
49086
|
-
var pkg = JSON.parse(
|
|
49516
|
+
var __dirname = dirname16(fileURLToPath3(import.meta.url));
|
|
49517
|
+
var pkg = JSON.parse(readFileSync29(resolve18(__dirname, "../package.json"), "utf-8"));
|
|
49087
49518
|
function versionLabel() {
|
|
49088
49519
|
const base = `v${pkg.version}`;
|
|
49089
49520
|
try {
|
|
49090
|
-
const info2 = JSON.parse(
|
|
49521
|
+
const info2 = JSON.parse(readFileSync29(resolve18(__dirname, "build-info.json"), "utf-8"));
|
|
49091
49522
|
if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
|
|
49092
49523
|
} catch {
|
|
49093
49524
|
}
|