sekura 0.1.1 → 0.3.0

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 CHANGED
@@ -6,25 +6,56 @@ Connect your coding tool to [Sekura](https://sekura.ai) in one command.
6
6
  npx sekura@latest init
7
7
  ```
8
8
 
9
- Sekura is an AI red team as a service: it scans a GitHub repository you have granted it, exploits what it finds to prove each finding, and delivers a report. Its MCP server is remote, at `https://sekura.ai/mcp`, so this package runs no server and holds no credential. It writes that address into the coding tools on your machine, installs a skill that teaches the agent the quote-then-confirm rule, and gets out of the way.
9
+ Sekura is an AI red team as a service: it scans a GitHub repository you have granted it, exploits what it finds to prove each finding, and delivers a report. Its MCP server is remote, at `https://sekura.ai/mcp`, so this package runs no server. It writes that address into the coding tools on your machine and installs a skill that teaches the agent the quote-then-confirm rule. Then it finishes getting started right in the terminal: it signs you in once, waits while you accept the Terms and install the GitHub App, and lets you pick a repository. When you open your coding tool, Sekura already works.
10
+
11
+ `npx sekura@latest` on its own runs `init` too.
10
12
 
11
13
  ## What `init` does
12
14
 
13
15
  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.
14
- 2. **Asks** which to connect, and whether for every project (your user configuration) or this project only.
15
- 3. **Shows the plan** before anything is written: each file and the exact entry, or the tool's own command.
16
- 4. **Applies** it, one step at a time, and says what each did. Files that are not plain JSON (Zed's `settings.json` with comments, for one) are never rewritten; you are shown the lines to add instead.
17
- 5. **Checks** that the Sekura server answers, and tells you how to sign in from each tool.
18
-
19
- Signing in happens in the tool: the first time it uses Sekura, a sekura.ai page opens in your browser. Sign in with GitHub and approve. Nothing to copy.
16
+ 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 for every project, with the skill, and sign in to Sekura?` Answer **Yes**, **No**, or **Edit** to choose the tools, every project or this project only, the skill, and the sign-in one by one. A flag answers its own question and skips it.
17
+ 3. **Shows the plan** before anything happens: each file and the exact entry, or the tool's own command. The key isn't there yet, so the plan shows `Authorization: Bearer <your key, after sign-in>` where it will go (a key you already have is shown as `sek_live_…abcd`). Then it asks **Apply?**
18
+ 4. **Signs you in** once you've said yes. You sign in with GitHub on sekura.ai and approve, and the CLI receives a Sekura key. On a machine whose browser is somewhere else (over SSH, in a devcontainer or Codespace, with `--device`, or when no browser opens), it prints a code instead: open `https://sekura.ai/connect/device` on any device and enter it. If the sign-in doesn't finish, the same plan is applied without a key, and each tool signs in the first time it uses Sekura.
19
+ 5. **Applies** the plan with the key in it, one step at a time, and says what each step did. Files that are not plain JSON (Zed's `settings.json` with comments, for one) are never rewritten; you are shown the lines to add instead. Codex and Devin can't take a key in their configuration, so the CLI runs their own `mcp login`; since your browser is already signed in, that's one click.
20
+ 6. **Checks** that the Sekura server answers.
21
+ 7. **Gets you to a first scan**:
22
+ - If your account still needs the Terms or email verification, it opens sekura.ai and carries on by itself once they are done.
23
+ - If nothing can be scanned yet, or the repository in the current folder isn't covered, it offers to open the GitHub App install and carries on by itself once the repository shows up.
24
+ - It lets you pick a repository, with the current folder's first.
25
+
26
+ Each wait shows a one-line spinner, stops after five minutes, and Enter skips it.
27
+ 8. **Tells you the next step in each tool**, such as "Cursor: restart Cursor (or reload MCP servers in Settings → MCP)" or "Claude Code: start a new Claude Code session, then type /sekura", and what to type to scan, such as `/sekura scan owner/repo` (`/sekura help` lists every command).
28
+
29
+ Every scan you then ask for in your coding tool is quoted first, with the price and the authorization wording, and starts only after you agree.
30
+
31
+ ## Flags
32
+
33
+ | Flag | What it does |
34
+ |---|---|
35
+ | `-y, --yes` | No questions: every detected tool, user scope, the skill, and the key in `SEKURA_API_KEY` or the one `sekura login` saved. Signs in nowhere. |
36
+ | `--tools <ids>` | Only these, comma-separated: `claude`, `cursor`, `copilot`, `codex`, `kiro`, `cline`, `zed`, `antigravity`, `opencode`, `jetbrains`, `factory`, `tabnine`, `devin`, `goose`. |
37
+ | `--scope <user\|project>` | `user` (every project, the default) or `project` (this directory). |
38
+ | `--no-skill` | The MCP server only: no skill, no guidance block. |
39
+ | `--no-login` | No sign-in here; each tool opens a sekura.ai sign-in page the first time it uses Sekura. This is how 0.1.x worked. |
40
+ | `--device` | Sign in with a code on another device. The default over SSH (`SSH_CONNECTION`, `SSH_TTY`), in Codespaces, devcontainers (`REMOTE_CONTAINERS`) and Gitpod. `sekura login` takes it too. |
41
+ | `--dry-run` | Show the plan and change nothing. Never signs in and needs no key. |
42
+ | `--no-verify` | Don't check that the Sekura server answers. |
43
+
44
+ Project scope never writes the key, because project files get committed.
20
45
 
21
46
  ```bash
47
+ npx sekura@latest # the same as init
22
48
  npx sekura@latest init --yes # every detected tool, user scope, with the skill, no questions
23
49
  npx sekura@latest init --dry-run # show the plan and change nothing
24
50
  npx sekura@latest init --scope project # this project only: .mcp.json, .cursor/mcp.json, AGENTS.md …
25
51
  npx sekura@latest init --tools claude,cursor --no-skill
26
- npx sekura@latest status # what is connected
27
- npx sekura@latest uninstall # remove the entries, the skill and the guidance block
52
+ npx sekura@latest init --no-login # no sign-in here; each tool signs in on first use
53
+ npx sekura@latest init --device # sign in with a code, for a terminal on another machine
54
+ npx sekura@latest login # sign in again, give connected tools the key, pick a repository
55
+ npx sekura@latest status # what is connected, and who is signed in
56
+ npx sekura@latest logout # forget the saved key
57
+ npx sekura@latest uninstall # remove the entries, the skill, the guidance block and the saved key
58
+ SEKURA_API_KEY=sek_live_… npx sekura@latest init --yes # unattended, with a key from Settings
28
59
  ```
29
60
 
30
61
  ## What it writes
@@ -49,8 +80,16 @@ The skill goes to `~/.agents/skills/sekura/SKILL.md` and, when Claude Code is pr
49
80
  ## What stays untouched
50
81
 
51
82
  - Every other server, setting and file. The installer sets one key, `sekura`, and reads nothing else.
52
- - Your source code. Nothing is read, uploaded or committed.
53
- - Your credentials. There is no login step and no token on disk; the sign-in is the tool's own OAuth flow with sekura.ai.
83
+ - Your source code isn't read or uploaded by this installer.
84
+
85
+ ## Your key
86
+
87
+ 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.
88
+
89
+ - **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.
90
+ - **`sekura logout`** removes the saved copy. Tools that were given the key keep it.
91
+ - **`sekura uninstall`** removes the entries (with their key), the skill, the guidance block and the saved copy.
92
+ - **`--no-login`** writes no key anywhere, as 0.1.x did.
54
93
 
55
94
  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.
56
95
 
package/dist/api.js ADDED
@@ -0,0 +1,42 @@
1
+ // The few Sekura tools the CLI calls itself, over the same MCP endpoint the
2
+ // coding tools use. The server is stateless JSON-RPC over POST and answers
3
+ // in plain JSON, so no session and no MCP library: one request per call.
4
+ // Only tools that read are called here; every scan is quoted and agreed in
5
+ // the coding tool.
6
+ import { ENDPOINT } from './catalogue.js';
7
+ export class SignedOut extends Error {
8
+ constructor(detail) { super(detail); this.name = 'SignedOut'; }
9
+ }
10
+ let nextId = 1;
11
+ export async function callTool(key, name, args = {}) {
12
+ const r = await fetch(ENDPOINT, {
13
+ method: 'POST',
14
+ headers: { authorization: `Bearer ${key}`, 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
15
+ body: JSON.stringify({ jsonrpc: '2.0', id: nextId++, method: 'tools/call', params: { name, arguments: args } }),
16
+ signal: AbortSignal.timeout(30_000),
17
+ });
18
+ const body = (await r.json().catch(() => null));
19
+ if (r.status === 401)
20
+ throw new SignedOut(body?.error_description || 'the key is no longer valid');
21
+ if (!r.ok || !body)
22
+ throw new Error(`Sekura answered ${r.status} to ${name}${body?.error_description ? `: ${body.error_description}` : ''}`);
23
+ if (body.error)
24
+ throw new Error(`Sekura ${name}: ${body.error.message ?? JSON.stringify(body.error)}`);
25
+ const result = body.result ?? {};
26
+ if (result.isError)
27
+ throw new Error(`Sekura ${name}: ${result.content?.[0]?.text ?? 'failed'}`);
28
+ if (result.structuredContent)
29
+ return result.structuredContent;
30
+ // Older answers carry the data as JSON in the second text block.
31
+ for (const c of result.content ?? []) {
32
+ if (c?.type !== 'text')
33
+ continue;
34
+ try {
35
+ return JSON.parse(c.text);
36
+ }
37
+ catch { /* the prose block */ }
38
+ }
39
+ throw new Error(`Sekura ${name}: no data in the answer`);
40
+ }
41
+ export const getAccount = (key) => callTool(key, 'getAccount');
42
+ export const listRepositories = (key) => callTool(key, 'listRepositories');
package/dist/auth.js ADDED
@@ -0,0 +1,199 @@
1
+ // Signing in to Sekura from the terminal, once, so the tools do not have to.
2
+ //
3
+ // OAuth 2.1 against sekura.ai, the way the tools themselves do it: a client
4
+ // registered on the spot (public, no secret), PKCE S256, and a loopback
5
+ // redirect on a port picked per run (RFC 8252; sekura.ai accepts any port
6
+ // on 127.0.0.1 for a client that registered a loopback URI). What comes back
7
+ // is an ordinary `sek_live_` key with no expiry, listed and revocable under
8
+ // Settings → Agents and API keys, bound to the MCP address (RFC 8707).
9
+ // Where the browser is on another machine (SSH, a container, --device, or
10
+ // none to open here), the same client signs in with a code instead
11
+ // (device.ts, RFC 8628).
12
+ //
13
+ // The key is kept in ~/.config/sekura/credentials.json, readable by the
14
+ // person only, so a rerun of `init` or `login` does not sign in again.
15
+ // SEKURA_API_KEY in the environment wins over the file.
16
+ import { createHash, randomBytes } from 'node:crypto';
17
+ import { createServer } from 'node:http';
18
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, chmodSync } from 'node:fs';
19
+ import { hostname, platform } from 'node:os';
20
+ import { dirname, join } from 'node:path';
21
+ import { spawn } from 'node:child_process';
22
+ import { ENDPOINT, home, onPath } from './catalogue.js';
23
+ import { DEVICE_GRANT, deviceSignIn, remoteSession } from './device.js';
24
+ export const ISSUER = new URL(ENDPOINT).origin;
25
+ export const credentialsPath = () => join(process.env.XDG_CONFIG_HOME || join(home(), '.config'), 'sekura', 'credentials.json');
26
+ export function readKey() {
27
+ const env = process.env.SEKURA_API_KEY?.trim();
28
+ if (env)
29
+ return env;
30
+ try {
31
+ const c = JSON.parse(readFileSync(credentialsPath(), 'utf8'));
32
+ return typeof c.key === 'string' && c.key ? c.key : null;
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ }
38
+ export function saveKey(key, email) {
39
+ const p = credentialsPath();
40
+ mkdirSync(dirname(p), { recursive: true });
41
+ writeFileSync(p, JSON.stringify({ key, ...(email ? { email } : {}), createdAt: new Date().toISOString() }, null, 2) + '\n', { mode: 0o600 });
42
+ try {
43
+ chmodSync(p, 0o600);
44
+ }
45
+ catch { /* Windows */ }
46
+ return p;
47
+ }
48
+ export function forgetKey() {
49
+ const p = credentialsPath();
50
+ if (!existsSync(p))
51
+ return false;
52
+ rmSync(p);
53
+ return true;
54
+ }
55
+ /** A key as it may be shown: the prefix and the last four characters. */
56
+ export function redact(key) {
57
+ const m = /^(sek_[a-z]+_)/.exec(key);
58
+ return `${m ? m[1] : ''}…${key.slice(-4)}`;
59
+ }
60
+ /** Every key in a piece of text, redacted. */
61
+ export const redactAll = (s) => s.replace(/sek_[a-z]+_[A-Za-z0-9]+/g, (k) => redact(k));
62
+ // ── PKCE ───────────────────────────────────────────────────────────────────
63
+ const b64url = (b) => b.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
64
+ export function pkce() {
65
+ const verifier = b64url(randomBytes(32));
66
+ return { verifier, challenge: b64url(createHash('sha256').update(verifier).digest()) };
67
+ }
68
+ // ── the browser ────────────────────────────────────────────────────────────
69
+ /** Whether this machine has a browser to open. On Linux that takes a
70
+ * display and xdg-open; a bare server or container has neither, and the
71
+ * spawn's failure would only arrive after the URL was promised. */
72
+ export function hasBrowser(env = process.env) {
73
+ if (platform() === 'darwin' || platform() === 'win32')
74
+ return true;
75
+ return !!(env.DISPLAY || env.WAYLAND_DISPLAY) && onPath('xdg-open');
76
+ }
77
+ /** Opens a URL in the default browser; false when there is none to ask. */
78
+ export function openBrowser(url) {
79
+ if (!hasBrowser())
80
+ return false;
81
+ const [cmd, args] = platform() === 'darwin' ? ['open', [url]]
82
+ : platform() === 'win32' ? ['cmd', ['/c', 'start', '""', url.replace(/&/g, '^&')]]
83
+ : ['xdg-open', [url]];
84
+ try {
85
+ const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
86
+ child.on('error', () => { });
87
+ child.unref();
88
+ return true;
89
+ }
90
+ catch {
91
+ return false;
92
+ }
93
+ }
94
+ // ── the loopback callback ──────────────────────────────────────────────────
95
+ const PAGE = (title, body) => `<!doctype html><meta charset="utf-8"><title>${title}</title><body style="font:16px system-ui;max-width:32em;margin:4em auto;padding:0 1em"><h1 style="font-size:1.4em">${title}</h1><p>${body}</p>`;
96
+ /** What one request to the callback means, given the state this run sent. */
97
+ export function readCallback(url, state) {
98
+ if (url.pathname !== '/callback')
99
+ return null;
100
+ if (url.searchParams.get('state') !== state)
101
+ return { error: 'the sign-in came back with another state; start again' };
102
+ const iss = url.searchParams.get('iss');
103
+ if (iss !== null && iss !== ISSUER)
104
+ return { error: `the sign-in came back from ${iss}, not ${ISSUER}` };
105
+ const err = url.searchParams.get('error');
106
+ if (err)
107
+ return { error: url.searchParams.get('error_description') || err };
108
+ const code = url.searchParams.get('code');
109
+ return code ? { code } : { error: 'the sign-in came back without a code' };
110
+ }
111
+ /** Listens on 127.0.0.1, on a port the system picks, for one callback. */
112
+ export async function listen(state, timeoutMs) {
113
+ let settle;
114
+ const result = new Promise((r) => { settle = r; });
115
+ const server = createServer((req, res) => {
116
+ const r = readCallback(new URL(req.url ?? '/', 'http://127.0.0.1'), state);
117
+ if (!r) {
118
+ res.writeHead(404).end();
119
+ return;
120
+ }
121
+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
122
+ res.end('code' in r
123
+ ? PAGE('Signed in to Sekura', 'You can close this tab and go back to the terminal.')
124
+ : PAGE('Sekura could not sign you in', r.error.replace(/</g, '&lt;')));
125
+ settle(r);
126
+ });
127
+ await new Promise((ok, fail) => { server.once('error', fail); server.listen(0, '127.0.0.1', () => ok()); });
128
+ const port = server.address().port;
129
+ const timer = setTimeout(() => settle({ error: 'no answer from the browser in time' }), timeoutMs);
130
+ timer.unref();
131
+ let closed = false;
132
+ const close = () => { if (closed)
133
+ return; closed = true; clearTimeout(timer); server.close(); server.closeAllConnections?.(); };
134
+ return { redirectUri: `http://127.0.0.1:${port}/callback`, result, close };
135
+ }
136
+ // ── the flow ───────────────────────────────────────────────────────────────
137
+ async function post(path, body, type) {
138
+ const r = await fetch(`${ISSUER}${path}`, { method: 'POST', headers: { 'content-type': type, accept: 'application/json' }, body });
139
+ const data = (await r.json().catch(() => ({})));
140
+ if (!r.ok)
141
+ throw new Error(`sekura.ai refused the sign-in (${path}): ${data.error_description || data.error || r.status}`);
142
+ return data;
143
+ }
144
+ /** One public client for both ways in: the loopback redirect and the
145
+ * device code. sekura.ai accepts any port on the registered loopback URI. */
146
+ export async function register() {
147
+ const reg = await post('/oauth/register', JSON.stringify({
148
+ client_name: `Sekura CLI (${hostname().slice(0, 60)})`,
149
+ redirect_uris: ['http://127.0.0.1/callback'],
150
+ token_endpoint_auth_method: 'none',
151
+ grant_types: ['authorization_code', DEVICE_GRANT],
152
+ response_types: ['code'],
153
+ }), 'application/json');
154
+ const clientId = String(reg.client_id ?? '');
155
+ if (!clientId)
156
+ throw new Error('sekura.ai did not register the CLI');
157
+ return clientId;
158
+ }
159
+ /** Signs in and returns the key. */
160
+ export async function signIn(opts = {}) {
161
+ const clientId = await register();
162
+ const remote = remoteSession();
163
+ const why = opts.device ? '--device' : remote ? `${remote} is set` : opts.open !== false && !hasBrowser() ? 'there is no browser to open here' : null;
164
+ if (why) {
165
+ opts.onDevice?.(why);
166
+ return deviceSignIn(clientId, opts);
167
+ }
168
+ const state = b64url(randomBytes(16));
169
+ const { verifier, challenge } = pkce();
170
+ const cb = await listen(state, opts.timeoutMs ?? 300_000);
171
+ try {
172
+ const url = new URL(`${ISSUER}/oauth/authorize`);
173
+ for (const [k, v] of Object.entries({
174
+ response_type: 'code', client_id: clientId, redirect_uri: cb.redirectUri, state,
175
+ code_challenge: challenge, code_challenge_method: 'S256', scope: 'read write', resource: ENDPOINT,
176
+ }))
177
+ url.searchParams.set(k, v);
178
+ opts.onUrl?.(url.href);
179
+ if (opts.open !== false && !openBrowser(url.href)) {
180
+ cb.close();
181
+ opts.onDevice?.('the browser did not open');
182
+ return deviceSignIn(clientId, opts);
183
+ }
184
+ const r = await cb.result;
185
+ if ('error' in r)
186
+ throw new Error(`Sekura sign-in: ${r.error}`);
187
+ const tok = await post('/oauth/token', new URLSearchParams({
188
+ grant_type: 'authorization_code', code: r.code, code_verifier: verifier,
189
+ client_id: clientId, redirect_uri: cb.redirectUri, resource: ENDPOINT,
190
+ }).toString(), 'application/x-www-form-urlencoded');
191
+ const key = String(tok.access_token ?? '');
192
+ if (!key)
193
+ throw new Error('sekura.ai answered without a key');
194
+ return key;
195
+ }
196
+ finally {
197
+ cb.close();
198
+ }
199
+ }
package/dist/catalogue.js CHANGED
@@ -66,33 +66,47 @@ export function onPath(bin) {
66
66
  }
67
67
  return false;
68
68
  }
69
+ /** Stands in for the key in the plan shown before the sign-in. Not a key
70
+ * shape (no sek_ prefix), so it is never redacted into one, and writers.ts
71
+ * refuses to write a target that carries it. */
72
+ export const PENDING_KEY = '<your key, after sign-in>';
69
73
  const SIGN_IN = 'the first time the tool uses Sekura, a sekura.ai page opens in your browser: sign in with GitHub and approve.';
70
74
  const url = { url: ENDPOINT };
71
75
  const http = { type: 'http', url: ENDPOINT };
76
+ /** The header a key is sent in, as JSON configurations spell it. */
77
+ const auth = (key) => (key ? { headers: { Authorization: `Bearer ${key}` } } : {});
78
+ /** The generic next step, for a tool with nothing more specific. */
79
+ export const NEXT = (name) => `restart ${name} so it loads the sekura server.`;
80
+ export const nextStep = (t) => t.next ?? NEXT(t.name);
81
+ /** True when a target sends a key, so its tool needs no sign-in. */
82
+ export const carriesKey = (t) => JSON.stringify(t).includes('Bearer sek_');
72
83
  export const TOOLS = [
73
84
  {
74
85
  id: 'tools-claude', name: 'Claude Code',
75
86
  detect: (h) => existsSync(join(h, '.claude')) || existsSync(join(h, '.claude.json')) || onPath('claude'),
76
- user: (h) => [
77
- { kind: 'command', bin: 'claude', add: ['mcp', 'add', '--transport', 'http', '-s', 'user', SERVER_NAME, ENDPOINT], remove: ['mcp', 'remove', '-s', 'user', SERVER_NAME], get: ['mcp', 'get', SERVER_NAME] },
78
- { kind: 'json', path: join(h, '.claude.json'), key: 'mcpServers', entry: http },
87
+ user: (h, key) => [
88
+ { kind: 'command', bin: 'claude', add: ['mcp', 'add', '--transport', 'http', '-s', 'user', SERVER_NAME, ENDPOINT, ...(key ? ['--header', `Authorization: Bearer ${key}`] : [])], remove: ['mcp', 'remove', '-s', 'user', SERVER_NAME], get: ['mcp', 'get', SERVER_NAME] },
89
+ { kind: 'json', path: join(h, '.claude.json'), key: 'mcpServers', entry: { ...http, ...auth(key) } },
79
90
  ],
80
91
  project: (cwd) => [{ kind: 'json', path: join(cwd, '.mcp.json'), key: 'mcpServers', entry: http }],
81
92
  signIn: `type /mcp in Claude Code, choose ${SERVER_NAME}, and sign in with GitHub.`,
93
+ next: `start a new Claude Code session, then type /${SERVER_NAME}.`,
82
94
  },
83
95
  {
84
96
  id: 'tools-cursor', name: 'Cursor',
85
97
  detect: (h) => existsSync(join(h, '.cursor')) || onPath('cursor'),
86
- user: (h) => [{ kind: 'json', path: join(h, '.cursor', 'mcp.json'), key: 'mcpServers', entry: url }],
98
+ user: (h, key) => [{ kind: 'json', path: join(h, '.cursor', 'mcp.json'), key: 'mcpServers', entry: { ...url, ...auth(key) } }],
87
99
  project: (cwd) => [{ kind: 'json', path: join(cwd, '.cursor', 'mcp.json'), key: 'mcpServers', entry: url }],
88
100
  signIn: SIGN_IN,
101
+ next: `restart Cursor (or reload MCP servers in Settings → MCP).`,
89
102
  },
90
103
  {
91
104
  id: 'tools-copilot', name: 'GitHub Copilot in VS Code',
92
105
  detect: (h) => existsSync(codeUserDir(h)),
93
- user: (h) => [{ kind: 'json', path: join(codeUserDir(h), 'mcp.json'), key: 'servers', entry: http }],
106
+ user: (h, key) => [{ kind: 'json', path: join(codeUserDir(h), 'mcp.json'), key: 'servers', entry: { ...http, ...auth(key) } }],
94
107
  project: (cwd) => [{ kind: 'json', path: join(cwd, '.mcp.json'), key: 'mcpServers', entry: http }],
95
108
  signIn: SIGN_IN,
109
+ next: `reload the VS Code window (Command Palette → Developer: Reload Window), then use Copilot Chat in Agent mode.`,
96
110
  },
97
111
  {
98
112
  id: 'tools-codex', name: 'OpenAI Codex',
@@ -102,41 +116,48 @@ export const TOOLS = [
102
116
  { kind: 'toml', path: join(h, '.codex', 'config.toml'), table: `mcp_servers.${SERVER_NAME}`, lines: [`url = "${ENDPOINT}"`] },
103
117
  ],
104
118
  signIn: `run codex mcp login ${SERVER_NAME}, or sign in when Codex first uses Sekura.`,
119
+ next: `start a new codex session.`,
120
+ login: ['mcp', 'login', SERVER_NAME],
105
121
  },
106
122
  {
107
123
  id: 'tools-kiro', name: 'Kiro',
108
124
  detect: (h) => existsSync(join(h, '.kiro')) || onPath('kiro'),
109
- user: (h) => [{ kind: 'json', path: join(h, '.kiro', 'settings', 'mcp.json'), key: 'mcpServers', entry: url }],
125
+ user: (h, key) => [{ kind: 'json', path: join(h, '.kiro', 'settings', 'mcp.json'), key: 'mcpServers', entry: { ...url, ...auth(key) } }],
110
126
  project: (cwd) => [{ kind: 'json', path: join(cwd, '.kiro', 'settings', 'mcp.json'), key: 'mcpServers', entry: url }],
111
127
  signIn: SIGN_IN,
128
+ next: `restart Kiro (or reconnect ${SERVER_NAME} in the MCP servers view of the Kiro panel).`,
112
129
  },
113
130
  {
114
131
  id: 'tools-cline', name: 'Cline',
115
132
  // A fresh v4 install has no global-storage folder until the extension
116
133
  // writes one, so the installed extension and ~/.cline count too.
117
134
  detect: (h) => existsSync(join(h, '.cline')) || hasExtension(h, 'saoudrizwan.claude-dev') || existsSync(join(codeUserDir(h), 'globalStorage', 'saoudrizwan.claude-dev')),
118
- user: (h) => [{ kind: 'json', path: clineSettingsPath(h), key: 'mcpServers', entry: { type: 'streamableHttp', url: ENDPOINT } }],
135
+ user: (h, key) => [{ kind: 'json', path: clineSettingsPath(h), key: 'mcpServers', entry: { type: 'streamableHttp', url: ENDPOINT, ...auth(key) } }],
119
136
  signIn: SIGN_IN,
137
+ next: `reload the VS Code window, or start a new session in the Cline CLI; Cline's MCP Servers view should show ${SERVER_NAME}.`,
120
138
  },
121
139
  {
122
140
  id: 'tools-zed', name: 'Zed',
123
141
  detect: (h) => existsSync(join(xdg(h), 'zed')) || onPath('zed'),
124
- user: (h) => [{ kind: 'json', path: join(xdg(h), 'zed', 'settings.json'), key: 'context_servers', entry: url }],
142
+ user: (h, key) => [{ kind: 'json', path: join(xdg(h), 'zed', 'settings.json'), key: 'context_servers', entry: { ...url, ...auth(key) } }],
125
143
  signIn: `${SIGN_IN} Zed keeps the sign-in in your system keychain.`,
144
+ next: `Zed reads settings.json again by itself; start a new thread in the Agent Panel.`,
126
145
  },
127
146
  {
128
147
  id: 'tools-antigravity', name: 'Antigravity',
129
148
  detect: (h) => existsSync(join(h, '.gemini', 'config')),
130
- user: (h) => [{ kind: 'json', path: join(h, '.gemini', 'config', 'mcp_config.json'), key: 'mcpServers', entry: { serverUrl: ENDPOINT } }],
149
+ user: (h, key) => [{ kind: 'json', path: join(h, '.gemini', 'config', 'mcp_config.json'), key: 'mcpServers', entry: { serverUrl: ENDPOINT, ...auth(key) } }],
131
150
  project: (cwd) => [{ kind: 'json', path: join(cwd, '.agents', 'mcp_config.json'), key: 'mcpServers', entry: { serverUrl: ENDPOINT } }],
132
151
  signIn: SIGN_IN,
152
+ next: `restart Antigravity (or refresh in Manage MCP servers).`,
133
153
  },
134
154
  {
135
155
  id: 'tools-opencode', name: 'OpenCode',
136
156
  detect: (h) => existsSync(join(xdg(h), 'opencode')) || onPath('opencode'),
137
- user: (h) => [{ kind: 'json', path: join(xdg(h), 'opencode', 'opencode.json'), key: 'mcp', entry: { type: 'remote', url: ENDPOINT } }],
157
+ user: (h, key) => [{ kind: 'json', path: join(xdg(h), 'opencode', 'opencode.json'), key: 'mcp', entry: { type: 'remote', url: ENDPOINT, ...auth(key) } }],
138
158
  project: (cwd) => [{ kind: 'json', path: join(cwd, 'opencode.json'), key: 'mcp', entry: { type: 'remote', url: ENDPOINT } }],
139
159
  signIn: `OpenCode registers itself with Sekura and opens the sign-in on first use; ${SIGN_IN}`,
160
+ next: `start a new opencode session.`,
140
161
  },
141
162
  {
142
163
  id: 'tools-jetbrains', name: 'JetBrains Junie',
@@ -153,29 +174,34 @@ export const TOOLS = [
153
174
  { kind: 'link', href: `${DOCS}#tools-factory`, note: 'droid is not on PATH; run the command from the page in a terminal where it is.' },
154
175
  ],
155
176
  signIn: `type /mcp in Droid and sign in to ${SERVER_NAME}.`,
177
+ next: `start a new droid session.`,
156
178
  },
157
179
  {
158
180
  id: 'tools-tabnine', name: 'Tabnine CLI',
159
181
  detect: () => onPath('tabnine'),
160
182
  user: () => [{ kind: 'command', bin: 'tabnine', add: ['mcp', 'add', SERVER_NAME, ENDPOINT, '--type', 'http'], remove: ['mcp', 'remove', SERVER_NAME] }],
161
183
  signIn: 'run /mcp auth in the Tabnine CLI.',
184
+ next: `start a new tabnine session.`,
162
185
  },
163
186
  {
164
187
  id: 'tools-devin', name: 'Devin Desktop and CLI',
165
188
  detect: () => onPath('devin'),
166
189
  user: () => [{ kind: 'command', bin: 'devin', add: ['mcp', 'add', SERVER_NAME, ENDPOINT], remove: ['mcp', 'remove', SERVER_NAME] }],
167
190
  signIn: `run devin mcp login ${SERVER_NAME}.`,
191
+ next: `start a new devin session, or restart Devin Desktop.`,
192
+ login: ['mcp', 'login', SERVER_NAME],
168
193
  },
169
194
  {
170
195
  id: 'tools-goose', name: 'Goose',
171
196
  detect: (h) => existsSync(gooseDir(h)) || onPath('goose'),
172
197
  // The streamable_http shape of Goose's ExtensionConfig (block/goose,
173
198
  // crates/goose/src/agents/extension.rs; documentation/docs/guides/config-files.md).
174
- user: (h) => [{ kind: 'yaml', path: join(gooseDir(h), 'config.yaml'), key: 'extensions', lines: [
199
+ user: (h, key) => [{ kind: 'yaml', path: join(gooseDir(h), 'config.yaml'), key: 'extensions', lines: [
175
200
  'type: streamable_http', `name: ${SERVER_NAME}`, 'enabled: true', `uri: ${ENDPOINT}`,
176
- 'envs: {}', 'env_keys: []', 'headers: {}', 'timeout: 300', 'bundled: null', 'available_tools: []',
201
+ 'envs: {}', 'env_keys: []', key ? `headers: { Authorization: "Bearer ${key}" }` : 'headers: {}', 'timeout: 300', 'bundled: null', 'available_tools: []',
177
202
  ] }],
178
203
  signIn: SIGN_IN,
204
+ next: `start a new goose session, or restart Goose Desktop.`,
179
205
  },
180
206
  ];
181
207
  export const toolById = (id) => TOOLS.find((t) => t.id === id);
package/dist/cli.js CHANGED
@@ -1,28 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  // sekura: connect your coding tool to Sekura in one command.
3
3
  //
4
- // npx sekura@latest init
4
+ // npx sekura@latest init (a bare `npx sekura@latest` runs init too)
5
5
  //
6
6
  // Sekura's MCP server is remote (https://sekura.ai/mcp), so this package
7
- // runs no server and holds no credential: it writes the server's address
8
- // into the tools on this machine, installs the skill that teaches an agent
9
- // the quote-then-confirm rule, and gets out of the way. Signing in happens
10
- // in the tool, on a sekura.ai page, the first time it uses Sekura.
7
+ // runs no server: it writes the server's address into the tools on this
8
+ // machine, installs the skill that teaches an agent the quote-then-confirm
9
+ // rule, and then finishes getting started in the terminal. Once the plan is
10
+ // agreed it signs in on a sekura.ai page (or with a code, where the browser
11
+ // is on another device) and gives the resulting key to each tool, so none
12
+ // of them asks, then helps with the Terms, the GitHub App and a repository.
11
13
  import { Command } from 'commander';
12
14
  import { createRequire } from 'node:module';
13
15
  import { initCommand } from './commands/init.js';
14
16
  import { statusCommand } from './commands/status.js';
15
17
  import { uninstallCommand } from './commands/uninstall.js';
18
+ import { loginCommand, logoutCommand } from './commands/login.js';
16
19
  import { DOCS } from './catalogue.js';
17
20
  const { version } = createRequire(import.meta.url)('../package.json');
18
21
  const program = new Command();
19
22
  program
20
23
  .name('sekura')
21
- .description(`Connect your coding tool to Sekura.\n\n npx sekura@latest init\n\nDocumentation: ${DOCS}`)
24
+ .description(`Connect your coding tool to Sekura.\n\n npx sekura@latest init (a bare npx sekura@latest runs init too)\n\nDocumentation: ${DOCS}`)
22
25
  .version(version)
23
- .addCommand(initCommand, { isDefault: false })
26
+ .addCommand(initCommand, { isDefault: true })
27
+ .addCommand(loginCommand)
24
28
  .addCommand(statusCommand)
25
- .addCommand(uninstallCommand);
29
+ .addCommand(uninstallCommand)
30
+ .addCommand(logoutCommand);
26
31
  try {
27
32
  await program.parseAsync(process.argv);
28
33
  }