sekura 0.5.0 → 0.5.1
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/commands/init.js +43 -14
- package/dist/commands/shared.js +17 -4
- package/dist/commands/uninstall.js +2 -3
- package/dist/flow.js +3 -3
- package/dist/steps.js +3 -3
- package/dist/terms.js +3 -3
- package/dist/ui.js +34 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
// they have seen what will be written. Nothing is written before the review
|
|
7
7
|
// is agreed (unless --yes).
|
|
8
8
|
import { Command } from 'commander';
|
|
9
|
-
import { checkbox,
|
|
9
|
+
import { checkbox, select } from '@inquirer/prompts';
|
|
10
10
|
import { realpathSync } from 'node:fs';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { dirname, resolve } from 'node:path';
|
|
13
13
|
import { DOCS, ENDPOINT, PENDING_KEY, TOOLS, carriesKey, home, link, serverNote, toolById } from '../catalogue.js';
|
|
14
14
|
import { applyStep, buildPlan, describeStep, detectTools } from '../plan.js';
|
|
15
15
|
import { verifyEndpoint } from '../verify.js';
|
|
16
|
+
import { openLink } from '../open.js';
|
|
16
17
|
import { credentialsPath, readKey, readToolKey, savedCredentials } from '../auth.js';
|
|
17
18
|
import { tools as sekura } from '../api.js';
|
|
18
19
|
import { EXIT, Exit, exitCodeFor, messageFor } from '../exit.js';
|
|
@@ -20,7 +21,7 @@ import { howToScan, nextSteps } from '../guide.js';
|
|
|
20
21
|
import { currentSession, signInFresh, toolKeyFor, toolKeyName } from '../session.js';
|
|
21
22
|
import { ensureRepository, ensureTerms } from '../steps.js';
|
|
22
23
|
import { runScan } from './scan.js';
|
|
23
|
-
import { banner, cross, dot, say, tick } from '../ui.js';
|
|
24
|
+
import { ask, banner, cross, dot, say, tick } from '../ui.js';
|
|
24
25
|
/** The home folder (or the top of the disk) is no project: project scope
|
|
25
26
|
* there would put AGENTS.md and .mcp.json in it for every tool to find. */
|
|
26
27
|
export function isProjectDir(cwd) {
|
|
@@ -65,9 +66,40 @@ async function noScanYet(key) {
|
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Whether this key can start the account's first scan, which the server says
|
|
71
|
+
* is free (freeScanAvailable). Only a key from
|
|
72
|
+
* the GitHub-code sign-in carries the cli scope; a key from the older browser
|
|
73
|
+
* sign-in is an ordinary connector key, and the server quotes it a paid $10
|
|
74
|
+
* scan with the account's first scan still unused (29 November 2026: dev's GitHub-code
|
|
75
|
+
* sign-in answered 404, the CLI fell back, and a person told "your first scan
|
|
76
|
+
* is free" was shown $10). So when that scan is still unused but this key cannot
|
|
77
|
+
* take it, the first-scan step sends the person to the website's first scan
|
|
78
|
+
* and never shows a price. The words come from the server's own answer, so the
|
|
79
|
+
* CLI still never calls a scan free on its own (guide.test.mjs).
|
|
80
|
+
*/
|
|
81
|
+
async function freeScanElsewhere(key) {
|
|
82
|
+
try {
|
|
83
|
+
const a = (await sekura.getAccount(key)).data;
|
|
84
|
+
return a.freeScanAvailable === true && a.freeScanDoor !== 'cli';
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function firstScan(repo, opts, cwd, key) {
|
|
69
91
|
say();
|
|
70
|
-
|
|
92
|
+
if (await freeScanElsewhere(key)) {
|
|
93
|
+
const url = link('/app/start');
|
|
94
|
+
say(` Your first scan is free. Start it on the website: ${url}`);
|
|
95
|
+
if (await ask('Open it in your browser?', { default: true, short: 'Open it in your browser?' })) {
|
|
96
|
+
const o = openLink(url, { browser: opts.browser });
|
|
97
|
+
if (!o.opened)
|
|
98
|
+
say(` Open ${url} in your browser.`);
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const go = await ask(`See the quote for a first scan of ${repo}? Nothing starts and nothing is charged unless you then agree.`, { default: true, short: 'See the quote?' });
|
|
71
103
|
if (!go) {
|
|
72
104
|
say(` No scan started. When you are ready: npx sekura@latest scan ${repo}`);
|
|
73
105
|
return undefined;
|
|
@@ -179,20 +211,17 @@ export async function runInit(opts) {
|
|
|
179
211
|
});
|
|
180
212
|
}
|
|
181
213
|
if (open.skill)
|
|
182
|
-
skill = await
|
|
214
|
+
skill = await ask('Also install the sekura skill, which teaches the agent the quote-then-confirm rule?', { default: true, short: 'Install the skill?' });
|
|
183
215
|
if (open.login) {
|
|
184
|
-
login = await
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
: 'Sign in to Sekura once you have reviewed the plan, so your tools do not have to and your account is set up here?',
|
|
188
|
-
default: true,
|
|
189
|
-
});
|
|
216
|
+
login = await ask(hasKey
|
|
217
|
+
? 'Use your saved Sekura sign-in, so your tools do not ask and your account is set up here?'
|
|
218
|
+
: 'Sign in to Sekura once you have reviewed the plan, so your tools do not have to and your account is set up here?', { default: true, short: hasKey ? 'Use the saved sign-in?' : 'Sign in to Sekura?' });
|
|
190
219
|
}
|
|
191
220
|
}
|
|
192
221
|
}
|
|
193
222
|
}
|
|
194
223
|
else if (interactive && opts.login === undefined) {
|
|
195
|
-
const go = await
|
|
224
|
+
const go = await ask('Set up your Sekura account here: sign in, the Terms, the Sekura GitHub App and a first scan?', { default: true, short: 'Set up your account?' });
|
|
196
225
|
if (!go) {
|
|
197
226
|
say(' Nothing was changed.');
|
|
198
227
|
return { written: 0, byHand: 0, failed: 0 };
|
|
@@ -234,7 +263,7 @@ export async function runInit(opts) {
|
|
|
234
263
|
say();
|
|
235
264
|
return { written: 0, byHand: 0, failed: 0 };
|
|
236
265
|
}
|
|
237
|
-
if (interactive && shown.steps.length && !(await
|
|
266
|
+
if (interactive && shown.steps.length && !(await ask('Apply?', { default: true, short: 'Apply?' }))) {
|
|
238
267
|
say(' Nothing was changed.');
|
|
239
268
|
return { written: 0, byHand: 0, failed: 0 };
|
|
240
269
|
}
|
|
@@ -329,7 +358,7 @@ export async function runInit(opts) {
|
|
|
329
358
|
say(`${dot} Your email address is not verified yet, and a scan cannot start before that: ${session.account?.links?.dashboard ?? link('/app')}`);
|
|
330
359
|
const accountReady = (terms === 'current' || terms === 'accepted') && !unverified;
|
|
331
360
|
if (repo && accountReady && opts.scan !== false && interactive && await noScanYet(session.key))
|
|
332
|
-
exit = await firstScan(repo, opts, cwd);
|
|
361
|
+
exit = await firstScan(repo, opts, cwd, session.key);
|
|
333
362
|
}
|
|
334
363
|
// 9. What is left, per tool.
|
|
335
364
|
say();
|
package/dist/commands/shared.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { confirm } from '@inquirer/prompts';
|
|
2
1
|
import { writeFileSync } from 'node:fs';
|
|
3
2
|
import { resolve } from 'node:path';
|
|
4
3
|
import { CLI_API, ToolError, cliApi, cliFetch, isMissingRoute, isToolError, tools } from '../api.js';
|
|
@@ -7,7 +6,7 @@ import { exitCodeOfStart, scanFinished, watchScan } from '../flow.js';
|
|
|
7
6
|
import { scanLink } from '../payment.js';
|
|
8
7
|
import { currentGithubRepo } from '../repo.js';
|
|
9
8
|
import { defaultRepository } from '../state.js';
|
|
10
|
-
import { cross, dot, interactive, say, tick } from '../ui.js';
|
|
9
|
+
import { ask, cross, dot, interactive, say, tick } from '../ui.js';
|
|
11
10
|
export const DOCTOR_HINT = 'Run npx sekura@latest doctor to see what is left to set up.';
|
|
12
11
|
export function withQuoteOptions(cmd) {
|
|
13
12
|
return cmd
|
|
@@ -56,12 +55,26 @@ export function resolveRepository(given, cwd = process.cwd()) {
|
|
|
56
55
|
const AGENT_LINE = /^If the person agrees, call |payment: \{ sharedPaymentToken|^nextStep:/;
|
|
57
56
|
const CONFIRM_WITH = /; confirm with payment: \{ savedCard: (?:true|\{ card: "[^"]*" \}) \}/g;
|
|
58
57
|
const CHECKOUT_HOW = /: leave payment out; the answer is 402 with a Stripe Checkout link to open in the person's browser/;
|
|
58
|
+
// The server writes a quote for an agent that shows it to a person ("the
|
|
59
|
+
// person must read ... Show it to them as it stands"). Printed as it is in a
|
|
60
|
+
// terminal, it talks about the reader in the third person and tells them to
|
|
61
|
+
// show themselves the price (29 November 2026). These turn the agent's
|
|
62
|
+
// sentences into the reader's; anything they do not match is printed as sent.
|
|
63
|
+
const PERSON_REWRITES = [
|
|
64
|
+
[/, the person must read and agree to the authorization below\. Show it to them as it stands, with [^.]*?, and ask whether they agree\./g, ': read the authorization below, and agree only if it is right.'],
|
|
65
|
+
[/Before Sekura (brings forward|starts) (.+?), show the person what it does below and ask whether they agree\./g, (_m, verb, what) => `Sekura ${verb === 'starts' ? 'would start' : 'would bring forward'} ${what}. Here is what it does.`],
|
|
66
|
+
[/This account's free[ ]first[ ]scan is still available(?:, on sekura\.ai only)?: the person starts it themselves (?:by running `[^`]+` in a terminal, or )?at (\S+?)\. It is not started through a connected tool, and confirming here buys a one-time scan at (\$[\d.,]+) instead\./g,
|
|
67
|
+
(_m, url, price) => `Your first scan is still free, at ${url}. Agreeing here buys a one-time scan at ${price} instead.`],
|
|
68
|
+
];
|
|
59
69
|
export function personText(text) {
|
|
60
70
|
const out = [];
|
|
61
71
|
for (const raw of text.split('\n')) {
|
|
62
72
|
if (AGENT_LINE.test(raw.replace(/^- /, '')))
|
|
63
73
|
continue;
|
|
64
|
-
|
|
74
|
+
let line = raw.replace(CONFIRM_WITH, '').replace(CHECKOUT_HOW, ': a Stripe Checkout page in your browser');
|
|
75
|
+
for (const [re, to] of PERSON_REWRITES)
|
|
76
|
+
line = line.replace(re, to);
|
|
77
|
+
out.push(line);
|
|
65
78
|
}
|
|
66
79
|
while (out.length && !out[out.length - 1].trim())
|
|
67
80
|
out.pop();
|
|
@@ -106,7 +119,7 @@ export function sayAbandoned(result) {
|
|
|
106
119
|
export async function offerAbandon(key, planId) {
|
|
107
120
|
if (!planId || !interactive())
|
|
108
121
|
return null;
|
|
109
|
-
const yes = await
|
|
122
|
+
const yes = await ask('Cancel this payment? Nothing is charged, and the Checkout link stops working.', { default: false, short: 'Cancel this payment?' });
|
|
110
123
|
if (!yes)
|
|
111
124
|
return null;
|
|
112
125
|
const result = await abandonPayment(key, planId);
|
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
// a tool keeps in its own store (Codex, Devin) are keys the CLI never sees;
|
|
7
7
|
// the person is pointed at Settings → Agents and API keys for those.
|
|
8
8
|
import { Command } from 'commander';
|
|
9
|
-
import { confirm } from '@inquirer/prompts';
|
|
10
9
|
import { buildPlan, detectTools, removalLabel, removeStep } from '../plan.js';
|
|
11
10
|
import { credentialsPath, forgetAllKeys, hostOf, keyName, revokeKey, savedKeys } from '../auth.js';
|
|
12
11
|
import { revokeSessionKey, toolKeyName } from '../session.js';
|
|
13
12
|
import { KEYS_PAGE, serverNote } from '../catalogue.js';
|
|
14
|
-
import { cross, dot, say, tick } from '../ui.js';
|
|
13
|
+
import { ask, cross, dot, say, tick } from '../ui.js';
|
|
15
14
|
/** The Settings page on the server a key belongs to. */
|
|
16
15
|
const keysPageOf = (endpoint) => `${new URL(endpoint).origin}/app/settings → Agents and API keys`;
|
|
17
16
|
export async function runUninstall(opts) {
|
|
@@ -39,7 +38,7 @@ export async function runUninstall(opts) {
|
|
|
39
38
|
say();
|
|
40
39
|
return 0;
|
|
41
40
|
}
|
|
42
|
-
if (interactive && !(await
|
|
41
|
+
if (interactive && !(await ask('Remove?', { default: false, short: 'Remove?' }))) {
|
|
43
42
|
say(' Nothing was changed.');
|
|
44
43
|
return 0;
|
|
45
44
|
}
|
package/dist/flow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
3
|
import { readKey } from './auth.js';
|
|
4
4
|
import { call, getPlans, paymentRequiredOf, tools } from './api.js';
|
|
@@ -6,7 +6,7 @@ import { EXIT, Exit, SIGN_IN_HINT } from './exit.js';
|
|
|
6
6
|
import { openLink } from './open.js';
|
|
7
7
|
import { openableLink, paymentState } from './payment.js';
|
|
8
8
|
import { dropQuote, findQuote, saveQuote } from './state.js';
|
|
9
|
-
import { dot, interactive, printJson, say, tick, waitFor } from './ui.js';
|
|
9
|
+
import { ask, dot, interactive, printJson, say, tick, waitFor } from './ui.js';
|
|
10
10
|
export function requireKey() {
|
|
11
11
|
const key = readKey();
|
|
12
12
|
if (!key)
|
|
@@ -119,7 +119,7 @@ export async function confirmQuote(req) {
|
|
|
119
119
|
if (!interactive())
|
|
120
120
|
throw new Exit(EXIT.agreementRequired, `There is no terminal to agree in, so nothing was started. Run ${again}, show the quote to the person, then --confirm <quoteId>.`);
|
|
121
121
|
const payment = await askPayment(q, flags.card);
|
|
122
|
-
const agreed = await
|
|
122
|
+
const agreed = await ask(req.question ?? 'Do you agree?', { default: false, short: 'Do you agree?' });
|
|
123
123
|
if (!agreed)
|
|
124
124
|
throw new Exit(EXIT.declined, 'Nothing was started or charged.');
|
|
125
125
|
return { kind: 'agreed', how: 'asked', confirmOperation: q.confirmOperation, confirmArguments: withPayment(q.confirmArguments, payment), amountCents: amount, quoteId: null, quote: q };
|
package/dist/steps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { readKey, readToolKey, redact } from './auth.js';
|
|
3
3
|
import { getAccount, getBilling, getPlans, isMissingRoute, isToolError, listRepositories, SignedOut } from './api.js';
|
|
4
4
|
import { ENDPOINT, HOST, carriesKey, link } from './catalogue.js';
|
|
@@ -10,7 +10,7 @@ import { currentGithubRepo } from './repo.js';
|
|
|
10
10
|
import { obtainSession } from './session.js';
|
|
11
11
|
import { defaultRepository, setDefaultRepository } from './state.js';
|
|
12
12
|
import { termsFlow } from './terms.js';
|
|
13
|
-
import { cross, dot, say, tick, waitFor } from './ui.js';
|
|
13
|
+
import { ask, cross, dot, say, tick, waitFor } from './ui.js';
|
|
14
14
|
const isInteractive = (f) => f.interactive ?? (!f.yes && !f.json && !!process.stdin.isTTY && !!process.stderr.isTTY);
|
|
15
15
|
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
16
16
|
export function localConnections(opts = {}) {
|
|
@@ -189,7 +189,7 @@ export async function ensureTerms(s, flags = {}) {
|
|
|
189
189
|
}
|
|
190
190
|
const page = a?.links?.dashboard ?? link('/app');
|
|
191
191
|
say(`${dot} Before a scan can start, accept the Terms on ${HOST}: ${page}`);
|
|
192
|
-
if (interactive && await
|
|
192
|
+
if (interactive && await ask(`Open ${HOST} to do that now?`, { default: true, short: 'Open it now?' })) {
|
|
193
193
|
const o = openLink(page, { browser: flags.browser });
|
|
194
194
|
if (!o.opened)
|
|
195
195
|
say(` Open ${page}`);
|
package/dist/terms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { cliApi, isToolError } from './api.js';
|
|
3
3
|
import { EXIT, Exit } from './exit.js';
|
|
4
|
-
import { dot, say, tick } from './ui.js';
|
|
4
|
+
import { ask, dot, say, tick } from './ui.js';
|
|
5
5
|
export const termsCurrent = (t) => t.state === 'current';
|
|
6
6
|
export async function getTerms(key) {
|
|
7
7
|
const t = await cliApi(key, 'GET', '/terms');
|
|
@@ -62,7 +62,7 @@ export async function termsFlow(key, opts) {
|
|
|
62
62
|
return 'declined';
|
|
63
63
|
let marketing = opts.marketing === true;
|
|
64
64
|
if (opts.marketing === undefined && terms.marketingText)
|
|
65
|
-
marketing = await
|
|
65
|
+
marketing = await ask(terms.marketingText, { default: false, short: 'Send me product news?' });
|
|
66
66
|
try {
|
|
67
67
|
await acceptTerms(key, { version: terms.version, textHash: terms.textHash }, marketing);
|
|
68
68
|
say(`${tick} Terms accepted (version ${terms.version})`);
|
package/dist/ui.js
CHANGED
|
@@ -109,3 +109,37 @@ export async function waitFor(message, check, opts = {}) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* A yes/no question that never wraps. The prompt library word-wraps a long
|
|
114
|
+
* question but places the cursor as if the line were cut at the terminal's
|
|
115
|
+
* edge, so any question wider than the window leaves the cursor in the middle
|
|
116
|
+
* of a word ("rule", 29 November 2026; "here?", the same evening, in 0.5.0).
|
|
117
|
+
* A question that fits is asked as it is; a longer one is printed above,
|
|
118
|
+
* wrapped by us, and the prompt itself is the short form.
|
|
119
|
+
*/
|
|
120
|
+
export async function ask(message, opts) {
|
|
121
|
+
const { confirm } = await import('@inquirer/prompts');
|
|
122
|
+
const cols = Math.max(40, process.stderr.columns || process.stdout.columns || 80);
|
|
123
|
+
// "? " before it and " (Y/n) " after it.
|
|
124
|
+
if (message.length + 10 <= cols)
|
|
125
|
+
return confirm({ message, default: opts.default });
|
|
126
|
+
for (const line of wrapWords(message, cols - 4))
|
|
127
|
+
say(` ${line}`);
|
|
128
|
+
return confirm({ message: opts.short, default: opts.default });
|
|
129
|
+
}
|
|
130
|
+
/** Plain word wrap at `width` characters; a single longer word keeps its own line. */
|
|
131
|
+
export function wrapWords(text, width) {
|
|
132
|
+
const out = [];
|
|
133
|
+
let line = '';
|
|
134
|
+
for (const word of text.split(/\s+/).filter(Boolean)) {
|
|
135
|
+
if (line && line.length + 1 + word.length > width) {
|
|
136
|
+
out.push(line);
|
|
137
|
+
line = word;
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
line = line ? `${line} ${word}` : word;
|
|
141
|
+
}
|
|
142
|
+
if (line)
|
|
143
|
+
out.push(line);
|
|
144
|
+
return out;
|
|
145
|
+
}
|
package/package.json
CHANGED