gipity 1.1.22 → 1.1.24

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.
@@ -2,12 +2,12 @@ import { Command } from 'commander';
2
2
  import { basename, resolve, dirname } from 'path';
3
3
  import { existsSync, readFileSync } from 'fs';
4
4
  import { getAccountSlug } from '../api.js';
5
- import { getConfig, getConfigPath, saveConfigAt } from '../config.js';
5
+ import { getConfig, getConfigPath, saveConfigAt, captureEnabled } 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
9
  import { success, error as clrError, info, muted, bold, brand, warning } from '../colors.js';
10
- import { confirm } from '../utils.js';
10
+ import { confirm, getAutoConfirm, rerunWithYes } from '../utils.js';
11
11
  import { scanForAdoption, adoptCurrentDir, canAdoptCwd, formatBytes, formatCwdLabel, ADOPT_THRESHOLDS, } from '../adopt-cwd.js';
12
12
  import { ensureDevicePaired } from '../relay/setup.js';
13
13
  const TOOL_KEYS = SUPPORTED_TOOLS.map(t => t.key);
@@ -41,12 +41,12 @@ function resolveTools(forFlag) {
41
41
  }
42
42
  /** Recording sessions needs this machine registered as a device. Best-effort:
43
43
  * a failure only means sessions aren't recorded yet, so say so and move on. */
44
- async function pairForCapture() {
44
+ async function pairForCapture(log) {
45
45
  try {
46
46
  await ensureDevicePaired();
47
47
  }
48
48
  catch (err) {
49
- console.log(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
49
+ log(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
50
50
  }
51
51
  }
52
52
  export const initCommand = new Command('init')
@@ -56,6 +56,7 @@ export const initCommand = new Command('init')
56
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
57
  .option('--no-capture', 'Stop recording sessions in this directory (sets captureHooks: false in .gipity.json)')
58
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`)
59
+ .option('--json', 'Output a structured result as JSON (confirmations need -y; notes go to stderr)')
59
60
  .addHelpText('after', `
60
61
  Examples:
61
62
  $ gipity init Link cwd as a new project (slug = dir name);
@@ -79,6 +80,22 @@ Working with an existing Gipity project:
79
80
  $ gipity sync Pull the project's files down.
80
81
  `)
81
82
  .action(async (name, opts) => {
83
+ // JSON mode: stdout carries only the final result object. Human progress
84
+ // lines are dropped, warnings go to stderr, and the y/N confirmations
85
+ // can't share stdout, so they need -y up front.
86
+ const json = !!opts.json;
87
+ const say = (line) => { if (!json)
88
+ console.log(line); };
89
+ const note = (line) => { (json ? console.error : console.log)(line); };
90
+ const ask = async (question, def) => {
91
+ if (!json)
92
+ return confirm(question, { default: def });
93
+ if (getAutoConfirm())
94
+ return true;
95
+ console.error(clrError(`Confirmation required in --json mode: ${question}`));
96
+ console.error(`Re-run with --yes:\n ${rerunWithYes()}`);
97
+ process.exit(1);
98
+ };
82
99
  // Resolve the requested tool primer set up front so a bad --for value
83
100
  // fails fast with a clear message instead of going through the catch.
84
101
  let tools;
@@ -113,7 +130,7 @@ Working with an existing Gipity project:
113
130
  // shadowed by a parent project's config the way walk-up commands are.
114
131
  if (existsSync(resolve(cwd, '.gipity.json'))) {
115
132
  const existing = getConfig();
116
- console.log(`Already linked to ${info(`"${existing?.projectSlug ?? ''}"`)} ${muted(`(${existing?.projectGuid ?? ''})`)}`);
133
+ say(`Already linked to ${info(`"${existing?.projectSlug ?? ''}"`)} ${muted(`(${existing?.projectGuid ?? ''})`)}`);
117
134
  // Re-run setup in case primers/hooks/skills are missing - each tool's
118
135
  // integration self-gates on its binary and current-version state.
119
136
  setupProjectTools(tools);
@@ -145,13 +162,25 @@ Working with an existing Gipity project:
145
162
  if (changed)
146
163
  saveConfigAt(cwd, existing);
147
164
  }
148
- console.log(success(`Refreshed primer files: ${primerSummary}.`));
165
+ if (json) {
166
+ if (opts.capture)
167
+ await pairForCapture(note);
168
+ console.log(JSON.stringify({
169
+ linked: true, alreadyLinked: true, created: false,
170
+ project: { guid: existing?.projectGuid ?? null, slug: existing?.projectSlug ?? null },
171
+ dir: cwd, synced: 0,
172
+ primers: tools.map(t => t.key), skippedTools: skipped.map(t => t.key),
173
+ captureHooks: captureEnabled(existing ?? null),
174
+ }));
175
+ return;
176
+ }
177
+ say(success(`Refreshed primer files: ${primerSummary}.`));
149
178
  if (skippedNote)
150
- console.log(skippedNote);
179
+ say(skippedNote);
151
180
  if (opts.capture !== undefined) {
152
181
  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).`));
182
+ await pairForCapture(note);
183
+ say(success(`Session recording ${opts.capture ? 'enabled' : 'disabled'} for this project (captureHooks: ${opts.capture} in .gipity.json).`));
155
184
  }
