gipity 1.1.16 → 1.1.19

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.
Files changed (59) hide show
  1. package/README.md +58 -75
  2. package/dist/adopt-cwd.js +2 -13
  3. package/dist/api.js +26 -44
  4. package/dist/auth.js +1 -1
  5. package/dist/banner.js +3 -7
  6. package/dist/catalog.js +8 -7
  7. package/dist/commands/add.js +26 -9
  8. package/dist/commands/approval.js +1 -1
  9. package/dist/commands/ask.js +112 -0
  10. package/dist/commands/bug.js +5 -5
  11. package/dist/commands/build.js +10 -35
  12. package/dist/commands/credits.js +3 -3
  13. package/dist/commands/doctor.js +7 -8
  14. package/dist/commands/email.js +6 -56
  15. package/dist/commands/generate.js +4 -4
  16. package/dist/commands/init.js +40 -30
  17. package/dist/commands/key.js +1 -1
  18. package/dist/commands/load.js +2 -12
  19. package/dist/commands/logs.js +2 -2
  20. package/dist/commands/memory.js +5 -17
  21. package/dist/commands/notify.js +1 -1
  22. package/dist/commands/page-eval.js +55 -38
  23. package/dist/commands/page-inspect.js +6 -6
  24. package/dist/commands/page-screenshot.js +51 -54
  25. package/dist/commands/page-test.js +188 -14
  26. package/dist/commands/payments.js +2 -2
  27. package/dist/commands/project.js +66 -15
  28. package/dist/commands/realtime.js +96 -4
  29. package/dist/commands/records.js +4 -6
  30. package/dist/commands/sandbox.js +2 -3
  31. package/dist/commands/skill.js +50 -22
  32. package/dist/commands/status.js +7 -9
  33. package/dist/commands/test.js +2 -2
  34. package/dist/commands/token.js +4 -4
  35. package/dist/commands/workflow.js +45 -8
  36. package/dist/config.js +22 -6
  37. package/dist/flag-aliases.js +75 -18
  38. package/dist/help-skills.js +2 -2
  39. package/dist/hooks/capture-runner.js +5 -3
  40. package/dist/index.js +1616 -1498
  41. package/dist/knowledge.js +24 -21
  42. package/dist/login-flow.js +4 -4
  43. package/dist/net.js +91 -0
  44. package/dist/opencode-setup.js +2 -2
  45. package/dist/page-fixtures.js +3 -3
  46. package/dist/project-setup.js +2 -3
  47. package/dist/prompts.js +1 -1
  48. package/dist/realtime-bench.js +12040 -0
  49. package/dist/relay/agent-token.js +1 -1
  50. package/dist/relay/daemon.js +0 -1
  51. package/dist/relay/setup.js +13 -2
  52. package/dist/setup.js +11 -12
  53. package/dist/sync.js +3 -3
  54. package/dist/utils.js +1 -1
  55. package/package.json +10 -4
  56. package/dist/commands/agent.js +0 -251
  57. package/dist/commands/chat.js +0 -137
  58. package/dist/commands/claude.js +0 -1056
  59. package/dist/commands/plan.js +0 -93
