sekura 0.5.1 → 0.5.3
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.
- package/dist/session.js +1 -1
- package/dist/steps.js +62 -28
- package/dist/ui.js +6 -2
- package/package.json +1 -1
package/dist/session.js
CHANGED
|
@@ -114,7 +114,7 @@ export async function signInFresh(flags = {}) {
|
|
|
114
114
|
}
|
|
115
115
|
const where = saveKey(signed.key, account?.email ?? signed.account?.email, 'cli');
|
|
116
116
|
say(`${tick} Signed in to Sekura as ${who(account ?? signed.account, signed.key)}${signed.account?.created ? ' (new Sekura account)' : ''}; the key (${redact(signed.key)}) is kept in ${where}`);
|
|
117
|
-
return { key: signed.key, account, kind: 'cli', fresh: true };
|
|
117
|
+
return { key: signed.key, account, kind: 'cli', fresh: true, githubLogin: signed.account?.login ?? null };
|
|
118
118
|
}
|
|
119
119
|
catch (e) {
|
|
120
120
|
stop();
|
package/dist/steps.js
CHANGED
|
@@ -222,6 +222,8 @@ export function sayInstallWarnings(list) {
|
|
|
222
222
|
}
|
|
223
223
|
export const repositoriesOf = (list) => (list.installations ?? []).flatMap((i) => i.repositories);
|
|
224
224
|
export const installLink = (s, list) => s.account?.links?.installGithubApp ?? list?.installUrl ?? s.account?.links?.start ?? link('/app/start');
|
|
225
|
+
/** The GitHub accounts the App is installed on, as GitHub names them. */
|
|
226
|
+
const accountsOf = (list) => [...new Set((list.installations ?? []).map((i) => i.account).filter((a) => !!a))];
|
|
225
227
|
export async function ensureApp(s, flags = {}) {
|
|
226
228
|
const interactive = isInteractive(flags);
|
|
227
229
|
const want = flags.want ?? null;
|
|
@@ -233,28 +235,38 @@ export async function ensureApp(s, flags = {}) {
|
|
|
233
235
|
let repos = repositoriesOf(list);
|
|
234
236
|
const covered = () => (want ? repos.some((r) => same(r.fullName, want)) : repos.length > 0);
|
|
235
237
|
const url = installLink(s, list);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
// The App on the person's own GitHub account (29 November 2026). Repositories
|
|
239
|
+
// reached only through someone else's installation, on an account where the
|
|
240
|
+
// person collaborates, counted as "installed", so findsekura was never asked
|
|
241
|
+
// to install the App on findsekura and was shown Tikka's repository instead.
|
|
242
|
+
// Known only right after the GitHub-code sign-in; without it, as before.
|
|
243
|
+
const own = s.githubLogin ?? null;
|
|
244
|
+
const onOwn = () => !own || accountsOf(list).some((a) => same(a, own));
|
|
245
|
+
const ownMissing = !want && !flags.add && repos.length > 0 && !onOwn();
|
|
246
|
+
if (covered() && !flags.add && !ownMissing)
|
|
247
|
+
return { installed: true, found: true, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
238
248
|
const onGithub = /^https:\/\/github\.com\//.test(url);
|
|
239
|
-
say(
|
|
240
|
-
?
|
|
241
|
-
:
|
|
249
|
+
say(ownMissing
|
|
250
|
+
? `${dot} The Sekura GitHub App is not installed on ${own} yet. It can reach ${repos.length === 1 ? 'one repository' : `${repos.length} repositories`} through ${accountsOf(list).join(', ')}, where you collaborate.`
|
|
251
|
+
: repos.length
|
|
252
|
+
? want && !covered() ? `${dot} ${want} is not one Sekura can scan yet: the Sekura GitHub App needs access to it.` : `${dot} To give Sekura more repositories, change the Sekura GitHub App's access.`
|
|
253
|
+
: `${dot} The Sekura GitHub App is not installed on any of your GitHub accounts yet, so there is nothing to scan.`);
|
|
242
254
|
if (!interactive) {
|
|
243
255
|
say(` Install it and choose repositories at ${url}`);
|
|
244
256
|
if (flags.soft || covered())
|
|
245
|
-
return { installed: repos.length > 0, found: covered(), repositories: repos, link: url };
|
|
257
|
+
return { installed: repos.length > 0, found: covered(), repositories: repos, link: url, accounts: accountsOf(list) };
|
|
246
258
|
throw new Exit(EXIT.accountNotReady, `Sekura cannot scan ${want ?? 'any repository'} yet. Install the Sekura GitHub App at the link above, then run the command again.`, { installUrl: url });
|
|
247
259
|
}
|
|
248
260
|
if (!flags.add) {
|
|
249
261
|
const go = await select({
|
|
250
|
-
message: repos.length ? `Give Sekura access to ${want}?` : 'Install the Sekura GitHub App?',
|
|
262
|
+
message: ownMissing ? `Install the Sekura GitHub App on ${own}?` : repos.length ? `Give Sekura access to ${want}?` : 'Install the Sekura GitHub App?',
|
|
251
263
|
choices: [
|
|
252
264
|
{ name: `Yes, open ${onGithub ? 'github.com' : HOST} (GitHub asks which repositories)`, value: true },
|
|
253
265
|
{ name: repos.length ? 'No, pick from the repositories Sekura can already scan' : 'Not now', value: false },
|
|
254
266
|
],
|
|
255
267
|
});
|
|
256
268
|
if (!go)
|
|
257
|
-
return { installed: repos.length > 0, found: false, repositories: repos, link: url };
|
|
269
|
+
return { installed: repos.length > 0, found: false, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
258
270
|
}
|
|
259
271
|
const opened = openLink(url, { browser: flags.browser });
|
|
260
272
|
say(opened.opened ? ` Opened ${url}` : ` Open ${url}`);
|
|
@@ -264,13 +276,15 @@ export async function ensureApp(s, flags = {}) {
|
|
|
264
276
|
repos = repositoriesOf(list);
|
|
265
277
|
if (want)
|
|
266
278
|
return repos.some((x) => same(x.fullName, want));
|
|
279
|
+
if (ownMissing)
|
|
280
|
+
return accountsOf(list).some((a) => same(a, own));
|
|
267
281
|
return flags.add && before.size ? repos.some((x) => !before.has(x.fullName.toLowerCase())) : repos.length > 0;
|
|
268
282
|
}, flags.wait);
|
|
269
283
|
const found = r === 'done';
|
|
270
284
|
say(found
|
|
271
|
-
? `${tick} ${want ? `Sekura can scan ${want}` : before.size ? 'Sekura can scan more repositories now' : 'The Sekura GitHub App is installed'}`
|
|
285
|
+
? `${tick} ${want ? `Sekura can scan ${want}` : ownMissing ? `The Sekura GitHub App is installed on ${own}` : before.size ? 'Sekura can scan more repositories now' : 'The Sekura GitHub App is installed'}`
|
|
272
286
|
: `${dot} Not there yet; you can finish the install later with npx sekura@latest repos --add`);
|
|
273
|
-
return { installed: repos.length > 0, found, repositories: repos, link: url };
|
|
287
|
+
return { installed: repos.length > 0, found, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
274
288
|
}
|
|
275
289
|
export async function ensureRepository(s, flags = {}) {
|
|
276
290
|
const interactive = isInteractive(flags);
|
|
@@ -308,23 +322,43 @@ export async function ensureRepository(s, flags = {}) {
|
|
|
308
322
|
return null;
|
|
309
323
|
throw new Exit(EXIT.error, `Name the repository: Sekura can scan ${scannable.length}, and this folder is not one of them. Run npx sekura@latest repos to list them.`);
|
|
310
324
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
325
|
+
// Always asked, even with one repository (Sudhir, 29 November 2026: "why
|
|
326
|
+
// did it pick nagiclaw?"). With one, the CLI used to choose it and print a
|
|
327
|
+
// tick: the person saw a repository they had not named, from an account
|
|
328
|
+
// they had forgotten the App was on, with no way to pick another. Nothing
|
|
329
|
+
// about which repository is scanned happens without the person choosing it,
|
|
330
|
+
// and the list always offers giving Sekura another one.
|
|
331
|
+
let repos = app.repositories;
|
|
332
|
+
let accounts = app.accounts ?? [];
|
|
333
|
+
for (;;) {
|
|
334
|
+
// Say where the list comes from: an installation the person made long
|
|
335
|
+
// ago, or one on another account they collaborate on, otherwise looks
|
|
336
|
+
// like Sekura found repositories by itself (29 November 2026: the App was
|
|
337
|
+
// still on sekura-ai, and findsekura saw sekura-ai/nagiclaw).
|
|
338
|
+
if (accounts.length)
|
|
339
|
+
say(`${dot} The Sekura GitHub App is installed on ${accounts.join(', ')}; these are the repositories it can reach.`);
|
|
340
|
+
const hereNow = find(here) ? repos.find((r) => same(r.fullName, here)) : undefined;
|
|
341
|
+
const savedNow = repos.find((r) => same(r.fullName, defaultRepository() ?? ''));
|
|
342
|
+
const first = hereNow ?? savedNow;
|
|
343
|
+
const ordered = first ? [first, ...repos.filter((r) => r !== first)] : repos;
|
|
344
|
+
const picked = await select({
|
|
345
|
+
message: 'Which repository should Sekura scan?',
|
|
346
|
+
pageSize: 12,
|
|
347
|
+
choices: [
|
|
348
|
+
...ordered.map((r) => ({
|
|
349
|
+
name: `${r.fullName}${r === hereNow ? ' (this folder)' : r === savedNow ? ' (your default)' : ''}${r.private ? ' (private)' : ''}`,
|
|
350
|
+
value: r.fullName,
|
|
351
|
+
disabled: r.empty ? '(empty, nothing to scan)' : false,
|
|
352
|
+
})),
|
|
353
|
+
{ name: 'Another repository: give Sekura access on GitHub', value: ADD_REPOSITORY },
|
|
354
|
+
{ name: 'Skip for now', value: '' },
|
|
355
|
+
],
|
|
356
|
+
});
|
|
357
|
+
if (picked !== ADD_REPOSITORY)
|
|
358
|
+
return picked ? keep(picked) : null;
|
|
359
|
+
const again = await ensureApp(s, { ...flags, add: true });
|
|
360
|
+
repos = again.repositories;
|
|
361
|
+
accounts = again.accounts ?? accounts;
|
|
314
362
|
}
|
|
315
|
-
const first = hereRepo ?? saved;
|
|
316
|
-
const ordered = first ? [first, ...app.repositories.filter((r) => r !== first)] : app.repositories;
|
|
317
|
-
const picked = await select({
|
|
318
|
-
message: 'Which repository?',
|
|
319
|
-
pageSize: 12,
|
|
320
|
-
choices: [
|
|
321
|
-
...ordered.map((r) => ({
|
|
322
|
-
name: `${r.fullName}${r === hereRepo ? ' (this folder)' : r === saved ? ' (your default)' : ''}${r.private ? ' (private)' : ''}`,
|
|
323
|
-
value: r.fullName,
|
|
324
|
-
disabled: r.empty ? '(empty, nothing to scan)' : false,
|
|
325
|
-
})),
|
|
326
|
-
{ name: 'Skip for now', value: '' },
|
|
327
|
-
],
|
|
328
|
-
});
|
|
329
|
-
return picked ? keep(picked) : null;
|
|
330
363
|
}
|
|
364
|
+
const ADD_REPOSITORY = '\u0000add';
|
package/dist/ui.js
CHANGED
|
@@ -117,15 +117,19 @@ export async function waitFor(message, check, opts = {}) {
|
|
|
117
117
|
* A question that fits is asked as it is; a longer one is printed above,
|
|
118
118
|
* wrapped by us, and the prompt itself is the short form.
|
|
119
119
|
*/
|
|
120
|
+
/** "(y/n)" in lower case, both letters (Sudhir, 29 November 2026: "keep both
|
|
121
|
+
* small case"). The library writes the default in capitals, "(Y/n)"; Enter
|
|
122
|
+
* still takes the default. Dim, as the library draws it. */
|
|
123
|
+
const YES_NO = { style: { defaultAnswer: (text) => `\x1b[2m(${text.toLowerCase()})\x1b[22m` } };
|
|
120
124
|
export async function ask(message, opts) {
|
|
121
125
|
const { confirm } = await import('@inquirer/prompts');
|
|
122
126
|
const cols = Math.max(40, process.stderr.columns || process.stdout.columns || 80);
|
|
123
127
|
// "? " before it and " (Y/n) " after it.
|
|
124
128
|
if (message.length + 10 <= cols)
|
|
125
|
-
return confirm({ message, default: opts.default });
|
|
129
|
+
return confirm({ message, default: opts.default, theme: YES_NO });
|
|
126
130
|
for (const line of wrapWords(message, cols - 4))
|
|
127
131
|
say(` ${line}`);
|
|
128
|
-
return confirm({ message: opts.short, default: opts.default });
|
|
132
|
+
return confirm({ message: opts.short, default: opts.default, theme: YES_NO });
|
|
129
133
|
}
|
|
130
134
|
/** Plain word wrap at `width` characters; a single longer word keeps its own line. */
|
|
131
135
|
export function wrapWords(text, width) {
|
package/package.json
CHANGED