156
185
  return;
157
186
  }
@@ -165,10 +194,10 @@ Working with an existing Gipity project:
165
194
  // Heads-up if this would create a project nested inside an existing one.
166
195
  const ancestorConfigPath = getConfigPath();
167
196
  if (ancestorConfigPath) {
168
- console.log(muted(`Note: ${formatCwdLabel(dirname(ancestorConfigPath))} is already a Gipity project.`));
169
- const ok = await confirm(`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`, { default: 'no' });
197
+ note(muted(`Note: ${formatCwdLabel(dirname(ancestorConfigPath))} is already a Gipity project.`));
198
+ const ok = await ask(`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`, 'no');
170
199
  if (!ok) {
171
- console.log(muted('Aborted.'));
200
+ say(muted('Aborted.'));
172
201
  process.exit(1);
173
202
  }
174
203
  }
@@ -191,9 +220,9 @@ Working with an existing Gipity project:
191
220
  process.exit(1);
192
221
  }
193
222
  if (scan.tier === 'moderate') {
194
- const ok = await confirm(`About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`, { default: 'yes' });
223
+ const ok = await ask(`About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`, 'yes');
195
224
  if (!ok) {
196
- console.log(muted('Aborted.'));
225
+ say(muted('Aborted.'));
197
226
  process.exit(1);
198
227
  }
199
228
  }
@@ -203,17 +232,19 @@ Working with an existing Gipity project:
203
232
  projectName,
204
233
  projectSlug,
205
234
  accountSlug,
206
- confirmDeletions: true,
235
+ // No y/N on stdout in JSON mode: a non-interactive sync fails safe
236
+ // (aborts rather than deleting) instead of asking.
237
+ confirmDeletions: !json,
207
238
  tools,
208
239
  });
209
240
  if (adopted.isNew) {
210
- console.log(success(`Created project "${adopted.project.name}" (${adopted.project.slug})`));
241
+ say(success(`Created project "${adopted.project.name}" (${adopted.project.slug})`));
211
242
  }
212
243
  else {
213
- console.log(`Found existing project ${info(`"${adopted.project.name}"`)} ${muted(`(${adopted.project.slug})`)}`);
244
+ say(`Found existing project ${info(`"${adopted.project.name}"`)} ${muted(`(${adopted.project.slug})`)}`);
214
245
  }
215
246
  if (adopted.applied > 0)
216
- console.log(`Synced ${adopted.applied} change${adopted.applied > 1 ? 's' : ''} with Gipity.`);
247
+ say(`Synced ${adopted.applied} change${adopted.applied > 1 ? 's' : ''} with Gipity.`);
217
248
  // Session recording choice. Written after adopt so it lands in the
218
249
  // freshly created .gipity.json regardless of how the link happened.
219
250
  const pinnedFresh = pinnedToolKeys(opts.for, tools);
@@ -229,21 +260,32 @@ Working with an existing Gipity project:
229
260
  catch { /* config missing/unreadable - nothing to record */ }
230
261
  }
231
262
  if (opts.capture)
