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.
@@ -87,36 +87,40 @@ emailCommand
87
87
  console.log(success(`✓ Sent to ${sent} recipient${sent === 1 ? '' : 's'}.`));
88
88
  else
89
89
  console.log(warning(`Nothing sent (${skipped} skipped).`));
90
- for (const r of results)
91
- console.log(muted(` ${r.to} — ${r.status}`));
90
+ for (const r of results) {
91
+ console.log(muted(` ${r.to} — ${r.status}${r.reason ? `: ${r.reason}` : ''}`));
92
+ }
92
93
  }));
93
94
  // --- gipity email log ---
94
- // Recent email() sends from the credits ledger (operation = email_send).
95
+ // Recent email() activity from the credits ledger: delivered sends
96
+ // (operation = email_send) plus skipped attempts (email_skip, 0-credit rows
97
+ // recording unsubscribed/blocked/not-configured recipients).
95
98
  emailCommand
96
99
  .command('log')
97
- .description('Recent email() sends from your app')
100
+ .description('Recent email() sends and skipped attempts from your app')
98
101
  .option('--range <range>', 'Time range (24h, 7d, 30d)', '7d')
99
102
  .option('--limit <n>', 'Max rows', '50')
100
103
  .option('--project <guid-or-slug>', 'Target a specific project instead of cwd / Home')
101
104
  .option('--json', 'Output raw JSON')
102
105
  .action((opts) => run('Email', async () => {
103
106
  const { config } = await resolveProjectContext({ projectOverride: opts.project });
104
- const res = await get(`/account/logs/credits?operations=email_send&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`);
107
+ const res = await get(`/account/logs/credits?operations=email_send,email_skip&app_guid=${config.projectGuid}&range=${encodeURIComponent(opts.range)}&limit=${encodeURIComponent(opts.limit)}`);
105
108
  if (opts.json) {
106
109
  console.log(JSON.stringify(res.data));
107
110
  return;
108
111
  }
109
112
  const { totals, items } = res.data;
110
113
  if (!items.length) {
111
- console.log(muted('No email() sends in this range.'));
114
+ console.log(muted('No email() activity in this range (sends and skipped attempts both appear here).'));
112
115
  return;
113
116
  }
114
- console.log(bold(`${totals.n} send${totals.n === 1 ? '' : 's'} · ${totals.credits} credit${totals.credits === 1 ? '' : 's'}`));
117
+ console.log(bold(`${totals.n} attempt${totals.n === 1 ? '' : 's'} · ${totals.credits} credit${totals.credits === 1 ? '' : 's'}`));
115
118
  for (const r of items) {
116
119
  const when = new Date(r.created_at).toISOString().replace('T', ' ').slice(0, 16);
117
120
  const to = r.detail?.to ?? '—';
118
121
  const subj = r.detail?.subject ? ` · ${r.detail.subject}` : '';
119
- console.log(` ${muted(when)} ${to}${muted(subj)}`);
122
+ const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : '';
123
+ console.log(` ${muted(when)} ${to}${status ? warning(status) : ''}${muted(subj)}`);
120
124
  }
121
125
  }));
122
126
  //# sourceMappingURL=email.js.map
@@ -36,9 +36,13 @@ fileCommand
36
36
  }));
37
37
  fileCommand
38
38
  .command('url <path>')
39
- .description('Durable public URL for a project file - no deploy needed. Reachable by browsers, GPU jobs, and external services the moment the file syncs; ideal for throwaway test fixtures (delete the file to revoke the link).')
39
+ .description('Durable public URL for a project file - no deploy needed')
40
40
  .option('--download', 'URL forces a download (Content-Disposition: attachment)')
41
41
  .option('--json', 'Output as JSON')
