@mandujs/mcp 0.29.0 → 0.31.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.
@@ -57,7 +57,10 @@ export const ateRunToolDefinitions: Tool[] = [
57
57
  "`graphVersion` (agent cache invalidation key), and trace/screenshot/dom artifacts " +
58
58
  "staged under .mandu/ate-artifacts/<runId>/. Use `shard: { current, total }` to " +
59
59
  "distribute across CI workers. Emits notifications/progress per spec_done event. " +
60
- "On timeout / cancel, writes .mandu/reports/run-<runId>/results.json with partial state.",
60
+ "On timeout / cancel, writes .mandu/reports/run-<runId>/results.json with partial state. " +
61
+ "Issue #237 — `grep` narrows execution to specific `test(...)` titles inside the " +
62
+ "selected spec (forwarded to Playwright --grep / bun:test --test-name-pattern). " +
63
+ "For batch / multi-spec runs use mandu.ate.run (which also accepts onlyFiles + onlyRoutes).",
61
64
  inputSchema: {
62
65
  type: "object",
63
66
  properties: {
@@ -88,6 +91,12 @@ export const ateRunToolDefinitions: Tool[] = [
88
91
  type: "boolean",
89
92
  description: "Playwright only — capture trace. Default: true.",
90
93
  },
94
+ grep: {
95
+ type: "string",
96
+ description:
97
+ "Issue #237 — pass-through to Playwright --grep / bun:test --test-name-pattern. " +
98
+ "Filters by test-block title within the selected spec.",
99
+ },
91
100
  shard: {
92
101
  type: "object",
93
102
  properties: {
@@ -264,12 +273,13 @@ export function createAteProgressTracker(options: {
264
273
  export function ateRunTools(_projectRoot: string, server?: Server) {
265
274
  return {
266
275
  mandu_ate_run: async (args: Record<string, unknown>) => {
267
- const { repoRoot, spec, headed, trace, shard, progressToken } = args as {
276
+ const { repoRoot, spec, headed, trace, shard, grep, progressToken } = args as {
268
277
  repoRoot: string;
269
278
  spec: string | { path: string };
270
279
  headed?: boolean;
271
280
  trace?: boolean;
272
281
  shard?: { current: number; total: number };
282
+ grep?: string;
273
283
  progressToken?: string | number;
274
284
  };
275
285
  if (!repoRoot || typeof repoRoot !== "string") {
@@ -336,6 +346,7 @@ export function ateRunTools(_projectRoot: string, server?: Server) {
336
346
  headed,
337
347
  trace,
338
348
  shard,
349
+ grep,
339
350
  });
340
351
  } catch (err) {
341
352
  // Runner timeout / exec error — persist partial state so heal
package/src/tools/ate.ts CHANGED
@@ -93,7 +93,10 @@ export const ateToolDefinitions: Tool[] = [
93
93
  "Returns a runId for use with mandu.ate.report and mandu.ate.heal. " +
94
94
  "Streams notifications/progress per spec_done event (issue #238). " +
95
95
  "On timeout / kill, persists partial state under .mandu/reports/run-<runId>/results.json " +
96
- "so mandu.ate.heal remains reachable after the 10-min watchdog.",
96
+ "so mandu.ate.heal remains reachable after the 10-min watchdog. " +
97
+ "Issue #237 — scope filters (onlyFiles / onlyRoutes / grep) let callers " +
98
+ "run a single spec or route and stay under the 10-min MCP watchdog; omit " +
99
+ "them for the full suite.",
97
100
  inputSchema: {
98
101
  type: "object",
99
102
  properties: {
@@ -109,6 +112,26 @@ export const ateToolDefinitions: Tool[] = [
109
112
  items: { type: "string", enum: ["chromium", "firefox", "webkit"] },
110
113
  description: "Browsers to test against (default: ['chromium'])",
111
114
  },
115
+ onlyFiles: {
116
+ type: "array",
117
+ items: { type: "string" },
118
+ description:
119
+ "Issue #237 — explicit spec file paths (absolute or relative to repoRoot). " +
120
+ "Forwarded to Playwright as positional <file> args.",
121
+ },
122
+ onlyRoutes: {
123
+ type: "array",
124
+ items: { type: "string" },
125
+ description:
126
+ "Issue #237 — route ids (e.g. 'api-signup'). Resolved to spec paths via " +
127
+ "the spec-indexer. Unknown ids emit a warning; the remaining ids run.",
128
+ },
129
+ grep: {
130
+ type: "string",
131
+ description:
132
+ "Issue #237 — pass-through to Playwright --grep. Applied on top of the " +
133
+ "onlyFiles ∪ resolved(onlyRoutes) set.",
134
+ },
112
135
  progressToken: {
113
136
  type: ["string", "number"],
114
137
  description:
@@ -170,6 +193,10 @@ export const ateToolDefinitions: Tool[] = [
170
193
  "ATE Step 5 — Heal: Analyze test failures from a run and generate safe diff suggestions for fixing the code. " +
171
194
  "Classifies failures by root cause (schema mismatch, missing handler, wrong status, selector stale, etc.) " +
172
195
  "and produces reviewable diffs — never auto-commits or overwrites files. " +
196
+ "Requires a runId produced by mandu.ate.run (or the partial-results stub written " +
197
+ "on timeout under .mandu/reports/run-<runId>/results.json). " +
198
+ "See mandu.brain.status for LLM availability — template-based heals always run; " +
199
+ "LLM-assisted analysis activates when active_tier is openai or anthropic. " +
173
200
  "Use mandu.ate.apply_heal to apply a specific suggestion after review. " +
174
201
  "Supports rollback via mandu_rollback if applied changes cause regressions.",
175
202
  inputSchema: {
@@ -404,16 +431,38 @@ export function ateTools(projectRoot: string, server?: Server) {
404
431
  return ateGenerate({ repoRoot, oracleLevel, onlyRoutes });
405
432
  },
406
433
  "mandu.ate.run": async (args: Record<string, unknown>) => {
407
- const { repoRoot, baseURL, ci, headless, browsers, progressToken } = args as {
434
+ const {
435
+ repoRoot,
436
+ baseURL,
437
+ ci,
438
+ headless,
439
+ browsers,
440
+ onlyFiles,
441
+ onlyRoutes,
442
+ grep,
443
+ progressToken,
444
+ } = args as {
408
445
  repoRoot: string;
409
446
  baseURL?: string;
410
447
  ci?: boolean;
411
448
  headless?: boolean;
412
449
  browsers?: ("chromium" | "firefox" | "webkit")[];
450
+ onlyFiles?: string[];
451
+ onlyRoutes?: string[];
452
+ grep?: string;
413
453
  progressToken?: string | number;
414
454
  };
415
455
  return await runWithObservability(
416
- { repoRoot, baseURL, ci, headless, browsers },
456
+ {
457
+ repoRoot,
458
+ baseURL,
459
+ ci,
460
+ headless,
461
+ browsers,
462
+ onlyFiles,
463
+ onlyRoutes,
464
+ grep,
465
+ },
417
466
  { progressToken },
418
467
  );
419
468
  },
@@ -33,7 +33,10 @@ export const brainToolDefinitions: Tool[] = [
33
33
  {
34
34
  name: "mandu.brain.doctor",
35
35
  description:
36
- "Analyze Guard failures and suggest patches. Works with or without LLM - template-based analysis is always available.",
36
+ "Analyze Guard failures and suggest patches. Returns early with no LLM call when " +
37
+ "guard has no violations (passed: true). When violations are present and an LLM " +
38
+ "tier is active (see mandu.brain.status), runs LLM-assisted analysis and returns " +
39
+ "llmAssisted: true. Template-based analysis is always available as a fallback.",
37
40
  annotations: {
38
41
  readOnlyHint: true,
39
42
  },
@@ -212,6 +215,32 @@ export const brainToolDefinitions: Tool[] = [
212
215
  /** Module-level unsubscribe handle for MCP warning notifications */
213
216
  let mcpWarningUnsubscribe: (() => void) | null = null;
214
217
 
218
+ /**
219
+ * Issue #237 Concern 4 — build a list of next-step suggestions for the
220
+ * currently resolved brain tier. Exposed for unit tests so the tier →
221
+ * suggestion mapping is pinned without spinning up a credential store.
222
+ *
223
+ * - openai / anthropic tiers → point at the LLM-heal loop + guard doctor.
224
+ * - ollama / template tiers → point at `mandu brain login` for higher
225
+ * quality. Everyone also gets a generic status pointer.
226
+ */
227
+ export function buildBrainStatusSuggestions(activeTier: string): string[] {
228
+ const suggestions: string[] = [];
229
+ if (activeTier === "openai" || activeTier === "anthropic") {
230
+ suggestions.push(
231
+ "Run mandu.ate.auto_pipeline or mandu.ate.run followed by mandu.ate.heal to exercise the LLM-healing loop.",
232
+ );
233
+ suggestions.push(
234
+ "Call mandu.brain.doctor after a mandu.guard.check failure to get LLM-assisted diagnosis + patch suggestions.",
235
+ );
236
+ } else if (activeTier === "ollama" || activeTier === "template") {
237
+ suggestions.push(
238
+ "Run `mandu brain login --provider=openai` (or --provider=anthropic) to unlock higher-quality LLM-assisted heal + doctor output.",
239
+ );
240
+ }
241
+ return suggestions;
242
+ }
243
+
215
244
  /**
216
245
  * #236 — surface a clear error when a stale `@mandujs/core` resolves
217
246
  * under `node_modules/@mandujs/mcp/node_modules/` (Bun's installer
@@ -669,6 +698,12 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
669
698
  : { logged_in: false };
670
699
  }
671
700
 
701
+ // Issue #237 Concern 4 — surface next-step suggestions keyed to the
702
+ // active tier so agents can find the LLM invocation paths without
703
+ // grep-archaeology. LLM tiers point at ate.heal / brain.doctor;
704
+ // offline tiers point at `mandu brain login` for an upgrade.
705
+ const suggestions = buildBrainStatusSuggestions(resolution.resolved);
706
+
672
707
  return {
673
708
  content: [
674
709
  {
@@ -679,6 +714,7 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
679
714
  reason: resolution.reason,
680
715
  backend: store.backendName,
681
716
  providers,
717
+ suggestions,
682
718
  },
683
719
  null,
684
720
  2,