gipity 1.1.7 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  * Source: platform/server/src/config/constants/provider-docs.ts
6
6
  * Run `just sync-docs` to refresh from platform.
7
7
  */
8
- export const GEMINI_LLM_MODELS_DOC = `gemini-3.5-flash (Gemini 3.5 Flash, $1.5/$9 per 1M tok, 1049K ctx), gemini-3.1-pro-preview (Gemini 3.1 Pro, $2/$12 per 1M tok, 1049K ctx), gemini-3.1-flash-lite (Gemini 3.1 Flash-Lite, $0.25/$1.5 per 1M tok, 1049K ctx), gemini-3-flash-preview (Gemini 3 Flash, $0.5/$3 per 1M tok, 1049K ctx), gemini-2.5-pro (Gemini 2.5 Pro, $1.25/$10 per 1M tok, 1049K ctx), gemini-2.5-flash (Gemini 2.5 Flash, $0.3/$2.5 per 1M tok, 1049K ctx), gemini-2.5-flash-lite (Gemini 2.5 Flash-Lite, $0.1/$0.4 per 1M tok, 1049K ctx)`;
8
+ export const GEMINI_LLM_MODELS_DOC = `gemini-3.6-flash (Gemini 3.6 Flash, $1.5/$7.5 per 1M tok, 1049K ctx), gemini-3.5-flash (Gemini 3.5 Flash, $1.5/$9 per 1M tok, 1049K ctx), gemini-3.1-pro-preview (Gemini 3.1 Pro, $2/$12 per 1M tok, 1049K ctx), gemini-3.1-flash-lite (Gemini 3.1 Flash-Lite, $0.25/$1.5 per 1M tok, 1049K ctx), gemini-3-flash-preview (Gemini 3 Flash, $0.5/$3 per 1M tok, 1049K ctx), gemini-2.5-pro (Gemini 2.5 Pro, $1.25/$10 per 1M tok, 1049K ctx), gemini-2.5-flash (Gemini 2.5 Flash, $0.3/$2.5 per 1M tok, 1049K ctx), gemini-2.5-flash-lite (Gemini 2.5 Flash-Lite, $0.1/$0.4 per 1M tok, 1049K ctx)`;
9
9
  export const GEMINI_TTS_VOICES = [
10
10
  'Zephyr',
11
11
  'Puck',
@@ -0,0 +1,155 @@
1
+ import { AGENT_ADAPTERS } from '../agents/index.js';
2
+ import { parseVersion } from './diagnostics.js';
3
+ import { compareSemver } from '../updater/check.js';
4
+ import { resolveCommand, spawnCommand } from '../platform.js';
5
+ const UPDATE_TIMEOUT_MS = parseInt(process.env.GIPITY_RELAY_AGENT_UPDATE_TIMEOUT_MS || String(5 * 60_000), 10);
6
+ const PROBE_TIMEOUT_MS = 4000;
7
+ const REGISTRY_TIMEOUT_MS = 10_000;
8
+ // Test seam (mirrors GIPITY_RELAY_CLAUDE_CMD): when set, the pass updates ONE
9
+ // synthetic agent whose binary is this script (it must answer `--version` and
10
+ // `update`) instead of the real adapter registry, so the daemon integration
11
+ // test exercises the full tick → pass → probe → exec → re-probe → log path
12
+ // without ever touching a real install.
13
+ const UPDATE_STUB = process.env.GIPITY_RELAY_AGENT_UPDATE_STUB;
14
+ function stubAdapters(stub) {
15
+ return [{
16
+ source: 'stub_agent',
17
+ binary: stub,
18
+ updatePlan: () => ({ argv: [stub, 'update'], label: 'stub' }),
19
+ }];
20
+ }
21
+ // Cross-loop flag: the dispatch loop consults this before claiming work so a
22
+ // dispatch is never spawned mid-binary-swap. Module-level is safe - the
23
+ // daemon's pid lock guarantees one daemon per machine, and the heartbeat
24
+ // loop starts at most one pass at a time.
25
+ let inProgress = false;
26
+ export function agentUpdateInProgress() {
27
+ return inProgress;
28
+ }
29
+ /** Run argv (no shell) capturing stdout+stderr, bounded by a hard timeout
30
+ * and the daemon's abort signal. Resolves, never rejects. */
31
+ function execCapture(argv, timeoutMs, signal) {
32
+ return new Promise((resolve) => {
33
+ let output = '';
34
+ let settled = false;
35
+ const done = (ok) => { if (!settled) {
36
+ settled = true;
37
+ resolve({ ok, output });
38
+ } };
39
+ let child;
40
+ try {
41
+ child = spawnCommand(resolveCommand(argv[0]), argv.slice(1), { stdio: ['ignore', 'pipe', 'pipe'] });
42
+ }
43
+ catch (err) {
44
+ output = err?.message ?? 'spawn failed';
45
+ return done(false);
46
+ }
47
+ const kill = () => { try {
48
+ child.kill('SIGKILL');
49
+ }
50
+ catch { /* already gone */ } };
51
+ const timer = setTimeout(() => { output += '\n[timed out]'; kill(); }, timeoutMs);
52
+ signal?.addEventListener('abort', kill, { once: true });
53
+ child.stdout?.on('data', (d) => { output += d.toString(); });
54
+ child.stderr?.on('data', (d) => { output += d.toString(); });
55
+ child.on('error', (err) => { clearTimeout(timer); output += `\n${err.message}`; done(false); });
56
+ child.on('close', (code) => { clearTimeout(timer); done(code === 0); });
57
+ });
58
+ }
59
+ async function defaultProbeVersion(binary) {
60
+ const r = await execCapture([binary, '--version'], PROBE_TIMEOUT_MS);
61
+ return parseVersion(r.output);
62
+ }
63
+ /** Latest published version of an npm package, or null on any failure
64
+ * (offline, registry down) - the caller then defers to the next daily tick
65
+ * rather than blind-running npm. */
66
+ async function defaultFetchLatest(pkg) {
67
+ try {
68
+ const res = await fetch(`https://registry.npmjs.org/${pkg}/latest`, {
69
+ headers: { accept: 'application/json' },
70
+ signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS),
71
+ });
72
+ if (!res.ok)
73
+ return null;
74
+ const json = await res.json();
75
+ return typeof json.version === 'string' ? json.version : null;
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ const tail = (s) => s.trim().slice(-300).replace(/\s+/g, ' ');
82
+ /**
83
+ * One update pass over all adapters. `busy` is re-checked before each agent
84
+ * so a dispatch that slipped in mid-pass defers the remaining updates to the
85
+ * next tick instead of racing it.
86
+ */
87
+ export async function runAgentUpdates(opts, deps = {}) {
88
+ const adapters = deps.adapters ?? (UPDATE_STUB ? stubAdapters(UPDATE_STUB) : AGENT_ADAPTERS);
89
+ const exec = deps.exec ?? execCapture;
90
+ const probe = deps.probeVersion ?? defaultProbeVersion;
91
+ const fetchLatest = deps.fetchLatest ?? defaultFetchLatest;
92
+ const results = [];
93
+ inProgress = true;
94
+ try {
95
+ for (const adapter of adapters) {
96
+ const source = adapter.source;
97
+ if (opts.signal?.aborted) {
98
+ results.push({ source, status: 'skipped', detail: 'daemon shutting down' });
99
+ continue;
100
+ }
101
+ let plan;
102
+ try {
103
+ plan = adapter.updatePlan?.();
104
+ }
105
+ catch {
106
+ plan = null;
107
+ }
108
+ if (!plan) {
109
+ results.push({ source, status: 'skipped', detail: 'no unattended update path' });
110
+ continue;
111
+ }
112
+ if (opts.busy?.()) {
113
+ results.push({ source, status: 'skipped', detail: 'dispatch in flight' });
114
+ continue;
115
+ }
116
+ const before = await probe(adapter.binary);
117
+ // npm plans: skip the (slow, churny) install when the registry says
118
+ // we're already at latest. Registry unreachable = defer, don't guess.
119
+ if (plan.pkg && before) {
120
+ const latest = await fetchLatest(plan.pkg);
121
+ if (!latest) {
122
+ results.push({ source, status: 'skipped', from: before, detail: 'registry check failed' });
123
+ continue;
124
+ }
125
+ if (compareSemver(latest, before) <= 0) {
126
+ results.push({ source, status: 'current', from: before });
127
+ opts.log('debug', `agent up-to-date: ${source} ${before}`);
128
+ continue;
129
+ }
130
+ }
131
+ opts.log('info', `agent update starting: ${source} via ${plan.label}`, { from: before ?? 'unknown' });
132
+ const res = await exec(plan.argv, UPDATE_TIMEOUT_MS, opts.signal);
133
+ const after = await probe(adapter.binary);
134
+ if (!res.ok) {
135
+ results.push({ source, status: 'failed', from: before, to: after, detail: tail(res.output) });
136
+ opts.log('warn', `agent update failed: ${source}`, { detail: tail(res.output) });
137
+ }
138
+ else if (after && after !== before) {
139
+ results.push({ source, status: 'updated', from: before, to: after });
140
+ opts.log('info', `agent updated: ${source} ${before ?? 'unknown'} -> ${after}`);
141
+ }
142
+ else {
143
+ // Exit 0 with an unchanged version: the agent's own self-updater
144
+ // decided it was current (e.g. `claude update` no-op).
145
+ results.push({ source, status: 'current', from: before, to: after });
146
+ opts.log('debug', `agent up-to-date: ${source} ${after ?? 'unknown'}`);
147
+ }
148
+ }
149
+ }
150
+ finally {
151
+ inProgress = false;
152
+ }
153
+ return results;
154
+ }
155
+ //# sourceMappingURL=agent-updates.js.map
@@ -20,6 +20,7 @@ import { ensureRelayAgentToken } from './agent-token.js';
20
20
  import { redactEntries, redactString, normalizeSecrets } from './redact.js';
21
21
  import { getMachineId } from './machine-id.js';
22
22
  import { collectDiagnostics } from './diagnostics.js';
23
+ import { runAgentUpdates, agentUpdateInProgress } from './agent-updates.js';
23
24
  import { SessionPool, PoolFullError } from './session-pool.js';
24
25
  import { getConfig } from '../config.js';
25
26
  import { getAccountSlug } from '../api.js';
@@ -313,16 +314,55 @@ async function heartbeatLoop(ctx) {
313
314
  // DIAGNOSTICS_INTERVAL_MS after, but only if the user consented. Between
314
315
  // refreshes the heartbeat is a bare liveness ping.
315
316
  let lastDiagnosticsAt = 0;
317
+ // Agent auto-updates: same daily cadence, fire-and-forget so a slow npm
318
+ // install never delays the liveness ping. Stamped only when a pass actually
319
+ // ran - a tick deferred for in-flight dispatches retries on the next 60s
320
+ // beat instead of waiting another day. After a real upgrade the loop is
321
+ // asked for a fresh diagnostics snapshot + poked, so the server sees the
322
+ // new version on the next ping instead of tomorrow. The ask is a sticky
323
+ // flag (NOT a lastDiagnosticsAt reset): the pass often finishes while the
324
+ // startup diagnostics collection is still in flight, and that collection
325
+ // stamping lastDiagnosticsAt on completion would silently swallow a reset.
326
+ let lastAgentUpdateAt = 0;
327
+ let agentUpdatePass = null;
328
+ let diagnosticsRefreshNeeded = false;
316
329
  while (!ctx.abort.signal.aborted) {
317
330
  try {
331
+ if (!agentUpdatePass && state.agentUpdatesEnabled() && Date.now() - lastAgentUpdateAt >= DIAGNOSTICS_INTERVAL_MS) {
332
+ if (getRunningDispatchGuids().length > 0) {
333
+ log('debug', 'agent updates deferred - dispatches in flight');
334
+ }
335
+ else {
336
+ agentUpdatePass = runAgentUpdates({
337
+ log,
338
+ busy: () => getRunningDispatchGuids().length > 0,
339
+ signal: ctx.abort.signal,
340
+ }).then((results) => {
341
+ lastAgentUpdateAt = Date.now();
342
+ if (results.some(r => r.status === 'updated')) {
343
+ diagnosticsRefreshNeeded = true;
344
+ pokeHeartbeat();
345
+ }
346
+ }).catch((err) => {
347
+ lastAgentUpdateAt = Date.now();
348
+ log('warn', 'agent update pass failed', { err: err?.message });
349
+ }).finally(() => { agentUpdatePass = null; });
350
+ }
351
+ }
318
352
  let body = {};
319
- if (state.diagnosticsConsented() && Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS) {
353
+ if (state.diagnosticsConsented() && (diagnosticsRefreshNeeded || Date.now() - lastDiagnosticsAt >= DIAGNOSTICS_INTERVAL_MS)) {
354
+ // Consume the refresh ask BEFORE collecting: an update pass that
355
+ // completes while this collection is in flight sets it again, and it
356
+ // must survive into the next beat (this collection's probes started
357
+ // too early to see the new binary).
358
+ diagnosticsRefreshNeeded = false;
320
359
  try {
321
360
  body = { diagnostics: await collectDiagnostics() };
322
361
  lastDiagnosticsAt = Date.now();
323
362
  }
324
363
  catch (err) {
325
364
  // Never let a diagnostics probe failure block the liveness ping.
365
+ diagnosticsRefreshNeeded = true; // don't lose a consumed ask
326
366
  log('debug', 'diagnostics collection failed', { err: err?.message });
327
367
  }
328
368
  }
@@ -460,6 +500,15 @@ async function dispatchLoop(ctx, opts) {
460
500
  break;
461
501
  }
462
502
  await waitForSlot();
503
+ if (ctx.abort.signal.aborted)
504
+ break;
505
+ // Hold off claiming while the daily agent update is swapping binaries -
506
+ // spawning `claude` mid-`npm install -g` could hit a half-written
507
+ // install. The dispatch stays queued server-side and is claimed the
508
+ // moment the pass finishes (bounded by its hard timeout).
509
+ while (agentUpdateInProgress() && !ctx.abort.signal.aborted) {
510
+ await sleep(1000, ctx.abort.signal);
511
+ }
463
512
  if (ctx.abort.signal.aborted)
464
513
  break;
465
514
  try {
@@ -22,6 +22,7 @@ import { statfsSync, readdirSync } from 'fs';
22
22
  import { join } from 'path';
23
23
  import { resolveCommand, spawnCommand } from '../platform.js';
24
24
  import { cliVersion } from '../client-context.js';
25
+ import { AGENT_ADAPTERS } from '../agents/index.js';
25
26
  const PROBE_TIMEOUT_MS = 4000;
26
27
  /** Extract a semver-ish token from a `--version` line ("2.0.14 (Claude Code)"
27
28
  * → "2.0.14"). Returns undefined when nothing version-like is present.
@@ -136,19 +137,20 @@ export async function collectDiagnostics() {
136
137
  return [];
137
138
  } })();
138
139
  // Run the subprocess probes concurrently (each already bounded + best-effort)
139
- // so the whole snapshot costs one timeout, not the sum of four.
140
- const [claude, codex, grok, agy, cursor, gpu] = await Promise.all([
141
- probeVersion('claude'), probeVersion('codex'), probeVersion('grok'), probeVersion('agy'), probeVersion('cursor'), detectGpu(),
140
+ // so the whole snapshot costs one timeout, not the sum of four. `cursor` is
141
+ // a non-agent extra (no adapter - it's not a coding agent Gipity dispatches
142
+ // to), probed alongside the registry-driven agent binaries.
143
+ const [versions, cursor, gpu] = await Promise.all([
144
+ Promise.all(AGENT_ADAPTERS.map((a) => probeVersion(a.binary))),
145
+ probeVersion('cursor'),
146
+ detectGpu(),
142
147
  ]);
143
148
  const agents = {};
144
- if (claude)
145
- agents.claude_code = claude;
146
- if (codex)
147
- agents.codex = codex;
148
- if (grok)
149
- agents.grok = grok;
150
- if (agy)
151
- agents.agy = agy;
149
+ AGENT_ADAPTERS.forEach((a, i) => {
150
+ const v = versions[i];
151
+ if (v)
152
+ agents[a.source] = v;
153
+ });
152
154
  if (cursor)
153
155
  agents.cursor = cursor;
154
156
  return {
@@ -39,6 +39,7 @@ export function loadState() {
39
39
  relay_enabled: typeof raw.relay_enabled === 'boolean' ? raw.relay_enabled : undefined,
40
40
  onboard_shown: Boolean(raw.onboard_shown),
41
41
  diagnostics_consent: typeof raw.diagnostics_consent === 'boolean' ? raw.diagnostics_consent : undefined,
42
+ agent_updates: typeof raw.agent_updates === 'boolean' ? raw.agent_updates : undefined,
42
43
  agent_token: typeof raw.agent_token === 'string' ? raw.agent_token : null,
43
44
  agent_token_guid: typeof raw.agent_token_guid === 'string' ? raw.agent_token_guid : null,
44
45
  };
@@ -131,6 +132,35 @@ export function diagnosticsConsented() {
131
132
  return false;
132
133
  return loadState().diagnostics_consent !== false;
133
134
  }
135
+ // ─── Agent auto-updates (tri-state, default-on) ────────────────────────
136
+ /** Stored preference: `undefined` = default (on); `true`/`false` = explicit. */
137
+ export function getAgentUpdatesPref() {
138
+ return loadState().agent_updates;
139
+ }
140
+ export function setAgentUpdatesPref(on) {
141
+ mutate(s => { s.agent_updates = on; });
142
+ }
143
+ /** Effective switch for the daemon's daily agent auto-update pass. Default-on
144
+ * unless the user opted out (`gipity relay updates off`), the CLI-updater
145
+ * kill-switch is set (DISABLE_AUTOUPDATER=1 - one switch stops ALL
146
+ * unattended installs on the machine), an explicit env override is present
147
+ * (GIPITY_RELAY_AGENT_UPDATES=off), or we're in a CI/test run (never spawn
148
+ * a real `npm install -g` from a test-driven daemon). */
149
+ export function agentUpdatesEnabled() {
150
+ if (process.env.DISABLE_AUTOUPDATER === '1')
151
+ return false;
152
+ const env = (process.env.GIPITY_RELAY_AGENT_UPDATES || '').toLowerCase();
153
+ if (['0', 'off', 'false', 'no'].includes(env))
154
+ return false;
155
+ // An explicit opt-in beats the ambient CI/test guard below - that's how the
156
+ // daemon integration test drives a real pass (against the stubbed update
157
+ // command; see agent-updates.ts GIPITY_RELAY_AGENT_UPDATE_STUB).
158
+ if (['1', 'on', 'true', 'yes'].includes(env))
159
+ return true;
160
+ if (process.env.CI || process.env.NODE_ENV === 'test')
161
+ return false;
162
+ return loadState().agent_updates !== false;
163
+ }
134
164
  // ─── Daemon PID file (lives at ~/.gipity/relay.pid) ────────────────────
135
165
  const RELAY_PID_FILE = join(RELAY_DIR, 'relay.pid');
136
166
  export function getDaemonPidPath() {
package/dist/setup.js CHANGED
@@ -283,6 +283,39 @@ export function userScopeInstallState() {
283
283
  export function userScopePluginCurrent() {
284
284
  return userScopeInstallState().current;
285
285
  }
286
+ /** Remove Gipity's entries from the user-scope Claude Code settings: the
287
+ * plugin enablement, the marketplace registration, and any legacy hook
288
+ * blocks older CLI versions wrote there. Surgical - everything else in the
289
+ * file (the user's own permissions, hooks, other plugins) is untouched.
290
+ * Used by `gipity uninstall` via the claude adapter's `setup.uninstall`. */
291
+ export function removeGipityPluginConfig() {
292
+ const settingsPath = join(homedir(), '.claude', 'settings.json');
293
+ if (!existsSync(settingsPath))
294
+ return false;
295
+ let settings;
296
+ try {
297
+ settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
298
+ }
299
+ catch {
300
+ return false;
301
+ }
302
+ let changed = stripGipityHooks(settings);
303
+ if (settings.enabledPlugins && GIPITY_PLUGIN_ID in settings.enabledPlugins) {
304
+ delete settings.enabledPlugins[GIPITY_PLUGIN_ID];
305
+ if (Object.keys(settings.enabledPlugins).length === 0)
306
+ delete settings.enabledPlugins;
307
+ changed = true;
308
+ }
309
+ if (settings.extraKnownMarketplaces?.[GIPITY_MARKETPLACE_NAME]) {
310
+ delete settings.extraKnownMarketplaces[GIPITY_MARKETPLACE_NAME];
311
+ if (Object.keys(settings.extraKnownMarketplaces).length === 0)
312
+ delete settings.extraKnownMarketplaces;
313
+ changed = true;
314
+ }
315
+ if (changed)
316
+ writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
317
+ return changed;
318
+ }
286
319
  export function binaryOnPath(bin) {
287
320
  const probe = spawnSyncCommand(process.platform === 'win32' ? 'where' : 'which', [bin], {
288
321
  encoding: 'utf-8',
@@ -383,6 +416,17 @@ export function ensureGrokPluginInstalled() {
383
416
  console.log('Installed the Gipity plugin for Grok (skills + file-sync hooks).');
384
417
  }
385
418
  }
419
+ /** Uninstall the Gipity plugin from Grok Build, if present. Used by
420
+ * `gipity uninstall` via the grok adapter's `setup.uninstall`. */
421
+ export function removeGrokPlugin() {
422
+ if (!grokInstallState().exists)
423
+ return false;
424
+ spawnSyncCommand(resolveCommand('grok'), ['plugin', 'uninstall', 'gipity', '--confirm'], {
425
+ stdio: 'ignore',
426
+ timeout: 60_000,
427
+ });
428
+ return true;
429
+ }
386
430
  // --- OpenAI Codex ------------------------------------------------------------
387
431
  // Codex has no Claude-plugin compatibility, but it reads the same SKILL.md
388
432
  // skill format from the cross-agent `~/.agents/skills` directory (also read by
@@ -424,6 +468,29 @@ export function agentSkillsState() {
424
468
  export function agySkillsState() {
425
469
  return skillsManifestState(AGY_SKILLS_MANIFEST);
426
470
  }
471
+ /** Remove exactly the skill dirs a manifest recorded (never someone else's
472
+ * skills) from `skillsDir`. Returns the count removed. Shared core for the
473
+ * Codex/agy adapters' `setup.uninstall`. */
474
+ function removeManifestSkills(skillsDir, manifestPath) {
475
+ const { skills } = skillsManifestState(manifestPath);
476
+ for (const name of skills) {
477
+ try {
478
+ rmSync(join(skillsDir, name), { recursive: true, force: true });
479
+ }
480
+ catch { /* best-effort */ }
481
+ }
482
+ return skills.length;
483
+ }
484
+ /** Remove the Gipity skills copied into Codex's cross-agent ~/.agents/skills.
485
+ * Used by `gipity uninstall` via the codex adapter's `setup.uninstall`. */
486
+ export function removeAgentSkills() {
487
+ return removeManifestSkills(AGENTS_SKILLS_DIR, AGENT_SKILLS_MANIFEST);
488
+ }
489
+ /** Remove the Gipity skills copied into Antigravity's own global skill root.
490
+ * Used by `gipity uninstall` via the agy adapter's `setup.uninstall`. */
491
+ export function removeAgySkills() {
492
+ return removeManifestSkills(AGY_SKILLS_DIR, AGY_SKILLS_MANIFEST);
493
+ }
427
494
  /** Shared core: clone GipityAI/skills, copy every skill dir with a SKILL.md
428
495
  * into `skillsDir`, stage the plugin's hook scripts into ~/.gipity/agent-hooks
429
496
  * (shared infra - launch.sh/capture.cjs/sync-push.cjs are agent-agnostic, so
@@ -474,17 +541,26 @@ function installSkillsAndHooks(skillsDir, manifestPath, harnessLabel) {
474
541
  rmSync(tmp, { recursive: true, force: true });
475
542
  }
476
543
  }
544
+ /** Self-gating like ensureGipityPluginInstalled()/ensureGrokPluginInstalled():
545
+ * skips instantly when the codex binary is absent, so it's safe to call
546
+ * directly (e.g. via the codex adapter's `setup.install`) without a
547
+ * binaryOnPath() check at the call site. */
477
548
  export function ensureAgentSkillsInstalled() {
478
549
  if (agentSkillsState().current)
479
550
  return;
551
+ if (!binaryOnPath('codex'))
552
+ return;
480
553
  installSkillsAndHooks(AGENTS_SKILLS_DIR, AGENT_SKILLS_MANIFEST, 'Codex');
481
554
  }
482
555
  /** Materialize the Gipity skills into Antigravity's global skill root. Mirrors
483
556
  * ensureAgentSkillsInstalled() but targets agy's own directory - see the
484
- * AGY_SKILLS_DIR comment above for why it differs from Codex's. */
557
+ * AGY_SKILLS_DIR comment above for why it differs from Codex's. Self-gating
558
+ * on the agy binary for the same reason. */
485
559
  export function ensureAgySkillsInstalled() {
486
560
  if (agySkillsState().current)
487
561
  return;
562
+ if (!binaryOnPath('agy'))
563
+ return;
488
564
  installSkillsAndHooks(AGY_SKILLS_DIR, AGY_SKILLS_MANIFEST, 'Antigravity');
489
565
  }
490
566
  /** Pure core of the .codex/hooks.json merge: given the file's current content
@@ -666,8 +742,13 @@ export function applyAgyHooks(existing) {
666
742
  PostToolUse: [
667
743
  { matcher: '.*', hooks: [{ type: 'command', command: wrapCmd('post-tool-use'), timeout: 30 }] },
668
744
  ],
745
+ // Stop (like PreInvocation/PostInvocation) is FLAT in agy's schema - a
746
+ // list of handler objects directly, NOT wrapped in a {matcher, hooks}
747
+ // group like PreToolUse/PostToolUse. Confirmed live: the wrapped shape
748
+ // silently invalidates the WHOLE named block (PostToolUse stopped firing
749
+ // too, not just Stop) - agy gives no parse error, it just never fires.
669
750
  Stop: [
670
- { hooks: [{ type: 'command', command: wrapCmd('stop'), timeout: 60 }] },
751
+ { type: 'command', command: wrapCmd('stop'), timeout: 60 },
671
752
  ],
672
753
  };
673
754
  let settings = {};
package/dist/utils.js CHANGED
@@ -172,40 +172,53 @@ export async function confirm(question, opts = {}) {
172
172
  }
173
173
  /**
174
174
  * Single-keypress picker for 1–9 options.
175
- * Returns the 1-based index chosen, or `defaultIdx` on Enter.
175
+ * Returns the 1-based index chosen, or `defaultIdx` on Enter. A key that
176
+ * matches neither is ignored - it does not advance, does not fall back to
177
+ * the default, and the prompt just keeps waiting for a valid one.
176
178
  */
177
179
  export function pickOne(label, max, defaultIdx = 1) {
178
- return new Promise(resolve => {
180
+ return new Promise((resolve, reject) => {
179
181
  process.stdout.write(` ${bold(label)} (1-${max}) [${bold(String(defaultIdx))}]: `);
180
182
  const { stdin } = process;
181
183
  const wasRaw = stdin.isRaw ?? false;
182
184
  if (stdin.isTTY)
183
185
  stdin.setRawMode(true);
184
186
  stdin.resume();
185
- stdin.once('data', (key) => {
187
+ const cleanup = () => {
186
188
  if (stdin.isTTY)
187
189
  stdin.setRawMode(wasRaw);
188
190
  stdin.pause();
191
+ stdin.off('data', onData);
192
+ stdin.off('end', onEnd);
193
+ };
194
+ const onData = (key) => {
189
195
  const ch = key.toString();
190
196
  // Ctrl-C
191
197
  if (ch === '\x03') {
198
+ cleanup();
192
199
  console.log('');
193
200
  process.exit(0);
194
201
  }
195
202
  // Enter → default
196
203
  if (ch === '\r' || ch === '\n') {
204
+ cleanup();
197
205
  console.log(String(defaultIdx));
198
206
  return resolve(defaultIdx);
199
207
  }
200
208
  const n = parseInt(ch, 10);
201
209
  if (n >= 1 && n <= max) {
210
+ cleanup();
202
211
  console.log(String(n));
203
212
  return resolve(n);
204
213
  }
205
- // Invalid key → default
206
- console.log(String(defaultIdx));
207
- resolve(defaultIdx);
208
- });
214
+ // Invalid key → ignore, keep waiting for a real one.
215
+ };
216
+ // Piped/non-TTY stdin that closes without ever sending a valid choice
217
+ // (EOF) - waiting forever would hang the process, so bail out loudly
218
+ // instead of guessing.
219
+ const onEnd = () => { cleanup(); reject(new Error('input ended before a choice was made')); };
220
+ stdin.on('data', onData);
221
+ stdin.on('end', onEnd);
209
222
  });
210
223
  }
211
224
  /** Check if a file is likely binary by reading its first bytes */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.7",
3
+ "version": "1.1.10",
4
4
  "description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
5
5
  "bin": {
6
6
  "gipity": "dist/updater/shim.js",
@@ -14,7 +14,7 @@
14
14
  "prepack": "npm run build",
15
15
  "dev": "tsc --watch",
16
16
  "test": "npm run test:smoke",
17
- "test:smoke": "npm run build && node --test dist/__tests__/utils.test.js dist/__tests__/template-vars.test.js dist/__tests__/platform.test.js dist/__tests__/colors.test.js dist/__tests__/config.test.js dist/__tests__/sync.test.js dist/__tests__/sync-apply.test.js dist/__tests__/sync-unretrievable.test.js dist/__tests__/sync-clean-check.test.js dist/__tests__/sync-lock.test.js dist/__tests__/auth-lock.test.js dist/__tests__/api-401-retry.test.js dist/__tests__/push-cas.test.js dist/__tests__/upload.test.js dist/__tests__/progress.test.js dist/__tests__/updater.test.js dist/__tests__/cli-smoke.test.js dist/__tests__/claude-noninteractive.test.js dist/__tests__/claude-trust.test.js dist/__tests__/build-picker.test.js dist/__tests__/relay-state.test.js dist/__tests__/relay-daemon.test.js dist/__tests__/session-pool.test.js dist/__tests__/relay-diagnostics.test.js dist/__tests__/relay-installers.test.js dist/__tests__/relay-bridge-abort.test.js dist/__tests__/relay-redact.test.js dist/__tests__/relay-machine-id.test.js dist/__tests__/stream-json.test.js dist/__tests__/ingest-queue.test.js dist/__tests__/media-upload.test.js dist/__tests__/stream-delta.test.js dist/__tests__/phase-tracker.test.js dist/__tests__/relay-ingest-contract.test.js dist/__tests__/prompts.test.js dist/__tests__/capture-transcript.test.js dist/__tests__/capture-parsers.test.js dist/__tests__/agents.test.js dist/__tests__/capture-lock.test.js dist/__tests__/capture-resolve.test.js dist/__tests__/flag-aliases.test.js dist/__tests__/client-context.test.js dist/__tests__/adopt-cwd.test.js dist/__tests__/cli-cmd-agent.test.js dist/__tests__/cli-cmd-approval.test.js dist/__tests__/cli-cmd-audit.test.js dist/__tests__/cli-cmd-brand.test.js dist/__tests__/cli-cmd-bug.test.js dist/__tests__/cli-cmd-bug-queue.test.js dist/__tests__/cli-cmd-chat.test.js dist/__tests__/cli-cmd-credits.test.js dist/__tests__/cli-cmd-db.test.js dist/__tests__/cli-cmd-db-checkpoint.test.js dist/__tests__/cli-cmd-deploy.test.js dist/__tests__/cli-cmd-domain.test.js dist/__tests__/cli-cmd-email.test.js dist/__tests__/cli-cmd-file.test.js dist/__tests__/cli-cmd-storage.test.js dist/__tests__/cli-cmd-fn.test.js dist/__tests__/cli-cmd-service.test.js dist/__tests__/cli-cmd-job.test.js dist/__tests__/cli-cmd-generate.test.js dist/__tests__/cli-cmd-gmail.test.js dist/__tests__/cli-cmd-info.test.js dist/__tests__/cli-cmd-init.test.js dist/__tests__/cli-cmd-location.test.js dist/__tests__/cli-cmd-text.test.js dist/__tests__/cli-cmd-login.test.js dist/__tests__/cli-cmd-status.test.js dist/__tests__/cli-cmd-logout.test.js dist/__tests__/cli-cmd-token.test.js dist/__tests__/cli-cmd-key.test.js dist/__tests__/cli-cmd-logs.test.js dist/__tests__/cli-cmd-memory.test.js dist/__tests__/cli-cmd-page.test.js dist/__tests__/cli-cmd-plan.test.js dist/__tests__/cli-cmd-project.test.js dist/__tests__/cli-cmd-rbac.test.js dist/__tests__/cli-cmd-realtime.test.js dist/__tests__/cli-cmd-records.test.js dist/__tests__/cli-cmd-relay.test.js dist/__tests__/cli-cmd-setup.test.js dist/__tests__/cli-cmd-doctor.test.js dist/__tests__/claude-setup.test.js dist/__tests__/cli-cmd-sandbox.test.js dist/__tests__/cli-cmd-add.test.js dist/__tests__/cli-cmd-remove.test.js dist/__tests__/cli-cmd-skill.test.js dist/__tests__/cli-cmd-test.test.js dist/__tests__/cli-cmd-workflow.test.js dist/__tests__/setup-skills-block.test.js dist/__tests__/setup-hooks.test.js dist/__tests__/setup-codex-hooks.test.js dist/__tests__/trace.test.js",
17
+ "test:smoke": "npm run build && node --test dist/__tests__/utils.test.js dist/__tests__/template-vars.test.js dist/__tests__/platform.test.js dist/__tests__/colors.test.js dist/__tests__/config.test.js dist/__tests__/sync.test.js dist/__tests__/sync-apply.test.js dist/__tests__/sync-unretrievable.test.js dist/__tests__/sync-clean-check.test.js dist/__tests__/sync-lock.test.js dist/__tests__/auth-lock.test.js dist/__tests__/api-401-retry.test.js dist/__tests__/push-cas.test.js dist/__tests__/upload.test.js dist/__tests__/progress.test.js dist/__tests__/updater.test.js dist/__tests__/cli-smoke.test.js dist/__tests__/claude-noninteractive.test.js dist/__tests__/claude-trust.test.js dist/__tests__/build-picker.test.js dist/__tests__/relay-state.test.js dist/__tests__/relay-daemon.test.js dist/__tests__/session-pool.test.js dist/__tests__/relay-diagnostics.test.js dist/__tests__/relay-agent-updates.test.js dist/__tests__/relay-installers.test.js dist/__tests__/relay-bridge-abort.test.js dist/__tests__/relay-redact.test.js dist/__tests__/relay-machine-id.test.js dist/__tests__/stream-json.test.js dist/__tests__/ingest-queue.test.js dist/__tests__/media-upload.test.js dist/__tests__/stream-delta.test.js dist/__tests__/phase-tracker.test.js dist/__tests__/relay-ingest-contract.test.js dist/__tests__/prompts.test.js dist/__tests__/capture-transcript.test.js dist/__tests__/capture-parsers.test.js dist/__tests__/agents.test.js dist/__tests__/capture-lock.test.js dist/__tests__/capture-resolve.test.js dist/__tests__/flag-aliases.test.js dist/__tests__/client-context.test.js dist/__tests__/adopt-cwd.test.js dist/__tests__/cli-cmd-agent.test.js dist/__tests__/cli-cmd-approval.test.js dist/__tests__/cli-cmd-audit.test.js dist/__tests__/cli-cmd-brand.test.js dist/__tests__/cli-cmd-bug.test.js dist/__tests__/cli-cmd-bug-queue.test.js dist/__tests__/cli-cmd-chat.test.js dist/__tests__/cli-cmd-credits.test.js dist/__tests__/cli-cmd-db.test.js dist/__tests__/cli-cmd-db-checkpoint.test.js dist/__tests__/cli-cmd-deploy.test.js dist/__tests__/cli-cmd-domain.test.js dist/__tests__/cli-cmd-email.test.js dist/__tests__/cli-cmd-file.test.js dist/__tests__/cli-cmd-storage.test.js dist/__tests__/cli-cmd-fn.test.js dist/__tests__/cli-cmd-service.test.js dist/__tests__/cli-cmd-job.test.js dist/__tests__/cli-cmd-generate.test.js dist/__tests__/cli-cmd-gmail.test.js dist/__tests__/cli-cmd-info.test.js dist/__tests__/cli-cmd-init.test.js dist/__tests__/cli-cmd-location.test.js dist/__tests__/cli-cmd-text.test.js dist/__tests__/cli-cmd-login.test.js dist/__tests__/cli-cmd-status.test.js dist/__tests__/cli-cmd-logout.test.js dist/__tests__/cli-cmd-token.test.js dist/__tests__/cli-cmd-key.test.js dist/__tests__/cli-cmd-logs.test.js dist/__tests__/cli-cmd-memory.test.js dist/__tests__/cli-cmd-page.test.js dist/__tests__/cli-cmd-plan.test.js dist/__tests__/cli-cmd-project.test.js dist/__tests__/cli-cmd-rbac.test.js dist/__tests__/cli-cmd-realtime.test.js dist/__tests__/cli-cmd-records.test.js dist/__tests__/cli-cmd-relay.test.js dist/__tests__/cli-cmd-setup.test.js dist/__tests__/cli-cmd-doctor.test.js dist/__tests__/claude-setup.test.js dist/__tests__/cli-cmd-sandbox.test.js dist/__tests__/cli-cmd-add.test.js dist/__tests__/cli-cmd-remove.test.js dist/__tests__/cli-cmd-skill.test.js dist/__tests__/cli-cmd-test.test.js dist/__tests__/cli-cmd-workflow.test.js dist/__tests__/setup-skills-block.test.js dist/__tests__/setup-hooks.test.js dist/__tests__/setup-codex-hooks.test.js dist/__tests__/setup-agy-hooks.test.js dist/__tests__/trace.test.js",
18
18
  "test:smoke:quick": "node scripts/smoke-quick.mjs",
19
19
  "test:e2e": "tsc && GIPITY_E2E=1 node --test --test-timeout=180000 dist/__tests__/cli-e2e-live.test.js dist/__tests__/cli-e2e-sync-live.test.js dist/__tests__/cli-e2e-sync-stress-live.test.js dist/__tests__/cli-e2e-rollback-live.test.js dist/__tests__/cli-e2e-services-media-live.test.js dist/__tests__/cli-e2e-workflow-live.test.js dist/__tests__/cli-e2e-sandbox-live.test.js dist/__tests__/cli-e2e-page-fetch-live.test.js dist/__tests__/cli-e2e-page-test-live.test.js",
20
20
  "test:e2e:sync": "tsc && GIPITY_E2E=1 node --test --test-timeout=180000 dist/__tests__/cli-e2e-sync-live.test.js",