232
- await pairForCapture();
233
- console.log(success(`Wrote primer files: ${primerSummary}.`));
263
+ await pairForCapture(note);
264
+ if (json) {
265
+ const cfg = JSON.parse(readFileSync(resolve(cwd, '.gipity.json'), 'utf-8'));
266
+ console.log(JSON.stringify({
267
+ linked: true, alreadyLinked: false, created: adopted.isNew,
268
+ project: { guid: adopted.project.short_guid, slug: adopted.project.slug, name: adopted.project.name },
269
+ dir: cwd, synced: adopted.applied,
270
+ primers: tools.map(t => t.key), skippedTools: skipped.map(t => t.key),
271
+ captureHooks: captureEnabled(cfg),
272
+ }));
273
+ return;
274
+ }
275
+ say(success(`Wrote primer files: ${primerSummary}.`));
234
276
  if (skippedNote)
235
- console.log(skippedNote);
277
+ say(skippedNote);
236
278
  if (wantsClaude) {
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.`));
279
+ say(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map(a => a.key).join(', ')}), or \`gipity build\` to launch one with a picker.`));
238
280
  // Say which way session recording is set - consent should be
239
281
  // explicit, not discovered later.
240
282
  const recording = JSON.parse(readFileSync(resolve(cwd, '.gipity.json'), 'utf-8')).captureHooks !== false;
241
- console.log(muted(recording
283
+ say(muted(recording
242
284
  ? 'Claude Code sessions here are recorded to your Gipity project (Chats in your Gipity dashboard). Turn off: gipity init --no-capture.'
243
285
  : 'Claude Code sessions here are not recorded. To keep them in your Gipity project (Chats in your dashboard): gipity init --capture.'));
244
286
  }
245
287
  else {
246
- console.log(success('Ready! Open this directory in your AI coding tool.'));
288
+ say(success('Ready! Open this directory in your AI coding tool.'));
247
289
  }
248
290
  }
249
291
  catch (err) {
@@ -312,6 +312,7 @@ jobCommand
312
312
  .description('Run the job in a local Docker container against your local filesystem (no platform round-trip)')
313
313
  .option('--image <image>', 'Docker image to run inside', 'easyclaw/sandbox:latest')
314
314
  .option('--no-deps', 'Skip pip/npm install even if a deps file is present')
315
+ .option('--json', "Capture the job's output and print one JSON result (exitCode, stdout, stderr) instead of streaming it")
315
316
  .action(async (name, opts) => {
316
317
  const { existsSync, statSync } = await import('node:fs');
317
318
  const { resolve, join } = await import('node:path');
@@ -362,7 +363,13 @@ jobCommand
362
363
  shellCmd = `echo '[run-local] running ${handlerCmd} (${picked.runtime})' >&2 && exec ${handlerCmd}`;
363
364
  }
364
365
  const runArgs = ['run', ...sharedArgs, '--entrypoint', 'sh', opts.image, '-c', shellCmd];
365
- const child = spawnCommand('docker', runArgs, { stdio: 'inherit' });
366
+ const startedAt = Date.now();
367
+ const child = spawnCommand('docker', runArgs, { stdio: opts.json ? ['ignore', 'pipe', 'pipe'] : 'inherit' });
368
+ const captured = { stdout: '', stderr: '' };
369
+ if (opts.json) {
370
+ child.stdout?.on('data', (d) => { captured.stdout += d.toString(); });
371
+ child.stderr?.on('data', (d) => { captured.stderr += d.toString(); });
372
+ }
366
373
  // A missing `docker` binary is reported asynchronously via 'error' (not a
367
374
  // throw), so a try/catch can't stop it - without this handler Node crashes
368
375
  // with a raw stack trace instead of a clear message.
@@ -372,7 +379,16 @@ jobCommand
372
379
  : `Failed to launch docker: ${err.message}`));
373
380
  process.exit(1);
374
381
  });
