@viberaven/mcp 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,13 +41,14 @@ Reconnect, confirm tools appear, then pass the app root:
41
41
  }
42
42
  ```
43
43
 
44
- Use `C:/projects/your-app` on Windows. Omitted `cwd` means the server startup directory; npm validation accepts no `cwd`. This server invokes matching `@viberaven/cli@1.6.12` through npx. Scans need no VibeRaven login/API key; downloads and npm validation need network.
44
+ Use `C:/projects/your-app` on Windows. Omitted `cwd` means the server startup directory; npm validation accepts no `cwd`. This server prefers a matching CLI installed alongside the MCP and otherwise invokes the exact matching version through npx. Scans need no VibeRaven login/API key; downloads and npm validation need network.
45
45
 
46
- ## The 14 Tools
46
+ ## Repository tools
47
47
 
48
48
  | Tool | CLI operation |
49
49
  | --- | --- |
50
50
  | `viberaven_check_readiness` | `check --json`: fresh check, summary and artifact paths |
51
+ | `viberaven_rls_test` | Experimental `rls-test --json --matrix <path>`; optional `migrations` directory |
51
52
  | `viberaven_verify` | `check --json`: recheck after a batch of fixes |
52
53
  | `viberaven_audit` | `audit --vercel-supabase`; optional `json: true` |
53
54
  | `viberaven_init_rules` | `init`: native instructions; preview with `dryRun: true` |
@@ -64,6 +65,22 @@ Use `C:/projects/your-app` on Windows. Omitted `cwd` means the server startup di
64
65
 
65
66
  Responses contain `exit N`, CLI output and parseable JSON objects as structured content. Blocker exit 1 can be normal tool content.
66
67
 
68
+ ### Optional local behavioral RLS test (local candidate)
69
+
70
+ After reviewing the intended access in a permissions matrix, a local candidate host that lists `viberaven_rls_test` can run:
71
+
72
+ ```json
73
+ {"name":"viberaven_rls_test","arguments":{"cwd":"/absolute/path/to/app","matrix":"reviewed.permissions.json"}}
74
+ ```
75
+
76
+ This reuses the CLI's experimental PGlite imitation for owner, other_user and anon. Prefer `defaultGrants: none` with actual GRANT SQL for new schemas; disclose legacy defaults otherwise. Review expected access before running, and keep it unchanged while fixing a failure. Read Pass/Fail/Unknown and coverage: valid findings (exit 1) and inconclusive results (exit 2) retain their structured evidence. Unknown is inconclusive. Invalid/missing matrices, missing engine, failed migrations/role checks and malformed or inconsistent receipts are tool errors. Local observations do not prove live Supabase behavior or security.
77
+
78
+ Completed RLS results keep the complete receipt in both compact JSON text and `structuredContent`; only JSON formatting whitespace is removed. All evidence fields and stderr diagnostics remain available. Error diagnostics keep their original text.
79
+
80
+ RLS calls stop after 300 seconds or 8 MiB of combined child output. A stopped run terminates the CLI and returns a tool error without a partial passing receipt.
81
+
82
+ Use an already installed matching candidate CLI with optional `@electric-sql/pglite@0.5.8` next to it, configured for this local MCP host as described below. Installing PGlite only in the target project may not make it visible to the host CLI. The RLS route requires this installed CLI and never falls back to npx. Missing host setup returns setup guidance without spawning; missing PGlite returns the existing CLI guidance. The tool does not install dependencies, accept SQL/credentials or access a provider. Obtain normal user authorization before installing dependencies. The installed CLI fallback is `viberaven rls-test --matrix PATH --json`; this candidate tool is not assumed to exist in the published MCP version shown above.
83
+
67
84
  ## Work The Result
68
85
 
69
86
  Readiness refreshes `.viberaven/agent-tasklist.md`, `gate-result.json` and `context-map.json` without patching source. Read tasks/source, review `viberaven_heal_plan` before apply, and recheck each batch with `viberaven_verify`. Provider steps require provider evidence.
@@ -94,4 +111,4 @@ The [RLS comparison](https://ohad6k.github.io/VibeRaven/examples/proof/rls-compa
94
111
 
95
112
  For `viberaven_work_report`, standalone MCP resolves an already installed `@viberaven/cli/package.json` from the MCP installation, and requires its name and exact version to match the MCP candidate. Alternatively, set the host process environment `VIBERAVEN_CLI_PATH` to an absolute matching `dist/cli.js` path. This is an operator-controlled local-candidate setting, not a tool argument. Keep the CLI installation outside the task repository. A regular canonical CLI entry and adjacent manifest are validated before execution.
96
113
 
97
- Report runs Node directly with `shell: false`, strips Node/npm environment steering and never invokes npm, npx, package installation or registry fallback. Install/configure the matching candidate separately; reporting fails until it is available. Missing/mismatched installations, process failures, malformed results, output over the bounded transport budget and the 30-second read timeout return a generic error without raw child diagnostics or local paths. Other standalone MCP tools retain their existing pinned npx execution path. The source-level embedded MCP compatibility handler uses its own CLI entry with the same shared bounded report runner. It has parity/regression tests but is not exposed as a second installed CLI server entrypoint; the executable MCP route is `@viberaven/mcp`.
114
+ Report runs Node directly with `shell: false`, strips Node/npm environment steering and never invokes npm, npx, package installation or registry fallback. Install/configure the matching candidate separately; reporting fails until it is available. Missing/mismatched installations, process failures, malformed results, output over the bounded transport budget and the 30-second read timeout return a generic error without raw child diagnostics or local paths. Standalone MCP tools other than RLS tests and reports use the same installation validation and direct Node execution when a matching host CLI is available; otherwise they retain exact-version pinned npx fallback. An explicitly invalid `VIBERAVEN_CLI_PATH` fails without fallback. Task-local packages and symlinked entries are not trusted. Transport failures and missing/malformed JSON on JSON routes set MCP `isError`; completed checks with findings remain normal structured content. The source-level embedded MCP compatibility handler uses its own CLI entry with the same shared bounded report runner. It has parity/regression tests but is not exposed as a second installed CLI server entrypoint; the executable MCP route is `@viberaven/mcp`.
@@ -323,6 +323,30 @@ function buildWorkToolArgs(name, raw) {
323
323
  return [...out, "--json"];
324
324
  }
325
325
 
326
+ // ../../shared/rlsTool.ts
327
+ var RLS_TOOL_NAME = "viberaven_rls_test";
328
+ var RLS_RUN_TIMEOUT_MS = 3e5;
329
+ var RLS_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
330
+ var MAX_PATH_LENGTH = 4096;
331
+ function record(value) {
332
+ return value !== null && typeof value === "object" && !Array.isArray(value);
333
+ }
334
+ function nonempty(value) {
335
+ return typeof value === "string" && Boolean(value.trim());
336
+ }
337
+ function pathArg(value, name, commandLine = true) {
338
+ if (!nonempty(value) || value.length > MAX_PATH_LENGTH || /[\x00-\x1f\x7f]/.test(value)) throw Error(`Invalid RLS ${name}: expected a non-empty local path up to ${MAX_PATH_LENGTH} characters`);
339
+ if (commandLine && (value.trimStart().startsWith("-") || /[&|<>^%!"'`$();]/.test(value))) throw Error(`Unsafe RLS ${name} path`);
340
+ return value;
341
+ }
342
+ function buildRlsToolArgs(input) {
343
+ if (!record(input) || Object.keys(input).some((key) => !["matrix", "migrations", "cwd"].includes(key))) throw Error("Invalid RLS tool arguments: only matrix, migrations and cwd are accepted");
344
+ const args = ["rls-test", "--json", "--matrix", pathArg(input.matrix, "matrix")];
345
+ if ("migrations" in input) args.push("--migrations", pathArg(input.migrations, "migrations"));
346
+ if ("cwd" in input) pathArg(input.cwd, "cwd", false);
347
+ return args;
348
+ }
349
+
326
350
  // src/lib/cli-runner.ts
