@securityreviewai/securityreview-kit 0.1.23 → 0.1.24
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/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -29,6 +29,14 @@ export function run() {
|
|
|
29
29
|
.option('--skip-ide-cli-install', 'Do not install Cursor / Claude Code / Codex CLIs when those targets are selected')
|
|
30
30
|
.option('--profile-repo', 'After init, run the guardrails profiler agent (non-interactive; needs cursor, claude, or codex target)')
|
|
31
31
|
.option('--no-profile-repo', 'Skip the optional profiler agent step after init')
|
|
32
|
+
.option(
|
|
33
|
+
'--profiler-no-trust',
|
|
34
|
+
'When profiling with Cursor, do not pass --trust (use if you need interactive workspace trust or login in the terminal)',
|
|
35
|
+
)
|
|
36
|
+
.option(
|
|
37
|
+
'--profiler-cursor-login',
|
|
38
|
+
'Before Cursor profiling, run cursor-agent login in this terminal (then profiling runs in the same init)',
|
|
39
|
+
)
|
|
32
40
|
.action(async (options) => {
|
|
33
41
|
try {
|
|
34
42
|
if (options.switchProject) {
|
package/src/commands/init.js
CHANGED
|
@@ -4,7 +4,11 @@ import { TARGETS, TARGET_NAMES } from '../utils/constants.js';
|
|
|
4
4
|
import { detectTargets } from '../utils/detect.js';
|
|
5
5
|
import { ensureIdeClisForTargets } from '../utils/ide-cli-install.js';
|
|
6
6
|
import { writeGuardrailsProfilerBundle } from '../utils/guardrails-profiler-bundle.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
pickProfilerAgentTarget,
|
|
9
|
+
runCursorAgentLogin,
|
|
10
|
+
runProfilerAgent,
|
|
11
|
+
} from '../utils/profiler-agent.js';
|
|
8
12
|
import { fetchVibeReviewProjectNames, getStoredCredentials, normalizeApiUrl } from '../utils/srai.js';
|
|
9
13
|
|
|
10
14
|
// Dynamic imports for generators (avoids loading all at startup)
|
|
@@ -397,8 +401,53 @@ export async function initCommand(options) {
|
|
|
397
401
|
} else {
|
|
398
402
|
console.log('');
|
|
399
403
|
console.log(chalk.bold.white(` Starting profiler via ${TARGETS[agentTarget].name} CLI…`));
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
if (agentTarget === 'cursor') {
|
|
405
|
+
console.log(
|
|
406
|
+
chalk.dim(
|
|
407
|
+
' Cursor: headless profiling uses `--trust` and `--approve-mcps` on this folder (you confirmed above).',
|
|
408
|
+
),
|
|
409
|
+
);
|
|
410
|
+
if (options.profilerNoTrust) {
|
|
411
|
+
console.log(
|
|
412
|
+
chalk.dim(
|
|
413
|
+
' You passed `--profiler-no-trust`: complete any login or workspace-trust prompts in this terminal.',
|
|
414
|
+
),
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
let runLogin = Boolean(options.profilerCursorLogin);
|
|
419
|
+
if (!runLogin && interactive) {
|
|
420
|
+
runLogin = await confirm({
|
|
421
|
+
message:
|
|
422
|
+
'Run Cursor Agent login in this terminal now? (Same init — profiling runs next. Choose No if already signed in.)',
|
|
423
|
+
default: true,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (runLogin) {
|
|
427
|
+
console.log('');
|
|
428
|
+
console.log(chalk.bold.white(' Cursor Agent login'));
|
|
429
|
+
console.log(chalk.dim(' Complete the browser or code prompt, then return here.\n'));
|
|
430
|
+
const loginResult = runCursorAgentLogin(cwd);
|
|
431
|
+
if (loginResult.ok) {
|
|
432
|
+
console.log(chalk.green(' \u2713 Cursor Agent login step finished.'));
|
|
433
|
+
} else {
|
|
434
|
+
console.log(
|
|
435
|
+
chalk.yellow(
|
|
436
|
+
` \u26a0 Login exited with status ${loginResult.status ?? 'unknown'}. Profiling will still be attempted; sign in and re-run init if it fails.`,
|
|
437
|
+
),
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
console.log('');
|
|
441
|
+
}
|
|
442
|
+
} else {
|
|
443
|
+
console.log(chalk.dim(' (Sign-in or approvals may be required in your terminal.)'));
|
|
444
|
+
}
|
|
445
|
+
console.log('');
|
|
446
|
+
const pr = runProfilerAgent(cwd, {
|
|
447
|
+
target: agentTarget,
|
|
448
|
+
projectName: projectNameForSkill,
|
|
449
|
+
cursorTrust: !options.profilerNoTrust,
|
|
450
|
+
});
|
|
402
451
|
if (pr.ok) {
|
|
403
452
|
console.log(chalk.green(' \u2713 Profiler agent finished.'));
|
|
404
453
|
} else {
|
|
@@ -410,6 +459,20 @@ export async function initCommand(options) {
|
|
|
410
459
|
` \u26a0 Profiler agent exited with an error: ${detail}. You can run the guardrails-init-profile workflow manually.`,
|
|
411
460
|
),
|
|
412
461
|
);
|
|
462
|
+
if (agentTarget === 'cursor') {
|
|
463
|
+
console.log('');
|
|
464
|
+
console.log(chalk.dim(' Typical fixes:'));
|
|
465
|
+
console.log(
|
|
466
|
+
chalk.dim(
|
|
467
|
+
' • Not signed in: re-run `securityreview-kit init` and choose Yes for “Run Cursor Agent login”, or pass `--profiler-cursor-login` with `--profile-repo`.',
|
|
468
|
+
),
|
|
469
|
+
);
|
|
470
|
+
console.log(
|
|
471
|
+
chalk.dim(
|
|
472
|
+
' • Want interactive trust instead of `--trust`: run `securityreview-kit init ... --profiler-no-trust` and answer the prompts, then profile again.',
|
|
473
|
+
),
|
|
474
|
+
);
|
|
475
|
+
}
|
|
413
476
|
}
|
|
414
477
|
}
|
|
415
478
|
}
|
|
@@ -16,3 +16,13 @@ Configured SRAI project name: `<SRAI_PROJECT_NAME>`
|
|
|
16
16
|
3. Call **`update_vibe_profile`** and **`write_default_pack`** on `security-review-mcp` after resolving `project_id` for `<SRAI_PROJECT_NAME>`.
|
|
17
17
|
|
|
18
18
|
Do not skip MCP upload when credentials and MCP are available.
|
|
19
|
+
|
|
20
|
+
## Cursor CLI (scripted)
|
|
21
|
+
|
|
22
|
+
From the repo root, non-interactive runs should include workspace trust and MCP approval (matches `securityreview-kit init`):
|
|
23
|
+
|
|
24
|
+
`cursor-agent -p "<your profiling instructions>" --trust --approve-mcps`
|
|
25
|
+
|
|
26
|
+
During `securityreview-kit init`, choose **Yes** when asked to run Cursor login in-terminal, or pass **`--profiler-cursor-login`** with **`--profile-repo`** so login and profiling stay in one run.
|
|
27
|
+
|
|
28
|
+
You can still sign in manually with `cursor-agent login`. To handle trust/login interactively in the terminal, omit `--trust` and `--approve-mcps`.
|
|
@@ -20,6 +20,18 @@ export function buildProfilerAgentPrompt(projectName) {
|
|
|
20
20
|
].join('\n');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Run Cursor Agent OAuth/login in the current terminal (stdio inherited).
|
|
25
|
+
* Call this from init before profiling so the user does not leave the kit flow.
|
|
26
|
+
*/
|
|
27
|
+
export function runCursorAgentLogin(cwd) {
|
|
28
|
+
if (!commandOk('cursor-agent', ['--version'])) {
|
|
29
|
+
return { ok: false, status: null, message: 'cursor-agent not on PATH' };
|
|
30
|
+
}
|
|
31
|
+
const r = spawnSync('cursor-agent', ['login'], { cwd, stdio: 'inherit', env: { ...process.env } });
|
|
32
|
+
return { ok: r.status === 0, status: r.status };
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
export function pickProfilerAgentTarget(targets) {
|
|
24
36
|
for (const t of PREFERRED_ORDER) {
|
|
25
37
|
if (targets.includes(t)) {
|
|
@@ -31,8 +43,13 @@ export function pickProfilerAgentTarget(targets) {
|
|
|
31
43
|
|
|
32
44
|
/**
|
|
33
45
|
* Spawn the IDE agent CLI to execute the profiler skill (user must be logged in where required).
|
|
46
|
+
*
|
|
47
|
+
* @param {object} opts
|
|
48
|
+
* @param {boolean} [opts.cursorTrust=true] When true, passes `--trust` and `--approve-mcps` so headless init is not blocked by
|
|
49
|
+
* workspace trust or MCP approval (user confirmed profiling in the kit). Set false with `--profiler-no-trust`
|
|
50
|
+
* if you need an interactive trust/login/MCP flow in the same terminal.
|
|
34
51
|
*/
|
|
35
|
-
export function runProfilerAgent(cwd, { target, projectName }) {
|
|
52
|
+
export function runProfilerAgent(cwd, { target, projectName, cursorTrust = true }) {
|
|
36
53
|
const prompt = buildProfilerAgentPrompt(projectName);
|
|
37
54
|
const opts = { cwd, stdio: 'inherit', env: { ...process.env } };
|
|
38
55
|
|
|
@@ -40,7 +57,11 @@ export function runProfilerAgent(cwd, { target, projectName }) {
|
|
|
40
57
|
if (!commandOk('cursor-agent', ['--version'])) {
|
|
41
58
|
return { ok: false, message: 'cursor-agent not on PATH' };
|
|
42
59
|
}
|
|
43
|
-
const
|
|
60
|
+
const args = ['-p', prompt];
|
|
61
|
+
if (cursorTrust) {
|
|
62
|
+
args.push('--trust', '--approve-mcps');
|
|
63
|
+
}
|
|
64
|
+
const r = spawnSync('cursor-agent', args, opts);
|
|
44
65
|
return { ok: r.status === 0, status: r.status };
|
|
45
66
|
}
|
|
46
67
|
|