375
- child.on('exit', (code) => {
382
+ // 'close' (not 'exit') so the captured pipes are fully drained in JSON mode.
383
+ child.on('close', (code) => {
384
+ if (opts.json) {
385
+ console.log(JSON.stringify({
386
+ name, runtime: picked.runtime, image: opts.image,
387
+ exitCode: code, durationMs: Date.now() - startedAt,
388
+ stdout: captured.stdout, stderr: captured.stderr,
389
+ }));
390
+ process.exit(code ?? 1);
391
+ }
376
392
  if (code === 0)
377
393
  console.error(muted(`[run-local] ${success('done')}`));
378
394
  else
@@ -9,27 +9,39 @@ export const loginCommand = new Command('login')
9
9
  .description('Log in or sign up')
10
10
  .option('--email <email>', 'Email address')
11
11
  .option('--code <code>', 'Verification code')
12
+ .option('--json', 'Output as JSON (prompts and warnings go to stderr)')
12
13
  .action(async (opts) => {
14
+ const json = !!opts.json;
15
+ // In JSON mode stdout carries only the final result object; every human
16
+ // line (instructions, prompts, new-account warnings) goes to stderr.
17
+ const say = json ? (line) => console.error(line) : (line) => console.log(line);
18
+ const promptOut = json ? process.stderr : process.stdout;
13
19
  try {
14
20
  let email = opts.email;
15
21
  let code = opts.code;
16
22
  // Both provided → verify immediately (non-interactive, ideal for scripts/CC)
17
23
  if (email && code) {
18
- await verify(email, code);
24
+ await verify(email, code, json, say);
19
25
  return;
20
26
  }
21
27
  // Email only → send code and exit (non-interactive step 1)
22
28
  if (email && !code) {
23
29
  const sendRes = await publicPost('/auth/login', { email });
24
- console.log('Check your email for a 6-digit code.');
25
- console.log(muted(`Then run: gipity login --email ${email} --code <code>`));
26
- warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email);
30
+ const next = `gipity login --email ${email} --code <code>`;
31
+ if (json) {
32
+ console.log(JSON.stringify({ codeSent: true, email, newAccount: sendRes.isNewUser === true, next }));
33
+ }
34
+ else {
35
+ console.log('Check your email for a 6-digit code.');
36
+ console.log(muted(`Then run: ${next}`));
37
+ }
38
+ warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email, '', say);
27
39
  return;
28
40
  }
29
41
  // Fully interactive flow
30
- console.log('Enter your email to log in or create an account.');
42
+ say('Enter your email to log in or create an account.');
31
43
  const existing = getAuth();
32
- email = await prompt(existing ? `Email [${existing.email}]: ` : 'Email: ');
44
+ email = await prompt(existing ? `Email [${existing.email}]: ` : 'Email: ', promptOut);
33
45
  if (!email && existing)
34
46
  email = existing.email;
35
47
  if (!email) {
@@ -37,18 +49,18 @@ export const loginCommand = new Command('login')
37
49
  process.exit(1);
38
50
  }
39
51
  const sendRes = await publicPost('/auth/login', { email });
40
- console.log('');
41
- console.log('Check your email for a 6-digit code.');
42
- warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email);
43
- code = await prompt('Code: ');
44
- await verify(email, code);
52
+ say('');
53
+ say('Check your email for a 6-digit code.');
54
+ warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email, '', say);
55
+ code = await prompt('Code: ', promptOut);
56
+ await verify(email, code, json, say);
45
57
  }
46
58
  catch (err) {
47
59
  console.error(clrError(`Login failed: ${err.message}`));
48
60
  process.exit(1);
49
61
  }
50
62
  });
51
- async function verify(email, code) {
63
+ async function verify(email, code, json, say) {
52
64
  const priorAuth = getAuth();
53
65
  const res = await publicPost('/auth/verify', { email, code });
54
66
  const exp = decodeJwtExp(res.accessToken);
@@ -63,11 +75,16 @@ async function verify(email, code) {
63
75
  email,
64
76
  expiresAt,
65
77
  });
66
- console.log(success(`Logged in (${email}).`));
67
- warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth);
78
+ if (!json)
79
+ console.log(success(`Logged in (${email}).`));
80
+ warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth, '', say);
68
81
  // A fresh session is the clearest "we're reconnected" signal - clear any bug
69
82
  // reports that got stranded while this account's session was expired/offline.
70
83
  const delivered = await flushBugQueue().catch(() => 0);
84
+ if (json) {
85
+ console.log(JSON.stringify({ loggedIn: true, email, newAccount: res.isNewUser === true, expiresAt, queuedBugReportsDelivered: delivered }));
86
+ return;
87
+ }
71
88
  if (delivered > 0) {
72
89
  console.log(muted(`Delivered ${delivered} queued bug report${delivered === 1 ? '' : 's'}.`));
73
90
  }
@@ -3,14 +3,15 @@ import { getAuth, clearAuth } from '../auth.js';
3
3
  import { success } from '../colors.js';
4
4
  export const logoutCommand = new Command('logout')
5
5
  .description('Log out')
