sekura 0.5.3 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +2 -0
- package/dist/catalogue.js +1 -1
- package/dist/cli.js +12 -3
- package/dist/commands/init.js +78 -48
- package/dist/commands/plans.js +59 -3
- package/dist/commands/shared.js +96 -3
- package/dist/flow.js +1 -2
- package/dist/guide.js +4 -4
- package/dist/plan.js +24 -3
- package/dist/session.js +4 -5
- package/dist/skill.js +2 -2
- package/dist/steps.js +5 -6
- package/dist/terms.js +7 -7
- package/dist/ui.js +98 -15
- package/dist/verify.js +1 -1
- package/package.json +1 -1
- package/skills/sekura/SKILL.md +9 -1
package/dist/api.js
CHANGED
|
@@ -143,6 +143,8 @@ export const tools = {
|
|
|
143
143
|
startAlways: (key, args) => call(key, 'startAlways', args),
|
|
144
144
|
quoteSchedule: (key, args) => call(key, 'quoteSchedule', args),
|
|
145
145
|
updateSchedule: (key, args) => call(key, 'updateSchedule', args),
|
|
146
|
+
quotePlanChange: (key, args) => call(key, 'quotePlanChange', args),
|
|
147
|
+
changePlan: (key, args) => call(key, 'changePlan', args),
|
|
146
148
|
quoteRunNow: (key, args) => call(key, 'quoteRunNow', args),
|
|
147
149
|
runNow: (key, args) => call(key, 'runNow', args),
|
|
148
150
|
previewCancelPlan: (key, args) => call(key, 'previewCancelPlan', args),
|
package/dist/catalogue.js
CHANGED
|
@@ -62,7 +62,7 @@ export const KEYS_PAGE = `${SETTINGS} → Agents and API keys`;
|
|
|
62
62
|
export const SUPPORT = 'support@sekura.ai';
|
|
63
63
|
/** One line naming the server, for a run that is not against production. */
|
|
64
64
|
export const serverNote = () => ENDPOINT === PRODUCTION ? null
|
|
65
|
-
: `
|
|
65
|
+
: `Server: ${new URL(ENDPOINT).host}${ENDPOINT_SOURCE === 'env' ? '' : ' (your saved sign-in; SEKURA_ENDPOINT picks another)'}`;
|
|
66
66
|
/** VS Code's user directory, where Copilot's `mcp.json` lives. */
|
|
67
67
|
export function codeUserDir(h = home()) {
|
|
68
68
|
switch (platform()) {
|
package/dist/cli.js
CHANGED
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
// of them asks, then helps with the Terms, the GitHub App and a repository.
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
14
|
import { COMMANDS, ENDPOINT_FLAG, ENDPOINT_VAR, endpointFromArgv, parseOrigin, unknownCommand } from './origin.js';
|
|
15
|
+
import { say } from './ui.js';
|
|
15
16
|
const fail = (message, code = 1) => {
|
|
16
|
-
|
|
17
|
+
say();
|
|
18
|
+
say(` ${message}`);
|
|
19
|
+
say();
|
|
17
20
|
process.exit(code);
|
|
18
21
|
};
|
|
19
22
|
const flag = endpointFromArgv(process.argv.slice(2));
|
|
@@ -85,8 +88,14 @@ catch (e) {
|
|
|
85
88
|
if (e?.name === 'ExitPromptError')
|
|
86
89
|
process.exit(130);
|
|
87
90
|
if (e instanceof Exit) {
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
// Loaded here, not at the top: shared.js reads the server address, which
|
|
92
|
+
// --endpoint sets only after this file starts.
|
|
93
|
+
const { personText } = await import('./commands/shared.js');
|
|
94
|
+
if (e.message) {
|
|
95
|
+
say();
|
|
96
|
+
say(` ${personText(e.message)}`);
|
|
97
|
+
say();
|
|
98
|
+
}
|
|
90
99
|
process.exit(e.code);
|
|
91
100
|
}
|
|
92
101
|
if (e instanceof SignedOut || e instanceof ToolError)
|
package/dist/commands/init.js
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
// they have seen what will be written. Nothing is written before the review
|
|
7
7
|
// is agreed (unless --yes).
|
|
8
8
|
import { Command } from 'commander';
|
|
9
|
-
import { checkbox, select } from '@inquirer/prompts';
|
|
10
9
|
import { realpathSync } from 'node:fs';
|
|
11
10
|
import { homedir } from 'node:os';
|
|
12
11
|
import { dirname, resolve } from 'node:path';
|
|
13
12
|
import { DOCS, ENDPOINT, PENDING_KEY, TOOLS, carriesKey, home, link, serverNote, toolById } from '../catalogue.js';
|
|
14
|
-
import { applyStep, buildPlan, describeStep, detectTools } from '../plan.js';
|
|
13
|
+
import { applyStep, buildPlan, describeStep, detectTools, planLine, stepPresent, tilde } from '../plan.js';
|
|
15
14
|
import { verifyEndpoint } from '../verify.js';
|
|
16
15
|
import { openLink } from '../open.js';
|
|
17
16
|
import { credentialsPath, readKey, readToolKey, savedCredentials } from '../auth.js';
|
|
@@ -21,7 +20,8 @@ import { howToScan, nextSteps } from '../guide.js';
|
|
|
21
20
|
import { currentSession, signInFresh, toolKeyFor, toolKeyName } from '../session.js';
|
|
22
21
|
import { ensureRepository, ensureTerms } from '../steps.js';
|
|
23
22
|
import { runScan } from './scan.js';
|
|
24
|
-
import {
|
|
23
|
+
import { personText } from './shared.js';
|
|
24
|
+
import { select, checkbox, ask, banner, c, cross, dot, say, step, tick, warn } from '../ui.js';
|
|
25
25
|
/** The home folder (or the top of the disk) is no project: project scope
|
|
26
26
|
* there would put AGENTS.md and .mcp.json in it for every tool to find. */
|
|
27
27
|
export function isProjectDir(cwd) {
|
|
@@ -36,10 +36,28 @@ export function isProjectDir(cwd) {
|
|
|
36
36
|
}
|
|
37
37
|
const and = (xs) => (xs.length < 2 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}`);
|
|
38
38
|
/** The one question: everything init will do, in a sentence. */
|
|
39
|
+
/** What a finished step says: the tool and where, never the command line
|
|
40
|
+
* with its key. */
|
|
41
|
+
function doneLine(s, where) {
|
|
42
|
+
if (s.kind === 'tool' && s.tool)
|
|
43
|
+
return s.target?.path ? `${s.tool.name} ${c.dim(tilde(s.target.path))}` : s.tool.name;
|
|
44
|
+
if (s.kind === 'skill')
|
|
45
|
+
return `Skill ${c.dim(tilde(where))}`;
|
|
46
|
+
return tilde(where);
|
|
47
|
+
}
|
|
48
|
+
/** The question and its details apart: the details go on a dim line above,
|
|
49
|
+
* so the question stays short enough not to wrap. */
|
|
50
|
+
export function summaryParts(o) {
|
|
51
|
+
const where = o.scope === 'user' ? 'Every project' : 'This project only';
|
|
52
|
+
const sign = o.signIn === 'sign-in' ? ' · sign in with GitHub' : o.signIn === 'saved' ? ' · saved sign-in' : '';
|
|
53
|
+
return { question: `Connect ${and(o.names)}?`, details: `${where} · ${o.skill ? 'with' : 'no'} skill${sign}` };
|
|
54
|
+
}
|
|
39
55
|
export function summary(o) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
// The question first, the details after it in brackets, so it reads at a
|
|
57
|
+
// glance (29 November 2026: "keep it crisp").
|
|
58
|
+
const where = o.scope === 'user' ? 'every project' : 'this project only';
|
|
59
|
+
const sign = o.signIn === 'sign-in' ? ', sign in with GitHub' : o.signIn === 'saved' ? ', saved sign-in' : '';
|
|
60
|
+
return `Connect ${and(o.names)}? (${where}, ${o.skill ? 'with' : 'no'} skill${sign})`;
|
|
43
61
|
}
|
|
44
62
|
export const toolFlags = () => TOOLS.map((t) => t.id.replace('tools-', ''));
|
|
45
63
|
export function unknownTools(names) {
|
|
@@ -88,7 +106,7 @@ async function freeScanElsewhere(key) {
|
|
|
88
106
|
}
|
|
89
107
|
}
|
|
90
108
|
async function firstScan(repo, opts, cwd, key) {
|
|
91
|
-
|
|
109
|
+
step('First scan');
|
|
92
110
|
if (await freeScanElsewhere(key)) {
|
|
93
111
|
const url = link('/app/start');
|
|
94
112
|
say(` Your first scan is free. Start it on the website: ${url}`);
|
|
@@ -99,7 +117,7 @@ async function firstScan(repo, opts, cwd, key) {
|
|
|
99
117
|
}
|
|
100
118
|
return undefined;
|
|
101
119
|
}
|
|
102
|
-
const go = await ask(`See the quote for
|
|
120
|
+
const go = await ask(`See the quote for your first scan of ${repo}?`, { default: true, short: 'See the quote?' });
|
|
103
121
|
if (!go) {
|
|
104
122
|
say(` No scan started. When you are ready: npx sekura@latest scan ${repo}`);
|
|
105
123
|
return undefined;
|
|
@@ -114,7 +132,7 @@ async function firstScan(repo, opts, cwd, key) {
|
|
|
114
132
|
if (e instanceof Exit) {
|
|
115
133
|
if (e.message) {
|
|
116
134
|
say();
|
|
117
|
-
say(` ${e.message}`);
|
|
135
|
+
say(` ${personText(e.message)}`);
|
|
118
136
|
}
|
|
119
137
|
if (e.code === EXIT.declined) {
|
|
120
138
|
say(` When you are ready: npx sekura@latest scan ${repo}`);
|
|
@@ -122,7 +140,7 @@ async function firstScan(repo, opts, cwd, key) {
|
|
|
122
140
|
}
|
|
123
141
|
return e.code;
|
|
124
142
|
}
|
|
125
|
-
say(`${cross} The scan could not be started: ${messageFor(e)}`);
|
|
143
|
+
say(`${cross} The scan could not be started: ${personText(messageFor(e))}`);
|
|
126
144
|
return exitCodeFor(e);
|
|
127
145
|
}
|
|
128
146
|
}
|
|
@@ -132,10 +150,8 @@ export async function runInit(opts) {
|
|
|
132
150
|
const cwd = opts.cwd ?? process.cwd();
|
|
133
151
|
banner({ login: opts.login });
|
|
134
152
|
const note = serverNote();
|
|
135
|
-
if (note)
|
|
136
|
-
say(` ${note}`);
|
|
137
|
-
say();
|
|
138
|
-
}
|
|
153
|
+
if (note)
|
|
154
|
+
say(` ${c.dim(note)}`);
|
|
139
155
|
// 1. Detect. Every detected tool, user scope, the skill and the sign-in
|
|
140
156
|
// are the defaults; a flag answers its own question.
|
|
141
157
|
const detected = detectTools(cwd);
|
|
@@ -152,6 +168,21 @@ export async function runInit(opts) {
|
|
|
152
168
|
}
|
|
153
169
|
else {
|
|
154
170
|
chosen = detected.map((t) => t.id);
|
|
171
|
+
step('Detect tools');
|
|
172
|
+
for (const t of detected) {
|
|
173
|
+
let present = false;
|
|
174
|
+
try {
|
|
175
|
+
const st = buildPlan({ tools: [t.id], scope: 'user', skill: false, cwd }).steps[0];
|
|
176
|
+
present = st ? stepPresent(st) : false;
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
present = false;
|
|
180
|
+
}
|
|
181
|
+
say(present === true ? `${tick} ${t.name} ${c.dim('connected')}` : `${warn} ${t.name} ${c.dim('needs setup')}`);
|
|
182
|
+
}
|
|
183
|
+
const missing = TOOLS.length - detected.length;
|
|
184
|
+
if (missing > 0)
|
|
185
|
+
say(` ${c.dim(`○ ${missing} more supported tools, not installed here`)}`);
|
|
155
186
|
}
|
|
156
187
|
let scope = opts.scope ?? 'user';
|
|
157
188
|
const inProject = isProjectDir(cwd);
|
|
@@ -164,28 +195,25 @@ export async function runInit(opts) {
|
|
|
164
195
|
let login = opts.login !== false;
|
|
165
196
|
const hasKey = !!readKey();
|
|
166
197
|
if (!chosen.length) {
|
|
167
|
-
say(
|
|
168
|
-
say(`
|
|
169
|
-
say(` Sekura connects to Claude Code, Cursor, GitHub Copilot, OpenAI Codex and nearly forty other tools; the page has every one: ${DOCS}`);
|
|
198
|
+
say(`${dot} No supported coding tool found on this machine.`);
|
|
199
|
+
say(` ${c.dim(`Using one? Name it: npx sekura@latest init --tools claude. Every tool: ${DOCS}`)}`);
|
|
170
200
|
if (!login)
|
|
171
201
|
return { written: 0, byHand: 0, failed: 0 };
|
|
172
|
-
say('
|
|
173
|
-
say();
|
|
202
|
+
say(' You can still set up your Sekura account here.');
|
|
174
203
|
}
|
|
175
204
|
// 2. One question, with Edit for the four it stands for.
|
|
176
205
|
if (interactive && chosen.length) {
|
|
177
206
|
const open = { tools: !opts.tools, scope: !opts.scope && inProject, skill: opts.skill === undefined, login: opts.login === undefined };
|
|
178
|
-
if (open.tools) {
|
|
179
|
-
say(` Found ${detected.length === 1 ? 'one tool' : `${detected.length} tools`}: ${detected.map((t) => t.name).join(', ')}`);
|
|
180
|
-
say();
|
|
181
|
-
}
|
|
182
207
|
if (open.tools || open.scope || open.skill || open.login) {
|
|
208
|
+
step('Choose tools');
|
|
183
209
|
const names = chosen.map((id) => toolById(id)?.name ?? id);
|
|
210
|
+
const parts = summaryParts({ names, scope, skill, signIn: login ? (hasKey ? 'saved' : 'sign-in') : null });
|
|
211
|
+
say(` ${c.dim(parts.details)}`);
|
|
184
212
|
const answer = await select({
|
|
185
|
-
message:
|
|
213
|
+
message: parts.question,
|
|
186
214
|
choices: [
|
|
187
215
|
{ name: 'Yes', value: 'yes' },
|
|
188
|
-
{ name: '
|
|
216
|
+
{ name: 'Choose: tools, where, skill, sign-in', value: 'edit' },
|
|
189
217
|
{ name: 'No, change nothing', value: 'no' },
|
|
190
218
|
],
|
|
191
219
|
});
|
|
@@ -196,32 +224,32 @@ export async function runInit(opts) {
|
|
|
196
224
|
if (answer === 'edit') {
|
|
197
225
|
if (open.tools) {
|
|
198
226
|
chosen = await checkbox({
|
|
199
|
-
message: '
|
|
227
|
+
message: 'Which tools?',
|
|
200
228
|
choices: detected.map((t) => ({ name: t.name, value: t.id, checked: chosen.includes(t.id) })),
|
|
201
229
|
required: true,
|
|
202
230
|
});
|
|
203
231
|
}
|
|
204
232
|
if (open.scope) {
|
|
205
233
|
scope = await select({
|
|
206
|
-
message: 'Where',
|
|
234
|
+
message: 'Where?',
|
|
207
235
|
choices: [
|
|
208
|
-
{ name: '
|
|
209
|
-
{ name: `This project only (${cwd})`, value: 'project' },
|
|
236
|
+
{ name: 'Every project (your user settings)', value: 'user' },
|
|
237
|
+
{ name: `This project only (${tilde(cwd)})`, value: 'project' },
|
|
210
238
|
],
|
|
211
239
|
});
|
|
212
240
|
}
|
|
213
241
|
if (open.skill)
|
|
214
|
-
skill = await ask('
|
|
242
|
+
skill = await ask('Install the skill? It teaches your agent to quote every scan first.', { default: true, short: 'Install the skill?' });
|
|
215
243
|
if (open.login) {
|
|
216
244
|
login = await ask(hasKey
|
|
217
|
-
? 'Use your saved
|
|
218
|
-
: 'Sign in to Sekura
|
|
245
|
+
? 'Use your saved sign-in? Your tools use it too.'
|
|
246
|
+
: 'Sign in to Sekura after the review? Your tools use the same sign-in.', { default: true, short: hasKey ? 'Use the saved sign-in?' : 'Sign in to Sekura?' });
|
|
219
247
|
}
|
|
220
248
|
}
|
|
221
249
|
}
|
|
222
250
|
}
|
|
223
251
|
else if (interactive && opts.login === undefined) {
|
|
224
|
-
const go = await ask('Set up your Sekura account
|
|
252
|
+
const go = await ask('Set up your Sekura account: sign in, Terms, GitHub App, first scan?', { default: true, short: 'Set up your account?' });
|
|
225
253
|
if (!go) {
|
|
226
254
|
say(' Nothing was changed.');
|
|
227
255
|
return { written: 0, byHand: 0, failed: 0 };
|
|
@@ -244,17 +272,16 @@ export async function runInit(opts) {
|
|
|
244
272
|
// 4. The plan, shown before anything happens, with a placeholder for the
|
|
245
273
|
// key the sign-in will bring.
|
|
246
274
|
const shown = buildPlan({ tools: chosen, scope, skill, cwd, key: shownKey(session, login, willSignIn) });
|
|
247
|
-
|
|
248
|
-
say(opts.dryRun ? ' Dry run. This would:' : ' This will:');
|
|
275
|
+
step(opts.dryRun ? 'Review (dry run)' : 'Review');
|
|
249
276
|
if (willSignIn)
|
|
250
|
-
say(`${dot}
|
|
277
|
+
say(`${dot} Sign in with GitHub ${c.dim(`(key kept in ${tilde(credentialsPath())})`)}`);
|
|
251
278
|
for (const s of shown.steps)
|
|
252
|
-
say(`${dot} ${describeStep(s,
|
|
279
|
+
say(`${dot} ${opts.dryRun ? describeStep(s, true) : planLine(s)}`);
|
|
253
280
|
for (const s of shown.skipped)
|
|
254
|
-
say(`${dot} ${s.tool.name}: skipped, ${s.why}`);
|
|
281
|
+
say(`${dot} ${s.tool.name}: ${c.dim(`skipped, ${s.why}`)}`);
|
|
255
282
|
if (account)
|
|
256
|
-
say(`${dot}
|
|
257
|
-
say(
|
|
283
|
+
say(`${dot} Then: Terms, GitHub App, a repository${opts.scan === false ? '' : ', your first scan (quoted before it starts)'}`);
|
|
284
|
+
say(` ${c.dim('Nothing else is changed.')}`);
|
|
258
285
|
say();
|
|
259
286
|
if (opts.dryRun)
|
|
260
287
|
return { written: 0, byHand: 0, failed: 0 };
|
|
@@ -270,6 +297,7 @@ export async function runInit(opts) {
|
|
|
270
297
|
// 5. Sign in, now that the plan is agreed, and put the key where the
|
|
271
298
|
// placeholder was.
|
|
272
299
|
if (willSignIn) {
|
|
300
|
+
step('Sign in');
|
|
273
301
|
session = await signInFresh({ legacy: opts.legacyLogin, device: opts.device, browser: opts.browser });
|
|
274
302
|
if (!session)
|
|
275
303
|
throw new Exit(EXIT.notSignedIn, 'The sign-in did not finish, so nothing was changed. Run npx sekura@latest again to retry, or npx sekura@latest init --no-login to connect your tools without a key.');
|
|
@@ -280,7 +308,7 @@ export async function runInit(opts) {
|
|
|
280
308
|
const made = await toolKeyFor(session);
|
|
281
309
|
toolKey = made.key;
|
|
282
310
|
if (made.minted)
|
|
283
|
-
say(`${tick}
|
|
311
|
+
say(`${tick} Key for your coding tools ${c.dim(toolKeyName())}`);
|
|
284
312
|
}
|
|
285
313
|
catch (e) {
|
|
286
314
|
if (session.kind === 'cli')
|
|
@@ -290,7 +318,8 @@ export async function runInit(opts) {
|
|
|
290
318
|
}
|
|
291
319
|
const plan = buildPlan({ tools: chosen, scope, skill, cwd, key: toolKey });
|
|
292
320
|
// 6. Apply, one step at a time, saying what each did.
|
|
293
|
-
|
|
321
|
+
if (plan.steps.length)
|
|
322
|
+
step('Connect tools');
|
|
294
323
|
let written = 0, byHand = 0, failed = 0;
|
|
295
324
|
const signIns = new Map();
|
|
296
325
|
const connected = [];
|
|
@@ -300,12 +329,12 @@ export async function runInit(opts) {
|
|
|
300
329
|
case 'written':
|
|
301
330
|
case 'ran':
|
|
302
331
|
written++;
|
|
303
|
-
say(`${tick} ${r.where}`);
|
|
332
|
+
say(`${tick} ${doneLine(s, r.where)}`);
|
|
304
333
|
break;
|
|
305
334
|
case 'removed':
|
|
306
335
|
case 'absent': break;
|
|
307
336
|
case 'unchanged':
|
|
308
|
-
say(`${tick} ${r.where}
|
|
337
|
+
say(`${tick} ${doneLine(s, r.where)} ${c.dim('already set up')}`);
|
|
309
338
|
break;
|
|
310
339
|
case 'by-hand':
|
|
311
340
|
byHand++;
|
|
@@ -334,9 +363,9 @@ export async function runInit(opts) {
|
|
|
334
363
|
let repo = null;
|
|
335
364
|
let exit;
|
|
336
365
|
if (session) {
|
|
337
|
-
say();
|
|
338
366
|
const flags = { interactive, browser: opts.browser, wait: opts.wait, cwd, soft: true };
|
|
339
367
|
let terms = 'unknown';
|
|
368
|
+
step('Terms');
|
|
340
369
|
try {
|
|
341
370
|
terms = await ensureTerms(session, flags);
|
|
342
371
|
}
|
|
@@ -345,6 +374,7 @@ export async function runInit(opts) {
|
|
|
345
374
|
throw e;
|
|
346
375
|
say(`${dot} The Terms could not be checked just now: ${messageFor(e)}`);
|
|
347
376
|
}
|
|
377
|
+
step('GitHub App and repository');
|
|
348
378
|
try {
|
|
349
379
|
repo = await ensureRepository(session, flags);
|
|
350
380
|
}
|
|
@@ -361,13 +391,13 @@ export async function runInit(opts) {
|
|
|
361
391
|
exit = await firstScan(repo, opts, cwd, session.key);
|
|
362
392
|
}
|
|
363
393
|
// 9. What is left, per tool.
|
|
364
|
-
|
|
394
|
+
step('Next steps');
|
|
365
395
|
if (signIns.size) {
|
|
366
396
|
const ready = [...signIns].filter(([, how]) => how === null).map(([name]) => name);
|
|
367
397
|
const pending = [...signIns].filter(([, how]) => how !== null);
|
|
368
398
|
const confirmed = !!session?.account || reachable === true;
|
|
369
399
|
if (ready.length)
|
|
370
|
-
say(confirmed ? `${tick} Ready
|
|
400
|
+
say(confirmed ? `${tick} Ready: ${ready.join(', ')}` : `${dot} Key given, not yet confirmed (Sekura did not answer): ${ready.join(', ')}`);
|
|
371
401
|
if (pending.length) {
|
|
372
402
|
say(' Sign in once per tool:');
|
|
373
403
|
for (const [name, how] of pending)
|
|
@@ -383,7 +413,7 @@ export async function runInit(opts) {
|
|
|
383
413
|
}
|
|
384
414
|
if (!session && login && signIns.size)
|
|
385
415
|
say(' To give your tools a key so they do not each ask you to sign in: run npx sekura@latest login');
|
|
386
|
-
say(`
|
|
416
|
+
say(` ${c.dim(`Docs and every other tool: ${DOCS}`)}`);
|
|
387
417
|
say();
|
|
388
418
|
return { written, byHand, failed, ...(exit ? { exit } : {}) };
|
|
389
419
|
}
|
package/dist/commands/plans.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { input
|
|
2
|
+
import { input } from '@inquirer/prompts';
|
|
3
3
|
import { call, getPlans, tools } from '../api.js';
|
|
4
4
|
import { EXIT, Exit } from '../exit.js';
|
|
5
5
|
import { confirmQuote, requireKey, startWithPayment } from '../flow.js';
|
|
6
6
|
import { monthlyName } from '../payment.js';
|
|
7
|
-
import { dot, interactive, printJson, printTable, say } from '../ui.js';
|
|
7
|
+
import { select, dot, interactive, printJson, printTable, say } from '../ui.js';
|
|
8
8
|
import { afterStart, 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'
|
|
@@ -194,6 +194,56 @@ export async function runPlanSchedule(repo, opts = {}) {
|
|
|
194
194
|
await afterStart(key, outcome, { what: `The new schedule for ${repository}`, watch: false, json: opts.json });
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Move a repository between Weekly and More frequently (Sudhir, 29 November
|
|
199
|
+
* 2026: "add plan changes to cli and coding tool"). Quoted first like every
|
|
200
|
+
* change that can charge: an upgrade charges the difference for the rest of
|
|
201
|
+
* the month now, a downgrade nothing until the renewal. The two plans run on
|
|
202
|
+
* different schedules, so the new plan's schedule is asked for (or taken from
|
|
203
|
+
* --weekday/--every/--on-demand) with the change.
|
|
204
|
+
*/
|
|
205
|
+
export async function runPlanChange(repo, opts = {}) {
|
|
206
|
+
const key = requireKey();
|
|
207
|
+
const repository = resolveRepository(repo, opts.cwd);
|
|
208
|
+
const command = `npx sekura@latest plan change ${repository}`;
|
|
209
|
+
await ready(async () => {
|
|
210
|
+
let args = { repository };
|
|
211
|
+
let toName = 'the other plan';
|
|
212
|
+
if (!opts.confirm) {
|
|
213
|
+
const plan = await planFor(key, repository);
|
|
214
|
+
if (!plan || !monthlyName(plan))
|
|
215
|
+
throw new Exit(EXIT.error, `${repository} has no monthly plan to change. To start one: npx sekura@latest plan start ${repository}`);
|
|
216
|
+
const now = tierOf(plan.tier === 'pro' ? 'pro' : 'always');
|
|
217
|
+
const to = opts.to ? tierOf(opts.to) : now === 'pro' ? 'always' : 'pro';
|
|
218
|
+
if (to === now)
|
|
219
|
+
throw new Exit(EXIT.error, `${repository} is already on ${monthlyName(plan)}. To change when it scans: npx sekura@latest plan schedule ${repository}`);
|
|
220
|
+
toName = to === 'pro' ? 'More frequently' : 'Weekly';
|
|
221
|
+
if (!flagged(opts) && interactive())
|
|
222
|
+
say(` ${toName} scans ${to === 'pro' ? 'every one to three days' : 'once a week'}. Choose its schedule:`);
|
|
223
|
+
args = { repository, tier: to, schedule: await scheduleFor(to, opts, command) };
|
|
224
|
+
}
|
|
225
|
+
const agreed = await confirmQuote({
|
|
226
|
+
op: 'quotePlanChange',
|
|
227
|
+
args,
|
|
228
|
+
fetch: () => tools.quotePlanChange(key, args),
|
|
229
|
+
flags: opts,
|
|
230
|
+
command,
|
|
231
|
+
question: `Move ${repository} to ${toName}?`,
|
|
232
|
+
sayQuote: sayText,
|
|
233
|
+
});
|
|
234
|
+
if (agreed.kind === 'quoted')
|
|
235
|
+
return;
|
|
236
|
+
const outcome = await startWithPayment(key, agreed.confirmOperation, agreed.confirmArguments, { quoteId: agreed.quoteId, browser: opts.browser });
|
|
237
|
+
if (outcome.kind === 'started') {
|
|
238
|
+
if (opts.json)
|
|
239
|
+
printJson(outcome.data);
|
|
240
|
+
else
|
|
241
|
+
sayText(outcome.text);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
await afterStart(key, outcome, { what: `The plan change for ${repository}`, watch: false, json: opts.json });
|
|
245
|
+
});
|
|
246
|
+
}
|
|
197
247
|
export async function runPlanRun(repo, opts = {}) {
|
|
198
248
|
const key = requireKey();
|
|
199
249
|
const repository = resolveRepository(repo, opts.cwd);
|
|
@@ -247,6 +297,11 @@ const schedule = withScheduleOptions(withQuoteOptions(new Command('schedule')
|
|
|
247
297
|
.description('Change when a monthly plan scans: shows the change, asks, then applies it.')
|
|
248
298
|
.argument('[repo]', REPO_ARG)))
|
|
249
299
|
.action(async (repo, opts) => { await runPlanSchedule(repo, opts); });
|
|
300
|
+
const change = withScheduleOptions(withQuoteOptions(new Command('change')
|
|
301
|
+
.description('Move a repository to the other monthly plan, up to More frequently or down to Weekly: shows the change and what it costs, asks, then applies it.')
|
|
302
|
+
.argument('[repo]', REPO_ARG)
|
|
303
|
+
.option('--to <plan>', 'weekly (Weekly) or frequent (More frequently); the default is the plan it is not on')))
|
|
304
|
+
.action(async (repo, opts) => { await runPlanChange(repo, opts); });
|
|
250
305
|
const run = withFollowOptions(withQuoteOptions(new Command('run')
|
|
251
306
|
.description('Start a monthly plan\'s scan now, within the plan\'s run limit: shows what it does, asks, then starts.')
|
|
252
307
|
.argument('[repo]', REPO_ARG)))
|
|
@@ -256,8 +311,9 @@ const cancel = withQuoteOptions(new Command('cancel')
|
|
|
256
311
|
.argument('[repo]', REPO_ARG))
|
|
257
312
|
.action(async (repo, opts) => { await runPlanCancel(repo, opts); });
|
|
258
313
|
export const planCommand = new Command('plan')
|
|
259
|
-
.description('Start, schedule, run or cancel a monthly plan for a repository. sekura plans lists them.')
|
|
314
|
+
.description('Start, change, schedule, run or cancel a monthly plan for a repository. sekura plans lists them.')
|
|
260
315
|
.addCommand(start)
|
|
316
|
+
.addCommand(change)
|
|
261
317
|
.addCommand(schedule)
|
|
262
318
|
.addCommand(run)
|
|
263
319
|
.addCommand(cancel);
|
package/dist/commands/shared.js
CHANGED
|
@@ -6,7 +6,7 @@ import { exitCodeOfStart, scanFinished, watchScan } from '../flow.js';
|
|
|
6
6
|
import { scanLink } from '../payment.js';
|
|
7
7
|
import { currentGithubRepo } from '../repo.js';
|
|
8
8
|
import { defaultRepository } from '../state.js';
|
|
9
|
-
import { ask, cross, dot, interactive, say, tick } from '../ui.js';
|
|
9
|
+
import { ask, c, cross, dot, interactive, say, tick } from '../ui.js';
|
|
10
10
|
export const DOCTOR_HINT = 'Run npx sekura@latest doctor to see what is left to set up.';
|
|
11
11
|
export function withQuoteOptions(cmd) {
|
|
12
12
|
return cmd
|
|
@@ -65,6 +65,10 @@ const PERSON_REWRITES = [
|
|
|
65
65
|
[/Before Sekura (brings forward|starts) (.+?), show the person what it does below and ask whether they agree\./g, (_m, verb, what) => `Sekura ${verb === 'starts' ? 'would start' : 'would bring forward'} ${what}. Here is what it does.`],
|
|
66
66
|
[/This account's free[ ]first[ ]scan is still available(?:, on sekura\.ai only)?: the person starts it themselves (?:by running `[^`]+` in a terminal, or )?at (\S+?)\. It is not started through a connected tool, and confirming here buys a one-time scan at (\$[\d.,]+) instead\./g,
|
|
67
67
|
(_m, url, price) => `Your first scan is still free, at ${url}. Agreeing here buys a one-time scan at ${price} instead.`],
|
|
68
|
+
// The refusal for a stale wording tells an agent to re-quote and show the
|
|
69
|
+
// person; in a terminal the person is the reader (29 November 2026).
|
|
70
|
+
[/The authorization wording has changed since it was shown: the current version is \S+\. Nothing was started\. Call \w+ again to get the current text, show it to the person, and confirm with \w+ and disclosureVersion "[^"]+" only once they agree\.(?:\s+https?:\/\/\S+)?/g,
|
|
71
|
+
'The authorization wording changed since you saw it. Nothing was started. Run the same command again to see the current wording.'],
|
|
68
72
|
];
|
|
69
73
|
export function personText(text) {
|
|
70
74
|
const out = [];
|
|
@@ -80,10 +84,99 @@ export function personText(text) {
|
|
|
80
84
|
out.pop();
|
|
81
85
|
return out.join('\n');
|
|
82
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* A quote laid out for a terminal (Sudhir, 29 November 2026: tidy the quote
|
|
89
|
+
* as it prints). The server sends one block for an agent: facts as
|
|
90
|
+
* "Label: value", then the authorization in its hashed form, with marker lines
|
|
91
|
+
* ("-- you warrant --") and a version line. Printed as sent, it read as raw
|
|
92
|
+
* text. Here the facts become aligned label columns, the authorization a
|
|
93
|
+
* titled section with its clauses indented under two headings, and the
|
|
94
|
+
* version a dim line at the end. The words are the server's, unchanged: the
|
|
95
|
+
* text the person agrees to is the text that was hashed. Anything this does
|
|
96
|
+
* not recognise is printed as it came.
|
|
97
|
+
*/
|
|
98
|
+
export function quoteLines(text) {
|
|
99
|
+
const out = [];
|
|
100
|
+
let version = null;
|
|
101
|
+
let inAuth = false;
|
|
102
|
+
let titleNext = false;
|
|
103
|
+
const facts = [];
|
|
104
|
+
const flushFacts = () => {
|
|
105
|
+
if (!facts.length)
|
|
106
|
+
return;
|
|
107
|
+
const w = Math.max(...facts.map(([k]) => k.length));
|
|
108
|
+
for (const [k, v] of facts)
|
|
109
|
+
out.push(`${c.dim(k.padEnd(w))} ${v}`);
|
|
110
|
+
facts.length = 0;
|
|
111
|
+
};
|
|
112
|
+
for (const raw of personText(text).split('\n')) {
|
|
113
|
+
const line = raw.trimEnd();
|
|
114
|
+
const wording = /^Authorization wording, version (.+?):$/.exec(line);
|
|
115
|
+
if (wording) {
|
|
116
|
+
flushFacts();
|
|
117
|
+
version = wording[1];
|
|
118
|
+
inAuth = true;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (inAuth) {
|
|
122
|
+
if (/^(single_scan|continuous):\S+$/.test(line)) {
|
|
123
|
+
titleNext = true;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (titleNext && line) {
|
|
127
|
+
titleNext = false;
|
|
128
|
+
out.push(c.bold(line));
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (line === '-- you warrant --') {
|
|
132
|
+
out.push('', c.bold('You confirm'));
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (/^-- sekura commits/.test(line)) {
|
|
136
|
+
out.push('', c.bold('Sekura commits'));
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (line === '-- affirmation --') {
|
|
140
|
+
out.push('');
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (/^([a-z]\)|\d+\.) /.test(line)) {
|
|
144
|
+
out.push(` ${line}`);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!line && out[out.length - 1] === '')
|
|
148
|
+
continue;
|
|
149
|
+
out.push(line);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const fact = /^(Repository|Price|How it is paid|Schedule|Plan|Target|Live app|Test account|Card|Charged today|Then|Tests?): (.+)$/.exec(line);
|
|
153
|
+
if (fact) {
|
|
154
|
+
const value = fact[1] === 'Price' && /^nothing\. This is the account's free[ ]first[ ]scan/.test(fact[2]) ? 'Free, your first scan (no card needed)' : fact[2];
|
|
155
|
+
facts.push([fact[1], value]);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const nothing = /^(.*?)\s*Nothing has been started or charged\.$/.exec(line);
|
|
159
|
+
if (nothing && nothing[1]) {
|
|
160
|
+
flushFacts();
|
|
161
|
+
out.push(nothing[1], c.dim('Nothing has been started or charged.'));
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
flushFacts();
|
|
165
|
+
if (!line && out[out.length - 1] === '')
|
|
166
|
+
continue;
|
|
167
|
+
out.push(line);
|
|
168
|
+
}
|
|
169
|
+
flushFacts();
|
|
170
|
+
while (out.length && !out[out.length - 1])
|
|
171
|
+
out.pop();
|
|
172
|
+
if (version)
|
|
173
|
+
out.push('', c.dim(`Version ${version}`));
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
83
176
|
export function sayText(text) {
|
|
84
177
|
say();
|
|
85
|
-
for (const l of
|
|
86
|
-
say(` ${l}`);
|
|
178
|
+
for (const l of quoteLines(text))
|
|
179
|
+
say(l ? ` ${l}` : '');
|
|
87
180
|
say();
|
|
88
181
|
}
|
|
89
182
|
export const withoutConfirm = (args) => {
|
package/dist/flow.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { select } from '@inquirer/prompts';
|
|
2
1
|
import { randomBytes } from 'node:crypto';
|
|
3
2
|
import { readKey } from './auth.js';
|
|
4
3
|
import { call, getPlans, paymentRequiredOf, tools } from './api.js';
|
|
@@ -6,7 +5,7 @@ import { EXIT, Exit, SIGN_IN_HINT } from './exit.js';
|
|
|
6
5
|
import { openLink } from './open.js';
|
|
7
6
|
import { openableLink, paymentState } from './payment.js';
|
|
8
7
|
import { dropQuote, findQuote, saveQuote } from './state.js';
|
|
9
|
-
import { ask, dot, interactive, printJson, say, tick, waitFor } from './ui.js';
|
|
8
|
+
import { select, ask, dot, interactive, printJson, say, tick, waitFor } from './ui.js';
|
|
10
9
|
export function requireKey() {
|
|
11
10
|
const key = readKey();
|
|
12
11
|
if (!key)
|
package/dist/guide.js
CHANGED
|
@@ -60,7 +60,7 @@ export function toolLogin(s) {
|
|
|
60
60
|
}
|
|
61
61
|
/** What to do in each tool now, so it loads the server. */
|
|
62
62
|
export function nextSteps(tools) {
|
|
63
|
-
say('
|
|
63
|
+
say(' In each tool:');
|
|
64
64
|
for (const t of tools)
|
|
65
65
|
say(`${dot} ${t.name}: ${nextStep(t)}`);
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ export function nextSteps(tools) {
|
|
|
68
68
|
export function howToScan(tools, repo, _account) {
|
|
69
69
|
const target = repo ?? 'owner/repo';
|
|
70
70
|
if (tools.length) {
|
|
71
|
-
say('
|
|
71
|
+
say(' Scan from your coding tool (quoted first, starts only when you agree):');
|
|
72
72
|
for (const name of tools) {
|
|
73
73
|
if (name === 'Claude Code')
|
|
74
74
|
say(`${dot} ${name}: /${SERVER_NAME} scan ${target} (/${SERVER_NAME} help lists every command)`);
|
|
@@ -76,7 +76,7 @@ export function howToScan(tools, repo, _account) {
|
|
|
76
76
|
say(`${dot} ${name}: ask "scan ${target} with Sekura"`);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
say(`
|
|
79
|
+
say(` Or from this terminal: npx sekura@latest scan${repo ? ` ${repo}` : ' owner/repo'}`);
|
|
80
80
|
if (!repo)
|
|
81
|
-
say(' No repository
|
|
81
|
+
say(' No repository yet: npx sekura@latest repos --add');
|
|
82
82
|
}
|
package/dist/plan.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// step by step. `status` and `uninstall` read the same plan, so the three
|
|
4
4
|
// commands cannot disagree about where Sekura lives.
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
|
-
import { TOOLS, home,
|
|
6
|
+
import { TOOLS, home, pickTarget, toolById } from './catalogue.js';
|
|
7
7
|
import { apply, describe, has, remove } from './writers.js';
|
|
8
8
|
import { guidanceFiles, hasGuidance, removeGuidance, removeSkill, skillPaths, writeGuidance, writeSkill } from './skill.js';
|
|
9
9
|
export function detectTools(cwd = process.cwd()) {
|
|
@@ -34,8 +34,12 @@ export function buildPlan(opts) {
|
|
|
34
34
|
steps.push({ kind: 'tool', tool, target });
|
|
35
35
|
}
|
|
36
36
|
if (opts.skill) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Each skill copy only for a chosen tool that reads it (sekura-cli#1):
|
|
38
|
+
// ~/.claude/skills for Claude Code, ~/.agents/skills for the others.
|
|
39
|
+
// Choosing Claude Code alone wrote the shared .agents copy as well.
|
|
40
|
+
const claude = opts.tools.includes('tools-claude');
|
|
41
|
+
const others = opts.tools.some((t) => t !== 'tools-claude');
|
|
42
|
+
for (const p of skillPaths(root, claude, opts.scope, others))
|
|
39
43
|
steps.push({ kind: 'skill', path: p });
|
|
40
44
|
if (opts.scope === 'project')
|
|
41
45
|
for (const p of guidanceFiles(cwd))
|
|
@@ -51,6 +55,23 @@ export function describeStep(s, dryRun = false) {
|
|
|
51
55
|
case 'guidance': return `guidance: ${verb}add a marked Sekura section to ${s.path}`;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
58
|
+
/** "~/.claude.json", not "/Users/jams/.claude.json": a plan line is read, not run. */
|
|
59
|
+
export const tilde = (p) => { const h = home(); return p === h ? '~' : p.startsWith(`${h}/`) ? `~${p.slice(h.length)}` : p; };
|
|
60
|
+
/** One plain line per step for the review (sekura-cli#1, 29 November 2026).
|
|
61
|
+
* The review printed each tool's raw JSON entry, key placeholder and all,
|
|
62
|
+
* which a first-time person cannot use; describeStep keeps that detail for
|
|
63
|
+
* --dry-run. */
|
|
64
|
+
export function planLine(s) {
|
|
65
|
+
switch (s.kind) {
|
|
66
|
+
case 'tool': {
|
|
67
|
+
const t = s.target;
|
|
68
|
+
const how = t.kind === 'command' ? `add Sekura with the ${t.bin} command` : t.kind === 'link' ? t.note : `add Sekura to ${tilde(t.path)}`;
|
|
69
|
+
return `${s.tool.name}: ${how}`;
|
|
70
|
+
}
|
|
71
|
+
case 'skill': return `Skill: ${tilde(s.path)}`;
|
|
72
|
+
case 'guidance': return `Guidance: a Sekura section in ${tilde(s.path)}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
54
75
|
/** What uninstall will take out, as the person reads it before agreeing:
|
|
55
76
|
* the file or the tool's command, and each skill file by its full path.
|
|
56
77
|
* Until 0.4.2 this was describeStep cut at its first colon, which left the
|
package/dist/session.js
CHANGED
|
@@ -86,22 +86,21 @@ async function legacySession(flags) {
|
|
|
86
86
|
export async function signInFresh(flags = {}) {
|
|
87
87
|
if (flags.legacy)
|
|
88
88
|
return legacySession(flags);
|
|
89
|
-
say();
|
|
90
89
|
let stop = () => { };
|
|
91
90
|
try {
|
|
92
91
|
const signed = await signInWithGithub({
|
|
93
92
|
browser: flags.browser,
|
|
94
93
|
onCode: (c) => {
|
|
95
|
-
say(' Sign in
|
|
94
|
+
say(' Sign in with GitHub. Your code:');
|
|
96
95
|
say();
|
|
97
96
|
say(` ${c.userCode}${c.copied ? ' (copied to your clipboard)' : ''}`);
|
|
98
97
|
say();
|
|
99
98
|
say(c.opened.opened
|
|
100
|
-
? ` Opening ${c.uri}
|
|
99
|
+
? ` Opening ${c.uri}. Enter the code there and approve.`
|
|
101
100
|
: ` On any device, open ${c.uri}, enter the code and approve.`);
|
|
102
101
|
say();
|
|
103
102
|
const minutes = Math.max(1, Math.round(c.expiresIn / 60));
|
|
104
|
-
stop = spinner(`Waiting for
|
|
103
|
+
stop = spinner(`Waiting for approval on github.com (code expires in ${minutes} min)`);
|
|
105
104
|
},
|
|
106
105
|
});
|
|
107
106
|
stop();
|
|
@@ -113,7 +112,7 @@ export async function signInFresh(flags = {}) {
|
|
|
113
112
|
account = null;
|
|
114
113
|
}
|
|
115
114
|
const where = saveKey(signed.key, account?.email ?? signed.account?.email, 'cli');
|
|
116
|
-
say(`${tick} Signed in
|
|
115
|
+
say(`${tick} Signed in as ${who(account ?? signed.account, signed.key)}${signed.account?.created ? ' (new account)' : ''}`);
|
|
117
116
|
return { key: signed.key, account, kind: 'cli', fresh: true, githubLogin: signed.account?.login ?? null };
|
|
118
117
|
}
|
|
119
118
|
catch (e) {
|
package/dist/skill.js
CHANGED
|
@@ -18,8 +18,8 @@ export const SKILL_SOURCE = join(here, '..', 'skills', SERVER_NAME, 'SKILL.md');
|
|
|
18
18
|
/** LF whatever the checkout did: a Windows clone with autocrlf would otherwise
|
|
19
19
|
* install a skill whose every line ends in \r, and a rerun would rewrite it. */
|
|
20
20
|
export const skillText = () => readFileSync(SKILL_SOURCE, 'utf8').replace(/\r\n/g, '\n');
|
|
21
|
-
export function skillPaths(root, claude, scope) {
|
|
22
|
-
const out = [join(root, '.agents', 'skills', SERVER_NAME, 'SKILL.md')];
|
|
21
|
+
export function skillPaths(root, claude, scope, agents = true) {
|
|
22
|
+
const out = agents ? [join(root, '.agents', 'skills', SERVER_NAME, 'SKILL.md')] : [];
|
|
23
23
|
if (claude || (scope === 'project' && existsSync(join(root, '.claude'))))
|
|
24
24
|
out.push(join(root, '.claude', 'skills', SERVER_NAME, 'SKILL.md'));
|
|
25
25
|
return out;
|
package/dist/steps.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { select } from '@inquirer/prompts';
|
|
2
1
|
import { readKey, readToolKey, redact } from './auth.js';
|
|
3
2
|
import { getAccount, getBilling, getPlans, isMissingRoute, isToolError, listRepositories, SignedOut } from './api.js';
|
|
4
3
|
import { ENDPOINT, HOST, carriesKey, link } from './catalogue.js';
|
|
@@ -10,7 +9,7 @@ import { currentGithubRepo } from './repo.js';
|
|
|
10
9
|
import { obtainSession } from './session.js';
|
|
11
10
|
import { defaultRepository, setDefaultRepository } from './state.js';
|
|
12
11
|
import { termsFlow } from './terms.js';
|
|
13
|
-
import { ask, cross, dot, say, tick, waitFor } from './ui.js';
|
|
12
|
+
import { select, ask, cross, dot, say, tick, waitFor } from './ui.js';
|
|
14
13
|
const isInteractive = (f) => f.interactive ?? (!f.yes && !f.json && !!process.stdin.isTTY && !!process.stderr.isTTY);
|
|
15
14
|
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
16
15
|
export function localConnections(opts = {}) {
|
|
@@ -188,7 +187,7 @@ export async function ensureTerms(s, flags = {}) {
|
|
|
188
187
|
throw e;
|
|
189
188
|
}
|
|
190
189
|
const page = a?.links?.dashboard ?? link('/app');
|
|
191
|
-
say(`${dot}
|
|
190
|
+
say(`${dot} Accept the Terms before your first scan: ${page}`);
|
|
192
191
|
if (interactive && await ask(`Open ${HOST} to do that now?`, { default: true, short: 'Open it now?' })) {
|
|
193
192
|
const o = openLink(page, { browser: flags.browser });
|
|
194
193
|
if (!o.opened)
|
|
@@ -247,10 +246,10 @@ export async function ensureApp(s, flags = {}) {
|
|
|
247
246
|
return { installed: true, found: true, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
248
247
|
const onGithub = /^https:\/\/github\.com\//.test(url);
|
|
249
248
|
say(ownMissing
|
|
250
|
-
? `${dot}
|
|
249
|
+
? `${dot} Sekura GitHub App not installed on ${own} yet. It reaches ${repos.length === 1 ? 'one repository' : `${repos.length} repositories`} through ${accountsOf(list).join(', ')}, where you collaborate.`
|
|
251
250
|
: repos.length
|
|
252
251
|
? want && !covered() ? `${dot} ${want} is not one Sekura can scan yet: the Sekura GitHub App needs access to it.` : `${dot} To give Sekura more repositories, change the Sekura GitHub App's access.`
|
|
253
|
-
: `${dot}
|
|
252
|
+
: `${dot} Sekura GitHub App not installed yet, so there is nothing to scan.`);
|
|
254
253
|
if (!interactive) {
|
|
255
254
|
say(` Install it and choose repositories at ${url}`);
|
|
256
255
|
if (flags.soft || covered())
|
|
@@ -336,7 +335,7 @@ export async function ensureRepository(s, flags = {}) {
|
|
|
336
335
|
// like Sekura found repositories by itself (29 November 2026: the App was
|
|
337
336
|
// still on sekura-ai, and findsekura saw sekura-ai/nagiclaw).
|
|
338
337
|
if (accounts.length)
|
|
339
|
-
say(`${dot}
|
|
338
|
+
say(`${dot} Sekura GitHub App installed on ${accounts.join(', ')}. Repositories it can reach:`);
|
|
340
339
|
const hereNow = find(here) ? repos.find((r) => same(r.fullName, here)) : undefined;
|
|
341
340
|
const savedNow = repos.find((r) => same(r.fullName, defaultRepository() ?? ''));
|
|
342
341
|
const first = hereNow ?? savedNow;
|
package/dist/terms.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { select } from '@inquirer/prompts';
|
|
2
1
|
import { cliApi, isToolError } from './api.js';
|
|
3
2
|
import { EXIT, Exit } from './exit.js';
|
|
4
|
-
import { ask, dot, say, tick } from './ui.js';
|
|
3
|
+
import { select, ask, c, dot, say, tick } from './ui.js';
|
|
5
4
|
export const termsCurrent = (t) => t.state === 'current';
|
|
6
5
|
export async function getTerms(key) {
|
|
7
6
|
const t = await cliApi(key, 'GET', '/terms');
|
|
@@ -11,18 +10,19 @@ export async function getTerms(key) {
|
|
|
11
10
|
return t;
|
|
12
11
|
}
|
|
13
12
|
export const acceptTerms = (key, accept, marketing) => cliApi(key, 'POST', '/terms', { version: accept.version, textHash: accept.textHash, accept: true, marketing });
|
|
13
|
+
/** The Terms as they print: the sentence agreed to, each document with its
|
|
14
|
+
* link in an aligned column, the version dim (29 November 2026). */
|
|
14
15
|
export function showTerms(t) {
|
|
15
|
-
say();
|
|
16
16
|
for (const line of t.text.split('\n'))
|
|
17
17
|
say(` ${line}`);
|
|
18
18
|
const documents = (t.documents ?? []).filter((d) => d.url);
|
|
19
19
|
if (documents.length) {
|
|
20
|
+
const w = Math.max(...documents.map((d) => (d.title ?? 'Document').length));
|
|
20
21
|
say();
|
|
21
22
|
for (const d of documents)
|
|
22
|
-
say(
|
|
23
|
+
say(` ${(d.title ?? 'Document').padEnd(w)} ${c.dim(d.url)}`);
|
|
23
24
|
}
|
|
24
|
-
say();
|
|
25
|
-
say(` Version ${t.version}`);
|
|
25
|
+
say(` ${c.dim(`Version ${t.version}`)}`);
|
|
26
26
|
say();
|
|
27
27
|
}
|
|
28
28
|
const changed = (e) => isToolError(e, 'terms_changed') || (isToolError(e) && e.status === 409);
|
|
@@ -62,7 +62,7 @@ export async function termsFlow(key, opts) {
|
|
|
62
62
|
return 'declined';
|
|
63
63
|
let marketing = opts.marketing === true;
|
|
64
64
|
if (opts.marketing === undefined && terms.marketingText)
|
|
65
|
-
marketing = await ask(terms.marketingText, { default: false, short: 'Send me product news?' });
|
|
65
|
+
marketing = await ask(terms.marketingText.replace(/\.$/, '?'), { default: false, short: 'Send me product news?' });
|
|
66
66
|
try {
|
|
67
67
|
await acceptTerms(key, { version: terms.version, textHash: terms.textHash }, marketing);
|
|
68
68
|
say(`${tick} Terms accepted (version ${terms.version})`);
|
package/dist/ui.js
CHANGED
|
@@ -1,8 +1,69 @@
|
|
|
1
|
-
// Output goes to stderr
|
|
2
|
-
// the
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// Output goes to stderr, and stdout stays empty: the person may pipe it.
|
|
2
|
+
// Colour marks the steps, the answers and each line's state (Sudhir, 29
|
|
3
|
+
// November 2026: "use similar color distinctions to show users the different
|
|
4
|
+
// steps"). It is plain ANSI, no library, and only on a terminal: a log, a
|
|
5
|
+
// pipe, NO_COLOR or TERM=dumb gets the same words without it.
|
|
6
|
+
const COLOR = !!process.stderr.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb';
|
|
7
|
+
const paint = (open, close) => (s) => (COLOR ? `\x1b[${open}m${s}\x1b[${close}m` : s);
|
|
8
|
+
export const c = {
|
|
9
|
+
step: paint('1;35', '22;39'),
|
|
10
|
+
rule: paint('35', '39'),
|
|
11
|
+
accent: paint('36', '39'),
|
|
12
|
+
ok: paint('32', '39'),
|
|
13
|
+
warn: paint('33', '39'),
|
|
14
|
+
bad: paint('31', '39'),
|
|
15
|
+
dim: paint('2', '22'),
|
|
16
|
+
bold: paint('1', '22'),
|
|
17
|
+
};
|
|
18
|
+
/** Visible width: ANSI colour codes take no room on screen. */
|
|
19
|
+
const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
20
|
+
/**
|
|
21
|
+
* A line wider than the terminal, wrapped by us so every continuation line
|
|
22
|
+
* starts at the same indent as the first line's text (Sudhir, 29 November
|
|
23
|
+
* 2026: "both lines start at the same indent"). The terminal's own wrap puts
|
|
24
|
+
* the rest of the line at column 0. A bullet line ("· ", "✓ ", "⚠ ", "✗ ",
|
|
25
|
+
* "○ ") continues under the text, not under the mark. One word longer than the
|
|
26
|
+
* room (a long URL) keeps its own line rather than being cut.
|
|
27
|
+
*/
|
|
28
|
+
export function wrapLine(line, cols) {
|
|
29
|
+
if (visible(line) <= cols)
|
|
30
|
+
return [line];
|
|
31
|
+
const lead = /^(\s*)/.exec(line)[1];
|
|
32
|
+
const rest = line.slice(lead.length);
|
|
33
|
+
const mark = /^(?:\x1b\[[0-9;]*m)*[·✓⚠✗○](?:\x1b\[[0-9;]*m)* /.exec(rest);
|
|
34
|
+
const indent = lead + (mark ? ' ' : '');
|
|
35
|
+
const words = rest.split(' ');
|
|
36
|
+
const out = [];
|
|
37
|
+
let cur = lead;
|
|
38
|
+
let started = false;
|
|
39
|
+
for (const w of words) {
|
|
40
|
+
const add = started ? ` ${w}` : w;
|
|
41
|
+
if (started && visible(cur + add) > cols) {
|
|
42
|
+
out.push(cur);
|
|
43
|
+
cur = indent + w;
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
cur += add;
|
|
47
|
+
started = true;
|
|
48
|
+
}
|
|
49
|
+
out.push(cur);
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
export const say = (s = '') => {
|
|
53
|
+
const cols = process.stderr.isTTY ? process.stderr.columns || 0 : 0;
|
|
54
|
+
const lines = cols >= 40 ? s.split('\n').flatMap((l) => wrapLine(l, cols - 1)) : [s];
|
|
55
|
+
process.stderr.write(lines.join('\n') + '\n');
|
|
56
|
+
};
|
|
57
|
+
export const print = (s = '') => {
|
|
58
|
+
const cols = process.stdout.isTTY ? process.stdout.columns || 0 : 0;
|
|
59
|
+
const lines = cols >= 40 ? s.split('\n').flatMap((l) => wrapLine(l, cols - 1)) : [s];
|
|
60
|
+
process.stdout.write(lines.join('\n') + '\n');
|
|
61
|
+
};
|
|
62
|
+
/** A spinner line redraws in place with \r, so it must never wrap: cut to the width. */
|
|
63
|
+
const fitLine = (s) => {
|
|
64
|
+
const cols = process.stderr.columns || 0;
|
|
65
|
+
return cols >= 20 && s.length > cols - 1 ? `${s.slice(0, cols - 2)}…` : s;
|
|
66
|
+
};
|
|
6
67
|
export const printJson = (data) => { process.stdout.write(JSON.stringify(data, null, 2) + '\n'); };
|
|
7
68
|
export const interactive = () => !!process.stdin.isTTY && !!process.stderr.isTTY;
|
|
8
69
|
export function table(rows, columns) {
|
|
@@ -19,18 +80,31 @@ export function printTable(rows, columns, opts = {}) {
|
|
|
19
80
|
for (const l of table(rows, columns))
|
|
20
81
|
print(`${opts.indent ?? ''}${l}`);
|
|
21
82
|
}
|
|
22
|
-
export const tick = '
|
|
23
|
-
export const cross = '
|
|
24
|
-
export const dot = '
|
|
83
|
+
export const tick = ` ${c.ok('✓')}`;
|
|
84
|
+
export const cross = ` ${c.bad('✗')}`;
|
|
85
|
+
export const dot = ` ${c.dim('·')}`;
|
|
86
|
+
export const warn = ` ${c.warn('⚠')}`;
|
|
25
87
|
export function banner(opts = {}) {
|
|
26
88
|
say();
|
|
27
|
-
say('
|
|
28
|
-
say(
|
|
89
|
+
say(` ${c.step('Sekura')} ${c.dim('AI red team for your code')}`);
|
|
90
|
+
say();
|
|
91
|
+
say(' Sets up Sekura in your coding tools and gets your first scan ready.');
|
|
29
92
|
say(opts.login === false
|
|
30
|
-
? ' Each tool asks you to sign in
|
|
31
|
-
: '
|
|
93
|
+
? ' Each tool asks you to sign in the first time it uses Sekura.'
|
|
94
|
+
: ' You sign in once here; your tools use the same sign-in.');
|
|
95
|
+
say(` ${c.dim('Nothing is scanned or charged until you agree.')}`);
|
|
96
|
+
}
|
|
97
|
+
let stepNo = 0;
|
|
98
|
+
/** A numbered step heading, coloured and underlined, as each stage starts. */
|
|
99
|
+
export function step(title) {
|
|
100
|
+
stepNo++;
|
|
101
|
+
const head = `${stepNo}. ${title}`;
|
|
32
102
|
say();
|
|
103
|
+
say(` ${c.step(head)}`);
|
|
104
|
+
say(` ${c.rule('-'.repeat(head.length))}`);
|
|
33
105
|
}
|
|
106
|
+
/** Tests run several installs in one process. */
|
|
107
|
+
export const resetSteps = () => { stepNo = 0; };
|
|
34
108
|
/** How often a wait asks, and for how long. Tests make both short. */
|
|
35
109
|
export const WAIT = { intervalMs: 2500, timeoutMs: 300_000 };
|
|
36
110
|
const FRAMES = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏';
|
|
@@ -40,7 +114,7 @@ export function spinner(message) {
|
|
|
40
114
|
return () => { };
|
|
41
115
|
}
|
|
42
116
|
let f = 0;
|
|
43
|
-
const draw = () => { process.stderr.write(`\r ${FRAMES[f++ % FRAMES.length]} ${message}`); };
|
|
117
|
+
const draw = () => { process.stderr.write(`\r${fitLine(` ${FRAMES[f++ % FRAMES.length]} ${message}`)}`); };
|
|
44
118
|
draw();
|
|
45
119
|
const timer = setInterval(draw, 120);
|
|
46
120
|
let stopped = false;
|
|
@@ -74,7 +148,7 @@ export async function waitFor(message, check, opts = {}) {
|
|
|
74
148
|
process.stdin.resume();
|
|
75
149
|
}
|
|
76
150
|
let f = 0;
|
|
77
|
-
const draw = () => { process.stderr.write(`\r ${FRAMES[f++ % FRAMES.length]} ${message}`); };
|
|
151
|
+
const draw = () => { process.stderr.write(`\r${fitLine(` ${FRAMES[f++ % FRAMES.length]} ${message}`)}`); };
|
|
78
152
|
const spin = tty ? setInterval(draw, 120) : null;
|
|
79
153
|
if (tty)
|
|
80
154
|
draw();
|
|
@@ -117,10 +191,19 @@ export async function waitFor(message, check, opts = {}) {
|
|
|
117
191
|
* A question that fits is asked as it is; a longer one is printed above,
|
|
118
192
|
* wrapped by us, and the prompt itself is the short form.
|
|
119
193
|
*/
|
|
194
|
+
// ── questions ───────────────────────────────────────────────────────────────
|
|
195
|
+
// Every question sits at the same two-space indent as the lines around it
|
|
196
|
+
// (29 November 2026: "clean and well polished"); the library put its "?" and
|
|
197
|
+
// "✔" at column 0. select and checkbox are re-exported with that theme, so a
|
|
198
|
+
// file asks through ui.js and never imports the library's own.
|
|
199
|
+
import { checkbox as inqCheckbox, select as inqSelect } from '@inquirer/prompts';
|
|
200
|
+
const PROMPT_THEME = { prefix: { idle: ` ${c.accent('?')}`, done: ` ${c.ok('✓')}` } };
|
|
201
|
+
export const select = (config) => inqSelect({ ...config, theme: { ...PROMPT_THEME, ...(config.theme ?? {}) } });
|
|
202
|
+
export const checkbox = (config) => inqCheckbox({ ...config, theme: { ...PROMPT_THEME, ...(config.theme ?? {}) } });
|
|
120
203
|
/** "(y/n)" in lower case, both letters (Sudhir, 29 November 2026: "keep both
|
|
121
204
|
* small case"). The library writes the default in capitals, "(Y/n)"; Enter
|
|
122
205
|
* still takes the default. Dim, as the library draws it. */
|
|
123
|
-
const YES_NO = { style: { defaultAnswer: (text) => `\x1b[2m(${text.toLowerCase()})\x1b[22m` } };
|
|
206
|
+
const YES_NO = { ...PROMPT_THEME, style: { defaultAnswer: (text) => `\x1b[2m(${text.toLowerCase()})\x1b[22m` } };
|
|
124
207
|
export async function ask(message, opts) {
|
|
125
208
|
const { confirm } = await import('@inquirer/prompts');
|
|
126
209
|
const cols = Math.max(40, process.stderr.columns || process.stdout.columns || 80);
|
package/dist/verify.js
CHANGED
|
@@ -14,7 +14,7 @@ async function verifyWithKey(endpoint, key, signal) {
|
|
|
14
14
|
redirect: 'manual',
|
|
15
15
|
});
|
|
16
16
|
if (r.status === 200)
|
|
17
|
-
return { ok: true, detail:
|
|
17
|
+
return { ok: true, detail: `Connected to ${new URL(endpoint).host}` };
|
|
18
18
|
if (r.status === 401)
|
|
19
19
|
return { ok: false, detail: `${endpoint} answers, but no longer takes your saved key: run npx sekura@latest login` };
|
|
20
20
|
if (r.status === 403)
|
package/package.json
CHANGED
package/skills/sekura/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sekura
|
|
3
3
|
description: Use when the user wants a GitHub repository scanned for vulnerabilities, wants to read scan findings or a report, or wants to put a repository on a monthly plan. Covers the sekura MCP tools and the rule that every scan and plan is quoted first and started only after the user agrees.
|
|
4
|
-
argument-hint: "[help | repos | scan <owner/repo> | scans | scan-status <scan> | findings <scan> | report <scan> | cancel <scan|owner/repo> | monthly <owner/repo> | schedule <owner/repo> | plans | billing]"
|
|
4
|
+
argument-hint: "[help | repos | scan <owner/repo> | scans | scan-status <scan> | findings <scan> | report <scan> | cancel <scan|owner/repo> | monthly <owner/repo> | change <owner/repo> | schedule <owner/repo> | plans | billing]"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Sekura
|
|
@@ -45,6 +45,12 @@ the first word:
|
|
|
45
45
|
a day.
|
|
46
46
|
- On demand: `onDemand` true, keeping the plan's own `kind`, with `minute` and
|
|
47
47
|
`tz`. Nothing runs until the user asks; `quoteRunNow` then `runNow` starts each scan.
|
|
48
|
+
- `change <owner/repo>`: move the repository to the other monthly plan, up to More
|
|
49
|
+
frequently (`tier` `pro`) or down to Weekly (`tier` `always`). Ask which plan if it
|
|
50
|
+
is not clear, and ask the schedule on the new plan (the two plans run on different
|
|
51
|
+
schedules), then `quotePlanChange` and the two-step rule (`changePlan`). Say the
|
|
52
|
+
money as the quote does: an upgrade charges the difference for the rest of the
|
|
53
|
+
month now; a downgrade charges nothing until the renewal.
|
|
48
54
|
- `schedule <owner/repo>`: `quoteSchedule` for that repository with the schedule
|
|
49
55
|
the user gives (ask for one if they gave none), then the two-step rule.
|
|
50
56
|
- `plans`: `getPlans`. `billing`: `getBilling`.
|
|
@@ -65,6 +71,7 @@ Sekura: AI red team scans for your GitHub repositories
|
|
|
65
71
|
/sekura cancel <scan> what cancelling a scan means; cancels only after you agree
|
|
66
72
|
/sekura cancel <owner/repo> the same for a repository's monthly plan
|
|
67
73
|
/sekura monthly <owner/repo> quote a monthly plan: Weekly or More frequently
|
|
74
|
+
/sekura change <owner/repo> move a monthly plan up or down (Weekly, More frequently)
|
|
68
75
|
/sekura schedule <owner/repo> change when a monthly plan runs
|
|
69
76
|
/sekura plans repositories on a monthly plan
|
|
70
77
|
/sekura billing what is being billed
|
|
@@ -99,6 +106,7 @@ Quote, then confirm. The quote changes nothing and charges nothing:
|
|
|
99
106
|
- `quoteScan` → `startScan`: a one-time scan of one repository.
|
|
100
107
|
- `quoteAlways` → `startAlways`: a monthly plan (Weekly or More frequently) for one repository.
|
|
101
108
|
- `quoteSchedule` → `updateSchedule`: change when a repository on a monthly plan is scanned. It charges nothing.
|
|
109
|
+
- `quotePlanChange` → `changePlan`: move a repository between Weekly and More frequently. Moving up charges the difference for the rest of the month now; moving down charges nothing until the renewal.
|
|
102
110
|
- `quoteRunNow` → `runNow`: run a monthly plan's next scan now: brought forward on a schedule, started on demand. It is one of the plan's own runs, so there is no charge. Over the plan's limit it is refused with the first day a scan may start; tell the user that day.
|
|
103
111
|
|
|
104
112
|
Preview, then act. The preview cancels nothing:
|