@@ -0,0 +1,112 @@
1
+ import { Command } from 'commander';
2
+ import { readFileSync, fstatSync } from 'fs';
3
+ import { post } from '../api.js';
4
+ import { resolveProjectContext } from '../config.js';
5
+ import { guessMime } from '../upload.js';
6
+ import { warning } from '../colors.js';
7
+ import { run } from '../helpers/index.js';
8
+ import { withSpinner } from '../progress.js';
9
+ const IMAGE_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
10
+ /** True when stdin is piped or redirected (not a terminal, not /dev/null). */
11
+ function stdinIsPiped() {
12
+ try {
13
+ const st = fstatSync(0);
14
+ return st.isFIFO() || st.isFile();
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ /** A --file's text. `-` is stdin, read only when asked for: many harnesses
21
+ * leave stdin as an open pipe that never closes, so reading it unasked would
22
+ * hang an agent's `gipity ask "..."` forever. */
23
+ function readTextFile(path) {
24
+ try {
25
+ return readFileSync(path === '-' ? 0 : path, 'utf8');
26
+ }
27
+ catch (e) {
28
+ throw new Error(`can't read --file ${path} (${e.code || e.message}).`);
29
+ }
30
+ }
31
+ function readImage(path) {
32
+ const mime = guessMime(path);
33
+ if (!IMAGE_TYPES.has(mime))
34
+ throw new Error(`--image ${path} is ${mime}; use a png, jpg, gif or webp.`);
35
+ let buf;
36
+ try {
37
+ buf = readFileSync(path);
38
+ }
39
+ catch (e) {
40
+ throw new Error(`can't read --image ${path} (${e.code || e.message}).`);
41
+ }
42
+ return { data: buf.toString('base64'), mime_type: mime, name: path.split('/').pop() || path };
43
+ }
44
+ /** The question, then each --file under its own header (stdin, `-`, with none). */
45
+ export function buildAskPrompt(words, files) {
46
+ const parts = [];
47
+ if (words.length)
48
+ parts.push(words.join(' '));
49
+ for (const f of files)
50
+ parts.push(f.path === '-' ? f.content.trimEnd() : `--- ${f.path} ---\n${f.content.trimEnd()}`);
51
+ return parts.join('\n\n');
52
+ }
53
+ export const askCommand = new Command('ask')
54
+ .description('Ask a model one question and print the answer: no chat history, no tools. Attach text with --file (- for stdin) or images with --image')
55
+ .argument('[prompt...]', 'The question or instruction')
56
+ .option('--file <path...>', 'Add a text file to the prompt (repeatable); - reads stdin')
57
+ .option('--image <path...>', 'Attach an image: png, jpg, gif or webp (repeatable)')
58
+ .option('--model <model>', 'Model id, alias (small, fast, medium, large, haiku, sonnet, opus, ...) or provider (openai, anthropic, gemini). Default: small')
59
+ .option('--system <text>', 'Replace the default system prompt')
60
+ .option('--schema <json>', 'Answer with a JSON value matching this JSON schema; prints the JSON')
61
+ .option('--max-tokens <n>', 'Cap the answer length', (v) => parseInt(v, 10))
62
+ .option('--json', 'Output the whole result (answer, model, tokens) as JSON')
63
+ .addHelpText('after', `
64
+ Examples:
65
+ gipity ask "what does HTTP 425 mean?"
66
+ cat errors.log | gipity ask "group these by root cause" --file -
67
+ gipity ask "summarize this" --file notes.md
68
+ gipity ask "what's in this picture?" --image shot.png --model gemini
69
+ gipity ask "extract the dates" --file mail.txt --schema '{"type":"array","items":{"type":"string"}}'
70
+ `)
71
+ .action((words, opts) => run('Ask', async () => {
72
+ const paths = opts.file ?? [];
73
+ // Nothing else to ask: take piped stdin as the whole prompt (`... | gipity ask`).
74
+ if (!words.length && !paths.length && stdinIsPiped())
75
+ paths.push('-');
76
+ const files = paths.map(path => ({ path, content: readTextFile(path) }));
77
+ const prompt = buildAskPrompt(words, files);
78
+ if (!prompt.trim())
79
+ throw new Error('Nothing to ask. Pass a question, add --file <path> (or --file - for stdin), or pipe the prompt in.');
80
+ let schema;
81
+ if (opts.schema !== undefined) {
82
+ try {
83
+ schema = JSON.parse(opts.schema);
84
+ }
85
+ catch {
86
+ throw new Error('--schema must be JSON (a JSON schema, e.g. \'{"type":"object","properties":{"answer":{"type":"string"}}}\').');
87
+ }
88
+ }
89
+ const images = (opts.image ?? []).map(readImage);
90
+ const { config } = await resolveProjectContext();
91
+ const body = { prompt };
92
+ if (opts.model)
93
+ body.model = opts.model;
94
+ if (opts.system)
95
+ body.system = opts.system;
96
+ if (images.length)
97
+ body.images = images;
98
+ if (schema !== undefined)
99
+ body.schema = schema;
100
+ if (opts.maxTokens)
101
+ body.max_tokens = opts.maxTokens;
102
+ const call = () => post(`/projects/${config.projectGuid}/generate/text`, body);
103
+ const result = opts.json || !process.stderr.isTTY ? await call() : await withSpinner('Thinking...', call, { done: null });
104
+ if (opts.json) {
105
+ console.log(JSON.stringify(result));
106
+ return;
107
+ }
108
+ if (result.truncated)
109
+ console.error(warning(`The answer hit the length limit and is cut off. Raise --max-tokens or ask for less.`));
110
+ console.log(schema !== undefined ? JSON.stringify(result.json, null, 2) : result.text.trim());
111
+ }));
112
+ //# sourceMappingURL=ask.js.map
@@ -12,13 +12,13 @@ const SEVERITIES = ['S1', 'S2', 'S3', 'S4'];
12
12
  const SEVERITY_HINT = 'S1=blocker, S2=major, S3=minor, S4=friction';
13
13
  export const bugCommand = new Command('bug')
14
14
  .description('Report Gipity platform bugs / friction in real time')
15
- .addHelpText('after', `\nCapture platform friction the moment you hit it — even one you worked around —` +
15
+ .addHelpText('after', `\nCapture platform friction the moment you hit it, even one you worked around,` +
16
16
  `\nso the team can triage it into a fix.\n` +
17
17
  `\nCategories: ${CATEGORIES.join(', ')}` +
18
18
  `\nSeverity: ${SEVERITY_HINT}` +
19
- `\nNever include PII or user data — describe the platform problem in the abstract.` +
19
+ `\nNever include PII or user data: describe the platform problem in the abstract.` +
20
20
  `\nFiled one by mistake? Withdraw it yourself with \`gipity bug retract <id>\`` +
21
- `\n(works until a human picks it up) — don't file a second report asking for a close.`);
21
+ `\n(works until a human picks it up). Don't file a second report asking for a close.`);
22
22
  bugCommand
23
23
  .command('report')
24
24
  .description('File a bug / friction report about the Gipity platform')
@@ -52,7 +52,7 @@ bugCommand
52
52
  console.log(JSON.stringify(res.data));
53
53
  return;
54
54
  }
55
- console.log(success(`✓ Bug report filed (${res.data.report_guid}) — queued for triage.`));
55
+ console.log(success(`✓ Bug report filed (${res.data.report_guid}): queued for triage.`));
56
56
  }