6
- .action(() => {
6
+ .option('--json', 'Output as JSON')
7
+ .action((opts) => {
7
8
  const auth = getAuth();
8
- if (!auth) {
9
- console.log('Not logged in.');
10
- }
11
- else {
9
+ if (auth)
12
10
  clearAuth();
13
- console.log(success(`Logged out (${auth.email}).`));
11
+ if (opts.json) {
12
+ console.log(JSON.stringify({ loggedOut: !!auth, email: auth?.email ?? null }));
13
+ return;
14
14
  }
15
+ console.log(auth ? success(`Logged out (${auth.email}).`) : 'Not logged in.');
15
16
  });
16
17
  //# sourceMappingURL=logout.js.map
@@ -7,6 +7,7 @@ export const pushCommand = new Command('push')
7
7
  .argument('<files...>', 'File path(s) to push')
8
8
  .option('--quiet', 'Suppress output')
9
9
  .option('--background', 'Fork and exit immediately')
10
+ .option('--json', 'Output as JSON')
10
11
  .action(async (files, opts) => {
11
12
  try {
12
13
  const fullPaths = files.map(f => resolve(f));
@@ -22,15 +23,22 @@ export const pushCommand = new Command('push')
22
23
  stdio: 'ignore',
23
24
  });
24
25
  child.unref();
26
+ if (opts.json)
27
+ console.log(JSON.stringify({ background: true, files }));
25
28
  return;
26
29
  }
27
30
  // Sequential on purpose: pushFile takes the per-project sync lock, so
28
31
  // parallel pushes would just contend on it. One process pushing N files
29
32
  // still beats the old N processes × N lock acquisitions.
30
- for (const fullPath of fullPaths) {
31
- await pushFile(fullPath);
33
+ const pushed = [];
34
+ const skipped = [];
35
+ for (let i = 0; i < fullPaths.length; i++) {
36
+ (await pushFile(fullPaths[i]) ? pushed : skipped).push(files[i]);
32
37
  }
33
- if (!opts.quiet) {
38
+ if (opts.json) {
39
+ console.log(JSON.stringify({ pushed, skipped }));
40
+ }
41
+ else if (!opts.quiet) {
34
42
  console.log(success(files.length === 1 ? `Pushed ${files[0]}` : `Pushed ${files.length} files`));
35
43
  }
36
44
  }
@@ -53,6 +53,7 @@ rbacCommand
53
53
  .description('Delete a policy')
54
54
  .requiredOption('--role <role>', 'Role')
55
55
  .requiredOption('--op <operation>', 'Operation')
56
+ .option('--json', 'Output as JSON')
56
57
  .action((table, opts) => run('Delete', async () => {
57
58
  if (!await confirm(`Delete RBAC policy for "${table}"?`)) {
58
59
  console.log('Cancelled.');
@@ -64,6 +65,6 @@ rbacCommand
64
65
  role: opts.role,
65
66
  operation: opts.op,
66
67
  });
67
- printResult('Policy deleted.', { json: false });
68
+ printResult('Policy deleted.', opts, { success: true, table, role: opts.role, operation: opts.op });
68
69
  }));
69
70
  //# sourceMappingURL=rbac.js.map
@@ -29,6 +29,7 @@ const roomCommand = new Command('room')
29
29
  .option('--host-hold <seconds>', 'create: how long the host role waits for a dropped or reloading host (0-600, default 60)')
30
30
  .option('--host-handoff', 'create: move the host role to another player when the host is gone')
31
31
  .option('--host-grace <seconds>', 'create: with handoff, how long the host may be unreachable before the role moves (1-60, default 5)')
32
+ .option('--server-channels <names>', 'create: comma-separated channels only the app\'s functions may publish on (realtime.publish)')
32
33
  .option('--json', 'Output as JSON')
33
34
  .action((action, name, opts) => run('Realtime room', async () => {
34
35
  const config = requireConfig();
@@ -56,6 +57,9 @@ const roomCommand = new Command('room')
56
57
  body.host_handoff = true;
57
58
  if (opts.hostGrace !== undefined)
58
59
  body.host_grace_seconds = Number(opts.hostGrace);
60
+ if (opts.serverChannels !== undefined) {
61
+ body.server_channels = String(opts.serverChannels).split(',').map((c) => c.trim()).filter(Boolean);
62
+ }
59
63
  const res = await post(base, body);
60
64
  if (opts.json) {
61
65
  console.log(JSON.stringify(res.data));
@@ -108,6 +112,8 @@ const roomCommand = new Command('room')
108
112
  console.log(`Max clients: ${room.max_clients}`);
109
113
  console.log(`Seat hold: ${room.config?.seat_hold_seconds ?? 30}s (host ${room.config?.host_hold_seconds ?? 60}s)`);
110
114
  console.log(`Handoff: ${room.config?.host_handoff ? `on, after ${room.config?.host_grace_seconds ?? 5}s` : 'off'}`);
115
+ const serverChannels = Array.isArray(room.config?.server_channels) ? room.config.server_channels : [];
116
+ console.log(`Server-only: ${serverChannels.length ? serverChannels.join(', ') : 'none'}`);
111
117
  console.log(`Live: ${live ? `${live.instances} instance(s), ${live.clients} client(s)` : muted('Gipity Realtime unreachable')}`);
112
118
  }
113
119
  break;
@@ -48,17 +48,21 @@ recordsCommand
48
48
  }));
49
49
  recordsCommand
50
50
  .command('config <table>')
51
- .description('Show or set a table\'s Records API config (auth level, search, etc.)')
52
- .addOption(new Option('--auth <level>', 'Auth level: public (anonymous writes), member (sign-in), or user').choices(['public', 'member', 'user']))
51
+ .description('Show or set a table\'s Records API config (auth level, search, auto-numbering, etc.)')
52
+ .addOption(new Option('--auth <level>', 'Auth level: public (anonymous writes), user (any signed-in caller), or member (owner and project members only)').choices(['public', 'member', 'user']))
53
53
  .option('--searchable <bool>', 'Enable full-text search (true/false)')
54
54
  .option('--primary-key <col>', 'Primary key column (default: id)')
55
55
  .option('--soft-delete <col>', 'Soft-delete column (pass "none" to clear)')
56
+ .option('--auto-number <prefix>', 'Number new records automatically, e.g. INC -> INC0001001 (pass "none" to turn off). Same as auto_number in gipity.yaml')
57
+ .option('--auto-number-pad <n>', 'Zero-pad width of the auto-number (default 7)')
58
+ .option('--auto-number-column <col>', 'Column the auto-number is written to (default: number)')
56
59
  .option('--json', 'Output as JSON')
57
60
  .action((table, opts) => run('Config', async () => {
58
61
  const config = requireConfig();
59
62
  const base = `/api/${config.projectGuid}/records/${table}/config`;
60
63
  // No setter flags → just show the current config.
61
- const setting = opts.auth || opts.searchable !== undefined || opts.primaryKey || opts.softDelete;
64
+ const setting = opts.auth || opts.searchable !== undefined || opts.primaryKey || opts.softDelete
65
+ || opts.autoNumber || opts.autoNumberPad || opts.autoNumberColumn;
62
66
  if (!setting) {
63
67
  const res = await get(base);
64
68
  printResult(JSON.stringify(res.data, null, 2), opts, res.data);
@@ -73,8 +77,22 @@ recordsCommand
73
77
  body.primary_key_column = opts.primaryKey;
74
78
  if (opts.softDelete)
75
79
  body.soft_delete_column = opts.softDelete === 'none' ? null : opts.softDelete;
80
+ if (opts.autoNumber)
81
+ body.auto_number_prefix = opts.autoNumber === 'none' ? null : opts.autoNumber;
82
+ if (opts.autoNumberPad) {
83
+ const pad = Number(opts.autoNumberPad);
84
+ if (!Number.isInteger(pad))
85
+ throw new Error(`--auto-number-pad must be a whole number (got '${opts.autoNumberPad}')`);
86
+ body.auto_number_pad = pad;
87
+ }
88
+ if (opts.autoNumberColumn)
89
+ body.auto_number_column = opts.autoNumberColumn;
76
90
  const res = await patch(base, body);
77
- printResult(`Configured "${table}": auth=${res.data.auth_level}, searchable=${res.data.searchable}, pk=${res.data.primary_key_column}`, opts, res.data);
91
+ const d = res.data;
92
+ const autoNumber = d.auto_number_prefix
93
+ ? `${d.auto_number_prefix} (pad ${d.auto_number_pad}, column ${d.auto_number_column})`
94
+ : 'off';
95
+ printResult(`Configured "${table}": auth=${d.auth_level}, searchable=${d.searchable}, pk=${d.primary_key_column}, auto-number=${autoNumber}`, opts, d);
78
96
  }));
79
97
  recordsCommand
80
98
  .command('query <table>')
@@ -64,7 +64,7 @@ export function anonBillingHint(name, err) {
64
64
  `visitor to a public page is asked to sign in and pay from their own credits. If this app serves the ` +
65
65
  `public (a help bubble, a landing page), switch it to owner-pays in gipity.yaml and redeploy:\n` +
66
66
  ` deploy:\n phases:\n - services\n service_definitions:\n - service: ${service}\n billing_mode: owner_pays\n` +
67
- ` gipity deploy dev --only services`);
67
+ ` gipity deploy --only services`);
68
68
  }
69
69
  serviceCommand
70
70
  .command('call <name> [body]')
@@ -110,7 +110,7 @@ serviceCommand
110
110
  const headers = await mintAppToken(config.projectGuid);
111
111
  if (!headers) {
112
112
  throw new Error(`Could not mint a visitor token for this project, so there is no anonymous path to call. ` +
113
- `That means the app is not deployed on this API base yet: run \`gipity deploy dev\` first, ` +
113
+ `That means the app is not deployed on this API base yet: run \`gipity deploy\` first, ` +
114
114
  `then re-run this command.`);
115
115
  }
116
116
  res = await publicRequest(opts.get ? 'GET' : 'POST', url, opts.get ? undefined : body, headers, LONG_REQUEST_TIMEOUT_MS);
@@ -91,6 +91,7 @@ export const statusCommand = new Command('status')
91
91
  apiBase: config.apiBase,
92
92
  apiBaseInUse,
93
93
  url: liveUrl(config),
94
+ ...(config.env ? { env: config.env.name } : {}),
94
95
  } : null,
95
96
  // `valid` reflects the refresh token (the real session) - access
96
97
  // tokens auto-renew, so their expiry must not read as "invalid".
@@ -115,6 +116,8 @@ export const statusCommand = new Command('status')
115
116
  else {
116
117
  console.log(`${muted('Project:')} ${brand(config.projectSlug)} ${muted(`(${config.projectGuid})`)}`);
117
118
  console.log(`${muted('Account:')} ${config.accountSlug}`);
119
+ if (config.env)
120
+ console.log(`${muted('Env:')} ${config.env.name}`);
118
121
  console.log(`${muted('Live:')} ${liveUrl(config)}`);
119
122
  console.log(`${muted('API:')} ${config.apiBase}`);
120
123
  // apiBase is only what THIS project recorded - resolveApiBase() is what
@@ -247,15 +247,15 @@ export const testCommand = new Command('test')
247
247
  }
248
248
  console.log('');
249
249
  }
