gipity 1.1.27 → 1.1.29

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.
@@ -140,11 +140,11 @@ export async function inspectPage(url, opts = {}) {
140
140
  // dropped above with every other attributed failure).
141
141
  b.failedResources = (b.failedResources || []).filter((r) => !isPlatformLog(r));
142
142
  // Pull message-less cross-origin "Script error." lines out first. They carry
143
- // no source/stack, so they're never actionable as app-code defects, and on a
144
- // Gipity-deployed page the platform's own injected SDK is itself a
145
- // cross-origin script — so these are reported separately (not as app console
146
- // errors, and not folded into the re-probe count) instead of misleading the
147
- // agent into chasing its own code.
143
+ // no source/stack: the app's own scripts and the Gipity SDK (loaded with
144
+ // crossorigin) always report full messages, so what remains is a third-party
145
+ // script loaded without CORS. Reported separately (not folded into the
146
+ // re-probe count), with a pointer to page eval so the agent still checks
147
+ // that the page works.
148
148
  const crossOriginErrors = (b.console || []).filter(isMessagelessCrossOrigin);
149
149
  b.console = (b.console || []).filter((l) => !isMessagelessCrossOrigin(l));
150
150
  // Self-verify the remaining console errors before flagging them. A
@@ -235,7 +235,7 @@ export async function inspectPage(url, opts = {}) {
235
235
  // ── Cross-origin console errors (message-less; source hidden by the browser) ──
236
236
  if (crossOriginErrors.length > 0) {
237
237
  console.log(`\n${bold('Cross-origin console errors')} ${muted(`(${crossOriginErrors.length}, source hidden by the browser)`)}:`);
238
- console.log(muted("Message-less: the throwing <script> lacks CORS, so the browser hides its source and there's no own-code stack to chase. Gipity's injected SDK is itself cross-origin, so if your app loads no third-party CDN scripts these are platform noise; ignore them. If your app DOES load a third-party <script>, add crossorigin=\"anonymous\" to that tag to surface the real error."));
238
+ console.log(muted("Message-less: a <script> loaded without CORS threw, so the browser hides the message. Your own scripts and the Gipity SDK report full errors, so this is a third-party <script> (e.g. a CDN): add crossorigin=\"anonymous\" to that tag to see the real error. Don't assume it's harmless: confirm the page works with gipity page eval <url> \"<expr>\"."));
239
239
  }
240
240
  // ── Failed Resources ──
241
241
  // Browsers auto-request /favicon.ico at the site root for every page, so a
@@ -0,0 +1,221 @@
1
+ import { readFileSync } from 'fs';
2
+ import { get, put, del } from '../api.js';
3
+ import { requireConfig } from '../config.js';
4
+ import { error as clrError, muted, success, warning, bold } from '../colors.js';
5
+ import { run, printResult } from '../helpers/index.js';
6
+ const AUTH_MODES = ['gipity', 'app', 'both'];
7
+ const PROVIDERS = ['google', 'apple', 'discord'];
8
+ const PROVIDER_LABEL = { google: 'Google', apple: 'Apple', discord: 'Discord' };
9
+ function fail(msg) {
10
+ console.error(clrError(msg));
11
+ process.exit(1);
12
+ }
13
+ function credentialsLabel(p) {
14
+ if (p.credentials === 'own')
15
+ return 'own';
16
+ if (p.credentials === 'shared')
17
+ return 'shared (Gipity)';
18
+ return 'not set';
19
+ }
20
+ function formatStatus(s) {
21
+ const lines = [
22
+ `Sign-in: ${s.auth_mode}`,
23
+ `Unique names: ${s.unique_player_names ? 'on' : 'off'}`,
24
+ `Email codes: ${s.email_code ? 'on' : 'off'}`,
25
+ '',
26
+ ];
27
+ const rows = s.providers.map(p => [PROVIDER_LABEL[p.provider] ?? p.provider, credentialsLabel(p), p.note ?? '']);
28
+ const w0 = Math.max('Provider'.length, ...rows.map(r => r[0].length));
29
+ const w1 = Math.max('Credentials'.length, ...rows.map(r => r[1].length));
30
+ lines.push(bold(`${'Provider'.padEnd(w0)} ${'Credentials'.padEnd(w1)} Note`));
31
+ for (const r of rows)
32
+ lines.push(`${r[0].padEnd(w0)} ${r[1].padEnd(w1)} ${muted(r[2])}`.trimEnd());
33
+ for (const w of s.warnings)
34
+ lines.push('', warning(w));
35
+ lines.push('', muted('Set up a provider: gipity project auth provider <google|apple|discord>'));
36
+ return lines.join('\n');
37
+ }
38
+ const SETUP_STEPS = {
39
+ google: r => [
40
+ 'Google Cloud console > APIs & Services > Credentials > Create credentials > OAuth client ID.',
41
+ 'Application type: Web application.',
42
+ `Under "Authorized redirect URIs" add: ${r}`,
43
+ 'Copy the client ID and client secret.',
44
+ 'APIs & Services > OAuth consent screen: set your app name and logo (this is what users see).',
45
+ 'The basic scopes (openid email profile) need no Google verification.',
46
+ 'gipity project auth provider google --client-id <id> --client-secret <secret>',
47
+ ],
48
+ apple: r => [
49
+ 'Apple Developer > Certificates, Identifiers & Profiles > Identifiers > add a Services ID.',
50
+ ' Its identifier is your client ID.',
51
+ `Enable Sign in with Apple on it, register your domain and the return URL: ${r}`,
52
+ 'Keys > add a key with Sign in with Apple enabled. Note its Key ID and download the .p8 file (only once).',
53
+ 'Your Team ID is on the Membership details page.',
54
+ 'gipity project auth provider apple --client-id <services-id> --team-id <team> --key-id <key> --private-key-file AuthKey_XXXX.p8',
55
+ ],
56
+ discord: r => [
57
+ 'Discord Developer Portal > Applications > your application > OAuth2.',
58
+ `Add the redirect: ${r}`,
59
+ 'Copy the client ID and reset/copy the client secret.',
60
+ 'gipity project auth provider discord --client-id <id> --client-secret <secret>',
61
+ ],
62
+ };
63
+ function formatProvider(p) {
64
+ const name = PROVIDER_LABEL[p.provider];
65
+ const lines = [
66
+ `${bold(name)}: ${credentialsLabel(p)}${p.available ? '' : muted(' (off)')}`,
67
+ ];
68
+ if (p.note)
69
+ lines.push(muted(p.note));
70
+ lines.push('', `Redirect URI: ${p.redirect_uri}`, '', 'Use your own credentials:');
71
+ let n = 0;
72
+ for (const step of SETUP_STEPS[p.provider](p.redirect_uri)) {
73
+ lines.push(step.startsWith(' ') ? ` ${step.trim()}` : `${++n}. ${step}`);
74
+ }
75
+ if (p.provider === 'google') {
76
+ lines.push('', muted('Switching Google from shared to your own credentials keeps every existing user (a Google account has the same id under any client).'));
77
+ }
78
+ if (p.provider !== 'apple' && p.credentials === 'own') {
79
+ lines.push('', muted(`Back to Gipity's shared credentials: gipity project auth provider ${p.provider} --shared`));
80
+ }
81
+ return lines.join('\n');
82
+ }
83
+ export function registerAuthCommand(projectCommand) {
84
+ const auth = projectCommand
85
+ .command('auth [mode]')
86
+ .description('Show or set who can sign in to the deployed app: gipity, app (its own users), or both')
87
+ // Options after `provider` belong to it (`auth provider google --json`).
88
+ .enablePositionalOptions()
89
+ .addHelpText('after', `
90
+ Modes:
91
+ gipity Sign in with Gipity only (default)
92
+ app Users sign in to this app alone, without a Gipity account:
93
+ Google, Apple, Discord and email codes for web apps (the hosted sign-in
94
+ page / Gipity.auth.signIn), Steam (POST /api/<guid>/auth/steam) and guest
95
+ devices (POST /api/<guid>/auth/guest) for games
96
+ both Either
97
+
98
+ Sign-in providers:
99
+ gipity project auth provider <google|apple|discord> show setup steps and the redirect URI
100
+ Google and Discord work at once on Gipity's shared credentials; Apple needs your own.
101
+ Manage the app's users: gipity project users
102
+
103
+ --unique-names on|off
104
+ On: no two players of this app can have the same display name (case and
105
+ lookalike letters ignored). A taken name is refused with DISPLAY_NAME_TAKEN;
106
+ GET /api/<guid>/auth/player/name-available?name=... checks one and suggests
107
+ free alternatives. Players who already share a name keep it, and sign in with
108
+ nameConflict: true until they rename. Off by default.
109
+
110
+ Steam also needs the Steamworks publisher key and AppID:
111
+ gipity secrets set STEAM_WEB_API_KEY <key>
112
+ gipity secrets set STEAM_APP_ID <appid>
113
+ See: gipity skill read steam-game`)
114
+ .option('--unique-names <on|off>', 'Require unique player display names in this app')
115
+ .option('--json', 'Output as JSON')
116
+ .action((mode, opts) => run('Auth', async () => {
117
+ const config = requireConfig();
118
+ const body = {};
119
+ if (mode !== undefined) {
120
+ if (!AUTH_MODES.includes(mode)) {
121
+ fail(`Unknown mode "${mode}". Use one of: ${AUTH_MODES.join(', ')} (or: provider <name>).`);
122
+ }
123
+ body.auth_mode = mode;
124
+ }
125
+ if (opts.uniqueNames !== undefined) {
126
+ if (opts.uniqueNames !== 'on' && opts.uniqueNames !== 'off') {
127
+ fail(`--unique-names takes "on" or "off", not "${opts.uniqueNames}".`);
128
+ }
129
+ body.unique_player_names = opts.uniqueNames === 'on';
130
+ }
131
+ if (Object.keys(body).length === 0) {
132
+ const res = await get(`/projects/${config.projectGuid}/auth`);
133
+ printResult(formatStatus(res.data), opts, res.data);
134
+ return;
135
+ }
136
+ const res = await put(`/projects/${config.projectGuid}`, body);
137
+ const lines = [];
138
+ if (body.auth_mode)
139
+ lines.push(success(`Sign-in set to "${body.auth_mode}".`));
140
+ if (body.unique_player_names !== undefined) {
141
+ lines.push(success(`Unique names ${body.unique_player_names ? 'on' : 'off'}.`));
142
+ const sharing = res.data.players_sharing_names ?? 0;
143
+ if (sharing > 0) {
144
+ lines.push(muted(`${sharing} existing player${sharing === 1 ? '' : 's'} share${sharing === 1 ? 's' : ''} a name with an earlier player. They keep it, and sign in with nameConflict: true until they rename.`));
145
+ }
146
+ }
147
+ printResult(lines.join('\n'), opts, { ...body, ...(res.data.players_sharing_names !== undefined ? { players_sharing_names: res.data.players_sharing_names } : {}) });
148
+ }));
149
+ auth
150
+ .command('provider <name>')
151
+ .description('Show setup for a sign-in provider (google, apple, discord), set your own credentials, or go back to shared')
152
+ .option('--client-id <id>', 'OAuth client ID (Apple: the Services ID)')
153
+ .option('--client-secret <secret>', 'OAuth client secret (Google, Discord)')
154
+ .option('--team-id <id>', 'Apple Team ID')
155
+ .option('--key-id <id>', 'Apple Sign in with Apple key ID')
156
+ .option('--private-key-file <path>', 'Apple .p8 private key file')
157
+ .option('--shared', "Remove your own credentials and use Gipity's shared ones")
158
+ .option('--json', 'Output as JSON')
159
+ .action((name, opts) => run('Provider', async () => {
160
+ const provider = name.toLowerCase();
161
+ if (!PROVIDERS.includes(provider))
162
+ fail(`Unknown provider "${name}". Use one of: ${PROVIDERS.join(', ')}.`);
163
+ const config = requireConfig();
164
+ const base = `/projects/${config.projectGuid}/auth/providers/${provider}`;
165
+ const label = PROVIDER_LABEL[provider];
166
+ const credFlags = ['clientId', 'clientSecret', 'teamId', 'keyId', 'privateKeyFile'].filter(k => opts[k] !== undefined);
167
+ if (opts.shared) {
168
+ if (credFlags.length)
169
+ fail('--shared cannot be combined with credential flags.');
170
+ const res = await del(base);
171
+ const msg = res.data.credentials === 'shared'
172
+ ? success(`${label} sign-in now uses Gipity's shared credentials.`)
173
+ : success(`Removed your ${label} credentials.`) + '\n' + muted(`${label} sign-in is off until you set your own credentials.`);
174
+ printResult(msg, opts, res.data);
175
+ return;
176
+ }
177
+ if (credFlags.length === 0) {
178
+ const res = await get(`/projects/${config.projectGuid}/auth`);
179
+ const p = res.data.providers.find(x => x.provider === provider);
180
+ if (!p)
181
+ fail(`${label} sign-in is not available.`);
182
+ printResult(formatProvider(p), opts, p);
183
+ return;
184
+ }
185
+ let body;
186
+ if (provider === 'apple') {
187
+ const missing = [['clientId', '--client-id'], ['teamId', '--team-id'], ['keyId', '--key-id'], ['privateKeyFile', '--private-key-file']]
188
+ .filter(([k]) => !opts[k]).map(([, f]) => f);
189
+ if (missing.length)
190
+ fail(`Apple needs ${missing.join(', ')}. See: gipity project auth provider apple`);
191
+ if (opts.clientSecret)
192
+ fail('Apple takes --team-id, --key-id and --private-key-file, not --client-secret.');
193
+ let privateKey;
194
+ try {
195
+ privateKey = readFileSync(opts.privateKeyFile, 'utf-8');
196
+ }
197
+ catch (err) {
198
+ fail(`Cannot read ${opts.privateKeyFile}: ${err.code === 'ENOENT' ? 'no such file' : err.message}`);
199
+ }
200
+ if (!privateKey.includes('PRIVATE KEY'))
201
+ fail(`${opts.privateKeyFile} does not look like a .p8 private key.`);
202
+ body = { client_id: opts.clientId, team_id: opts.teamId, key_id: opts.keyId, private_key: privateKey };
203
+ }
204
+ else {
205
+ const missing = [['clientId', '--client-id'], ['clientSecret', '--client-secret']]
206
+ .filter(([k]) => !opts[k]).map(([, f]) => f);
207
+ if (missing.length)
208
+ fail(`${label} needs ${missing.join(' and ')}. See: gipity project auth provider ${provider}`);
209
+ const extra = ['teamId', 'keyId', 'privateKeyFile'].filter(k => opts[k] !== undefined);
210
+ if (extra.length)
211
+ fail(`--team-id, --key-id and --private-key-file are for Apple only.`);
212
+ body = { client_id: opts.clientId, client_secret: opts.clientSecret };
213
+ }
214
+ const res = await put(base, body);
215
+ const lines = [success(`${label} sign-in now uses your own credentials.`)];
216
+ if (provider === 'google')
217
+ lines.push(muted('Existing Google users keep their accounts.'));
218
+ printResult(lines.join('\n'), opts, res.data);
219
+ }));
220
+ }
221
+ //# sourceMappingURL=project-auth.js.map
@@ -0,0 +1,130 @@
1
+ import { writeFileSync } from 'fs';
2
+ import { get, post, del } from '../api.js';
3
+ import { requireConfig } from '../config.js';
4
+ import { error as clrError, muted, success, bold } from '../colors.js';
5
+ import { confirm } from '../utils.js';
6
+ import { run, printResult } from '../helpers/index.js';
7
+ const EXPORT_PAGE_SIZE = 500;
8
+ function fail(msg) {
9
+ console.error(clrError(msg));
10
+ process.exit(1);
11
+ }
12
+ function usersPath(params) {
13
+ const q = new URLSearchParams();
14
+ if (params.search)
15
+ q.set('search', params.search);
16
+ if (params.limit !== undefined)
17
+ q.set('limit', String(params.limit));
18
+ if (params.cursor)
19
+ q.set('cursor', params.cursor);
20
+ const qs = q.toString();
21
+ return `/projects/${requireConfig().projectGuid}/app-users${qs ? `?${qs}` : ''}`;
22
+ }
23
+ function day(iso) {
24
+ return iso ? iso.slice(0, 10) : '-';
25
+ }
26
+ function formatTable(users) {
27
+ const head = ['GUID', 'Name', 'Email', 'Providers', 'Created', 'Last sign-in'];
28
+ const rows = users.map(u => [u.guid, u.display_name ?? '-', u.email ?? '-', u.providers.join(', ') || '-', day(u.created_at), day(u.last_login_at)]);
29
+ const widths = head.map((h, i) => Math.max(h.length, ...rows.map(r => r[i].length)));
30
+ const line = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(' ').trimEnd();
31
+ return [bold(line(head)), ...rows.map(line)].join('\n');
32
+ }
33
+ /** One CSV field: quoted when it holds a comma, quote, or line break. */
34
+ export function csvField(value) {
35
+ return /[",\r\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
36
+ }
37
+ function toCsv(users) {
38
+ const cols = ['guid', 'display_name', 'email', 'providers', 'created_at', 'last_login_at'];
39
+ const rows = users.map(u => [u.guid, u.display_name ?? '', u.email ?? '', u.providers.join(';'), u.created_at, u.last_login_at ?? '']);
40
+ return [cols, ...rows].map(r => r.map(csvField).join(',')).join('\n') + '\n';
41
+ }
42
+ export function registerUsersCommand(projectCommand) {
43
+ const users = projectCommand
44
+ .command('users')
45
+ .description("Manage the app's own users (app sign-in mode): list, export, delete, sign out")
46
+ .addHelpText('after', `
47
+ These are the people who signed in to this app with Google, Apple, Discord, an
48
+ email code, Steam or a guest device. They belong to the app, not to Gipity.
49
+ gipity project users --search ann find users by name or email
50
+ gipity project users export -o users.csv every user, as CSV (or --format json)
51
+ gipity project users delete <guid> erase a user (runs the app's user_deleted hooks)
52
+ gipity project users signout <guid> end all of a user's web sessions`);
53
+ users
54
+ .command('list', { isDefault: true })
55
+ .description("List the app's users")
56
+ .option('--search <text>', 'Match name or email')
57
+ .option('--limit <n>', 'How many to show (1-500, default 100)')
58
+ .option('--json', 'Output as JSON')
59
+ .action((opts) => run('Users', async () => {
60
+ let limit;
61
+ if (opts.limit !== undefined) {
62
+ limit = Number(opts.limit);
63
+ if (!Number.isInteger(limit) || limit < 1 || limit > 500)
64
+ fail(`--limit takes a whole number from 1 to 500, not "${opts.limit}".`);
65
+ }
66
+ const res = await get(usersPath({ search: opts.search, limit }));
67
+ const d = res.data;
68
+ if (opts.json) {
69
+ console.log(JSON.stringify(d));
70
+ return;
71
+ }
72
+ if (d.users.length === 0) {
73
+ console.log(muted(opts.search ? `No users match "${opts.search}".` : 'No users yet.'));
74
+ return;
75
+ }
76
+ console.log(formatTable(d.users));
77
+ console.log('');
78
+ console.log(muted(`${d.users.length} of ${d.total} user${d.total === 1 ? '' : 's'}`));
79
+ if (d.users.length < d.total) {
80
+ console.log(muted('Narrow with --search, show more with --limit (up to 500), or get them all: gipity project users export'));
81
+ }
82
+ }));
83
+ users
84
+ .command('export')
85
+ .description('Export every user of the app as CSV or JSON')
86
+ .option('--format <format>', 'csv or json', 'csv')
87
+ .option('-o, --output <file>', 'Write to this file instead of stdout')
88
+ .option('--json', 'Output the result as JSON (with -o)')
89
+ .action((opts) => run('Export', async () => {
90
+ if (opts.format !== 'csv' && opts.format !== 'json')
91
+ fail(`--format takes "csv" or "json", not "${opts.format}".`);
92
+ const all = [];
93
+ let cursor = null;
94
+ do {
95
+ const res = await get(usersPath({ limit: EXPORT_PAGE_SIZE, cursor }));
96
+ all.push(...res.data.users);
97
+ cursor = res.data.next_cursor;
98
+ } while (cursor);
99
+ const out = opts.format === 'csv' ? toCsv(all) : JSON.stringify(all, null, 2) + '\n';
100
+ if (!opts.output) {
101
+ process.stdout.write(out);
102
+ return;
103
+ }
104
+ writeFileSync(opts.output, out);
105
+ printResult(success(`Exported ${all.length} user${all.length === 1 ? '' : 's'} to ${opts.output}.`), opts, { file: opts.output, count: all.length, format: opts.format });
106
+ }));
107
+ users
108
+ .command('delete <userGuid>')
109
+ .description("Erase a user and everything the app keeps for them (runs the app's user_deleted hooks)")
110
+ .option('--json', 'Output as JSON')
111
+ .action((userGuid, opts) => run('Delete', async () => {
112
+ const ok = await confirm(`Delete user ${userGuid}? This erases the user and runs the app's user_deleted hooks to remove their data. It cannot be undone.`);
113
+ if (!ok) {
114
+ console.log('Cancelled.');
115
+ return;
116
+ }
117
+ const res = await del(`/projects/${requireConfig().projectGuid}/app-users/${encodeURIComponent(userGuid)}`);
118
+ printResult(success(`Deleted user ${userGuid}.`), opts, { guid: userGuid, ...res.data });
119
+ }));
120
+ users
121
+ .command('signout <userGuid>')
122
+ .description("Sign a user out everywhere (revoke all of the user's web sessions)")
123
+ .option('--json', 'Output as JSON')
124
+ .action((userGuid, opts) => run('Sign out', async () => {
125
+ const res = await post(`/projects/${requireConfig().projectGuid}/app-users/${encodeURIComponent(userGuid)}/signout`);
126
+ const n = res.data.signed_out_sessions;
127
+ printResult(success(`Signed out ${userGuid}: ${n} session${n === 1 ? '' : 's'} ended.`), opts, { guid: userGuid, ...res.data });
128
+ }));
129
+ }
130
+ //# sourceMappingURL=project-users.js.map
@@ -10,7 +10,8 @@ import { run, printList, printResult } from '../helpers/index.js';
10
10
  import { getProjectsRoot } from '../relay/paths.js';
11
11
  import { finalizeLocalProject } from '../project-setup.js';
12
12
  import * as relayState from '../relay/state.js';
13
- const AUTH_MODES = ['gipity', 'app', 'both'];
13
+ import { registerAuthCommand } from './project-auth.js';
14
+ import { registerUsersCommand } from './project-users.js';
14
15
  export const projectCommand = new Command('project')
15
16
  .description('Manage projects')
16
17
  // Options after a subcommand (`project auth --json`) belong to it, not to `project`.
@@ -170,63 +171,6 @@ projectCommand
170
171
  console.log(`Desc: ${p.description}`);
171
172
  }
172
173
  }));