57
57
  catch (err) {
58
58
  // The report itself is the record of "the platform broke" - don't lose it
@@ -84,7 +84,7 @@ bugCommand
84
84
  console.log(JSON.stringify(res.data));
85
85
  return;
86
86
  }
87
- console.log(success(`✓ Bug report ${res.data.report_guid} retracted — it is out of the triage queue.`));
87
+ console.log(success(`✓ Bug report ${res.data.report_guid} retracted: it is out of the triage queue.`));
88
88
  }));
89
89
  bugCommand
90
90
  .command('list')
@@ -8,12 +8,11 @@ import { resolveCommand, spawnCommand, spawnSyncCommand } from '../platform.js';
8
8
  import { getAuth, sessionExpired, accessTokenExpired, refreshTokenIfNeeded } from '../auth.js';
9
9
  import { get, post, ApiError, getAccountSlug } from '../api.js';
10
10
  import { interactiveLogin } from '../login-flow.js';
11
- import { getConfig, saveConfigAt, clearConfigCache, getApiBaseOverride, DEFAULT_API_BASE, getConfigPath } from '../config.js';
11
+ import { getConfig, saveConfigAt, clearConfigCache, getApiBaseOverride, DEFAULT_API_BASE, getConfigPath, captureEnabled } from '../config.js';
12
12
  import { sync } from '../sync.js';
13
13
  import { slugify, ensureGipityPluginInstalled, setupProjectTools, setupToolForAgent, DEFAULT_SYNC_IGNORE, isSyncIgnored } from '../setup.js';
14
14
  import { buildProjectContextBlock as buildProjectContextBlockText, buildNewProjectPrompt, buildResumeWrap, buildFreshWrap, } from '../prompts.js';
15
15
  import * as relayState from '../relay/state.js';
16
- import { maybeOfferRelayOn, ensureDaemonRunning } from '../relay/onboarding.js';
17
16
  import { prompt, pickOne, confirm } from '../utils.js';
18
17
  import { brand, bold, info, success, warning, error as clrError, muted } from '../colors.js';
19
18
  import { createProgressReporter } from '../progress.js';
@@ -67,6 +66,7 @@ function reportSyncResult(result) {
67
66
  }
68
67
  }
69
68
  import { getProjectsRoot } from '../relay/paths.js';
69
+ import { ensureDevicePaired } from '../relay/setup.js';
70
70
  /** Ask the server for recursive VFS counts. Server owns the file metadata
71
71
  * (counts, bytes, paths), so a single aggregate query beats walking the
72
72
  * local filesystem - which only sees depth 1 without recursion and led
@@ -144,10 +144,9 @@ async function buildProjectContextBlock(opts) {
144
144
  // Interactive email+code login now lives in `login-flow.ts` (shared with
145
145
  // `gipity setup`). Used on first login and when the server returns 401
146
146
  // mid-command (session expired).
147
- // First-run relay onboarding now lives in `relay/onboarding.ts`
148
- // (`maybeOfferRelayOn`). `gipity claude` invokes it after project
149
- // selection, and also calls `ensureDaemonRunning` unconditionally before
150
- // launching Claude Code so a paired user doesn't have to think about it.
147
+ // Relay (driving this machine from the web) is parked: `gipity build` no
148
+ // longer offers it or starts its daemon. `gipity relay` still works where the
149
+ // server has the `relay` feature on. See relay/onboarding.ts.
151
150
  /** Format a millisecond duration as hh:mm:ss.s (one decimal on seconds). */