250
- // Tests call functions against the DEPLOYED build, so a function written
251
- // but not yet deployed 404s. That ordering (deploy → test) is invisible in
252
- // a bare 404, so when we see that failure shape, name the fix once.
250
+ // `gipity test` registers the working-tree functions/ before every run,
251
+ // so a 404 from ctx.fn.call means there is no such function file (or it
252
+ // failed to register). Name that once instead of a bare 404 per test.
253
253
  const undeployed = undeployedFunctionsFromFailures(data.results);
254
254
  if (undeployed.length > 0) {
255
255
  const list = undeployed.map((n) => `'${n}'`).join(', ');
256
- console.log(warning(`${undeployed.length === 1 ? 'Function' : 'Functions'} ${list} 404'd: tests call functions against the ` +
257
- `DEPLOYED build, and ${undeployed.length === 1 ? 'this one is' : 'these are'} not deployed yet.`));
258
- console.log(muted('Deploy first, then re-run: gipity deploy dev && gipity test'));
256
+ console.log(warning(`${undeployed.length === 1 ? 'Function' : 'Functions'} ${list} 404'd: \`gipity test\` registers every file in ` +
257
+ `functions/ before the run, so ${undeployed.length === 1 ? 'that name has' : 'those names have'} no function file, or failed to register.`));
258
+ console.log(muted('Check the name against functions/<name>.js (or functions/<name>/index.js) and gipity.yaml.'));
259
259
  console.log('');
260
260
  }
261
261
  // Summary