sekura 0.4.0 → 0.4.2
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 +8 -5
- package/dist/auth.js +137 -19
- package/dist/catalogue.js +53 -9
- package/dist/commands/billing.js +25 -3
- package/dist/commands/doctor.js +37 -0
- package/dist/commands/findings.js +38 -0
- package/dist/commands/init.js +20 -9
- package/dist/commands/login.js +2 -2
- package/dist/commands/pay.js +5 -2
- package/dist/commands/plans.js +263 -0
- package/dist/commands/report.js +33 -0
- package/dist/commands/repos.js +55 -0
- package/dist/commands/scan.js +100 -0
- package/dist/commands/scans.js +32 -0
- package/dist/commands/shared.js +236 -0
- package/dist/commands/status.js +14 -2
- package/dist/commands/terms.js +78 -0
- package/dist/commands/uninstall.js +38 -12
- package/dist/device.js +6 -6
- package/dist/errors.js +17 -0
- package/dist/exit.js +46 -0
- package/dist/flow.js +218 -0
- package/dist/guide.js +26 -11
- package/dist/open.js +68 -0
- package/dist/origin.js +66 -0
- package/dist/payment.js +32 -0
- package/dist/plan.js +15 -0
- package/dist/session.js +182 -0
- package/dist/state.js +72 -0
- package/dist/steps.js +330 -0
- package/dist/terms.js +81 -0
- package/dist/verify.js +5 -1
- package/dist/writers.js +76 -10
- package/package.json +2 -2
- package/skills/sekura/SKILL.md +33 -21
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Every scan you then ask for in your coding tool is quoted first, with the price
|
|
|
32
32
|
|
|
33
33
|
The quote lists how you can pay:
|
|
34
34
|
|
|
35
|
-
- **A saved card**, shown only by brand and last four (`Visa •••• •••• •••• 4242`). Pick one and it is charged right there, with no browser: `Charged $
|
|
35
|
+
- **A saved card**, shown only by brand and last four (`Visa •••• •••• •••• 4242`). Pick one and it is charged right there, with no browser: `Charged $10 to Visa ending 4242`, then the scan id and link.
|
|
36
36
|
- **Pay with a Checkout link.** The agent runs `npx sekura@latest pay "<link>" --plan <id>`, which opens Stripe Checkout in your default browser and waits. When the payment lands, the same session shows the scan id and link. Your first payment is always made this way, and the card you use is saved for next time.
|
|
37
37
|
- **Change payment method.** The agent runs `npx sekura@latest billing --open`, which opens the page where you add or change a card, then shows the updated list.
|
|
38
38
|
|
|
@@ -62,11 +62,11 @@ npx sekura@latest init --tools claude,cursor --no-skill
|
|
|
62
62
|
npx sekura@latest init --no-login # no sign-in here; each tool signs in on first use
|
|
63
63
|
npx sekura@latest init --device # sign in with a code, for a terminal on another machine
|
|
64
64
|
npx sekura@latest login # sign in again, give connected tools the key, pick a repository
|
|
65
|
-
npx sekura@latest status # what is connected, and who is signed in
|
|
66
|
-
npx sekura@latest billing # your saved cards, masked; --open to change
|
|
65
|
+
npx sekura@latest status # what is connected (asking Codex, Droid, Devin and Tabnine their own list), and who is signed in
|
|
66
|
+
npx sekura@latest billing # your saved cards, masked, and your active plans; --open to change the cards
|
|
67
67
|
npx sekura@latest pay "<checkout link>" --plan <id> # open Checkout and wait for the payment
|
|
68
68
|
npx sekura@latest logout # forget the saved key
|
|
69
|
-
npx sekura@latest uninstall # remove the entries, the skill
|
|
69
|
+
npx sekura@latest uninstall # remove the entries, the skill and the guidance block; revoke and delete the saved key
|
|
70
70
|
SEKURA_API_KEY=sek_live_… npx sekura@latest init --yes # unattended, with a key from Settings
|
|
71
71
|
SEKURA_ENDPOINT=https://dev.sekura.ai/mcp npx sekura@latest billing # against another Sekura server, for testing
|
|
72
72
|
```
|
|
@@ -99,9 +99,12 @@ The skill goes to `~/.agents/skills/sekura/SKILL.md` and, when Claude Code is pr
|
|
|
99
99
|
|
|
100
100
|
Signing in creates one Sekura key, named "Sekura CLI (your computer's name)", whichever way you signed in (browser or code). The CLI saves it in `~/.config/sekura/credentials.json` (under `$XDG_CONFIG_HOME` when that is set), readable by you only, and writes it as an `Authorization: Bearer` header into each tool's user configuration. `SEKURA_API_KEY` in the environment is used instead of the saved file when it is set. Nothing printed ever shows the whole key.
|
|
101
101
|
|
|
102
|
+
- **One key per Sekura server.** A rerun of `init` or `login` uses the saved key while Sekura still takes it, so it makes no new one. A key for `dev.sekura.ai` is kept beside the one for `sekura.ai`, and neither replaces the other.
|
|
103
|
+
- **The server follows the key.** Without `SEKURA_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`.
|
|
104
|
+
- **Codex and Devin** sign in with keys of their own, and each `mcp login` makes a new one. The CLI skips it when the tool's own list already shows it signed in (Codex shows this).
|
|
102
105
|
- **See or revoke it** at [sekura.ai/app/settings](https://sekura.ai/app/settings) → Agents and API keys. Revoking it there ends it everywhere at once; run `sekura login` for a new one.
|
|
103
106
|
- **`sekura logout`** removes the saved copy. Tools that were given the key keep it.
|
|
104
|
-
- **`sekura uninstall`** removes the entries (with their key), the skill
|
|
107
|
+
- **`sekura uninstall`** removes the entries (with their key), the skill and the guidance block. Then it revokes the saved key on the server that made it, and deletes the saved copy. 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 key, and revokes nothing.
|
|
105
108
|
- **`--no-login`** writes no key anywhere, as 0.1.x did.
|
|
106
109
|
|
|
107
110
|
Review before running: the source is this repository, the package is [`sekura` on npm](https://www.npmjs.com/package/sekura), and `--dry-run` prints every write the wizard would make.
|
package/dist/auth.js
CHANGED
|
@@ -11,47 +11,165 @@
|
|
|
11
11
|
// (device.ts, RFC 8628).
|
|
12
12
|
//
|
|
13
13
|
// The key is kept in ~/.config/sekura/credentials.json, readable by the
|
|
14
|
-
// person only, so a rerun of `init` or `login`
|
|
15
|
-
// SEKURA_API_KEY in the environment wins over
|
|
14
|
+
// person only, one per server, so a rerun of `init` or `login` reuses it
|
|
15
|
+
// instead of minting another. SEKURA_API_KEY in the environment wins over
|
|
16
|
+
// the file, and is never revoked here: it is a key the person made.
|
|
16
17
|
import { createHash, randomBytes } from 'node:crypto';
|
|
17
18
|
import { createServer } from 'node:http';
|
|
18
19
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, chmodSync } from 'node:fs';
|
|
19
20
|
import { hostname, platform } from 'node:os';
|
|
20
|
-
import { dirname
|
|
21
|
+
import { dirname } from 'node:path';
|
|
21
22
|
import { spawn } from 'node:child_process';
|
|
22
|
-
import { ENDPOINT,
|
|
23
|
+
import { ENDPOINT, HOST, PRODUCTION, credentialsPath, onPath, usableEndpoint } from './catalogue.js';
|
|
23
24
|
import { DEVICE_GRANT, deviceSignIn, remoteSession } from './device.js';
|
|
24
25
|
export const ISSUER = new URL(ENDPOINT).origin;
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (env)
|
|
29
|
-
return env;
|
|
26
|
+
export { credentialsPath };
|
|
27
|
+
const valid = (c) => !!c && typeof c.key === 'string' && !!c.key;
|
|
28
|
+
function readStore() {
|
|
30
29
|
try {
|
|
31
30
|
const c = JSON.parse(readFileSync(credentialsPath(), 'utf8'));
|
|
32
|
-
|
|
31
|
+
if (valid(c))
|
|
32
|
+
return { keys: {}, legacy: c };
|
|
33
|
+
const keys = {};
|
|
34
|
+
for (const [at, v] of Object.entries((c?.keys ?? {})))
|
|
35
|
+
if (usableEndpoint(at) && valid(v))
|
|
36
|
+
keys[at] = v;
|
|
37
|
+
return { current: typeof c?.current === 'string' ? c.current : undefined, keys };
|
|
33
38
|
}
|
|
34
39
|
catch {
|
|
35
|
-
return
|
|
40
|
+
return { keys: {} };
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
|
-
|
|
43
|
+
function writeStore(s) {
|
|
39
44
|
const p = credentialsPath();
|
|
45
|
+
if (!Object.keys(s.keys).length) {
|
|
46
|
+
if (existsSync(p))
|
|
47
|
+
rmSync(p);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!s.current || !s.keys[s.current])
|
|
51
|
+
s.current = Object.keys(s.keys)[0];
|
|
40
52
|
mkdirSync(dirname(p), { recursive: true });
|
|
41
|
-
writeFileSync(p, JSON.stringify({
|
|
53
|
+
writeFileSync(p, JSON.stringify({ current: s.current, keys: s.keys }, null, 2) + '\n', { mode: 0o600 });
|
|
42
54
|
try {
|
|
43
55
|
chmodSync(p, 0o600);
|
|
44
56
|
}
|
|
45
57
|
catch { /* Windows */ }
|
|
46
|
-
return p;
|
|
47
58
|
}
|
|
48
|
-
|
|
59
|
+
/** The key saved for this server, never SEKURA_API_KEY. */
|
|
60
|
+
export function readSavedKey(endpoint = ENDPOINT) {
|
|
61
|
+
const s = readStore();
|
|
62
|
+
return s.keys[endpoint]?.key ?? s.legacy?.key ?? null;
|
|
63
|
+
}
|
|
64
|
+
export function readKey() {
|
|
65
|
+
const env = process.env.SEKURA_API_KEY?.trim();
|
|
66
|
+
if (env)
|
|
67
|
+
return env;
|
|
68
|
+
return readSavedKey();
|
|
69
|
+
}
|
|
70
|
+
/** Every key saved here, with the server it belongs to. */
|
|
71
|
+
export function savedKeys() {
|
|
72
|
+
const s = readStore();
|
|
73
|
+
const out = Object.entries(s.keys).map(([endpoint, c]) => ({ ...c, endpoint }));
|
|
74
|
+
if (s.legacy)
|
|
75
|
+
out.push({ ...s.legacy, endpoint: ENDPOINT });
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
export function saveKey(key, email) {
|
|
79
|
+
const s = readStore();
|
|
80
|
+
// A key in the old shape is filed under this server first, as 0.4.1 used it.
|
|
81
|
+
if (s.legacy && s.legacy.key !== key && !s.keys[ENDPOINT])
|
|
82
|
+
s.keys[ENDPOINT] = s.legacy;
|
|
83
|
+
s.keys[ENDPOINT] = { key, ...(email ? { email } : {}), createdAt: new Date().toISOString() };
|
|
84
|
+
s.current = ENDPOINT;
|
|
85
|
+
delete s.legacy;
|
|
86
|
+
writeStore(s);
|
|
87
|
+
return credentialsPath();
|
|
88
|
+
}
|
|
89
|
+
/** Files a key read in the old shape under this server, once Sekura has
|
|
90
|
+
* said it is this server's. */
|
|
91
|
+
export function adoptSavedKey() {
|
|
92
|
+
const s = readStore();
|
|
93
|
+
if (!s.legacy)
|
|
94
|
+
return;
|
|
95
|
+
s.keys[ENDPOINT] = s.legacy;
|
|
96
|
+
s.current = ENDPOINT;
|
|
97
|
+
delete s.legacy;
|
|
98
|
+
writeStore(s);
|
|
99
|
+
}
|
|
100
|
+
/** Forgets this server's key; another server's stays. A key in the old
|
|
101
|
+
* shape that this (non-production) server does not know was most likely
|
|
102
|
+
* made on production, which is where 0.4.1 signed in unless told
|
|
103
|
+
* otherwise: it is kept as production's rather than thrown away live. */
|
|
104
|
+
export function forgetKey(endpoint = ENDPOINT) {
|
|
105
|
+
const s = readStore();
|
|
106
|
+
if (s.legacy) {
|
|
107
|
+
if (endpoint !== PRODUCTION && !s.keys[PRODUCTION])
|
|
108
|
+
s.keys[PRODUCTION] = s.legacy;
|
|
109
|
+
delete s.legacy;
|
|
110
|
+
writeStore(s);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (!s.keys[endpoint])
|
|
114
|
+
return false;
|
|
115
|
+
delete s.keys[endpoint];
|
|
116
|
+
if (s.current === endpoint)
|
|
117
|
+
delete s.current;
|
|
118
|
+
writeStore(s);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
/** Forgets every saved key. */
|
|
122
|
+
export function forgetAllKeys() {
|
|
49
123
|
const p = credentialsPath();
|
|
50
124
|
if (!existsSync(p))
|
|
51
125
|
return false;
|
|
52
126
|
rmSync(p);
|
|
53
127
|
return true;
|
|
54
128
|
}
|
|
129
|
+
/** The host a key belongs to, as a person reads it: dev.sekura.ai. */
|
|
130
|
+
export const hostOf = (endpoint) => { try {
|
|
131
|
+
return new URL(endpoint).host;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return endpoint;
|
|
135
|
+
} };
|
|
136
|
+
/**
|
|
137
|
+
* Asks the server that made the key to revoke it (OAuth token revocation,
|
|
138
|
+
* RFC 7009), with the key as its own proof. The endpoint is the one the
|
|
139
|
+
* server advertises (RFC 8414 `revocation_endpoint`), and only on that same
|
|
140
|
+
* origin: a metadata document that named another host would otherwise be
|
|
141
|
+
* handed the key. 'unsupported' when the server advertises none.
|
|
142
|
+
*/
|
|
143
|
+
export async function revokeKey(key, endpoint = ENDPOINT) {
|
|
144
|
+
const origin = new URL(endpoint).origin;
|
|
145
|
+
try {
|
|
146
|
+
const m = await fetch(`${origin}/.well-known/oauth-authorization-server`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });
|
|
147
|
+
const doc = m.ok ? (await m.json().catch(() => null)) : null;
|
|
148
|
+
if (typeof doc?.revocation_endpoint !== 'string')
|
|
149
|
+
return 'unsupported';
|
|
150
|
+
let at;
|
|
151
|
+
try {
|
|
152
|
+
at = new URL(doc.revocation_endpoint);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return 'unsupported';
|
|
156
|
+
}
|
|
157
|
+
if (at.origin !== origin)
|
|
158
|
+
return 'unsupported';
|
|
159
|
+
const r = await fetch(at.href, {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
162
|
+
body: new URLSearchParams({ token: key, token_type_hint: 'access_token' }).toString(),
|
|
163
|
+
signal: AbortSignal.timeout(10_000),
|
|
164
|
+
});
|
|
165
|
+
return r.ok ? 'revoked' : 'failed';
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return 'failed';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** The name Sekura gives the CLI's key, for finding it in Settings. */
|
|
172
|
+
export const keyName = () => `Sekura CLI (${hostname().slice(0, 60)})`;
|
|
55
173
|
/** A key as it may be shown: the prefix and the last four characters. */
|
|
56
174
|
export function redact(key) {
|
|
57
175
|
const m = /^(sek_[a-z]+_)/.exec(key);
|
|
@@ -138,14 +256,14 @@ async function post(path, body, type) {
|
|
|
138
256
|
const r = await fetch(`${ISSUER}${path}`, { method: 'POST', headers: { 'content-type': type, accept: 'application/json' }, body });
|
|
139
257
|
const data = (await r.json().catch(() => ({})));
|
|
140
258
|
if (!r.ok)
|
|
141
|
-
throw new Error(
|
|
259
|
+
throw new Error(`${HOST} refused the sign-in (${path}): ${data.error_description || data.error || r.status}`);
|
|
142
260
|
return data;
|
|
143
261
|
}
|
|
144
262
|
/** One public client for both ways in: the loopback redirect and the
|
|
145
263
|
* device code. sekura.ai accepts any port on the registered loopback URI. */
|
|
146
264
|
export async function register() {
|
|
147
265
|
const reg = await post('/oauth/register', JSON.stringify({
|
|
148
|
-
client_name:
|
|
266
|
+
client_name: keyName(),
|
|
149
267
|
redirect_uris: ['http://127.0.0.1/callback'],
|
|
150
268
|
token_endpoint_auth_method: 'none',
|
|
151
269
|
grant_types: ['authorization_code', DEVICE_GRANT],
|
|
@@ -153,7 +271,7 @@ export async function register() {
|
|
|
153
271
|
}), 'application/json');
|
|
154
272
|
const clientId = String(reg.client_id ?? '');
|
|
155
273
|
if (!clientId)
|
|
156
|
-
throw new Error(
|
|
274
|
+
throw new Error(`${HOST} did not register the CLI`);
|
|
157
275
|
return clientId;
|
|
158
276
|
}
|
|
159
277
|
/** Signs in and returns the key. */
|
|
@@ -190,7 +308,7 @@ export async function signIn(opts = {}) {
|
|
|
190
308
|
}).toString(), 'application/x-www-form-urlencoded');
|
|
191
309
|
const key = String(tok.access_token ?? '');
|
|
192
310
|
if (!key)
|
|
193
|
-
throw new Error(
|
|
311
|
+
throw new Error(`${HOST} answered without a key`);
|
|
194
312
|
return key;
|
|
195
313
|
}
|
|
196
314
|
finally {
|
package/dist/catalogue.js
CHANGED
|
@@ -9,14 +9,58 @@
|
|
|
9
9
|
// A tool is "present" when its config directory exists or its binary is on
|
|
10
10
|
// PATH. Presence decides what the wizard offers, never what it writes: the
|
|
11
11
|
// person chooses, and a tool they did not choose is not touched.
|
|
12
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
12
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
13
13
|
import { homedir, platform } from 'node:os';
|
|
14
14
|
import { join, delimiter } from 'node:path';
|
|
15
|
-
export const ENDPOINT = process.env.SEKURA_ENDPOINT?.trim() || 'https://sekura.ai/mcp';
|
|
16
|
-
export const SERVER_NAME = 'sekura';
|
|
17
|
-
export const DOCS = 'https://sekura.ai/connect/';
|
|
18
15
|
/** The home directory, overridable for tests. */
|
|
19
16
|
export const home = () => process.env.SEKURA_HOME || homedir();
|
|
17
|
+
/** Where the saved keys live (auth.ts reads and writes the file). Here,
|
|
18
|
+
* because the address below is read from it before anything else loads. */
|
|
19
|
+
export const credentialsPath = () => join(process.env.XDG_CONFIG_HOME || join(home(), '.config'), 'sekura', 'credentials.json');
|
|
20
|
+
export const PRODUCTION = 'https://sekura.ai/mcp';
|
|
21
|
+
/** An address the CLI will send a key to: https, or http on this machine. */
|
|
22
|
+
export function usableEndpoint(raw) {
|
|
23
|
+
if (typeof raw !== 'string' || !raw.trim())
|
|
24
|
+
return null;
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(raw.trim());
|
|
27
|
+
const local = u.hostname === '127.0.0.1' || u.hostname === 'localhost';
|
|
28
|
+
return u.protocol === 'https:' || (local && u.protocol === 'http:') ? raw.trim() : null;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The server the last saved key was made for. Without it, a run with no
|
|
35
|
+
* SEKURA_ENDPOINT after a sign-in on dev.sekura.ai checked sekura.ai, found
|
|
36
|
+
* none of the entries it had just written, and linked to production's
|
|
37
|
+
* Settings for a key production had never seen (27 November 2026). */
|
|
38
|
+
function savedEndpoint() {
|
|
39
|
+
try {
|
|
40
|
+
return usableEndpoint(JSON.parse(readFileSync(credentialsPath(), 'utf8'))?.current);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const fromEnv = process.env.SEKURA_ENDPOINT?.trim();
|
|
47
|
+
const fromSaved = fromEnv ? null : savedEndpoint();
|
|
48
|
+
/** SEKURA_ENDPOINT, else the server the saved key belongs to, else production. */
|
|
49
|
+
export const ENDPOINT = fromEnv || fromSaved || PRODUCTION;
|
|
50
|
+
/** Where ENDPOINT came from, so a run against another server says so. */
|
|
51
|
+
export const ENDPOINT_SOURCE = fromEnv ? 'env' : fromSaved ? 'saved' : 'default';
|
|
52
|
+
/** Every link the CLI prints is on the server it talks to: dev.sekura.ai's
|
|
53
|
+
* pages for a dev key, never production's. */
|
|
54
|
+
export const ORIGIN = new URL(ENDPOINT).origin;
|
|
55
|
+
/** The server's host, where prose names it: sekura.ai, or dev.sekura.ai. */
|
|
56
|
+
export const HOST = new URL(ENDPOINT).host;
|
|
57
|
+
export const SERVER_NAME = 'sekura';
|
|
58
|
+
export const DOCS = `${ORIGIN}/connect/`;
|
|
59
|
+
export const SETTINGS = `${ORIGIN}/app/settings`;
|
|
60
|
+
export const KEYS_PAGE = `${SETTINGS} → Agents and API keys`;
|
|
61
|
+
/** One line naming the server, for a run that is not against production. */
|
|
62
|
+
export const serverNote = () => ENDPOINT === PRODUCTION ? null
|
|
63
|
+
: `Sekura server: ${ENDPOINT} (${ENDPOINT_SOURCE === 'env' ? 'from SEKURA_ENDPOINT' : 'where your saved key is from; set SEKURA_ENDPOINT to use another'})`;
|
|
20
64
|
/** VS Code's user directory, where Copilot's `mcp.json` lives. */
|
|
21
65
|
export function codeUserDir(h = home()) {
|
|
22
66
|
switch (platform()) {
|
|
@@ -70,7 +114,7 @@ export function onPath(bin) {
|
|
|
70
114
|
* shape (no sek_ prefix), so it is never redacted into one, and writers.ts
|
|
71
115
|
* refuses to write a target that carries it. */
|
|
72
116
|
export const PENDING_KEY = '<your key, after sign-in>';
|
|
73
|
-
const SIGN_IN =
|
|
117
|
+
const SIGN_IN = `the first time the tool uses Sekura, a ${HOST} page opens in your browser: sign in with GitHub and approve.`;
|
|
74
118
|
const url = { url: ENDPOINT };
|
|
75
119
|
const http = { type: 'http', url: ENDPOINT };
|
|
76
120
|
/** The header a key is sent in, as JSON configurations spell it. */
|
|
@@ -112,7 +156,7 @@ export const TOOLS = [
|
|
|
112
156
|
id: 'tools-codex', name: 'OpenAI Codex',
|
|
113
157
|
detect: (h) => existsSync(join(h, '.codex')) || onPath('codex'),
|
|
114
158
|
user: (h) => [
|
|
115
|
-
{ kind: 'command', bin: 'codex', add: ['mcp', 'add', SERVER_NAME, '--url', ENDPOINT], remove: ['mcp', 'remove', SERVER_NAME] },
|
|
159
|
+
{ kind: 'command', bin: 'codex', add: ['mcp', 'add', SERVER_NAME, '--url', ENDPOINT], remove: ['mcp', 'remove', SERVER_NAME], list: ['mcp', 'list'] },
|
|
116
160
|
{ kind: 'toml', path: join(h, '.codex', 'config.toml'), table: `mcp_servers.${SERVER_NAME}`, lines: [`url = "${ENDPOINT}"`] },
|
|
117
161
|
],
|
|
118
162
|
signIn: `run codex mcp login ${SERVER_NAME}, or sign in when Codex first uses Sekura.`,
|
|
@@ -170,7 +214,7 @@ export const TOOLS = [
|
|
|
170
214
|
id: 'tools-factory', name: 'Factory Droid',
|
|
171
215
|
detect: (h) => existsSync(join(h, '.factory')) || onPath('droid'),
|
|
172
216
|
user: () => [
|
|
173
|
-
{ kind: 'command', bin: 'droid', add: ['mcp', 'add', SERVER_NAME, ENDPOINT, '--type', 'http'], remove: ['mcp', 'remove', SERVER_NAME] },
|
|
217
|
+
{ kind: 'command', bin: 'droid', add: ['mcp', 'add', SERVER_NAME, ENDPOINT, '--type', 'http'], remove: ['mcp', 'remove', SERVER_NAME], list: ['mcp', 'list'] },
|
|
174
218
|
{ kind: 'link', href: `${DOCS}#tools-factory`, note: 'droid is not on PATH; run the command from the page in a terminal where it is.' },
|
|
175
219
|
],
|
|
176
220
|
signIn: `type /mcp in Droid and sign in to ${SERVER_NAME}.`,
|
|
@@ -179,14 +223,14 @@ export const TOOLS = [
|
|
|
179
223
|
{
|
|
180
224
|
id: 'tools-tabnine', name: 'Tabnine CLI',
|
|
181
225
|
detect: () => onPath('tabnine'),
|
|
182
|
-
user: () => [{ kind: 'command', bin: 'tabnine', add: ['mcp', 'add', SERVER_NAME, ENDPOINT, '--type', 'http'], remove: ['mcp', 'remove', SERVER_NAME] }],
|
|
226
|
+
user: () => [{ kind: 'command', bin: 'tabnine', add: ['mcp', 'add', SERVER_NAME, ENDPOINT, '--type', 'http'], remove: ['mcp', 'remove', SERVER_NAME], list: ['mcp', 'list'] }],
|
|
183
227
|
signIn: 'run /mcp auth in the Tabnine CLI.',
|
|
184
228
|
next: `start a new tabnine session.`,
|
|
185
229
|
},
|
|
186
230
|
{
|
|
187
231
|
id: 'tools-devin', name: 'Devin Desktop and CLI',
|
|
188
232
|
detect: () => onPath('devin'),
|
|
189
|
-
user: () => [{ kind: 'command', bin: 'devin', add: ['mcp', 'add', SERVER_NAME, ENDPOINT], remove: ['mcp', 'remove', SERVER_NAME] }],
|
|
233
|
+
user: () => [{ kind: 'command', bin: 'devin', add: ['mcp', 'add', SERVER_NAME, ENDPOINT], remove: ['mcp', 'remove', SERVER_NAME], list: ['mcp', 'list'] }],
|
|
190
234
|
signIn: `run devin mcp login ${SERVER_NAME}.`,
|
|
191
235
|
next: `start a new devin session, or restart Devin Desktop.`,
|
|
192
236
|
login: ['mcp', 'login', SERVER_NAME],
|
package/dist/commands/billing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { openBrowser, readKey } from '../auth.js';
|
|
3
|
-
import { getBilling, SignedOut } from '../api.js';
|
|
4
|
-
import { cardLines, cardsFingerprint, paymentMethodsLink } from '../payment.js';
|
|
3
|
+
import { getBilling, getPlans, SignedOut } from '../api.js';
|
|
4
|
+
import { cardLines, cardsFingerprint, paymentMethodsLink, planLines } from '../payment.js';
|
|
5
5
|
import { cross, dot, say, tick, waitFor } from '../ui.js';
|
|
6
6
|
function sayCards(b, heading) {
|
|
7
7
|
const lines = cardLines(b);
|
|
@@ -13,6 +13,26 @@ function sayCards(b, heading) {
|
|
|
13
13
|
for (const l of lines)
|
|
14
14
|
say(` ${l}`);
|
|
15
15
|
}
|
|
16
|
+
/** The active plans by repository, from getPlans: what the cards pay for.
|
|
17
|
+
* A failed read is said and is not a failure of the command; the cards
|
|
18
|
+
* above it are already shown. */
|
|
19
|
+
async function sayPlans(key) {
|
|
20
|
+
let lines;
|
|
21
|
+
try {
|
|
22
|
+
lines = planLines((await getPlans(key)).plans ?? []);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
say(`${cross} Could not list your plans: ${e.message}`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!lines.length) {
|
|
29
|
+
say(`${dot} No active plans.`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
say(`${tick} Active plans:`);
|
|
33
|
+
for (const l of lines)
|
|
34
|
+
say(` ${l}`);
|
|
35
|
+
}
|
|
16
36
|
export async function runBilling(opts = {}) {
|
|
17
37
|
const key = readKey();
|
|
18
38
|
if (!key) {
|
|
@@ -29,6 +49,7 @@ export async function runBilling(opts = {}) {
|
|
|
29
49
|
}
|
|
30
50
|
if (!opts.open) {
|
|
31
51
|
sayCards(before, 'Saved cards:');
|
|
52
|
+
await sayPlans(key);
|
|
32
53
|
return 0;
|
|
33
54
|
}
|
|
34
55
|
const link = paymentMethodsLink();
|
|
@@ -50,10 +71,11 @@ export async function runBilling(opts = {}) {
|
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
sayCards(now, cardsFingerprint(now) !== was ? 'Your cards now:' : 'No change seen. Saved cards:');
|
|
74
|
+
await sayPlans(key);
|
|
53
75
|
return 0;
|
|
54
76
|
}
|
|
55
77
|
export const billingCommand = new Command('billing')
|
|
56
|
-
.description('Show your saved cards, masked; with --open, change
|
|
78
|
+
.description('Show your saved cards, masked, and your active plans; with --open, change the cards in the browser and show the new list.')
|
|
57
79
|
.option('--open', 'open the page where cards are added or changed, then wait for the change')
|
|
58
80
|
.option('--timeout <minutes>', 'how long to wait with --open', '5')
|
|
59
81
|
.option('--no-browser', 'print the link instead of opening it')
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { ENDPOINT, serverNote } from '../catalogue.js';
|
|
3
|
+
import { readKey } from '../auth.js';
|
|
4
|
+
import { EXIT } from '../exit.js';
|
|
5
|
+
import { readiness, readinessJson, sayChecks } from '../steps.js';
|
|
6
|
+
import { verifyEndpoint } from '../verify.js';
|
|
7
|
+
import { cross, dot, printJson, say, tick } from '../ui.js';
|
|
8
|
+
export async function runDoctor(opts = {}) {
|
|
9
|
+
const key = readKey();
|
|
10
|
+
const [server, r] = await Promise.all([verifyEndpoint(ENDPOINT, 8000, key), readiness(key, { cwd: opts.cwd, scope: opts.scope })]);
|
|
11
|
+
const code = !r.signedIn ? EXIT.notSignedIn : !r.ready ? EXIT.accountNotReady : server.ok ? EXIT.done : EXIT.error;
|
|
12
|
+
if (opts.json) {
|
|
13
|
+
printJson({ ...readinessJson(r), serverAnswers: server.ok, serverDetail: server.detail, exitCode: code });
|
|
14
|
+
return code;
|
|
15
|
+
}
|
|
16
|
+
say();
|
|
17
|
+
const note = serverNote();
|
|
18
|
+
if (note)
|
|
19
|
+
say(` ${note}`);
|
|
20
|
+
say(`${server.ok ? tick : cross} Server: ${server.detail}`);
|
|
21
|
+
sayChecks(r, { fixes: true });
|
|
22
|
+
say();
|
|
23
|
+
const left = r.checks.filter((c) => c.required && c.state !== 'ready');
|
|
24
|
+
if (!r.signedIn)
|
|
25
|
+
say(`${dot} Not signed in: run npx sekura@latest login`);
|
|
26
|
+
else if (left.length)
|
|
27
|
+
say(`${dot} ${left.length} thing${left.length > 1 ? 's' : ''} left before a scan can start. npx sekura@latest walks through ${left.length > 1 ? 'them' : 'it'}.`);
|
|
28
|
+
else
|
|
29
|
+
say(`${tick} Everything is ready: npx sekura@latest scan`);
|
|
30
|
+
say();
|
|
31
|
+
return code;
|
|
32
|
+
}
|
|
33
|
+
export const doctorCommand = new Command('doctor')
|
|
34
|
+
.description('Check everything a scan needs (sign-in, Terms, email, GitHub App, repositories, tools) and say what to run for each thing that is not ready.')
|
|
35
|
+
.option('--scope <scope>', 'user or project', 'user')
|
|
36
|
+
.option('--json', 'print the checklist as JSON on stdout')
|
|
37
|
+
.action(async (opts) => { process.exitCode = await runDoctor(opts); });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { tools } from '../api.js';
|
|
3
|
+
import { Exit, EXIT } from '../exit.js';
|
|
4
|
+
import { requireKey } from '../flow.js';
|
|
5
|
+
import { dot, print, printJson, say, tick } from '../ui.js';
|
|
6
|
+
import { ready, severityWords } from './shared.js';
|
|
7
|
+
const line = (f, i) => {
|
|
8
|
+
const head = `${i + 1}. [${f.severity}] ${f.title}${f.location ? ` — ${f.location}` : ''}`;
|
|
9
|
+
return f.description && f.description !== f.title ? [head, ` ${f.description}`] : [head];
|
|
10
|
+
};
|
|
11
|
+
export async function runFindings(scanId, opts = {}) {
|
|
12
|
+
const key = requireKey();
|
|
13
|
+
const limit = opts.limit === undefined ? 20 : Number(opts.limit);
|
|
14
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 50)
|
|
15
|
+
throw new Exit(EXIT.error, '--limit takes a whole number from 1 to 50.');
|
|
16
|
+
const { data } = await ready(() => tools.getScanFindings(key, { scanId, limit }));
|
|
17
|
+
if (opts.json) {
|
|
18
|
+
printJson(data);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!data.total) {
|
|
22
|
+
say(`${tick} Scan ${data.scanId} has no findings.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
say(`${tick} Scan ${data.scanId}: ${data.total} ${data.total === 1 ? 'finding' : 'findings'} (${severityWords(data.counts)})`);
|
|
26
|
+
data.findings.forEach((f, i) => { for (const l of line(f, i))
|
|
27
|
+
print(l); });
|
|
28
|
+
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 ${data.scanId}`);
|
|
30
|
+
else
|
|
31
|
+
say(`${dot} The report has the proof for each: npx sekura@latest report ${data.scanId}`);
|
|
32
|
+
}
|
|
33
|
+
export const findingsCommand = new Command('findings')
|
|
34
|
+
.description('Show a finished scan\'s findings, most severe first.')
|
|
35
|
+
.argument('<scan-id>', 'the scan id, from sekura scans')
|
|
36
|
+
.option('--limit <n>', 'how many findings, 1 to 50', '20')
|
|
37
|
+
.option('--json', 'print the findings as JSON on stdout')
|
|
38
|
+
.action(async (id, opts) => { await runFindings(id, opts); });
|
package/dist/commands/init.js
CHANGED
|
@@ -10,7 +10,7 @@ import { checkbox, confirm, 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
|
-
import { DOCS, ENDPOINT, PENDING_KEY, TOOLS, carriesKey, home, toolById } from '../catalogue.js';
|
|
13
|
+
import { DOCS, ENDPOINT, PENDING_KEY, TOOLS, carriesKey, home, serverNote, toolById } from '../catalogue.js';
|
|
14
14
|
import { applyStep, buildPlan, describeStep, detectTools } from '../plan.js';
|
|
15
15
|
import { verifyEndpoint } from '../verify.js';
|
|
16
16
|
import { credentialsPath, readKey } from '../auth.js';
|
|
@@ -39,6 +39,11 @@ export async function runInit(opts) {
|
|
|
39
39
|
const interactive = !opts.yes && !!process.stdin.isTTY && !!process.stderr.isTTY;
|
|
40
40
|
const cwd = opts.cwd ?? process.cwd();
|
|
41
41
|
banner();
|
|
42
|
+
const note = serverNote();
|
|
43
|
+
if (note) {
|
|
44
|
+
say(` ${note}`);
|
|
45
|
+
say();
|
|
46
|
+
}
|
|
42
47
|
// 1. Detect. Every detected tool, user scope, the skill and the sign-in
|
|
43
48
|
// are the defaults; a flag answers its own question.
|
|
44
49
|
const detected = detectTools(cwd);
|
|
@@ -102,17 +107,23 @@ export async function runInit(opts) {
|
|
|
102
107
|
],
|
|
103
108
|
});
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
// Every yes/no question stays on one line, its explanation printed
|
|
111
|
+
// above it. A question that wraps leaves the cursor in the middle of a
|
|
112
|
+
// word: the prompt library word-wraps the text but places the cursor
|
|
113
|
+
// as if it were cut at the terminal's edge (29 November 2026, the
|
|
114
|
+
// cursor sat on the "r" of "rule"). A wider terminal is not the fix;
|
|
115
|
+
// the user's window decides that.
|
|
116
|
+
if (open.skill) {
|
|
117
|
+
say(' The sekura skill teaches the agent to quote every scan first.');
|
|
118
|
+
skill = await confirm({ message: 'Install the skill?', default: true });
|
|
119
|
+
}
|
|
107
120
|
// Project files never carry the key (they are committed), so there
|
|
108
121
|
// is no sign-in to ask about in project scope.
|
|
109
122
|
if (open.login && scope === 'user') {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
default: true,
|
|
115
|
-
});
|
|
123
|
+
say(hasKey
|
|
124
|
+
? ' Your tools can use your saved Sekura key, so they do not ask you to sign in.'
|
|
125
|
+
: ' Sign in once, after you review the plan, and your tools will not have to.');
|
|
126
|
+
login = await confirm({ message: hasKey ? 'Use the saved key?' : 'Sign in to Sekura?', default: true });
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// forget the saved key.
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { applyStep, buildPlan, detectTools, stepPresent } from '../plan.js';
|
|
8
|
-
import { carriesKey } from '../catalogue.js';
|
|
8
|
+
import { KEYS_PAGE, carriesKey } from '../catalogue.js';
|
|
9
9
|
import { credentialsPath, forgetKey } from '../auth.js';
|
|
10
10
|
import { checkAccount, howToScan, obtainKey, pickRepository, runToolLogins } from '../guide.js';
|
|
11
11
|
import { cross, dot, say, tick } from '../ui.js';
|
|
@@ -69,6 +69,6 @@ export const logoutCommand = new Command('logout')
|
|
|
69
69
|
.action(() => {
|
|
70
70
|
say();
|
|
71
71
|
say(forgetKey() ? `${tick} Removed ${credentialsPath()}` : `${dot} No saved key at ${credentialsPath()}`);
|
|
72
|
-
say(
|
|
72
|
+
say(` Tools that were given the key keep it until you run sekura uninstall. To end it everywhere: ${KEYS_PAGE}.`);
|
|
73
73
|
say();
|
|
74
74
|
});
|
package/dist/commands/pay.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { openBrowser, readKey } from '../auth.js';
|
|
3
3
|
import { getPlans, SignedOut } from '../api.js';
|
|
4
|
-
import { openableLink, paymentState, scanLink } from '../payment.js';
|
|
4
|
+
import { monthlyName, openableLink, paymentState, scanLink } from '../payment.js';
|
|
5
5
|
import { cross, dot, say, tick, waitFor } from '../ui.js';
|
|
6
6
|
export const PAY_EXIT = { started: 0, paid: 0, notSignedIn: 4, cancelled: 3, timeout: 2, badLink: 1 };
|
|
7
7
|
const planName = (p) => (p?.owner && p?.name ? `${p.owner}/${p.name}` : 'the repository');
|
|
@@ -21,7 +21,10 @@ function sayOpened(link, opened) {
|
|
|
21
21
|
function sayOutcome(state, plan) {
|
|
22
22
|
const repo = planName(plan);
|
|
23
23
|
if (state.kind === 'started') {
|
|
24
|
-
|
|
24
|
+
// Until 27 November 2026 this line printed a retired plan name for
|
|
25
|
+
// 'always' and named no plan at all for 'pro' (payment.ts has the names).
|
|
26
|
+
const monthly = monthlyName(plan);
|
|
27
|
+
const what = monthly ? `${monthly} is on for ${repo}, and its first scan` : `The scan of ${repo}`;
|
|
25
28
|
say(`${tick} Payment received. ${what} has started: scan id ${state.scanId} (${state.scanStatus}).`);
|
|
26
29
|
say(` ${scanLink(state.scanId)}`);
|
|
27
30
|
}
|