42
+ .addHelpText('after', `
43
+ Reachable by browsers, GPU jobs, and external services the moment the file
44
+ syncs; ideal for throwaway test fixtures (delete the file to revoke the link).
45
+ `)
42
46
  .action((path, opts) => run('Url', async () => {
43
47
  const { config } = await resolveProjectContext();
44
48
  const qs = new URLSearchParams({ path });
@@ -8,7 +8,7 @@ import { error as clrError, success, muted } from '../colors.js';
8
8
  import { printCommandError } from '../helpers/command.js';
9
9
  import { withSpinner } from '../progress.js';
10
10
  import { guessMime } from '../upload.js';
11
- import { IMAGE_MODELS_DOC, IMAGE_GEMINI_ASPECT_RATIOS, IMAGE_GEMINI_SIZES, VIDEO_MODELS_DOC, TTS_PROVIDER_DESCRIPTIONS } from '../provider-docs.js';
11
+ import { IMAGE_MODELS_DOC, VIDEO_MODELS_DOC, TTS_PROVIDER_DESCRIPTIONS } from '../provider-docs.js';
12
12
  /** Download a URL and save to a local file, then push it up to the project so
13
13
  * the cloud (and anything that mirrors it) immediately matches local disk.
14
14
  * Returns the absolute path written, so callers can report where it landed.
@@ -170,19 +170,14 @@ function readInputImages(paths) {
170
170
  }
171
171
  // ── IMAGE ──────────────────────────────────────────────────────────────
172
172
  const imageCommand = new Command('image')
173
- .description(`Generate an image from a text prompt, or EDIT existing images with --input.
174
-
173
+ .description('Generate an image from a text prompt, or edit existing images with --input')
174
+ .addHelpText('after', `
175
175
  Models: ${IMAGE_MODELS_DOC}
176
176
 
177
177
  Editing (--input): pass one or more source images and the prompt becomes an edit
178
178
  instruction applied to them - "make it night time", "add a hat", "remove the car
179
179
  in the background", or compose several inputs together. Editing routes to Gemini
180
- automatically. This is the first-party way to exercise the image-edit flow from
181
- the CLI; the CLI reads the file bytes itself, so there is no base64/argv fiddling.
182
-
183
- Gemini-specific options:
184
- --aspect-ratio Control output shape: ${IMAGE_GEMINI_ASPECT_RATIOS}
185
- --image-size Control resolution: ${IMAGE_GEMINI_SIZES} (default: 1K)
180
+ automatically; the CLI reads the file bytes itself, so there is no base64/argv fiddling.
186
181
 
187
182
  Examples:
188
183
  gipity generate image "a cat wearing a top hat"
@@ -190,7 +185,8 @@ Examples:
190
185
  gipity generate image "put the person in the first photo into the second scene" --input person.png --input scene.png
191
186
  gipity generate image "landscape sunset" --provider gemini --aspect-ratio 16:9 --image-size 2K
192
187
  gipity generate image "product photo" --provider openai --model gpt-image-2 --size 1536x1024 --quality high
193
- gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png`)
188
+ gipity generate image "abstract art" --provider bfl --model flux-2-pro -o art.png
189
+ `)
194
190
  .argument('<prompt>', 'Text description of the image, or (with --input) the edit instruction to apply')
195
191
  .option('--input <file>', 'Source image to edit/compose (repeatable). With --input the prompt is an edit instruction; routes to Gemini.', (v, acc) => (acc || []).concat(v))
196
192
  .option('--provider <provider>', 'Image provider: openai, bfl, or gemini (default: bfl)')
@@ -248,14 +244,10 @@ Examples:
248
244
  });
249
245
  // ── VIDEO ──────────────────────────────────────────────────────────────
250
246
  const videoCommand = new Command('video')
251
- .description(`Generate a short video (up to 8 seconds) from a text prompt using Google Veo.
252
-
247
+ .description('Generate a short video (up to 8 seconds) from a text prompt using Google Veo')
248
+ .addHelpText('after', `
253
249
  Models: ${VIDEO_MODELS_DOC}
254
250
 
255
- Options:
256
- --aspect 16:9 (landscape, default), 9:16 (portrait/vertical), 1:1 (square)
257
- --resolution 720p (default), 1080p, 4k
258
-
259
251
  Tips:
260
252
  - Describe the scene, camera movement, lighting, and any dialogue
261
253
  - Generation takes 30-120 seconds depending on model
@@ -264,11 +256,14 @@ Tips:
264
256
  Examples:
265
257
  gipity generate video "a bird flying over a mountain lake at sunset"
266
258
  gipity generate video "close-up of coffee being poured" --model veo-3.1-fast-generate-preview
267
- gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4`)
259
+ gipity generate video "vertical dance video" --aspect 9:16 --resolution 1080p -o dance.mp4
260
+ gipity generate video "a wave crashing" --duration 4 --model veo-3.1-lite-generate-preview
261
+ `)
268
262
  .argument('<prompt>', 'Description of the video scene, action, camera movement, and dialogue')
269
263
  .option('--model <model>', 'Veo model: veo-3.1-generate-preview (quality), veo-3.1-fast-generate-preview (speed), veo-3.1-lite-generate-preview (budget)')
270
264
  .option('--aspect <ratio>', 'Aspect ratio: 16:9 (landscape), 9:16 (portrait), 1:1 (square)')
271
265
  .option('--resolution <res>', 'Video resolution: 720p, 1080p, 4k')
266
+ .option('--duration <seconds>', 'Clip length in seconds. Veo models: 4, 6, or 8 (8 required at 1080p/4K); omni-flash: 3-10. Default 8. Billing is per second, so shorter is cheaper.')
272
267
  .option('-o, --output <file>', 'Output path (default ./generated.mp4). For a clip your app ships, write it into the source tree so it deploys, e.g. -o src/assets/video/clip.mp4; the cwd default is fine for one-off generation.')
273
268
  .option('--json', 'Output as JSON')
274
269
  .action(async (prompt, opts) => {
@@ -281,6 +276,7 @@ Examples:
281
276
  model: opts.model,
282
277
  aspect_ratio: opts.aspect,
283
278
  resolution: opts.resolution,
279
+ duration_seconds: opts.duration ? Number(opts.duration) : undefined,
284
280
  });
285
281
  // Veo runs 30-120s; the bouncing bar + timer keeps the wait honest.
286
282
  const result = opts.json
@@ -304,20 +300,20 @@ Examples:
304
300
  });
305
301
  // ── SPEECH ─────────────────────────────────────────────────────────────
306
302
  const speechCommand = new Command('speech')
307
- .description(`Generate speech audio from text using text-to-speech.
308
-
303
+ .description('Generate speech audio from text using text-to-speech')
304
+ .addHelpText('after', `
309
305
  Providers: ${Object.entries(TTS_PROVIDER_DESCRIPTIONS).map(([k, v]) => `${k} - ${v}`).join('\n ')}
310
306
 
311
- Gemini-specific options:
312
- --language BCP-47 language code (e.g. ja-JP, es-ES, fr-FR). 60+ languages supported.
313
- --speakers Multi-speaker mode (up to 2). JSON array: [{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]
314
- When using multi-speaker, format your text as "Name: dialogue" on each line.
307
+ Multi-speaker (--speakers, Gemini only): JSON array like
308
+ [{"name":"Joe","voice":"Kore"},{"name":"Jane","voice":"Puck"}]; format the
309
+ text as "Name: dialogue" on each line.
315
310
 
316
311
  Examples:
317
312
  gipity generate speech "Hello, welcome to Gipity!"
318
313
  gipity generate speech "こんにちは世界" --provider gemini --voice Kore --language ja-JP
319
314
  gipity generate speech "Bonjour le monde" --provider gemini --language fr-FR
320
- gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'`)
315
+ gipity generate speech 'Joe: Hey!\\nJane: Hi there!' --provider gemini --speakers '[{"name":"Joe","voice":"Charon"},{"name":"Jane","voice":"Leda"}]'
316
+ `)
321
317
  .argument('<text>', 'Text to convert to speech (max 5000 characters)')
322
318
  .option('--provider <provider>', 'TTS provider: elevenlabs (default), openai, or gemini')
323
319
  .option('--voice <voice>', 'Voice ID or name (provider-specific)')
@@ -368,8 +364,8 @@ Examples:
368
364
  });
369
365
  // ── MUSIC ──────────────────────────────────────────────────────────────
370
366
  const musicCommand = new Command('music')
371
- .description(`Generate music from a text prompt using AI.
372
-
367
+ .description('Generate music from a text prompt using AI')
368
+ .addHelpText('after', `
373
369
  The model is chosen from the platform's music catalog. Omit --model to use the
374
370
  default; pass --model <id> only if you want a specific one (see the catalog with
375
371
  \`gipity service call music/models --get\`).
@@ -382,7 +378,8 @@ Tips:
382
378
  Examples:
383
379
  gipity generate music "chill lo-fi beat for studying"
384
380
  gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
385
- gipity generate music "indie pop chorus" --vocals --duration 20`)
381
+ gipity generate music "indie pop chorus" --vocals --duration 20
382
+ `)
386
383
  .argument('<prompt>', 'Text description of the music to generate')
387
384
  .option('--duration <seconds>', 'Clip length in seconds (default 30; max depends on the model)', (v) => parseInt(v, 10))
388
385
  .option('--model <model>', 'Music model id (default: platform default)')
@@ -421,8 +418,8 @@ Examples:
421
418
  });
422
419
  // ── SOUND ──────────────────────────────────────────────────────────────
423
420
  const soundCommand = new Command('sound')
424
- .description(`Generate a sound effect from a text description using AI.
425
-
421
+ .description('Generate a sound effect from a text description using AI')
422
+ .addHelpText('after', `
426
423
  Always billed to you (the caller) - the app's service billing_mode does not
427
424
  apply to direct generation, so there is never a reason to flip a service to
428
425
  owner_pays just to create assets.
@@ -435,7 +432,8 @@ Tips:
435
432
  Examples:
436
433
  gipity generate sound "cartoon character saying oof"
437
434
  gipity generate sound "thunder rolling in the distance" --duration 5
438
- gipity generate sound "sci-fi laser blast" -o src/assets/sounds/laser.mp3`)
435
+ gipity generate sound "sci-fi laser blast" -o src/assets/sounds/laser.mp3
436
+ `)
439
437
  .argument('<text>', 'Text description of the sound effect (max 1000 characters)')
440
438
  .option('--duration <seconds>', 'Clip length in seconds (0.5-30; default: automatic)', (v) => parseFloat(v))
441
439
  .option('--influence <n>', 'How closely to follow the prompt, 0.0-1.0 (higher = more literal)', (v) => parseFloat(v))
@@ -5,6 +5,7 @@ import { getAccountSlug } from '../api.js';
5
5
  import { getConfig, getConfigPath, saveConfigAt } from '../config.js';
6
6
  import { getAuth } from '../auth.js';
7
7
  import { slugify, setupProjectTools, SUPPORTED_TOOLS, DEFAULT_TOOLS, DEFAULT_SYNC_IGNORE } from '../setup.js';
8
+ import { AGENT_ADAPTERS } from '../agents/index.js';
8
9
  import { success, error as clrError, info, muted, bold } from '../colors.js';
9
10
  import { confirm } from '../utils.js';
10
11
  import { scanForAdoption, adoptCurrentDir, canAdoptCwd, formatBytes, formatCwdLabel, ADOPT_THRESHOLDS, } from '../adopt-cwd.js';
@@ -23,7 +24,7 @@ function resolveTools(forFlag) {
23
24
  }
24
25
  export const initCommand = new Command('init')
25
26
  .description('Link this directory to a project')
26
- .addHelpText('after', '\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on this machine (Claude Code, Codex, Grok, Antigravity).')
27
+ .addHelpText('after', `\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on this machine (${AGENT_ADAPTERS.map(a => a.displayName).join(', ')}).`)
27
28
  .argument('[name]', 'Project name/slug (defaults to current directory name)')
28
29
  .option('--agent <guid>', 'Agent GUID to use')
29
30
  .option('--no-capture', 'Don\'t record Claude Code sessions in this directory to your Gipity project (sets captureHooks: false in .gipity.json)')
@@ -177,7 +178,7 @@ Working with an existing Gipity project:
177
178
  }
178
179
  console.log(success(`Wrote primer files: ${primerSummary}.`));
179
180
  if (wantsClaude) {
180
- console.log(success('Ready! Run your coding agent here (claude, codex, grok, agy), or `gipity build` to launch one with a picker.'));
181
+ console.log(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map(a => a.key).join(', ')}), or \`gipity build\` to launch one with a picker.`));
181
182
  // Recording happens by default (however Claude Code is launched), so
182
183
  // say so up front - consent should be explicit, not discovered later.
183
184
  if (opts.capture === false) {
@@ -417,7 +417,7 @@ export const pageEvalCommand = new Command('eval')
417
417
  .option('--wait <ms>', 'Sleep this many ms after DOMContentLoaded before evaluating (lets late async work settle; max 30000). With --wait-for, it elapses AFTER the selector appears - gate, then settle.', '500')
418
418
  .option('--wait-for <selector>', `Wait until this CSS selector appears before evaluating, then evaluate (deterministic - beats guessing a --wait). Gate on the state you are ASSERTING, not just a ready flag: '#verdict:not(:empty)' returns the instant the round lands, where a fixed wait snapshots mid-sequence. Same flag on page inspect/screenshot. Max ${WAIT_FOR_MAX_MS}ms (--wait-timeout).`)
419
419
  .option('--wait-timeout <ms>', `Max ms to wait for --wait-for before giving up (max ${WAIT_FOR_MAX_MS})`, '5000')
420
- .option('--timeout <ms>', `How long the script itself may run IN the page. Bare number = MILLISECONDS (so 90s = 90000, NOT 90); or pass an explicit unit that means the same on both this and \`sandbox run --timeout\` — --timeout 90s. Its own await/setTimeout pauses count (default ${EVAL_SCRIPT_BUDGET_MS}, ${EVAL_SCRIPT_BUDGET_CAMERA_MS} with --camera/--fake-media; floor 1000, max ${EVAL_SCRIPT_BUDGET_MAX_MS}). Raise it to trace a sequence that unfolds over time (a game round, an animation). Distinct from --wait, which only sleeps BEFORE the script.`)
420
+ .option('--timeout <ms>', `How long the script itself may run IN the page. Bare number = MILLISECONDS (so 90s = 90000, NOT 90); or pass an explicit unit that means the same on both this and \`sandbox run --timeout\` — --timeout 90s. Its own await/setTimeout pauses count (default ${EVAL_SCRIPT_BUDGET_MS}, ${EVAL_SCRIPT_BUDGET_CAMERA_MS} with --camera/--fake-media; floor 1000 - a bare number under it is rejected as a unit mix-up, a suffixed one just floors; max ${EVAL_SCRIPT_BUDGET_MAX_MS}). Raise it to trace a sequence that unfolds over time (a game round, an animation). Distinct from --wait, which only sleeps BEFORE the script.`)
421
421
  .option('--auth', 'Evaluate signed in as you (your Gipity account), so a page behind a Sign-in-with-Gipity login is reachable. Only works for apps using Sign in with Gipity, hosted on *.gipity.ai. Without this flag the page loads as a genuinely anonymous, signed-out visitor — nothing carries over from earlier --auth runs.')
422
422
  .option('--restore-db', "Snapshot the app database before the script runs and roll it back after, so a write-path check (click Approve, submit the form, edit a row) leaves the real data untouched. Use this whenever the eval WRITES - it is the undo for driving the deployed app against real project data. Same snapshot/undo standalone: gipity db checkpoint / gipity db restore.")
423
423
  .option('--json', 'Output as JSON')
@@ -483,10 +483,13 @@ export const pageEvalCommand = new Command('eval')
483
483
  // 90s` means 90 seconds on BOTH commands. A suffixed value is normalized to ms
484
484
  // up front, so the rest of this action (and the bare-number guard below) sees a
485
485
  // plain ms number and the portable form just works.
486
+ let timeoutHadSuffix = false;
486
487
  if (opts.timeout !== undefined) {
487
488
  const dur = parseDuration(opts.timeout, 'ms');
488
- if (dur?.hadSuffix)
489
+ if (dur?.hadSuffix) {
489
490
  opts.timeout = String(Math.round(dur.value));
491
+ timeoutHadSuffix = true;
492
+ }
490
493
  }
491
494
  // A BARE number below the in-page floor is the unit-mixup tell: a real ms
492
495
  // budget that small is useless (it just floors to the minimum), so a sub-floor
@@ -495,7 +498,12 @@ export const pageEvalCommand = new Command('eval')
495
498
  // an opaque "1s budget" error that never reveals the unit mix-up. Reject it up
496
499
  // front, naming the unit AND the portable suffix form, so the fix is one obvious
497
500
  // edit instead of a doomed run.
498
- if (opts.timeout !== undefined) {
501
+ //
502
+ // A SUFFIXED value is exempt: `--timeout 400ms` states the unit, so there is no
503
+ // mix-up left to name. Sent through the guard it drew the one answer that is
504
+ // certainly wrong for that caller - "pass --timeout 400s", a 400x jump they
505
+ // never asked for. Let it floor in capScriptBudgetMs like any other small value.
506
+ if (opts.timeout !== undefined && !timeoutHadSuffix) {
499
507
  const t = parseInt(opts.timeout, 10);
500
508
  if (Number.isFinite(t) && t > 0 && t < EVAL_SCRIPT_BUDGET_MIN_MS) {
501
509
  const overMax = t * 1000 > EVAL_SCRIPT_BUDGET_MAX_MS;
@@ -254,6 +254,36 @@ relayCommand
254
254
  ? `${success('Diagnostics sharing on.')} ${muted('Reported on the next daily heartbeat.')}`
255
255
  : `${success('Diagnostics sharing off.')} ${muted('No host/version data will be sent.')}`);
256
256
  });
257
+ // ─── gipity relay updates [on|off] ─────────────────────────────────────
258
+ relayCommand
259
+ .command('updates [state]')
260
+ .description('View or set daily auto-update of installed coding agents (on|off)')
261
+ .action((arg) => {
262
+ if (arg === undefined) {
263
+ const stored = state.getAgentUpdatesPref();
264
+ const effective = state.agentUpdatesEnabled();
265
+ const label = stored === undefined ? 'on (default, not yet chosen)' : stored ? 'on' : 'off';
266
+ console.log(`Agent auto-updates: ${effective ? success(label) : muted(label)}`);
267
+ if (!effective && stored !== false) {
268
+ console.log(muted(' (overridden off by DISABLE_AUTOUPDATER / GIPITY_RELAY_AGENT_UPDATES / CI)'));
269
+ }
270
+ console.log(muted(' Once a day, while idle, the relay brings its coding agents (Claude Code, Codex) to the latest release.'));
271
+ console.log(muted(' Upgrades appear in `gipity relay log` and in the device diagnostics on the web.'));
272
+ console.log(muted(' Set with `gipity relay updates on` / `gipity relay updates off`.'));
273
+ return;
274
+ }
275
+ const on = /^(on|true|yes|1|enable)$/i.test(arg);
276
+ const off = /^(off|false|no|0|disable)$/i.test(arg);
277
+ if (!on && !off) {
278
+ console.log(clrError("Expected 'on' or 'off'."));
279
+ process.exitCode = 1;
280
+ return;
281
+ }
282
+ state.setAgentUpdatesPref(on);
283
+ console.log(on
284
+ ? `${success('Agent auto-updates on.')} ${muted("Runs on the relay daemon's next daily maintenance tick.")}`
285
+ : `${success('Agent auto-updates off.')} ${muted('Installed agents only change when you update them yourself.')}`);
286
+ });
257
287
  // ─── gipity relay rename <name> ────────────────────────────────────────
258
288
  relayCommand
259
289
  .command('rename <new-name>')
@@ -16,6 +16,105 @@ function readInstalledKitReadme(name) {
16
16
  const readme = join(kitDir, 'README.md');
17
17
  return existsSync(readme) ? readFileSync(readme, 'utf-8') : null;
18
18
  }
19
+ function slugify(title) {
20
+ return title.toLowerCase().replace(/[`*_]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
21
+ }
22
+ /** Markdown headings, skipping anything inside a fenced code block (shell
23
+ * comments in examples start with `#` too). A section runs until the next
24
+ * heading at the same or a shallower level, so it carries its subsections. */
25
+ function parseSections(lines) {
26
+ const out = [];
27
+ let fenced = false;
28
+ lines.forEach((line, i) => {
29
+ if (/^\s*(```|~~~)/.test(line)) {
30
+ fenced = !fenced;
31
+ return;
32
+ }
33
+ if (fenced)
34
+ return;
35
+ const m = /^(#{1,6})\s+(.*\S)\s*$/.exec(line);
36
+ if (!m)
37
+ return;
38
+ out.push({ level: m[1].length, title: m[2], slug: slugify(m[2]), start: i + 1, end: lines.length });
39
+ });
40
+ out.forEach((s, i) => {
41
+ const next = out.find((o, j) => j > i && o.level <= s.level);
42
+ if (next)
43
+ s.end = next.start - 1;
44
+ });
45
+ return out;
46
+ }
47
+ /** The heading level worth listing in the one-line map: the shallowest level
48
+ * with more than one heading (docs open with a single `# Title`, so that lone
49
+ * H1 is never the useful outline), else the shallowest level present. */
50
+ function outlineLevel(sections) {
51
+ const levels = [...new Set(sections.map(s => s.level))].sort((a, b) => a - b);
52
+ return levels.find(l => sections.filter(s => s.level === l).length > 1) ?? levels[0];
53
+ }
54
+ function sectionText(lines, s) {
55
+ return lines.slice(s.start - 1, s.end).join('\n').replace(/\s+$/, '');
56
+ }
57
+ const MAX_MAPPED_SECTIONS = 12;
58
+ /** One line above every read: how long the doc is and what is in it, with the
59
+ * flag for pulling one part inline. Printed to stdout so it survives an
60
+ * agent's `| head -N`. */
61
+ function mapLine(name, lines, sections) {
62
+ const head = `${bold(name)} ${muted(`· ${lines.length} lines`)}`;
63
+ if (sections.length === 0)
64
+ return head;
65
+ const shown = sections.filter(s => s.level === outlineLevel(sections));
66
+ const names = shown.slice(0, MAX_MAPPED_SECTIONS).map(s => s.slug).join(', ');
67
+ const more = shown.length > MAX_MAPPED_SECTIONS ? `, +${shown.length - MAX_MAPPED_SECTIONS} more (--toc)` : '';
68
+ return `${head} ${muted(`· sections (--section <slug>): ${names}${more}`)}`;
69
+ }
70
+ function tocText(sections) {
71
+ return sections
72
+ .map(s => `${String(s.start).padStart(5)} ${' '.repeat(s.level - 1)}${s.slug}${muted(` - ${s.title}`)}`)
73
+ .join('\n');
74
+ }
75
+ /** Apply --toc / --section / --grep to a doc. Returns the text to print, or
76
+ * null when the filter matched nothing (caller reports it and exits 1). */
77
+ function filterContent(content, sections, opts) {
78
+ const lines = content.split('\n');
79
+ if (opts.toc)
80
+ return tocText(sections);
81
+ let hits = [];
82
+ if (opts.section) {
83
+ const want = slugify(opts.section);
84
+ hits = sections.filter(s => s.slug === want);
85
+ if (hits.length === 0)
86
+ hits = sections.filter(s => s.slug.includes(want));
87
+ }
88
+ else if (opts.grep) {
89
+ let re;
90
+ try {
91
+ re = new RegExp(opts.grep, 'i');
92
+ }
93
+ catch {
94
+ throw new Error(`--grep "${opts.grep}" is not a valid regex.`);
95
+ }
96
+ // Deepest matching section per hit: the smallest chunk that still answers
97
+ // the question, rather than the whole chapter it sits in.
98
+ const matched = new Set();
99
+ lines.forEach((line, i) => {
100
+ if (!re.test(line))
101
+ return;
102
+ const owning = sections.filter(s => s.start <= i + 1 && i + 1 <= s.end);
103
+ const deepest = owning[owning.length - 1];
104
+ if (deepest)
105
+ matched.add(deepest);
106
+ });
107
+ hits = sections.filter(s => matched.has(s));
108
+ }
109
+ else {
110
+ return content;
111
+ }
112
+ if (hits.length === 0)
113
+ return null;
114
+ // Drop sections already contained in an outer hit so nothing prints twice.
115
+ const outer = hits.filter(s => !hits.some(o => o !== s && o.start <= s.start && s.end <= o.end));
116
+ return outer.map(s => sectionText(lines, s)).join('\n\n');
117
+ }
19
118
  export const skillCommand = new Command('skill')
20
119
  .description('Task docs - read the matching skill before building');
21
120
  skillCommand
@@ -30,43 +129,78 @@ skillCommand
30
129
  }
31
130
  const res = await get(`/skills?agent=${config.agentGuid}`);
32
131
  const width = res.data.reduce((m, s) => Math.max(m, s.name.length), 0);
33
- printList(res.data, opts, 'No skills available.', s => ` ${bold(s.name.padEnd(width))} ${muted(s.description)}`, 'Read one with `gipity skill read <name>`:');
132
+ printList(res.data, opts, 'No skills available.', s => ` ${bold(s.name.padEnd(width))} ${muted(s.description)}`, 'Read with `gipity skill read <name> [<name>...]` (one turn, many docs; `--toc`, `--section <slug>` or `--grep <term>` for one part):');
34
133
  }));
35
134
  skillCommand
36
- .command('read <name>')
37
- .description('Read a skill')
135
+ .command('read <names...>')
136
+ .description('Read one or more skills (whole doc, or one part with --toc/--section/--grep)')
137
+ .option('--toc', 'Print the doc outline (section slugs + line numbers) instead of the content')
138
+ .option('--section <slug>', 'Print only this section (slug or heading text; subsections included)')
139
+ .option('--grep <term>', 'Print only the sections matching this term (case-insensitive regex)')
38
140
  .option('--json', 'Output as JSON')
39
- .action((name, opts) => run('Read', async () => {
141
+ .action((names, opts) => run('Read', async () => {
40
142
  const { config } = await resolveProjectContext();
41
143
  if (!config.agentGuid) {
42
144
  console.error(clrError('No agent configured for this project. Run `gipity init` to refresh.'));
43
145
  process.exit(1);
44
146
  }
45
147
  const listRes = await get(`/skills?agent=${config.agentGuid}`);
46
- const match = listRes.data.find(s => s.name.toLowerCase() === name.toLowerCase());
47
- if (!match) {
48
- // No catalog skill — but if a kit by this name is installed, its README is
49
- // the guidance the agent is after. Surface it instead of dead-ending.
50
- const readme = readInstalledKitReadme(name);
51
- if (readme) {
52
- if (opts.json) {
53
- console.log(JSON.stringify({ name, source: 'kit-readme', content: readme }, null, 2));
54
- }
55
- else {
56
- console.log(muted(`No skill doc for "${name}"; showing the installed kit's README (src/packages/${name}/README.md):\n`));
57
- console.log(readme);
148
+ const jsonDocs = [];
149
+ let failed = false;
150
+ let printed = 0;
151
+ for (const name of names) {
152
+ const match = listRes.data.find(s => s.name.toLowerCase() === name.toLowerCase());
153
+ let content;
154
+ let detail;
155
+ let note = null;
156
+ if (match) {
157
+ const res = await get(`/skills/${match.guid}?agent=${config.agentGuid}`);
158
+ content = res.data.content;
159
+ detail = { ...res.data };
160
+ }
161
+ else {
162
+ // No catalog skill — but if a kit by this name is installed, its README is
163
+ // the guidance the agent is after. Surface it instead of dead-ending.
164
+ const readme = readInstalledKitReadme(name);
165
+ if (!readme) {
166
+ console.error(clrError(`Skill "${name}" not found. Run: gipity skill list`));
167
+ failed = true;
168
+ continue;
58
169
  }
59
- return;
170
+ content = readme;
171
+ detail = { name, source: 'kit-readme' };
172
+ note = muted(`No skill doc for "${name}"; showing the installed kit's README (src/packages/${name}/README.md):`);
60
173
  }
61
- console.error(clrError(`Skill "${name}" not found. Run: gipity skill list`));
62
- process.exit(1);
174
+ const lines = content.split('\n');
175
+ const sections = parseSections(lines);
176
+ const filtered = filterContent(content, sections, opts);
177
+ if (filtered === null) {
178
+ const what = opts.section ? `section "${opts.section}"` : `match for "${opts.grep}"`;
179
+ console.error(clrError(`No ${what} in "${name}". Sections: ${sections.map(s => s.slug).join(', ') || '(none)'}`));
180
+ failed = true;
181
+ continue;
182
+ }
183
+ if (opts.json) {
184
+ jsonDocs.push({
185
+ ...detail,
186
+ content: filtered,
187
+ lines: lines.length,
188
+ sections: sections.map(s => ({ slug: s.slug, title: s.title, level: s.level, line: s.start })),
189
+ });
190
+ continue;
191
+ }
192
+ if (printed > 0)
193
+ console.log(''); // blank line between docs in a multi-name read
194
+ if (note)
195
+ console.log(note);
196
+ console.log(mapLine(name, lines, sections));
197
+ console.log(filtered);
198
+ printed++;
63
199
  }
64
- const res = await get(`/skills/${match.guid}?agent=${config.agentGuid}`);
65
200
  if (opts.json) {
66
- console.log(JSON.stringify(res.data, null, 2));
67
- }
68
- else {
69
- console.log(res.data.content);
201
+ console.log(JSON.stringify(names.length === 1 ? jsonDocs[0] ?? null : jsonDocs, null, 2));
70
202
  }
203
+ if (failed)
204
+ process.exit(1);
71
205
  }));
72
206
  //# sourceMappingURL=skill.js.map
@@ -12,46 +12,14 @@ import { Command } from 'commander';
12
12
  import { existsSync, rmSync, unlinkSync, readFileSync, writeFileSync } from 'fs';
13
13
  import { homedir, platform as osPlatform } from 'os';
14
14
  import { join, resolve } from 'path';
15
- import { spawnSyncCommand, resolveCommand } from '../platform.js';
15
+ import { spawnSyncCommand } from '../platform.js';
16
16
  import { post } from '../api.js';
17
17
  import { getAuth } from '../auth.js';
18
18
  import { confirm, getAutoConfirm } from '../utils.js';
19
19
  import { bold, brand, dim, success, error as clrError, muted } from '../colors.js';
20
20
  import * as relayState from '../relay/state.js';
21
21
  import { planFor, UnsupportedPlatformError } from '../relay/installers.js';
22
- import { GIPITY_PLUGIN_ID, GIPITY_MARKETPLACE_NAME, stripGipityHooks, grokInstallState, agentSkillsState, AGENTS_SKILLS_DIR, agySkillsState, AGY_SKILLS_DIR, } from '../setup.js';
23
- /** Remove Gipity's entries from the user-scope Claude Code settings: the
24
- * plugin enablement, the marketplace registration, and any legacy hook
25
- * blocks older CLI versions wrote there. Surgical - everything else in the
26
- * file (the user's own permissions, hooks, other plugins) is untouched. */
27
- function removeGipityPluginConfig() {
28
- const settingsPath = join(homedir(), '.claude', 'settings.json');
29
- if (!existsSync(settingsPath))
30
- return false;
31
- let settings;
32
- try {
33
- settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
34
- }
35
- catch {
36
- return false;
37
- }
38
- let changed = stripGipityHooks(settings);
39
- if (settings.enabledPlugins && GIPITY_PLUGIN_ID in settings.enabledPlugins) {
40
- delete settings.enabledPlugins[GIPITY_PLUGIN_ID];
41
- if (Object.keys(settings.enabledPlugins).length === 0)
42
- delete settings.enabledPlugins;
43
- changed = true;
44
- }
45
- if (settings.extraKnownMarketplaces?.[GIPITY_MARKETPLACE_NAME]) {
46
- delete settings.extraKnownMarketplaces[GIPITY_MARKETPLACE_NAME];
47
- if (Object.keys(settings.extraKnownMarketplaces).length === 0)
48
- delete settings.extraKnownMarketplaces;
49
- changed = true;
50
- }
51
- if (changed)
52
- writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
53
- return changed;
54
- }
22
+ import { AGENT_ADAPTERS } from '../agents/index.js';
55
23
  /** The install.sh / install.ps1 launcher appends a line to the user's shell rc
56
24
  * files putting ~/.gipity/launcher/bin on PATH. Once ~/.gipity is deleted that
57
25
  * line points at nothing, so strip it back out - matched by the installer's own
@@ -212,46 +180,20 @@ export const uninstallCommand = new Command('uninstall')
212
180
  // 3. Revoke device on server.
213
181
  await revokeDeviceBestEffort();
214
182
  console.log(`${success('Device revoked on server (or was already revoked).')}`);
215
- // 4. Remove the Claude Code plugin enablement + any legacy hook blocks.
216
- if (removeGipityPluginConfig()) {
217
- console.log(`${success('Gipity Claude Code plugin disabled (hooks removed).')}`);
218
- }
219
- else {
220
- console.log(`${muted('No Gipity entries in Claude Code settings.')}`);
221
- }
222
- // 4b. Uninstall the Gipity plugin from Grok Build and remove the skills
223
- // the CLI copied into the cross-agent ~/.agents/skills dir for Codex.
224
- // Both best-effort: neither existing is the common case.
225
- if (grokInstallState().exists) {
226
- spawnSyncCommand(resolveCommand('grok'), ['plugin', 'uninstall', 'gipity', '--confirm'], {
227
- stdio: 'ignore',
228
- timeout: 60_000,
229
- });
230
- console.log(`${success('Gipity plugin removed from Grok.')}`);
231
- }
232
- const agentSkills = agentSkillsState();
233
- if (agentSkills.skills.length) {
234
- for (const name of agentSkills.skills) {
235
- // Only names our manifest recorded - never someone else's skills.
236
- try {
237
- rmSync(join(AGENTS_SKILLS_DIR, name), { recursive: true, force: true });
238
- }
239
- catch { /* best-effort */ }
183
+ // 4. Remove each detected agent's Gipity integration: the Claude Code
184
+ // plugin enablement + legacy hook blocks, the Grok plugin, and the
185
+ // skills the CLI copied into Codex's/Antigravity's skill roots. Every
186
+ // step is best-effort - none existing is the common case.
187
+ let anyAgentIntegration = false;
188
+ for (const agent of AGENT_ADAPTERS) {
189
+ const note = agent.setup?.uninstall();
190
+ if (note) {
191
+ console.log(`${success(note)}`);
192
+ anyAgentIntegration = true;
240
193
  }
241
- console.log(`${success(`Removed ${agentSkills.skills.length} Gipity skills from ~/.agents/skills.`)}`);
242
194
  }
243
- // 4c. Remove the skills the CLI copied into Antigravity's own global
244
- // skill root (~/.gemini/config/skills - a different directory from
245
- // Codex's ~/.agents/skills, see setup.ts).
246
- const agySkills = agySkillsState();
247
- if (agySkills.skills.length) {
248
- for (const name of agySkills.skills) {
249
- try {
250
- rmSync(join(AGY_SKILLS_DIR, name), { recursive: true, force: true });
251
- }
252
- catch { /* best-effort */ }
253
- }
254
- console.log(`${success(`Removed ${agySkills.skills.length} Gipity skills from ~/.gemini/config/skills.`)}`);
195
+ if (!anyAgentIntegration) {
196
+ console.log(`${muted('No Gipity entries in any detected coding agent.')}`);
255
197
  }
256
198
  // 5. Wipe ~/.gipity/ (this also removes the agent-hooks scripts and the
257
199
  // agent-skills manifest, which live under it).