327
351
  var import_node_child_process = require("node:child_process");
328
352
  var import_node_fs3 = require("node:fs");
@@ -424,7 +448,7 @@ function runWorkReportProcess(entry, args, cwd3, spawnFn2) {
424
448
  } catch {
425
449
  return Promise.resolve(workReportFailure());
426
450
  }
427
- return new Promise((resolve) => {
451
+ return new Promise((resolve2) => {
428
452
  let settled = false, stdoutBytes = 0, stderrBytes = 0;
429
453
  const chunks = [];
430
454
  let child;
@@ -432,7 +456,7 @@ function runWorkReportProcess(entry, args, cwd3, spawnFn2) {
432
456
  if (!settled) {
433
457
  settled = true;
434
458
  clearTimeout(timer);
435
- resolve(result);
459
+ resolve2(result);
436
460
  }
437
461
  };
438
462
  const fail = () => {
@@ -481,27 +505,34 @@ var within = (root, target) => {
481
505
  const rel = (0, import_node_path.relative)(root, target);
482
506
  return !rel || !(0, import_node_path.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(`..${import_node_path.sep}`);
483
507
  };
484
- function installedReportCli(version, cwd3) {
508
+ function resolveInstalledCli(version, cwd3) {
485
509
  const override = process.env.VIBERAVEN_CLI_PATH;
486
- if (override !== void 0 && !(0, import_node_path.isAbsolute)(override)) throw new Error("Unavailable installed CLI");
487
- const selected = override ?? (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_module.createRequire)(__filename).resolve("@viberaven/cli/package.json")), "dist", "cli.js");
488
- const info = (0, import_node_fs2.lstatSync)(selected);
489
- if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unavailable installed CLI");
490
- const entry = (0, import_node_fs2.realpathSync)(selected);
491
- const root = (0, import_node_fs2.realpathSync)((0, import_node_path.join)((0, import_node_path.dirname)(entry), ".."));
492
- if (entry !== (0, import_node_path.join)(root, "dist", "cli.js") || within(cwd3, entry)) throw new Error("Unavailable installed CLI");
493
- const manifestPath = (0, import_node_path.join)(root, "package.json"), manifestInfo = (0, import_node_fs2.lstatSync)(manifestPath);
494
- if (!manifestInfo.isFile() || manifestInfo.isSymbolicLink() || manifestInfo.size > 65536 || (0, import_node_fs2.realpathSync)(manifestPath) !== manifestPath) throw new Error("Unavailable installed CLI");
495
- const manifest = JSON.parse((0, import_node_fs2.readFileSync)(manifestPath, "utf8"));
496
- if (manifest.name !== "@viberaven/cli" || manifest.version !== version) throw new Error("Unavailable installed CLI");
497
- return entry;
510
+ try {
511
+ if (override !== void 0 && !(0, import_node_path.isAbsolute)(override)) throw new Error("Unavailable installed CLI");
512
+ const selected = override ?? (0, import_node_path.join)((0, import_node_path.dirname)((0, import_node_module.createRequire)(__filename).resolve("@viberaven/cli/package.json")), "dist", "cli.js");
513
+ const info = (0, import_node_fs2.lstatSync)(selected);
514
+ if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unavailable installed CLI");
515
+ const entry = (0, import_node_fs2.realpathSync)(selected);
516
+ const root = (0, import_node_fs2.realpathSync)((0, import_node_path.join)((0, import_node_path.dirname)(entry), ".."));
517
+ if (entry !== (0, import_node_path.resolve)(selected) || entry !== (0, import_node_path.join)(root, "dist", "cli.js") || within((0, import_node_fs2.realpathSync)(cwd3), entry)) throw new Error("Unavailable installed CLI");
518
+ const manifestPath = (0, import_node_path.join)(root, "package.json"), manifestInfo = (0, import_node_fs2.lstatSync)(manifestPath);
519
+ if (!manifestInfo.isFile() || manifestInfo.isSymbolicLink() || manifestInfo.size > 65536 || (0, import_node_fs2.realpathSync)(manifestPath) !== manifestPath) throw new Error("Unavailable installed CLI");
520
+ const manifest = JSON.parse((0, import_node_fs2.readFileSync)(manifestPath, "utf8"));
521
+ if (manifest.name !== "@viberaven/cli" || manifest.version !== version) throw new Error("Unavailable installed CLI");
522
+ return entry;
523
+ } catch {
524
+ if (override !== void 0) throw new Error("Matching installed CLI unavailable. Check VIBERAVEN_CLI_PATH, its exact version and installation outside the task repository.");
525
+ return void 0;
526
+ }
498
527
  }
499
528
  function runInstalledWorkReport(args, cwd3, version, spawnFn2) {
500
529
  let entry, canonicalCwd;
501
530
  try {
502
531
  if (cwd3 !== void 0 && (typeof cwd3 !== "string" || !cwd3.trim())) return Promise.resolve(workReportFailure());
503
532
  canonicalCwd = (0, import_node_fs2.realpathSync)(cwd3 === void 0 ? process.cwd() : cwd3);
504
- entry = installedReportCli(version, canonicalCwd);
533
+ const installed = resolveInstalledCli(version, canonicalCwd);
534
+ if (!installed) return Promise.resolve(workReportFailure());
535
+ entry = installed;
505
536
  } catch {
506
537
  return Promise.resolve(workReportFailure());
507
538
  }
@@ -523,7 +554,7 @@ function mcpVersion() {
523
554
  } catch {
524
555
  }
525
556
  }
526
- found ??= true ? "1.7.0" : void 0;
557
+ found ??= true ? "1.7.2" : void 0;
527
558
  if (!found || !PLAIN_VERSION.test(found)) {
528
559
  throw new Error(`Could not read a valid ${MCP_PACKAGE} version (got ${JSON.stringify(found)}), so the matching ${CLI_PACKAGE} cannot be pinned.`);
529
560
  }
@@ -580,6 +611,7 @@ function buildHealArgs(prefix, args) {
580
611
  return cliArgs;
581
612
  }
582
613
  function buildToolArgs(name, args) {
614
+ if (name === RLS_TOOL_NAME) return buildRlsToolArgs(args);
583
615
  if (isLiveTool(name)) return buildLiveToolArgs(name, args);
584
616
  if (isWorkTool(name)) return buildWorkToolArgs(name, args);
585
617
  switch (name) {
@@ -629,6 +661,9 @@ function buildToolArgs(name, args) {
629
661
  throw new Error(`Unknown VibeRaven tool: ${name}`);
630
662
  }
631
663
  }
664
+ function transportFailure(error, stderr = "") {
665
+ return { stdout: "", stderr, exitCode: 1, transportError: true, text: `ERROR: ${error instanceof Error ? error.message : String(error)}` };
666
+ }
632
667
  async function runVibeRaven(args, cwd3) {
633
668
  return (await runVibeRavenDetailed(args, cwd3)).text;
634
669
  }
@@ -640,32 +675,87 @@ function runVibeRavenDetailed(args, cwd3) {
640
675
  return Promise.resolve(workReportFailure());
641
676
  }
642
677
  }
643
- let npxArgs;
678
+ let built;
679
+ let childCwd, env;
644
680
  try {
645
- npxArgs = cliNpxArgs(args);
681
+ childCwd = resolveCwd(cwd3);
682
+ const installed = resolveInstalledCli(mcpVersion(), childCwd);
683
+ if (args[0] === "rls-test" && !installed) return Promise.resolve(transportFailure(new Error("RLS testing requires a matching installed CLI outside the task repository, with optional PGlite installed next to it. Configure the local MCP host installation or VIBERAVEN_CLI_PATH; this tool does not download or install dependencies.")));
684
+ built = installed ? { command: process.execPath, args: [installed, ...args], shell: false } : buildNpxCommand(cliNpxArgs(args));
685
+ env = installed ? Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^(?:node_|npm_)/i.test(key) && key.toLowerCase() !== "viberaven_cli_path")) : cliChildEnv();
646
686
  } catch (error) {
647
- return Promise.resolve({ stdout: "", stderr: "", exitCode: 1, text: `ERROR: ${error instanceof Error ? error.message : String(error)}` });
687
+ return Promise.resolve(transportFailure(error));
648
688
  }
649
- return new Promise((resolve) => {
650
- const built = buildNpxCommand(npxArgs);
651
- const child = spawnFn(built.command, built.args, {
652
- cwd: resolveCwd(cwd3),
653
- env: cliChildEnv(),
654
- shell: built.shell,
655
- stdio: ["ignore", "pipe", "pipe"]
656
- });
689
+ return new Promise((resolve2) => {
690
+ let child;
691
+ try {
692
+ child = spawnFn(built.command, built.args, {
693
+ cwd: childCwd,
694
+ env,
695
+ shell: built.shell,
696
+ windowsHide: true,
697
+ stdio: ["ignore", "pipe", "pipe"]
698
+ });
699
+ } catch (error) {
700
+ resolve2(transportFailure(error));
701
+ return;
702
+ }
657
703
  let stdout = "";
658
704
  let stderr = "";
659
- child.stdout?.on("data", (chunk) => {
660
- stdout += chunk.toString();
661
- });
662
- child.stderr?.on("data", (chunk) => {
663
- stderr += chunk.toString();
664
- });
665
- child.on("error", (error) => resolve({ stdout: "", stderr, exitCode: 1, text: `ERROR: ${error.message}` }));
705
+ const boundedRls = args[0] === "rls-test";
706
+ const rlsChunks = { stdout: [], stderr: [] };
707
+ let outputBytes = 0;
708
+ let settled = false;
709
+ let timer;
710
+ const finish = (result) => {
711
+ if (settled) return;
712
+ settled = true;
713
+ if (timer) clearTimeout(timer);
714
+ resolve2(result);
715
+ };
716
+ const stopRls = (reason) => {
717
+ finish(transportFailure(new Error(reason)));
718
+ try {
719
+ child.kill("SIGKILL");
720
+ } catch {
721
+ }
722
+ };
723
+ if (boundedRls) timer = setTimeout(() => stopRls("RLS test exceeded its 300-second aggregate time limit and was stopped; no partial result is reported as passed."), RLS_RUN_TIMEOUT_MS);
724
+ const collect = (chunk, stream) => {
725
+ if (settled) return;
726
+ outputBytes += Buffer.byteLength(chunk);
727
+ if (boundedRls && outputBytes > RLS_MAX_OUTPUT_BYTES) {
728
+ stopRls("RLS test exceeded its combined output limit and was stopped; no partial result is reported as passed.");
729
+ return;
730
+ }
731
+ if (boundedRls) {
732
+ rlsChunks[stream].push(Buffer.from(chunk));
733
+ return;
734
+ }
735
+ if (stream === "stdout") stdout += chunk.toString();
736
+ else stderr += chunk.toString();
737
+ };
738
+ child.stdout?.on("data", (chunk) => collect(chunk, "stdout"));
739
+ child.stderr?.on("data", (chunk) => collect(chunk, "stderr"));
740
+ child.on("error", (error) => finish(transportFailure(error, boundedRls ? "" : stderr)));
666
741
  child.on("close", (code) => {
742
+ if (settled) return;
743
+ if (code === null) {
744
+ finish(transportFailure(new Error("CLI process ended without an exit code"), boundedRls ? "" : stderr));
745
+ return;
746
+ }
747
+ if (boundedRls) {
748
+ try {
749
+ const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
750
+ stdout = decoder.decode(Buffer.concat(rlsChunks.stdout));
751
+ stderr = decoder.decode(Buffer.concat(rlsChunks.stderr));
752
+ } catch {
753
+ finish(transportFailure(new Error("RLS test returned invalid UTF-8; no partial result is reported as passed.")));
754
+ return;
755
+ }
756
+ }
667
757
  const combined = `${stdout}${stderr}`.trim();
668
- resolve({ stdout, stderr, exitCode: code ?? 1, text: `exit ${code ?? 1}${combined ? `
758
+ finish({ stdout, stderr, exitCode: code ?? 1, text: `exit ${code ?? 1}${combined ? `
669
759
  ${combined}` : ""}` });
670
760
  });
671
761
  });