sekura 0.5.17 → 0.5.21
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/README.md +5 -5
- package/dist/api.js +20 -4
- package/dist/auth.js +4 -4
- package/dist/catalogue.js +12 -8
- package/dist/cli.js +7 -1
- package/dist/commands/billing.js +3 -2
- package/dist/commands/findings.js +8 -6
- package/dist/commands/init.js +28 -5
- package/dist/commands/login.js +21 -6
- package/dist/commands/pay.js +11 -13
- package/dist/commands/plans.js +29 -13
- package/dist/commands/report.js +9 -4
- package/dist/commands/scan.js +12 -9
- package/dist/commands/scans.js +2 -2
- package/dist/commands/shared.js +78 -11
- package/dist/commands/status.js +12 -1
- package/dist/device.js +2 -2
- package/dist/errors.js +23 -1
- package/dist/flow.js +67 -26
- package/dist/open.js +49 -5
- package/dist/payment.js +29 -13
- package/dist/session.js +8 -4
- package/dist/skill.js +20 -2
- package/dist/state.js +18 -0
- package/dist/steps.js +49 -14
- package/dist/verify.js +4 -4
- package/dist/writers.js +23 -5
- package/package.json +2 -2
- package/skills/sekura/SKILL.md +3 -2
package/README.md
CHANGED
|
@@ -14,20 +14,20 @@ Every step is read from your account, so a second run carries on where the first
|
|
|
14
14
|
|
|
15
15
|
## Which Sekura servers do this today
|
|
16
16
|
|
|
17
|
-
The GitHub-code sign-in, the Terms in the terminal, the report download and a free first scan started from the terminal need a Sekura server with CLI onboarding switched on.
|
|
17
|
+
The GitHub-code sign-in, the Terms in the terminal, the report download and a free first scan started from the terminal need a Sekura server with CLI onboarding switched on. Both `sekura.ai` and `dev.sekura.ai` have it. Against a server that does not offer the new sign-in, the CLI notices and uses the Sekura-page sign-in instead: you approve on a Sekura page, the Terms and the GitHub App are finished on Sekura pages the CLI opens and waits on, `report` and `billing --open` give you a link, and a first scan is quoted at its price. `--legacy-login` asks for that sign-in on any server. Every other command works the same either way.
|
|
18
18
|
|
|
19
19
|
## What a first run does
|
|
20
20
|
|
|
21
21
|
1. **Detects** the tools on this machine: Claude Code, Cursor, GitHub Copilot in VS Code, OpenAI Codex, Kiro, Cline, Zed, Antigravity, OpenCode, JetBrains Junie, Factory Droid, Tabnine, Devin and Goose. With none found it says how to name one (`--tools`) and carries on with your account.
|
|
22
|
-
2. **Asks one question**, with every detected tool, your user configuration, the skill and the sign-in as the defaults: `Connect Claude Code, Cursor and OpenAI Codex
|
|
23
|
-
3. **Shows the plan** before anything happens
|
|
22
|
+
2. **Asks one question**, with every detected tool, your user configuration, the skill and the sign-in as the defaults: `Connect Claude Code, Cursor and OpenAI Codex?`, under a line that reads `Every project · with skill · sign in with GitHub`. With more than three tools the question is `Connect these 5 tools?` and their names go on the line above. Answer **Yes**, **No**, or **Choose** to pick the tools, where (every project, or this project only when run inside one), the skill and the sign-in. A flag answers its own question and skips it.
|
|
23
|
+
3. **Shows the plan** before anything happens, one line for each step: the file Sekura is added to, or the tool's own command, then the skill. Then it asks **Apply?** `--dry-run` prints the detail instead and stops there: each file and the exact entry, with `Authorization: Bearer <your key, after sign-in>` where the key will go (a key you already have is shown as `sek_live_…abcd`).
|
|
24
24
|
4. **Signs you in.** It prints a code, copies it to your clipboard and opens `github.com/login/device`; you enter the code and approve. Over SSH, in a container, or with `--no-browser`, it prints the address instead of opening it. If the sign-in does not finish, nothing is written and the run stops with exit code 4.
|
|
25
25
|
5. **Writes the tool entries and the skill**, one step at a time, saying what each did. Your tools get a key of their own (see Your keys). Files that are not plain JSON (Zed's `settings.json` with comments, for one) are never rewritten; you are shown the lines to add. Codex and Devin cannot take a key in their configuration, so the CLI prints the one command that signs each in (`codex mcp login sekura`, `devin mcp login sekura`).
|
|
26
26
|
6. **Checks** that the Sekura server answers and takes your key.
|
|
27
27
|
7. **The Terms.** It prints the consent sentence and links to the documents, then asks **I accept** or **Not now**, and whether you want product emails. Nothing is accepted for you: `--yes` skips this step.
|
|
28
28
|
8. **The GitHub App.** If Sekura cannot scan anything yet, or not the repository in this folder, it opens the install page on github.com and carries on by itself once the repository shows up. Enter skips the wait.
|
|
29
29
|
9. **A repository.** This folder's GitHub remote first, otherwise your pick. It is saved as the default for `scan` and `plan`.
|
|
30
|
-
10. **A first scan**, when the account has none yet. The quote is printed as Sekura gives it, with the authorization wording and the price, and nothing starts until you agree. It is the $10 one-time scan: Stripe Checkout opens, the code
|
|
30
|
+
10. **A first scan**, when the account has none yet. The quote is printed as Sekura gives it, with the authorization wording and the price, and nothing starts until you agree. It is the $10 one-time scan: Stripe Checkout opens, the CLI prints the code to enter there (NPMSCAN, which makes it $0), and it waits for the payment. After the first scan, a repository is scanned on a monthly plan (`plan start`); Sekura sells no other one-time scan. Then it follows the scan (Enter stops watching; the scan carries on), prints the findings by severity and saves the report as `sekura-report-<scan-id>.html`.
|
|
31
31
|
11. **Says what is next in each tool**, such as "Claude Code: start a new Claude Code session, then type /sekura", and how to scan again from the terminal.
|
|
32
32
|
|
|
33
33
|
## Commands
|
|
@@ -174,7 +174,7 @@ The keys are stored in plain text. Every file the CLI writes one into, its own a
|
|
|
174
174
|
- **The server follows the key.** Without `SEKURA_ENDPOINT` or `--endpoint`, the CLI talks to the server your saved key is from, and every link it prints is on that server. It says so when that is not `sekura.ai`.
|
|
175
175
|
- **Codex and Devin** sign in with keys of their own; the CLI prints the command and runs nothing.
|
|
176
176
|
- **See or revoke a key** at [sekura.ai/app/settings](https://sekura.ai/app/settings) → Agents and API keys. Revoking one there ends it everywhere at once; run `sekura login` for a new one.
|
|
177
|
-
- **`sekura logout`** revokes the CLI's own key on Sekura and removes it here.
|
|
177
|
+
- **`sekura logout`** revokes the CLI's own key on Sekura and removes it here. The key your tools use was made from that sign-in, so Sekura ends it too; run `npx sekura@latest` again to sign in and give them a new one. With a single Sekura-page key, `logout` only removes the saved copy, because your tools are using it.
|
|
178
178
|
- **`sekura uninstall`** removes the entries (with their key), the skill and the guidance block. Then it revokes your tools' key and the CLI's key on the server that made them, and deletes the saved copies. If that server cannot revoke a key from the CLI, it tells you which key to revoke in Settings. `SEKURA_API_KEY` is never revoked: it is a key you made. `--keep-login` keeps the saved keys, and revokes nothing.
|
|
179
179
|
- **`--no-login`** writes no key anywhere.
|
|
180
180
|
|
package/dist/api.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// coding tools use. The server is stateless JSON-RPC over POST and answers
|
|
3
3
|
// in plain JSON, so no session and no MCP library: one request per call.
|
|
4
4
|
import { ENDPOINT, ORIGIN } from './catalogue.js';
|
|
5
|
-
import { reach, serverTrouble } from './errors.js';
|
|
5
|
+
import { USER_AGENT, reach, serverTrouble } from './errors.js';
|
|
6
6
|
export class SignedOut extends Error {
|
|
7
7
|
constructor(detail) { super(detail); this.name = 'SignedOut'; }
|
|
8
8
|
}
|
|
@@ -22,6 +22,15 @@ export class ToolError extends Error {
|
|
|
22
22
|
this.status = o.status;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* One form of a scan id everywhere: the bare uuid. The dashboard's links
|
|
27
|
+
* carry it as ss-<uuid>, so a person who copied one passed that to
|
|
28
|
+
* `report`, which echoed it back, while `scan show` printed the bare form:
|
|
29
|
+
* the same scan under two names (Varsha's 0.5.20 test, 1 December 2026,
|
|
30
|
+
* bug 7). Every command that takes a scan id accepts both, and every line
|
|
31
|
+
* that prints one prints this. The server reads both forms too.
|
|
32
|
+
*/
|
|
33
|
+
export const bareScanId = (raw) => raw.trim().replace(/^ss-/i, '');
|
|
25
34
|
export const isToolError = (e, code) => e instanceof ToolError && (code === undefined || e.code === code);
|
|
26
35
|
let nextId = 1;
|
|
27
36
|
const parsedBlock = (content) => {
|
|
@@ -46,7 +55,7 @@ const firstText = (content) => {
|
|
|
46
55
|
export async function call(key, op, args = {}, opts = {}) {
|
|
47
56
|
const r = await reach(ENDPOINT, {
|
|
48
57
|
method: 'POST',
|
|
49
|
-
headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
|
|
58
|
+
headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json', accept: 'application/json, text/event-stream', 'user-agent': USER_AGENT },
|
|
50
59
|
body: JSON.stringify({ jsonrpc: '2.0', id: nextId++, method: 'tools/call', params: { name: op, arguments: args } }),
|
|
51
60
|
signal: AbortSignal.timeout(opts.timeoutMs ?? 30_000),
|
|
52
61
|
});
|
|
@@ -72,7 +81,14 @@ export async function call(key, op, args = {}, opts = {}) {
|
|
|
72
81
|
const result = body.result ?? {};
|
|
73
82
|
const structured = result.structuredContent && typeof result.structuredContent === 'object' ? result.structuredContent : null;
|
|
74
83
|
const text = firstText(result.content);
|
|
75
|
-
|
|
84
|
+
// A refusal comes in two forms. The server marks it isError for this CLI
|
|
85
|
+
// (it knows the user-agent), and answers other clients with ok: false and
|
|
86
|
+
// the code in structuredContent, without isError, so an agent shows a 409
|
|
87
|
+
// or the Checkout hand-off as an answer rather than a fault. Read only
|
|
88
|
+
// isError, a CLI whose user-agent was lost would take a refusal for a
|
|
89
|
+
// quote and ask "Do you agree?" over it (coordinator, 1 December 2026).
|
|
90
|
+
const refused = structured?.ok === false && typeof structured.code === 'string';
|
|
91
|
+
if (result.isError || refused) {
|
|
76
92
|
const data = structured ?? parsedBlock(result.content) ?? {};
|
|
77
93
|
const link = typeof data.link === 'string' ? data.link : undefined;
|
|
78
94
|
const sentence = link && text.endsWith(` ${link}`) ? text.slice(0, -link.length - 1) : text;
|
|
@@ -90,7 +106,7 @@ export const CLI_API = '/api/cli/v1';
|
|
|
90
106
|
export async function cliFetch(key, method, path, body, opts = {}) {
|
|
91
107
|
return reach(`${ORIGIN}${CLI_API}${path}`, {
|
|
92
108
|
method,
|
|
93
|
-
headers: { authorization: `Bearer ${key}`, accept: 'application/json', ...(body ? { 'content-type': 'application/json' } : {}) },
|
|
109
|
+
headers: { authorization: `Bearer ${key}`, accept: 'application/json', 'user-agent': USER_AGENT, ...(body ? { 'content-type': 'application/json' } : {}) },
|
|
94
110
|
...(body ? { body: JSON.stringify(body) } : {}),
|
|
95
111
|
signal: AbortSignal.timeout(opts.timeoutMs ?? 30_000),
|
|
96
112
|
});
|
package/dist/auth.js
CHANGED
|
@@ -20,7 +20,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, chmodSync }
|
|
|
20
20
|
import { hostname } from 'node:os';
|
|
21
21
|
import { dirname } from 'node:path';
|
|
22
22
|
import { ENDPOINT, HOST, PRODUCTION, credentialsPath, usableEndpoint } from './catalogue.js';
|
|
23
|
-
import { reach, refusal } from './errors.js';
|
|
23
|
+
import { reach, refusal, withAgent } from './errors.js';
|
|
24
24
|
import { hasBrowser, openBrowser } from './open.js';
|
|
25
25
|
import { DEVICE_GRANT, deviceSignIn, remoteSession } from './device.js';
|
|
26
26
|
export const ISSUER = new URL(ENDPOINT).origin;
|
|
@@ -189,7 +189,7 @@ catch {
|
|
|
189
189
|
export async function revokeKey(key, endpoint = ENDPOINT) {
|
|
190
190
|
const origin = new URL(endpoint).origin;
|
|
191
191
|
try {
|
|
192
|
-
const m = await fetch(`${origin}/.well-known/oauth-authorization-server`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });
|
|
192
|
+
const m = await fetch(`${origin}/.well-known/oauth-authorization-server`, withAgent({ headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) }));
|
|
193
193
|
const doc = m.ok ? (await m.json().catch(() => null)) : null;
|
|
194
194
|
if (typeof doc?.revocation_endpoint !== 'string')
|
|
195
195
|
return 'unsupported';
|
|
@@ -202,12 +202,12 @@ export async function revokeKey(key, endpoint = ENDPOINT) {
|
|
|
202
202
|
}
|
|
203
203
|
if (at.origin !== origin)
|
|
204
204
|
return 'unsupported';
|
|
205
|
-
const r = await fetch(at.href, {
|
|
205
|
+
const r = await fetch(at.href, withAgent({
|
|
206
206
|
method: 'POST',
|
|
207
207
|
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
208
208
|
body: new URLSearchParams({ token: key, token_type_hint: 'access_token' }).toString(),
|
|
209
209
|
signal: AbortSignal.timeout(10_000),
|
|
210
|
-
});
|
|
210
|
+
}));
|
|
211
211
|
return r.ok ? 'revoked' : 'failed';
|
|
212
212
|
}
|
|
213
213
|
catch {
|
package/dist/catalogue.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// person chooses, and a tool they did not choose is not touched.
|
|
12
12
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
13
13
|
import { homedir, platform } from 'node:os';
|
|
14
|
-
import { join, delimiter } from 'node:path';
|
|
14
|
+
import { join, delimiter, isAbsolute } from 'node:path';
|
|
15
15
|
import { setCommandOrigin } from './ui.js';
|
|
16
16
|
/** The home directory, overridable for tests. */
|
|
17
17
|
export const home = () => process.env.SEKURA_HOME || homedir();
|
|
@@ -113,15 +113,19 @@ export function devinFile(h, name) {
|
|
|
113
113
|
}
|
|
114
114
|
/** True when `bin` is an executable on PATH. */
|
|
115
115
|
export function onPath(bin) {
|
|
116
|
+
return pathOf(bin) !== null;
|
|
117
|
+
}
|
|
118
|
+
export function pathOf(bin) {
|
|
116
119
|
const exts = platform() === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (existsSync(
|
|
122
|
-
return
|
|
120
|
+
const dirs = isAbsolute(bin) || /[\\/]/.test(bin) ? [''] : (process.env.PATH || '').split(delimiter).filter(Boolean);
|
|
121
|
+
for (const dir of dirs) {
|
|
122
|
+
for (const ext of exts) {
|
|
123
|
+
const candidate = dir ? join(dir, bin + ext) : bin + ext;
|
|
124
|
+
if (existsSync(candidate))
|
|
125
|
+
return candidate;
|
|
126
|
+
}
|
|
123
127
|
}
|
|
124
|
-
return
|
|
128
|
+
return null;
|
|
125
129
|
}
|
|
126
130
|
/** Stands in for the key in the plan shown before the sign-in. Not a key
|
|
127
131
|
* shape (no sek_ prefix), so it is never redacted into one, and writers.ts
|
package/dist/cli.js
CHANGED
|
@@ -98,7 +98,13 @@ catch (e) {
|
|
|
98
98
|
}
|
|
99
99
|
process.exit(e.code);
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
// A refusal that no command turned into an Exit is still the person's to
|
|
102
|
+
// read, with its commands (Varsha's 0.5.20 test, 1 December 2026).
|
|
103
|
+
if (e instanceof ToolError) {
|
|
104
|
+
const { refusalText } = await import('./commands/shared.js');
|
|
105
|
+
fail(refusalText(e), exitCodeFor(e));
|
|
106
|
+
}
|
|
107
|
+
if (e instanceof SignedOut)
|
|
102
108
|
fail(messageFor(e), exitCodeFor(e));
|
|
103
109
|
fail(`${e.message}\n If this keeps happening, write to ${SUPPORT}.`);
|
|
104
110
|
}
|
package/dist/commands/billing.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { readKey } from '../auth.js';
|
|
3
|
+
import { openLink } from '../open.js';
|
|
3
4
|
import { cliApi, getBilling, getPlans, isMissingRoute, isToolError, SignedOut } from '../api.js';
|
|
4
5
|
import { cardLines, cardsFingerprint, openableLink, paymentMethodsLink, planLines } from '../payment.js';
|
|
5
6
|
import { cross, dot, printJson, say, tick, waitFor } from '../ui.js';
|
|
@@ -98,7 +99,7 @@ export async function runBilling(opts = {}) {
|
|
|
98
99
|
return 1;
|
|
99
100
|
}
|
|
100
101
|
const link = page.link;
|
|
101
|
-
const opened = opts.browser
|
|
102
|
+
const opened = openLink(link, { browser: opts.browser }).opened;
|
|
102
103
|
const where = page.what === 'card' ? 'Stripe\'s page for saving a card' : page.what === 'portal' ? 'your cards on Stripe' : 'your payment methods';
|
|
103
104
|
if (opened)
|
|
104
105
|
say(`${tick} Opened ${where} in the browser.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { tools } from '../api.js';
|
|
2
|
+
import { bareScanId, tools } from '../api.js';
|
|
3
3
|
import { Exit, EXIT } from '../exit.js';
|
|
4
4
|
import { requireKey } from '../flow.js';
|
|
5
5
|
import { dot, print, printJson, say, tick } from '../ui.js';
|
|
@@ -8,8 +8,9 @@ const line = (f, i) => {
|
|
|
8
8
|
const head = `${i + 1}. [${f.severity}] ${f.title}${f.location ? ` — ${f.location}` : ''}`;
|
|
9
9
|
return f.description && f.description !== f.title ? [head, ` ${f.description}`] : [head];
|
|
10
10
|
};
|
|
11
|
-
export async function runFindings(
|
|
11
|
+
export async function runFindings(given, opts = {}) {
|
|
12
12
|
const key = requireKey();
|
|
13
|
+
const scanId = bareScanId(given);
|
|
13
14
|
const limit = opts.limit === undefined ? 20 : Number(opts.limit);
|
|
14
15
|
if (!Number.isInteger(limit) || limit < 1 || limit > 50)
|
|
15
16
|
throw new Exit(EXIT.error, '--limit takes a whole number from 1 to 50.');
|
|
@@ -18,17 +19,18 @@ export async function runFindings(scanId, opts = {}) {
|
|
|
18
19
|
printJson(data);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
22
|
+
const id = bareScanId(data.scanId ?? scanId);
|
|
21
23
|
if (!data.total) {
|
|
22
|
-
say(`${tick} Scan ${
|
|
24
|
+
say(`${tick} Scan ${id} has no findings.`);
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
say(`${tick} Scan ${
|
|
27
|
+
say(`${tick} Scan ${id}: ${data.total} ${data.total === 1 ? 'finding' : 'findings'} (${severityWords(data.counts)})`);
|
|
26
28
|
data.findings.forEach((f, i) => { for (const l of line(f, i))
|
|
27
29
|
print(l); });
|
|
28
30
|
if (data.total > data.findings.length)
|
|
29
|
-
say(`${dot} The ${data.findings.length} most severe are shown. The report has all ${data.total}, with the proof for each: npx sekura@latest report ${
|
|
31
|
+
say(`${dot} The ${data.findings.length} most severe are shown. The report has all ${data.total}, with the proof for each: npx sekura@latest report ${id}`);
|
|
30
32
|
else
|
|
31
|
-
say(`${dot} The report has the proof for each: npx sekura@latest report ${
|
|
33
|
+
say(`${dot} The report has the proof for each: npx sekura@latest report ${id}`);
|
|
32
34
|
}
|
|
33
35
|
export const findingsCommand = new Command('findings')
|
|
34
36
|
.description('Show a finished scan\'s findings, most severe first.')
|
package/dist/commands/init.js
CHANGED
|
@@ -179,6 +179,8 @@ export async function runInit(opts) {
|
|
|
179
179
|
// are the defaults; a flag answers its own question.
|
|
180
180
|
const detected = detectTools(cwd);
|
|
181
181
|
let chosen;
|
|
182
|
+
/** The tools step 1 named one by one; step 2 does not name them again. */
|
|
183
|
+
const listed = new Set();
|
|
182
184
|
if (opts.tools) {
|
|
183
185
|
const names = opts.tools.split(',').map((s) => s.trim()).filter(Boolean);
|
|
184
186
|
const unknown = unknownTools(names);
|
|
@@ -192,6 +194,11 @@ export async function runInit(opts) {
|
|
|
192
194
|
else {
|
|
193
195
|
chosen = detected.map((t) => t.id);
|
|
194
196
|
step('Detect tools');
|
|
197
|
+
// The tools already connected, by name, and the rest in one line. All
|
|
198
|
+
// thirteen were listed, twelve as "needs setup", and step 2 listed the
|
|
199
|
+
// same names again above "Connect these 13 tools?" (Varsha's 0.5.20
|
|
200
|
+
// test, 1 December 2026, W1 and W2).
|
|
201
|
+
const others = [];
|
|
195
202
|
for (const t of detected) {
|
|
196
203
|
let present = false;
|
|
197
204
|
try {
|
|
@@ -201,7 +208,16 @@ export async function runInit(opts) {
|
|
|
201
208
|
catch {
|
|
202
209
|
present = false;
|
|
203
210
|
}
|
|
204
|
-
|
|
211
|
+
if (present === true) {
|
|
212
|
+
say(`${tick} ${t.name} ${c.dim('connected')}`);
|
|
213
|
+
listed.add(t.id);
|
|
214
|
+
}
|
|
215
|
+
else
|
|
216
|
+
others.push(t.name);
|
|
217
|
+
}
|
|
218
|
+
if (others.length) {
|
|
219
|
+
const n = others.length;
|
|
220
|
+
say(`${warn} ${n}${listed.size ? ' other' : ''} ${n === 1 ? 'tool' : 'tools'} found; you choose ${n === 1 ? 'it' : 'them'} in the next step.`);
|
|
205
221
|
}
|
|
206
222
|
const missing = TOOLS.length - detected.length;
|
|
207
223
|
if (missing > 0)
|
|
@@ -234,13 +250,16 @@ export async function runInit(opts) {
|
|
|
234
250
|
step('Choose tools');
|
|
235
251
|
const names = chosen.map((id) => toolById(id)?.name ?? id);
|
|
236
252
|
const parts = summaryParts({ names, scope, skill, signIn: login ? (hasKey ? 'saved' : 'sign-in') : null });
|
|
237
|
-
for
|
|
253
|
+
// The names line only for tools step 1 did not name (W2).
|
|
254
|
+
const namedAbove = chosen.every((id) => listed.has(id));
|
|
255
|
+
const lines = parts.details.split('\n');
|
|
256
|
+
for (const l of namedAbove && lines.length > 1 ? lines.slice(1) : lines)
|
|
238
257
|
say(` ${c.dim(l.trim())}`);
|
|
239
258
|
const answer = await select({
|
|
240
259
|
message: parts.question,
|
|
241
260
|
choices: [
|
|
242
261
|
{ name: 'Yes', value: 'yes' },
|
|
243
|
-
{ name: '
|
|
262
|
+
{ name: 'Let me choose', value: 'edit' },
|
|
244
263
|
{ name: 'No, change nothing', value: 'no' },
|
|
245
264
|
],
|
|
246
265
|
});
|
|
@@ -269,9 +288,13 @@ export async function runInit(opts) {
|
|
|
269
288
|
if (open.skill)
|
|
270
289
|
skill = await ask('Install the skill? It teaches your agent to quote every scan first.', { default: true, short: 'Install the skill?' });
|
|
271
290
|
if (open.login) {
|
|
291
|
+
// No here leaves login false: the tools get no key and each signs in
|
|
292
|
+
// on its own the first time it is used, and the Terms, GitHub App
|
|
293
|
+
// and repository steps are left for later. "Use your saved
|
|
294
|
+
// sign-in? Your tools use it too." said neither (W4).
|
|
272
295
|
login = await ask(hasKey
|
|
273
|
-
? '
|
|
274
|
-
: 'Sign in to Sekura after the review? Your tools use the same sign-in.', { default: true, short: hasKey ? '
|
|
296
|
+
? 'Give your coding tools this sign-in? (No: each tool signs in on its own, and the account steps here are skipped)'
|
|
297
|
+
: 'Sign in to Sekura after the review? Your tools use the same sign-in.', { default: true, short: hasKey ? 'Give your coding tools this sign-in?' : 'Sign in to Sekura?' });
|
|
275
298
|
}
|
|
276
299
|
}
|
|
277
300
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -11,8 +11,8 @@ import { credentialsPath, forgetKey, hostOf, readSavedKey, savedCredentials } fr
|
|
|
11
11
|
import { EXIT, Exit } from '../exit.js';
|
|
12
12
|
import { howToScan, toolLogin } from '../guide.js';
|
|
13
13
|
import { revokeSessionKey, toolKeyFor, toolKeyName } from '../session.js';
|
|
14
|
-
import { ensureSignedIn } from '../steps.js';
|
|
15
|
-
import { defaultRepository } from '../state.js';
|
|
14
|
+
import { ensureSignedIn, ensureTerms, scannableDefault, TERMS_LATER } from '../steps.js';
|
|
15
|
+
import { defaultRepository, setDefaultRepository } from '../state.js';
|
|
16
16
|
import { cross, dot, say, tick } from '../ui.js';
|
|
17
17
|
/** A tool name that names two things ("Devin Desktop and the Devin CLI")
|
|
18
18
|
* takes a plural verb: "Devin Desktop and the Devin CLI keep their own
|
|
@@ -25,7 +25,7 @@ export async function runLogin(opts) {
|
|
|
25
25
|
const note = serverNote();
|
|
26
26
|
if (note)
|
|
27
27
|
say(` ${note}`);
|
|
28
|
-
const session = await ensureSignedIn({ interactive, legacy: opts.legacyLogin, device: opts.device, browser: opts.browser });
|
|
28
|
+
const session = await ensureSignedIn({ interactive, legacy: opts.legacyLogin, device: opts.device, browser: opts.browser, already: true });
|
|
29
29
|
let toolKey = session.key;
|
|
30
30
|
try {
|
|
31
31
|
const t = await toolKeyFor(session);
|
|
@@ -72,13 +72,20 @@ export async function runLogin(opts) {
|
|
|
72
72
|
if (!names.length)
|
|
73
73
|
say(`${dot} No tool on this machine has Sekura yet: run npx sekura@latest init.`);
|
|
74
74
|
const a = session.account;
|
|
75
|
+
// Asked here, not reported as a fault with a command to go and run (Sudhir,
|
|
76
|
+
// 1 December 2026, on Tikka's run: "Terms not accepted yet. A scan cannot
|
|
77
|
+
// start before that" read as an error and was "not polished"). A person
|
|
78
|
+
// who says Not now hears what it is for, and how to come back to it.
|
|
75
79
|
if (a?.termsAccepted === false || a?.termsUpdated === true) {
|
|
76
80
|
say();
|
|
77
|
-
|
|
81
|
+
if (interactive)
|
|
82
|
+
await ensureTerms(session, { interactive, soft: true });
|
|
83
|
+
else
|
|
84
|
+
say(`${dot} ${TERMS_LATER}`);
|
|
78
85
|
}
|
|
79
86
|
if (names.length) {
|
|
80
87
|
say();
|
|
81
|
-
howToScan(names,
|
|
88
|
+
howToScan(names, await scannableDefault(session.key), a);
|
|
82
89
|
}
|
|
83
90
|
say();
|
|
84
91
|
return failed;
|
|
@@ -107,8 +114,16 @@ export async function runLogout() {
|
|
|
107
114
|
say(r === 'revoked' ? `${tick} Revoked your sign-in key on ${hostOf(ENDPOINT)}` : `${dot} ${hostOf(ENDPOINT)} did not revoke your sign-in key from here. Revoke it at ${KEYS_PAGE}.`);
|
|
108
115
|
}
|
|
109
116
|
say(forgetKey() ? `${tick} Removed it from ${credentialsPath()}` : `${dot} No saved key at ${credentialsPath()}`);
|
|
117
|
+
// The default repository belongs to the account that chose it: kept, it
|
|
118
|
+
// was named to the next account that signed in here (Varsha's 0.5.20
|
|
119
|
+
// test, 1 December 2026, bug 17).
|
|
120
|
+
const repository = defaultRepository();
|
|
121
|
+
if (repository) {
|
|
122
|
+
setDefaultRepository(null);
|
|
123
|
+
say(`${tick} Forgot your default repository, ${repository}`);
|
|
124
|
+
}
|
|
110
125
|
say(saved.kind === 'cli'
|
|
111
|
-
? `
|
|
126
|
+
? ` The key your coding tools use was made from this sign-in, so Sekura ends it too. Run npx sekura@latest to sign in again and give them a new one.`
|
|
112
127
|
: ` Tools that were given the key keep it until you run npx sekura@latest uninstall. To end it everywhere: ${KEYS_PAGE}.`);
|
|
113
128
|
say();
|
|
114
129
|
}
|
package/dist/commands/pay.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { readKey } from '../auth.js';
|
|
3
3
|
import { SignedOut } from '../api.js';
|
|
4
|
-
import { planById, waitForPayment } from '../flow.js';
|
|
5
|
-
import {
|
|
4
|
+
import { planById, sayCheckout, waitForPayment } from '../flow.js';
|
|
5
|
+
import { openLink } from '../open.js';
|
|
6
|
+
import { checkoutCodeLine, monthlyName, openableLink, scanLink } from '../payment.js';
|
|
7
|
+
import { checkoutCodeFor, dropCheckoutCode } from '../state.js';
|
|
6
8
|
import { cross, dot, say, tick } from '../ui.js';
|
|
7
9
|
import { abandonPayment, offerAbandon, sayAbandoned } from './shared.js';
|
|
8
10
|
export const PAY_EXIT = { started: 0, paid: 0, notSignedIn: 4, cancelled: 3, timeout: 2, badLink: 1 };
|
|
@@ -11,14 +13,6 @@ const minutes = (raw, fallback) => {
|
|
|
11
13
|
const n = Number(raw);
|
|
12
14
|
return Number.isFinite(n) && n > 0 ? Math.min(n, 60) : fallback;
|
|
13
15
|
};
|
|
14
|
-
function sayOpened(link, opened) {
|
|
15
|
-
if (opened)
|
|
16
|
-
say(`${tick} Opened Stripe Checkout in your browser.`);
|
|
17
|
-
else {
|
|
18
|
-
say(`${dot} Open this link in a browser to pay:`);
|
|
19
|
-
say(` ${link.href}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
16
|
function sayOutcome(state, plan) {
|
|
23
17
|
const repo = planName(plan);
|
|
24
18
|
if (state.kind === 'started') {
|
|
@@ -61,14 +55,17 @@ export async function runPay(link, opts = {}) {
|
|
|
61
55
|
say(`${cross} Give the plan id Sekura answered with: npx sekura@latest pay --plan <id>`);
|
|
62
56
|
return PAY_EXIT.badLink;
|
|
63
57
|
}
|
|
58
|
+
const code = opts.plan ? checkoutCodeFor(opts.plan) : null;
|
|
64
59
|
if (link) {
|
|
65
60
|
const url = openableLink(link);
|
|
66
61
|
if (!url) {
|
|
67
62
|
say(`${cross} Not a Stripe Checkout or Sekura link, so it was not opened: ${link}`);
|
|
68
63
|
return PAY_EXIT.badLink;
|
|
69
64
|
}
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
sayCheckout(openLink(url.href, { browser: opts.open !== false }), url, code);
|
|
66
|
+
}
|
|
67
|
+
else if (code) {
|
|
68
|
+
say(`${dot} ${checkoutCodeLine(code)}`);
|
|
72
69
|
}
|
|
73
70
|
const key = readKey();
|
|
74
71
|
if (!opts.plan || !key) {
|
|
@@ -88,6 +85,7 @@ export async function runPay(link, opts = {}) {
|
|
|
88
85
|
}
|
|
89
86
|
const { result, state: final, plan: last } = await waitForPayment(key, planId, start, { timeoutMs: minutes(opts.timeout, 9) * 60_000, ...(opts.intervalMs ? { intervalMs: opts.intervalMs } : {}) });
|
|
90
87
|
if (result === 'done' || final.kind === 'paid') {
|
|
88
|
+
dropCheckoutCode(planId);
|
|
91
89
|
sayOutcome(final, last);
|
|
92
90
|
return final.kind === 'cancelled' ? PAY_EXIT.cancelled : PAY_EXIT.started;
|
|
93
91
|
}
|
package/dist/commands/plans.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { input } from '@inquirer/prompts';
|
|
3
|
-
import { call, getPlans, isToolError, tools } from '../api.js';
|
|
3
|
+
import { bareScanId, call, getPlans, isToolError, tools } from '../api.js';
|
|
4
4
|
import { EXIT, Exit, messageFor } from '../exit.js';
|
|
5
5
|
import { confirmQuote, requireKey, startWithPayment } from '../flow.js';
|
|
6
6
|
import { monthlyName } from '../payment.js';
|
|
7
7
|
import { select, cross, dot, interactive, printJson, printTable, say } from '../ui.js';
|
|
8
|
-
import { afterStart, ready, resolveRepository, sayText, withQuoteOptions, withoutConfirm } from './shared.js';
|
|
8
|
+
import { afterStart, alreadyHints, ready, resolveRepository, sayText, withQuoteOptions, withoutConfirm } from './shared.js';
|
|
9
9
|
const when = (iso) => (iso ? iso.replace('T', ' ').slice(0, 16) : '');
|
|
10
10
|
const stateOf = (p) => p.status === 'pending' ? 'waiting on a payment'
|
|
11
11
|
: p.status === 'canceled' ? 'ended'
|
|
@@ -19,7 +19,7 @@ const COLUMNS = [
|
|
|
19
19
|
{ header: 'SCHEDULE', value: (p) => (monthlyName(p) ? p.schedule?.description ?? '' : '') },
|
|
20
20
|
{ header: 'STATE', value: stateOf },
|
|
21
21
|
{ header: 'NEXT RUN (UTC)', value: (p) => when(p.nextRunAt) },
|
|
22
|
-
{ header: 'LAST SCAN', value: (p) => (p.lastScan ? `${p.lastScan.id} ${p.lastScan.status}` : '') },
|
|
22
|
+
{ header: 'LAST SCAN', value: (p) => (p.lastScan ? `${bareScanId(p.lastScan.id)} ${p.lastScan.status}` : '') },
|
|
23
23
|
];
|
|
24
24
|
export async function runPlans(opts = {}) {
|
|
25
25
|
const key = requireKey();
|
|
@@ -186,6 +186,17 @@ export async function runPlanStart(repo, opts = {}) {
|
|
|
186
186
|
const tier = tierOf(opts.tier);
|
|
187
187
|
const command = `npx sekura@latest plan start ${repository}`;
|
|
188
188
|
await ready(async () => {
|
|
189
|
+
// Asked first, as plan change does: the four schedule questions came
|
|
190
|
+
// before "already on a monthly plan" (Varsha's 0.5.20 test, 1 December
|
|
191
|
+
// 2026, bug 14). The plans list not answering is no reason to stop; the
|
|
192
|
+
// server refuses a second plan itself.
|
|
193
|
+
if (!opts.confirm) {
|
|
194
|
+
const plan = await planFor(key, repository).catch(() => undefined);
|
|
195
|
+
if (plan && liveMonthly(plan)) {
|
|
196
|
+
const sched = plan.schedule?.description ? `, scanned ${plan.schedule.description}` : '';
|
|
197
|
+
throw new Exit(EXIT.error, `${repository} is already on ${monthlyName(plan) === 'Your monthly plan' ? 'a monthly plan' : monthlyName(plan)}${sched}. Nothing was started or charged.\n ${alreadyHints(repository)}`, { code: 'already_always', planId: plan.id, repository });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
189
200
|
const agreed = await quoteSchedule(opts, async () => (opts.confirm ? { repository } : { repository, tier, schedule: await scheduleFor(tier, opts, command) }), (args) => confirmQuote({
|
|
190
201
|
op: 'quoteAlways',
|
|
191
202
|
args,
|
|
@@ -195,12 +206,16 @@ export async function runPlanStart(repo, opts = {}) {
|
|
|
195
206
|
question: `Do you agree, and start ${tier === 'pro' ? 'More frequently' : 'Weekly'} for ${repository}?`,
|
|
196
207
|
sayQuote: (text) => sayText(text, repository),
|
|
197
208
|
}));
|
|
198
|
-
if (agreed.kind
|
|
209
|
+
if (agreed.kind !== 'agreed')
|
|
199
210
|
return;
|
|
200
211
|
const outcome = await startWithPayment(key, agreed.confirmOperation, agreed.confirmArguments, { quoteId: agreed.quoteId, browser: opts.browser });
|
|
201
212
|
await afterStart(key, outcome, { what: `The plan for ${repository}`, repository, watch: opts.watch, report: opts.report, output: opts.output, json: opts.json });
|
|
202
|
-
});
|
|
213
|
+
}, { repository });
|
|
203
214
|
}
|
|
215
|
+
/** A monthly plan that is running and not cancelled: the server's test for
|
|
216
|
+
* already_always (sekura-www, src/connector/always.ts). A cancelled plan
|
|
217
|
+
* can be started again. */
|
|
218
|
+
export const liveMonthly = (p) => p.status === 'active' && p.plan === 'always' && !p.canceledAt;
|
|
204
219
|
async function planFor(key, repository) {
|
|
205
220
|
const [owner, name] = repository.toLowerCase().split('/');
|
|
206
221
|
const plans = (await getPlans(key)).plans ?? [];
|
|
@@ -227,7 +242,7 @@ export async function runPlanSchedule(repo, opts = {}) {
|
|
|
227
242
|
question: `Change the schedule for ${repository}?`,
|
|
228
243
|
sayQuote: (text) => sayText(text, repository),
|
|
229
244
|
}));
|
|
230
|
-
if (agreed.kind
|
|
245
|
+
if (agreed.kind !== 'agreed')
|
|
231
246
|
return;
|
|
232
247
|
const outcome = await startWithPayment(key, agreed.confirmOperation, agreed.confirmArguments, { quoteId: agreed.quoteId, browser: opts.browser });
|
|
233
248
|
if (outcome.kind === 'started') {
|
|
@@ -238,7 +253,7 @@ export async function runPlanSchedule(repo, opts = {}) {
|
|
|
238
253
|
return;
|
|
239
254
|
}
|
|
240
255
|
await afterStart(key, outcome, { what: `The new schedule for ${repository}`, repository, watch: false, json: opts.json });
|
|
241
|
-
});
|
|
256
|
+
}, { repository });
|
|
242
257
|
}
|
|
243
258
|
/**
|
|
244
259
|
* Move a repository between Weekly and More frequently (Sudhir, 29 November
|
|
@@ -276,7 +291,7 @@ export async function runPlanChange(repo, opts = {}) {
|
|
|
276
291
|
question: `Move ${repository} to ${toName}?`,
|
|
277
292
|
sayQuote: (text) => sayText(text, repository),
|
|
278
293
|
}));
|
|
279
|
-
if (agreed.kind
|
|
294
|
+
if (agreed.kind !== 'agreed')
|
|
280
295
|
return;
|
|
281
296
|
const outcome = await startWithPayment(key, agreed.confirmOperation, agreed.confirmArguments, { quoteId: agreed.quoteId, browser: opts.browser });
|
|
282
297
|
if (outcome.kind === 'started') {
|
|
@@ -287,7 +302,7 @@ export async function runPlanChange(repo, opts = {}) {
|
|
|
287
302
|
return;
|
|
288
303
|
}
|
|
289
304
|
await afterStart(key, outcome, { what: `The plan change for ${repository}`, repository, watch: false, json: opts.json });
|
|
290
|
-
});
|
|
305
|
+
}, { repository });
|
|
291
306
|
}
|
|
292
307
|
export async function runPlanRun(repo, opts = {}) {
|
|
293
308
|
const key = requireKey();
|
|
@@ -303,11 +318,11 @@ export async function runPlanRun(repo, opts = {}) {
|
|
|
303
318
|
question: `Start a scan of ${repository} now?`,
|
|
304
319
|
sayQuote: (text) => sayText(text, repository),
|
|
305
320
|
});
|
|
306
|
-
if (agreed.kind
|
|
321
|
+
if (agreed.kind !== 'agreed')
|
|
307
322
|
return;
|
|
308
323
|
const outcome = await startWithPayment(key, agreed.confirmOperation, agreed.confirmArguments, { quoteId: agreed.quoteId, browser: opts.browser });
|
|
309
324
|
await afterStart(key, outcome, { what: `The scan of ${repository}`, repository, watch: opts.watch, report: opts.report, output: opts.output, json: opts.json });
|
|
310
|
-
});
|
|
325
|
+
}, { repository });
|
|
311
326
|
}
|
|
312
327
|
export async function runPlanCancel(repo, opts = {}) {
|
|
313
328
|
const key = requireKey();
|
|
@@ -322,15 +337,16 @@ export async function runPlanCancel(repo, opts = {}) {
|
|
|
322
337
|
command: `npx sekura@latest plan cancel ${repository}`,
|
|
323
338
|
question: `Cancel the plan for ${repository}?`,
|
|
324
339
|
sayQuote: (text) => sayText(text, repository),
|
|
340
|
+
nothing: 'Nothing was cancelled.',
|
|
325
341
|
});
|
|
326
|
-
if (agreed.kind
|
|
342
|
+
if (agreed.kind !== 'agreed')
|
|
327
343
|
return;
|
|
328
344
|
const reply = await call(key, agreed.confirmOperation, withoutConfirm(agreed.confirmArguments));
|
|
329
345
|
if (opts.json)
|
|
330
346
|
printJson(reply.data);
|
|
331
347
|
else
|
|
332
348
|
sayText(reply.text, repository);
|
|
333
|
-
});
|
|
349
|
+
}, { repository });
|
|
334
350
|
}
|
|
335
351
|
const REPO_ARG = 'owner/repo; the default is your saved repository, then this folder\'s GitHub remote';
|
|
336
352
|
const start = withFollowOptions(withScheduleOptions(withQuoteOptions(new Command('start')
|
package/dist/commands/report.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { requireKey } from '../flow.js';
|
|
3
|
-
import {
|
|
3
|
+
import { bareScanId } from '../api.js';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { NOT_OPENED, SEKURA_HOSTS, openLink, openTrusted } from '../open.js';
|
|
4
6
|
import { dot, printJson, say, tick } from '../ui.js';
|
|
5
7
|
import { fetchReport, ready, saySaved } from './shared.js';
|
|
6
|
-
export async function runReport(
|
|
8
|
+
export async function runReport(given, opts = {}) {
|
|
7
9
|
const key = requireKey();
|
|
10
|
+
const scanId = bareScanId(given);
|
|
8
11
|
const saved = await ready(() => fetchReport(key, scanId, opts.output));
|
|
9
12
|
if (opts.json)
|
|
10
13
|
printJson(saved);
|
|
11
14
|
else
|
|
12
15
|
saySaved(saved);
|
|
13
16
|
if (saved.kind === 'saved') {
|
|
14
|
-
if (opts.open && openLink(
|
|
17
|
+
if (opts.open && openLink(pathToFileURL(saved.path).href, { browser: opts.browser }).opened && !opts.json)
|
|
15
18
|
say(`${tick} Opened it in your browser.`);
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
if (opts.json)
|
|
19
22
|
return;
|
|
20
|
-
const opened =
|
|
23
|
+
const opened = openTrusted(saved.link, SEKURA_HOSTS, { browser: opts.browser });
|
|
21
24
|
if (opened.opened)
|
|
22
25
|
say(`${tick} Opened it in your browser.`);
|
|
26
|
+
else if (opened.why === 'untrusted')
|
|
27
|
+
say(`${dot} ${NOT_OPENED} ${saved.link}`);
|
|
23
28
|
if (saved.expiresAt)
|
|
24
29
|
say(`${dot} The report is kept until ${saved.expiresAt}.`);
|
|
25
30
|
}
|