173
- projectCommand
174
- .command('auth [mode]')
175
- .description('Show or set who can sign in to the deployed app: gipity, app (Steam / guest players), or both')
176
- .addHelpText('after', `
177
- Modes:
178
- gipity Sign in with Gipity only (default)
179
- app Players sign in to this app alone, without a Gipity account:
180
- Steam (POST /api/<guid>/auth/steam) or a guest device (POST /api/<guid>/auth/guest)
181
- both Either
182
-
183
- --unique-names on|off
184
- On: no two players of this app can have the same display name (case and
185
- lookalike letters ignored). A taken name is refused with DISPLAY_NAME_TAKEN;
186
- GET /api/<guid>/auth/player/name-available?name=... checks one and suggests
187
- free alternatives. Players who already share a name keep it, and sign in with
188
- nameConflict: true until they rename. Off by default.
189
-
190
- Steam also needs the Steamworks publisher key and AppID:
191
- gipity secrets set STEAM_WEB_API_KEY <key>
192
- gipity secrets set STEAM_APP_ID <appid>
193
- See: gipity skill read steam-game`)
194
- .option('--unique-names <on|off>', 'Require unique player display names in this app')
195
- .option('--json', 'Output as JSON')
196
- .action((mode, opts) => run('Auth', async () => {
197
- const config = requireConfig();
198
- const body = {};
199
- if (mode !== undefined) {
200
- if (!AUTH_MODES.includes(mode)) {
201
- console.error(clrError(`Unknown mode "${mode}". Use one of: ${AUTH_MODES.join(', ')}.`));
202
- process.exit(1);
203
- }
204
- body.auth_mode = mode;
205
- }
206
- if (opts.uniqueNames !== undefined) {
207
- if (opts.uniqueNames !== 'on' && opts.uniqueNames !== 'off') {
208
- console.error(clrError(`--unique-names takes "on" or "off", not "${opts.uniqueNames}".`));
209
- process.exit(1);
210
- }
211
- body.unique_player_names = opts.uniqueNames === 'on';
212
- }
213
- if (Object.keys(body).length === 0) {
214
- const res = await get(`/projects/${config.projectGuid}`);
215
- const p = res.data;
216
- printResult(`Sign-in: ${p.auth_mode}\nUnique names: ${p.unique_player_names ? 'on' : 'off'}`, opts, { auth_mode: p.auth_mode, unique_player_names: p.unique_player_names });
217
- return;
218
- }
219
- const res = await put(`/projects/${config.projectGuid}`, body);
220
- const lines = [];
221
- if (body.auth_mode)
222
- lines.push(success(`Sign-in set to "${body.auth_mode}".`));
223
- if (body.unique_player_names !== undefined) {
224
- lines.push(success(`Unique names ${body.unique_player_names ? 'on' : 'off'}.`));
225
- const sharing = res.data.players_sharing_names ?? 0;
226
- if (sharing > 0) {
227
- lines.push(muted(`${sharing} existing player${sharing === 1 ? '' : 's'} share${sharing === 1 ? 's' : ''} a name with an earlier player. They keep it, and sign in with nameConflict: true until they rename.`));
228
- }
229
- }
230
- printResult(lines.join('\n'), opts, { ...body, ...(res.data.players_sharing_names !== undefined ? { players_sharing_names: res.data.players_sharing_names } : {}) });
231
- }));
174
+ registerAuthCommand(projectCommand);
175
+ registerUsersCommand(projectCommand);
232
176
  //# sourceMappingURL=project.js.map