152
151
  function formatElapsed(ms) {
153
152
  const totalSec = ms / 1000;
@@ -388,13 +387,6 @@ async function runLaunch(cmdName, cmdCfg, opts) {
388
387
  auth = await interactiveLogin();
389
388
  }
390
389
  console.log('');
391
- // ── Step 1b: Relay first-run onboarding (account-scoped, runs before project) ──
392
- if (!nonInteractive) {
393
- await maybeOfferRelayOn();
394
- }
395
- if (!nonInteractive && relayState.isRelayEnabled() && !relayState.isPaused()) {
396
- ensureDaemonRunning();
397
- }
398
390
  // ── Step 2: Project ───────────────────────────────────────────────
399
391
  let initialPrompt = '';
400
392
  let headlessNewProject = false;
@@ -476,19 +468,11 @@ async function runLaunch(cmdName, cmdCfg, opts) {
476
468
  mkdirSync(projectDir, { recursive: true });
477
469
  process.chdir(projectDir);
478
470
  clearConfigCache();
479
- let agentGuid = '';
480
- try {
481
- const agents = await get(`/projects/${project.short_guid}/agents`);
482
- if (agents.data.length > 0)
483
- agentGuid = agents.data[0].short_guid;
484
- }
485
- catch { /* no agents */ }
486
471
  const accountSlug = await getAccountSlug();
487
472
  saveConfigAt(projectDir, {
488
473
  projectGuid: project.short_guid,
489
474
  projectSlug: project.slug,
490
475
  accountSlug,
491
- agentGuid,
492
476
  conversationGuid: null,
493
477
  apiBase: getApiBaseOverride() || DEFAULT_API_BASE,
494
478
  ignore: DEFAULT_SYNC_IGNORE,
@@ -597,7 +581,6 @@ async function runLaunch(cmdName, cmdCfg, opts) {
597
581
  let project;
598
582
  let isNewProject = false;
599
583
  let accountSlug = '';
600
- let agentGuid = '';
601
584
  const result = forceAdoptCwd
602
585
  ? { kind: 'adopt-cwd' }
603
586
  : projects.length > 0
@@ -621,7 +604,6 @@ async function runLaunch(cmdName, cmdCfg, opts) {
621
604
  confirmDeletions: !nonInteractive,
622
605
  });
623
606
  project = adopted.project;
624
- agentGuid = adopted.agentGuid;
625
607
  // Treat as "new project" for the build prompt only when cwd is
626
608
  // genuinely empty - otherwise the user has chosen to adopt
627
609
  // existing content and shouldn't be asked "what to build?".
@@ -639,22 +621,12 @@ async function runLaunch(cmdName, cmdCfg, opts) {
639
621
  mkdirSync(projectDir, { recursive: true });
640
622
  process.chdir(projectDir);
641
623
  clearConfigCache();
642
- // Fetch agents
643
- try {
644
- const agents = await get(`/projects/${project.short_guid}/agents`);
645
- if (agents.data.length > 0)
646
- agentGuid = agents.data[0].short_guid;
647
- }
648
- catch {
649
- // No agents
650
- }
651
624
  accountSlug = await getAccountSlug();
652
625
  // Always write config (refresh stale GUIDs from a previous setup)
653
626
  saveConfigAt(projectDir, {
654
627
  projectGuid: project.short_guid,
655
628
  projectSlug: project.slug,
656
629
  accountSlug,
657
- agentGuid,
658
630
  conversationGuid: null,
659
631
  apiBase: getApiBaseOverride() || DEFAULT_API_BASE,
660
632
  ignore: DEFAULT_SYNC_IGNORE,
@@ -766,8 +738,11 @@ async function runLaunch(cmdName, cmdCfg, opts) {
766
738
  // empty forever (the qwen-flight zero-message bug, 2026-07-07).
767
739
  const inheritedConvGuid = Boolean(process.env.GIPITY_CONVERSATION_GUID);
768
740
  let convGuidForHooks = process.env.GIPITY_CONVERSATION_GUID ?? null;
769
- if (!convGuidForHooks) {
770
- const device = relayState.getDevice();
741
+ // Session recording is opt-in per project (captureEnabled): with it off
742
+ // no conversation is created and the hooks have nothing to post to.
743
+ if (!convGuidForHooks && captureEnabled(getConfig())) {
744
+ // Recording needs this machine registered; do it quietly the first time.
745
+ const device = relayState.getDevice() ?? await ensureDevicePaired().catch(() => null);
771
746
  if (device) {
772
747
  const cfg = getConfig();
773
748
  const resumeIdx = process.argv.indexOf('--resume');
@@ -129,7 +129,7 @@ export const creditsCommand = new Command('credits')
129
129
  }
130
130
  console.log('');
131
131
  if (sub.tier !== 'pro') {
132
- console.log(dim('Upgrade to Gipity Pro for higher limits and 20,000 credits/mo — run `gipity credits buy`.'));
132
+ console.log(dim('Upgrade to Gipity Pro for higher limits and 20,000 credits/mo: run `gipity credits buy`.'));
133
133
  }
134
134
  else {
135
135
  console.log(dim('Need more credits? Run `gipity credits list` to see credit packs, then `gipity credits buy <pack>`.'));
@@ -268,7 +268,7 @@ creditsCommand
268
268
  console.log('');
269
269
  console.log(` ${bold('Checkout:')} ${success(url)}`);
270
270
  console.log('');
271
- console.log(dim('Open the link to complete your purchase — 2 minutes, cancel anytime. Your plan unlocks the moment payment clears.'));
271
+ console.log(dim('Open the link to complete your purchase. It takes 2 minutes; cancel anytime. Your plan unlocks the moment payment clears.'));
272
272
  if (opts.open)
273
273
  openInBrowser(url);
274
274
  }
@@ -313,7 +313,7 @@ creditsCommand
313
313
  }
314
314
  console.log(` ${bold('Billing portal:')} ${success(url)}`);
315
315
  console.log('');
316
- console.log(dim('Open the link to cancel, renew, update your card, or view invoices. Cancelling takes effect at the end of the billing period — you keep your credits.'));
316
+ console.log(dim('Open the link to cancel, renew, update your card, or view invoices. Cancelling takes effect at the end of the billing period: you keep your credits.'));
317
317
  if (opts.open)
318
318
  openInBrowser(url);
319
319
  }
@@ -5,7 +5,7 @@ import { homedir } from 'os';
5
5
  import { LOCAL_PKG_DIR, LOCAL_ENTRY, STATE_FILE, SETTINGS_FILE, UPDATE_LOG, readState, readSettings, updatesDisabled } from '../updater/state.js';
6
6
  import { bold, dim, success, warning, error as clrError, muted } from '../colors.js';
7
7
  import { getAuth, sessionExpired } from '../auth.js';
8
- import { isClaudeInstalled, probeClaudeAuthenticated, claudeAuthStatus, claudeCredentialHeuristic, claudeLoginHint } from '../claude-setup.js';
8
+ import { isClaudeInstalled, probeClaudeAuthenticated, claudeAuthStatus, claudeCredentialHeuristic } from '../claude-setup.js';
9
9
  import * as relayState from '../relay/state.js';
10
10
  import { planFor, UnsupportedPlatformError } from '../relay/installers.js';
11
11
  import { resolveCliPath } from '../relay/setup.js';
@@ -176,20 +176,19 @@ export const doctorCommand = new Command('doctor')
176
176
  const claudeAccount = env.claude.account ? muted(` (${env.claude.account}${env.claude.method ? ` via ${env.claude.method}` : ''})`) : '';
177
177
  console.log(`${muted('claude code ')} installed ${yn(env.claude.installed)} · authenticated ${yn(env.claude.authenticated)}${claudeAccount}`);
178
178
  if (env.claude.installed && !env.claude.authenticated) {
179
- // The single most common cause of a relay that accepts messages and then
180
- // fails every one of them. Say the fix here rather than making them find
181
- // it from a failed dispatch.
182
- console.log(`${muted(' ')} ${warning(claudeLoginHint())}`);
179
+ console.log(`${muted(' ')} ${warning('Claude Code is not logged in. Run `claude auth login` and sign in.')}`);
183
180
  }
184
- const autostartLabel = env.relay.autostart === null ? muted('n/a') : yn(env.relay.autostart);
185
- console.log(`${muted('relay ')} paired ${yn(env.relay.paired)} · running ${yn(env.relay.running)} · autostart ${autostartLabel}${env.relay.paused ? warning(' · paused') : ''}${env.relay.device ? muted(` (${env.relay.device.name})`) : ''}`);
186
181
  // Codex approves project hooks interactively and stores the decision in
187
182
  // its own opaque state - we can't verify it from here, so surface the
188
183
  // one manual step whenever this project ships Codex hooks.
189
184
  if (existsSync(resolve(process.cwd(), '.codex', 'hooks.json'))) {
190
185
  console.log(`${muted('codex hooks ')} ${warning('written')} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
191
186
  }
192
- console.log(`${muted('ready ')} ${env.ready ? success('yes') : warning('no - run `gipity build` (or the desktop app) to finish setup')}`);
187
+ // The human verdict covers what building needs (node + a live Gipity
188
+ // login). The --json `ready` field keeps its parked-Relay meaning for the
189
+ // archived desktop client.
190
+ const buildReady = env.node.ok && env.gipity.logged_in;
191
+ console.log(`${muted('ready ')} ${buildReady ? success('yes') : warning('no - run `gipity build` to finish setup')}`);
193
192
  // ── CLI install / update health ────────────────────────────────────
194
193
  const state = readState();
195
194
  const settings = readSettings();
@@ -1,62 +1,12 @@
1
1
  import { Command, Option } from 'commander';
2
2
  import { get, post } from '../api.js';
3
3
  import { resolveProjectContext } from '../config.js';
4
- import { error as clrError, success, bold, muted, warning } from '../colors.js';
4
+ import { success, bold, muted, warning } from '../colors.js';
5
5
  import { run } from '../helpers/index.js';
6
- /** Commander collector: build an array from repeated flags (--to a --to b). */
7
- function collect(value, prev) {
8
- return [...prev, value];
9
- }
10
- // `email` is a command GROUP. Agent email is `email send`; the deployed app's
11
- // email() service is exercised via `email test` / `email log`. (Keeping agent
12
- // send under `send` rather than a bare-`email` default action avoids a
13
- // parent/subcommand `--subject` option collision — and matches the `email`
14
- // skill doc, which documents the CLI verb as `gipity email send`.)
6
+ // `email` is a command GROUP for the deployed app's email() service:
7
+ // `email test` sends through it, `email log` lists recent sends.
15
8
  export const emailCommand = new Command('email')
16
- .description("Send email as the agent (send), or test/inspect a deployed app's email() sends (test/log)");
17
- // --- gipity email send ---
18
- // Agent email from gipity@gipity.ai (omit --to to self-send).
19
- emailCommand
20
- .command('send')
21
- .description('Send an email as the agent (from gipity@gipity.ai; omit --to to self-send)')
22
- .requiredOption('--subject <subject>', 'Email subject')
23
- .requiredOption('--body <body>', 'Email body (plain text)')
24
- .option('--to <email>', 'Recipient (repeatable; omit for self-send)', collect, [])
25
- .option('--cc <email>', 'Cc recipient (repeatable)', collect, [])
26
- .option('--bcc <email>', 'Bcc recipient (repeatable)', collect, [])
27
- .option('--reply-to <email>', 'Reply-To header address')
28
- .option('--html <html>', 'Optional HTML body')
29
- .option('--json', 'Output as JSON')
30
- .action(async (opts) => {
31
- try {
32
- await resolveProjectContext();
33
- const payload = { subject: opts.subject, body: opts.body };
34
- if (opts.to.length)
35
- payload.to = opts.to;
36
- if (opts.cc.length)
37
- payload.cc = opts.cc;
38
- if (opts.bcc.length)
39
- payload.bcc = opts.bcc;
40
- if (opts.replyTo)
41
- payload.reply_to = opts.replyTo;
42
- if (opts.html)
43
- payload.html = opts.html;
44
- const res = await post('/agent-email/send', payload);
45
- if (opts.json) {
46
- console.log(JSON.stringify(res.data));
47
- }
48
- else {
49
- const recap = res.data.to.join(', ')
50
- + (res.data.cc.length ? `, cc: ${res.data.cc.join(', ')}` : '')
51
- + (res.data.bcc.length ? `, bcc: ${res.data.bcc.length}` : '');
52
- console.log(success(`Email sent to ${recap}: ${res.data.subject}`));
53
- }
54
- }
55
- catch (err) {
56
- console.error(clrError(`Email failed: ${err.message}`));
57
- process.exit(1);
58
- }
59
- });
9
+ .description("Test and inspect a deployed app's email() sends");
60
10
  // --- gipity email test <to> ---
61
11
  // Exercises the deployed app's email() send path (platform-brokered, owner-billed)
62
12
  // so the agent can verify email works after deploy — the parallel of `notify test`.
@@ -88,7 +38,7 @@ emailCommand
88
38
  else
89
39
  console.log(warning(`Nothing sent (${skipped} skipped).`));
90
40
  for (const r of results) {
91
- console.log(muted(` ${r.to} — ${r.status}${r.reason ? `: ${r.reason}` : ''}`));
41
+ console.log(muted(` ${r.to} - ${r.status}${r.reason ? `: ${r.reason}` : ''}`));
92
42
  }
93
43
  }));
94
44
  // --- gipity email log ---
@@ -117,7 +67,7 @@ emailCommand
117
67
  console.log(bold(`${totals.n} attempt${totals.n === 1 ? '' : 's'} · ${totals.credits} credit${totals.credits === 1 ? '' : 's'}`));
118
68
  for (const r of items) {
119
69
  const when = new Date(r.created_at).toISOString().replace('T', ' ').slice(0, 16);
120
- const to = r.detail?.to ?? '—';
70
+ const to = r.detail?.to ?? '-';
121
71
  const subj = r.detail?.subject ? ` · ${r.detail.subject}` : '';
122
72
  const status = r.detail?.status ? ` [skipped: ${r.detail.status}]` : '';
123
73
  console.log(` ${muted(when)} ${to}${status ? warning(status) : ''}${muted(subj)}`);
@@ -125,13 +125,13 @@ const formatName = (ext) => (canonicalExt(ext) === 'jpg' ? 'JPEG' : ext.toUpperC
125
125
  function correctExtension(filename, buf) {
126
126
  const actual = sniffExt(buf);
127
127
  if (!actual)
128
- return filename; // unrecognized bytes — nothing better to say
128
+ return filename; // unrecognized bytes: nothing better to say
129
129
  const dot = filename.lastIndexOf('.');
130
130
  const asked = dot > 0 ? filename.slice(dot + 1).toLowerCase() : '';
131
131
  if (canonicalExt(asked) === actual)
132
132
  return filename;
133
133
  const corrected = `${dot > 0 ? filename.slice(0, dot) : filename}.${actual}`;
134
- console.error(muted(`Note: the model returned ${formatName(actual)}, not ${asked ? formatName(asked) : 'the requested format'} — `
134
+ console.error(muted(`Note: the model returned ${formatName(actual)}, not ${asked ? formatName(asked) : 'the requested format'}: `
135
135
  + `saving as ${corrected} so the extension matches the actual bytes.`));
136
136
  return corrected;
137
137
  }
@@ -148,7 +148,7 @@ function noteFormatMismatch(filename, buf) {
148
148
  const asked = dot > 0 ? filename.slice(dot + 1).toLowerCase() : '';
149
149
  if (!asked || canonicalExt(asked) === actual)
150
150
  return;
151
- console.error(muted(`Note: ${basename(filename)} holds ${formatName(actual)} bytes though its name ends .${asked} — `
151
+ console.error(muted(`Note: ${basename(filename)} holds ${formatName(actual)} bytes though its name ends .${asked}: `
152
152
  + `that's fine (browsers and image/video/edit tools sniff the bytes, not the name). `
153
153
  + `Saved at the exact path you requested; reference it as-is.`));
154
154
  }
@@ -287,7 +287,7 @@ Examples:
287
287
  });
288
288
  // ── VIDEO ──────────────────────────────────────────────────────────────
289
289
  const videoCommand = new Command('video')
290
- .description('Generate a short video (up to 8 seconds) from a text prompt using Google Veo')
290
+ .description('Generate a short video (up to 8 seconds) from a text prompt')
291
291
  .addHelpText('after', `
292
292
  Models (default: veo-3.1-generate-preview):
293
293
  ${VIDEO_MODELS_TABLE}
@@ -6,9 +6,10 @@ 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, resolveProjectTools } from '../setup.js';
8
8
  import { AGENT_ADAPTERS } from '../agents/index.js';
9
- import { success, error as clrError, info, muted, bold, brand } from '../colors.js';
9
+ import { success, error as clrError, info, muted, bold, brand, warning } from '../colors.js';
10
10
  import { confirm } from '../utils.js';
11
11
  import { scanForAdoption, adoptCurrentDir, canAdoptCwd, formatBytes, formatCwdLabel, ADOPT_THRESHOLDS, } from '../adopt-cwd.js';
12
+ import { ensureDevicePaired } from '../relay/setup.js';
12
13
  const TOOL_KEYS = SUPPORTED_TOOLS.map(t => t.key);
13
14
  /** The tool keys to pin in .gipity.json, or null to leave the project on
14
15
  * auto-detect. Only an explicit `--for` pins: a bare `init` records nothing,
@@ -38,12 +39,22 @@ function resolveTools(forFlag) {
38
39
  // alongside it (`--for all,aider`).
39
40
  return SUPPORTED_TOOLS.filter(t => requested.includes(t.key) || (!t.optIn && requested.includes('all')));
40
41
  }
42
+ /** Recording sessions needs this machine registered as a device. Best-effort:
43
+ * a failure only means sessions aren't recorded yet, so say so and move on. */
44
+ async function pairForCapture() {
45
+ try {
46
+ await ensureDevicePaired();
47
+ }
48
+ catch (err) {
49
+ console.log(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
50
+ }
51
+ }
41
52
  export const initCommand = new Command('init')
42
53
  .description('Link this directory to a project')
43
- .addHelpText('after', `\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks. By default it only sets up the tools actually installed here (${AGENT_ADAPTERS.map(a => a.displayName).join(', ')}, …) - use --for to choose explicitly.`)
54
+ .addHelpText('after', `\nWrites CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks. By default it only sets up the tools actually installed here (${AGENT_ADAPTERS.map(a => a.displayName).join(', ')}, ...) - use --for to choose explicitly.`)
44
55
  .argument('[name]', 'Project name/slug (defaults to current directory name)')
45
- .option('--agent <guid>', 'Agent GUID to use')
46
- .option('--no-capture', 'Don\'t record Claude Code sessions in this directory to your Gipity project (sets captureHooks: false in .gipity.json)')
56
+ .option('--capture', 'Record Claude Code sessions in this directory to your Gipity project (sets captureHooks: true in .gipity.json; new projects start with it off)')
57
+ .option('--no-capture', 'Stop recording sessions in this directory (sets captureHooks: false in .gipity.json)')
47
58
  .option('--for <tools>', `Which AI tool primer files to write (comma-separated). Default: the tools detected on this machine. An explicit --for is remembered in .gipity.json, so later commands don't re-add the others. Choices: ${TOOL_KEYS.join(', ')}, all`)
48
59
  .addHelpText('after', `
49
60
  Examples:
@@ -117,12 +128,10 @@ Working with an existing Gipity project:
117
128
  cur.push(...missing);
118
129
  changed = true;
119
130
  }
120
- // `--no-capture` on a re-init is the documented way to opt an
121
- // existing project out of session recording. One-way from flags:
122
- // a bare re-run never silently reverses an explicit opt-out
123
- // (delete the key or set it true in .gipity.json to re-enable).
124
- if (opts.capture === false && existing.captureHooks !== false) {
125
- existing.captureHooks = false;
131
+ // `--capture` / `--no-capture` on a re-init switch session
132
+ // recording; a bare re-run never changes it.
133
+ if (opts.capture !== undefined && existing.captureHooks !== opts.capture) {
134
+ existing.captureHooks = opts.capture;
126
135
  changed = true;
127
136
  }
128
137
  // An explicit --for re-pins the project. Without persisting it,
@@ -139,8 +148,10 @@ Working with an existing Gipity project:
139
148
  console.log(success(`Refreshed primer files: ${primerSummary}.`));
140
149
  if (skippedNote)
141
150
  console.log(skippedNote);
142
- if (opts.capture === false) {
143
- console.log(success('Session recording disabled for this project (captureHooks: false in .gipity.json).'));
151
+ if (opts.capture !== undefined) {
152
+ if (opts.capture)
153
+ await pairForCapture();
154
+ console.log(success(`Session recording ${opts.capture ? 'enabled' : 'disabled'} for this project (captureHooks: ${opts.capture} in .gipity.json).`));
144
155
  }
145
156
  return;
146
157
  }
@@ -193,7 +204,6 @@ Working with an existing Gipity project:
193
204
  projectSlug,
194
205
  accountSlug,
195
206
  confirmDeletions: true,
196
- agentOverride: opts.agent || undefined,
197
207
  tools,
198
208
  });
199
209
  if (adopted.isNew) {
@@ -204,45 +214,45 @@ Working with an existing Gipity project:
204
214
  }
205
215
  if (adopted.applied > 0)
206
216
  console.log(`Synced ${adopted.applied} change${adopted.applied > 1 ? 's' : ''} with Gipity.`);
207
- // Session recording opt-out. Written after adopt so it lands in the
217
+ // Session recording choice. Written after adopt so it lands in the
208
218
  // freshly created .gipity.json regardless of how the link happened.
209
219
  const pinnedFresh = pinnedToolKeys(opts.for, tools);
210
- if (opts.capture === false || pinnedFresh) {
220
+ if (opts.capture !== undefined || pinnedFresh) {
211
221
  try {
212
222
  const cfg = JSON.parse(readFileSync(resolve(cwd, '.gipity.json'), 'utf-8'));
213
- if (opts.capture === false)
214
- cfg.captureHooks = false;
223
+ if (opts.capture !== undefined)
224
+ cfg.captureHooks = opts.capture;
215
225
  if (pinnedFresh)
216
226
  cfg.tools = pinnedFresh;
217
227
  saveConfigAt(cwd, cfg);
218
228
  }
219
229
  catch { /* config missing/unreadable - nothing to record */ }
220
230
  }
231
+ if (opts.capture)
232
+ await pairForCapture();
221
233
  console.log(success(`Wrote primer files: ${primerSummary}.`));
222
234
  if (skippedNote)
223
235
  console.log(skippedNote);
224
236
  if (wantsClaude) {
225
237
  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.`));
226
- // Recording happens by default (however Claude Code is launched), so
227
- // say so up front - consent should be explicit, not discovered later.
228
- if (opts.capture === false) {
229
- console.log(muted('Session recording is off for this project (captureHooks: false in .gipity.json).'));
230
- }
231
- else {
232
- console.log(muted('Claude Code sessions here are recorded to your Gipity project (view at prompt.gipity.ai). Opt out: gipity init --no-capture.'));
233
- }
238
+ // Say which way session recording is set - consent should be
239
+ // explicit, not discovered later.
240
+ const recording = JSON.parse(readFileSync(resolve(cwd, '.gipity.json'), 'utf-8')).captureHooks !== false;
241
+ console.log(muted(recording
242
+ ? 'Claude Code sessions here are recorded to your Gipity project (Chats in your Gipity dashboard). Turn off: gipity init --no-capture.'
243
+ : 'Claude Code sessions here are not recorded. To keep them in your Gipity project (Chats in your dashboard): gipity init --capture.'));
234
244
  }
235
245
  else {
236
246
  console.log(success('Ready! Open this directory in your AI coding tool.'));
237
247
  }
238
248
  }
239
249
  catch (err) {
240
- // `fetch failed` is Node's TypeError when DNS/connect fails. Translate
241
- // it to something an agent can act on instead of a cryptic stack line.
250
+ // `fetch failed: could not reach <origin> (<cause>)` is a DNS/connect
251
+ // failure (see net.ts). Say what that means for init on top of the cause.
242
252
  const msg = err?.message ?? String(err);
243
- if (msg === 'fetch failed' || /ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN/.test(msg)) {
244
- console.error(clrError('Init failed: could not reach Gipity servers.'));
245
- console.error(muted('Check your network connection and try again. Sandboxed environments often have no outbound network - run this on a machine with internet access.'));
253
+ if (msg.startsWith('fetch failed') || /ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN/.test(msg)) {
254
+ console.error(clrError(`Init failed: could not reach Gipity servers. ${msg}`));
255
+ console.error(muted('Sandboxed environments often have no outbound network (or need HTTPS_PROXY set) - run this on a machine with internet access.'));
246
256
  }
247
257
  else {
248
258
  console.error(clrError(`Init failed: ${msg}`));
@@ -72,7 +72,7 @@ keyCommand
72
72
  .option('--json', 'Output as JSON')
73
73
  .action((opts) => run('List', async () => {
74
74
  const res = await get(`/projects/${await projectGuid(opts)}/api-keys`);
75
- printList(res.data, opts, 'No API keys. Mint one with: gipity key create "my script" --role editor', (k) => `${bold(k.short_guid)} ${k.name} ${muted(`${k.role} ${k.prefix}… last used ${fmtDate(k.last_used_at)} expires ${fmtDate(k.expires_at)}`)}`);
75
+ printList(res.data, opts, 'No API keys. Mint one with: gipity key create "my script" --role editor', (k) => `${bold(k.short_guid)} ${k.name} ${muted(`${k.role} ${k.prefix}... last used ${fmtDate(k.last_used_at)} expires ${fmtDate(k.expires_at)}`)}`);
76
76
  }));
77
77
  keyCommand
78
78
  .command('revoke <short_guid>')
@@ -18,7 +18,7 @@ import fs from 'fs';
18
18
  import os from 'os';
19
19
  import path from 'path';
20
20
  import { Command } from 'commander';
21
- import { get, post, postBinary, getAccountSlug } from '../api.js';
21
+ import { post, postBinary, getAccountSlug } from '../api.js';
22
22
  import { success, muted, warning, bold, info, brand } from '../colors.js';
23
23
  import { run } from '../helpers/index.js';
24
24
  import { withSpinner } from '../progress.js';
@@ -170,25 +170,15 @@ export const loadCommand = new Command('load')
170
170
  const dir = path.join(getProjectsRoot(), project.slug);
171
171
  fs.mkdirSync(dir, { recursive: true });
172
172
  const accountSlug = await getAccountSlug();
173
- // Resolve the first assigned agent (if any) - not fatal if missing.
174
- let agentGuid = '';
175
- try {
176
- const agents = await get(`/projects/${project.short_guid}/agents`);
177
- if (agents.data.length > 0)
178
- agentGuid = agents.data[0].short_guid;
179
- }
180
- catch {
181
- // offline or no agents - non-fatal
182
- }
183
173
  const { applied } = await finalizeLocalProject({
184
174
  dir,
185
175
  projectGuid: project.short_guid,
186
176
  projectSlug: project.slug,
187
177
  projectName: project.name,
188
178
  accountSlug,
189
- agentGuid,
190
179
  sync: 'soft',
191
180
  interactive: false,
181
+ json: !!opts.json,
192
182
  });
193
183
  if (opts.json) {
194
184
  console.log(JSON.stringify({