@@ -38,10 +38,10 @@ async function recordsHttp(opts) {
38
38
  };
39
39
  }
40
40
  recordsCommand
41
- .command('list')
42
- .description('List record tables')
41
+ .command('tables')
42
+ .description('List the tables exposed through Gipity Records')
43
43
  .option('--json', 'Output as JSON')
44
- .action((opts) => run('List', async () => {
44
+ .action((opts) => run('Tables', async () => {
45
45
  const config = requireConfig();
46
46
  const res = await get(`/api/${config.projectGuid}/records-config`);
47
47
  printList(res.data, opts, 'No tables configured for Records API. Configure one with `gipity records config <table> --auth <level>`.', t => `${bold(t.table_name)} ${muted(t.auth_level)} ${muted(`pk=${t.primary_key_column}`)} ${muted(`db=${t.database_name}`)}`);
@@ -95,8 +95,8 @@ recordsCommand
95
95
  printResult(`Configured "${table}": auth=${d.auth_level}, searchable=${d.searchable}, pk=${d.primary_key_column}, auto-number=${autoNumber}`, opts, d);
96
96
  }));
97
97
  recordsCommand
98
- .command('query <table>')
99
- .description('List records (full-text search, filter, sort, recycle bin)')
98
+ .command('list <table>')
99
+ .description('List a table\'s records (full-text search, filter, sort, recycle bin)')
100
100
  .option('-q, --q <text>', 'Full-text search across the table\'s text columns (needs `--searchable true` on the table)')
101
101
  .option('--filter <filter>', 'AND filter string, "col:op:value" comma-joined. Ops: eq, neq, gt, gte, lt, lte, like, ilike, in (pipe-separated values), is_null, not_null. Full grammar: gipity skill read app-records')
102
102
  .option('--any <filter>', 'OR filter group, same grammar and ops as --filter (e.g., "owner:eq:me,shared:eq:true")')
@@ -108,7 +108,7 @@ recordsCommand
108
108
  .option('--only-deleted', 'Only soft-deleted rows - the recycle bin (owner/editor)')
109
109
  .option(ANON_FLAG, ANON_HELP)
110
110
  .option('--json', 'Output as JSON')
111
- .action((table, opts) => run('Query', async () => {
111
+ .action((table, opts) => run('List', async () => {
112
112
  const api = await recordsHttp(opts);
113
113
  const params = new URLSearchParams();
114
114
  if (opts.q)
@@ -213,7 +213,7 @@ recordsCommand
213
213
  const data = res?.data ?? { table, id, deleted: true, purged: !!opts.purge };
214
214
  printResult(data.purged
215
215
  ? 'Purged - the row and its audit history are gone.'
216
- : `Deleted. If "${table}" declares a soft-delete column the row is only stamped deleted (see it with \`gipity records query ${table} --only-deleted\`, bring it back with \`gipity records restore ${table} ${id}\`, remove it for good with \`--purge\`).`, opts, data);
216
+ : `Deleted. If "${table}" declares a soft-delete column the row is only stamped deleted (see it with \`gipity records list ${table} --only-deleted\`, bring it back with \`gipity records restore ${table} ${id}\`, remove it for good with \`--purge\`).`, opts, data);
217
217
  }));
218
218
  recordsCommand
219
219
  .command('restore <table> <id>')
@@ -2,9 +2,9 @@ import { Command, Option } from 'commander';
2
2
  import { readFileSync, existsSync, statSync, mkdirSync, writeFileSync } from 'fs';
3
3
  import { dirname, extname, relative, resolve, sep } from 'path';
4
4
  import { post } from '../api.js';
5
- import { resolveProjectContext, getConfigPath, getProjectRoot, shouldIgnore } from '../config.js';
5
+ import { resolveProjectContext, getConfigPath, getProjectRoot, shouldIgnore, requireConfig } from '../config.js';
6
6
  import { SCRATCH_IGNORE } from '../setup.js';
7
- import { sync } from '../sync.js';
7
+ import { sync, localEmptyDirs, effectiveIgnore } from '../sync.js';
8
8
  import { error as clrError, dim } from '../colors.js';
9
9
  import { run, parseDuration } from '../helpers/index.js';
10
10
  import { createProgressReporter, withSpinner } from '../progress.js';
@@ -215,6 +215,8 @@ export function isWriteTarget(code, p) {
215
215
  const afterInputFlag = /(?:^|[\s'"`])(?:-i|--input)[= ]\s*['"`]?$/.test(before);
216
216
  return cmd === 'ffmpeg' && !afterInputFlag;
217
217
  }
218
+ /** Most empty local directories sent with one run (matches the server cap). */
219
+ const MAX_INPUT_DIRS = 500;
218
220
  /** Project-relative path from the process cwd, or undefined when there's
219
221
  * no local config (one-off mode) or the cwd is at/above the project root. */
220
222
  function resolveRelativeCwd() {
@@ -445,8 +447,16 @@ GCC/Rust).
445
447
  // namespaces above, which sync ignores and so the mirror never carries.
446
448
  // Bidirectional + CAS, so it's a cheap manifest check when nothing changed.
447
449
  // Symmetric with the post-run pull below. Skip in one-off mode (no project).
450
+ // Sync carries files only, so a directory the caller just made locally
451
+ // (`mkdir -p docs`) and hasn't put a file in yet would be missing from /work.
452
+ // Send those directories so the run sees the same layout (cli#208).
453
+ let inputDirs;
448
454
  if (getConfigPath()) {
449
455
  await sync({ interactive: false, progress: opts.json ? undefined : createProgressReporter() });
456
+ const root = dirname(getConfigPath());
457
+ const dirs = localEmptyDirs(root, effectiveIgnore(root, requireConfig().ignore));
458
+ if (dirs.length)
459
+ inputDirs = dirs.slice(0, MAX_INPUT_DIRS);
450
460
  }
451
461
  // The run blocks until the sandbox finishes (up to the timeout); animate the
452
462
  // wait, then clear the spinner so stdout/stderr is the result. JSON skips it.
@@ -455,6 +465,7 @@ GCC/Rust).
455
465
  language,
456
466
  timeout: isNaN(timeout) ? 30 : timeout,
457
467
  input_files: opts.input,
468
+ input_dirs: inputDirs,
458
469
  cwd,
459
470
  // The filter must run SERVER-side (in the output extractor): skipping
460
471
  // only in the CLI would still write the files into project storage and
@@ -107,18 +107,29 @@ function filterContent(content, sections, opts) {
107
107
  return { text: tocText(sections) };
108
108
  let hits = [];
109
109
  let note;
110
- if (opts.section) {
111
- const want = slugify(opts.section);
112
- hits = sections.filter(s => s.slug === want);
113
- if (hits.length === 0)
114
- hits = sections.filter(s => s.slug.includes(want));
115
- if (hits.length === 0) {
116
- const closest = closestSection(sections, want);
117
- if (closest) {
118
- hits = [closest];
119
- note = `No section "${opts.section}"; showing the closest match "${closest.slug}" (all slugs: --toc).`;
110
+ if (opts.section?.length) {
111
+ // Repeatable: each --section adds its section(s), in the order asked for.
112
+ const notes = [];
113
+ for (const asked of opts.section) {
114
+ const want = slugify(asked);
115
+ let found = sections.filter(s => s.slug === want);
116
+ if (found.length === 0)
117
+ found = sections.filter(s => s.slug.includes(want));
118
+ if (found.length === 0) {
119
+ const closest = closestSection(sections, want);
120
+ if (closest) {
121
+ found = [closest];
122
+ notes.push(`No section "${asked}"; showing the closest match "${closest.slug}" (all slugs: --toc).`);
123
+ }
120
124
  }
125
+ if (found.length === 0)
126
+ notes.push(`No section "${asked}" (all slugs: --toc).`);
127
+ for (const f of found)
128
+ if (!hits.includes(f))
129
+ hits.push(f);
121
130
  }
131
+ if (notes.length)
132
+ note = notes.join(' ');
122
133
  }
123
134
  else if (opts.grep) {
124
135
  let re;
@@ -165,7 +176,7 @@ skillCommand
165
176
  .command('read <names...>')
166
177
  .description('Read one or more skills (whole doc, or one part with --toc/--section/--grep)')
167
178
  .option('--toc', 'Print the doc outline (section slugs + line numbers) instead of the content')
168
- .option('--section <slug>', 'Print only this section (slug or heading text; subsections included). A guess that clearly matches one section by its words prints that section')
179
+ .option('--section <slug>', 'Print only this section (slug or heading text; subsections included). Repeat for several. A guess that clearly matches one section by its words prints that section', (v, prev = []) => [...prev, v])
169
180
  .option('--grep <term>', 'Print only the sections matching this term (case-insensitive regex)')
170
181
  .option('--json', 'Output as JSON')
171
182
  .action((names, opts) => run('Read', async () => {
@@ -200,7 +211,7 @@ skillCommand
200
211
  const sections = parseSections(lines);
201
212
  const filtered = filterContent(content, sections, opts);
202
213
  if (filtered === null) {
203
- const what = opts.section ? `section "${opts.section}"` : `match for "${opts.grep}"`;
214
+ const what = opts.section?.length ? `section ${opts.section.map(x => `"${x}"`).join(' / ')}` : `match for "${opts.grep}"`;
204
215
  console.error(clrError(`No ${what} in "${name}". Sections: ${sections.map(s => s.slug).join(', ') || '(none)'}`));
205
216
  failed = true;
206
217
  continue;