@mandujs/mcp 0.36.2 → 0.37.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.
Files changed (153) hide show
  1. package/package.json +4 -4
  2. package/src/activity-adapter.ts +23 -23
  3. package/src/adapters/index.ts +20 -20
  4. package/src/adapters/monitor-adapter.ts +100 -100
  5. package/src/adapters/tool-adapter.ts +90 -90
  6. package/src/executor/index.ts +22 -22
  7. package/src/executor/tool-executor.ts +148 -148
  8. package/src/hooks/config-watcher.ts +173 -173
  9. package/src/hooks/index.ts +23 -23
  10. package/src/hooks/mcp-hooks.ts +227 -227
  11. package/src/index.ts +0 -0
  12. package/src/logging/index.ts +15 -15
  13. package/src/logging/mcp-transport.ts +134 -134
  14. package/src/profiles.ts +34 -34
  15. package/src/registry/index.ts +13 -13
  16. package/src/registry/mcp-tool-registry.ts +298 -298
  17. package/src/resources/skills/guides.ts +1136 -1136
  18. package/src/resources/skills/index.ts +12 -12
  19. package/src/resources/skills/mandu-composition/SKILL.md +91 -91
  20. package/src/resources/skills/mandu-composition/metadata.json +13 -13
  21. package/src/resources/skills/mandu-composition/rules/_sections.md +26 -26
  22. package/src/resources/skills/mandu-composition/rules/_template.md +77 -77
  23. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -146
  24. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -164
  25. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -161
  26. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -167
  27. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -149
  28. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -148
  29. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -150
  30. package/src/resources/skills/mandu-deployment/SKILL.md +92 -92
  31. package/src/resources/skills/mandu-deployment/_sections.md +41 -41
  32. package/src/resources/skills/mandu-deployment/_template.md +38 -38
  33. package/src/resources/skills/mandu-deployment/metadata.json +13 -13
  34. package/src/resources/skills/mandu-deployment/rules/db-provider-supabase.md +300 -300
  35. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -109
  36. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -115
  37. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -219
  38. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -150
  39. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -223
  40. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -152
  41. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -179
  42. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -140
  43. package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -82
  44. package/src/resources/skills/mandu-fs-routes/metadata.json +12 -12
  45. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -36
  46. package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -69
  47. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -65
  48. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -93
  49. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -55
  50. package/src/resources/skills/mandu-guard/SKILL.md +129 -129
  51. package/src/resources/skills/mandu-guard/metadata.json +12 -12
  52. package/src/resources/skills/mandu-guard/rules/_sections.md +36 -36
  53. package/src/resources/skills/mandu-guard/rules/_template.md +82 -82
  54. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -100
  55. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -76
  56. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -81
  57. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -80
  58. package/src/resources/skills/mandu-hydration/SKILL.md +91 -91
  59. package/src/resources/skills/mandu-hydration/metadata.json +12 -12
  60. package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -31
  61. package/src/resources/skills/mandu-hydration/rules/_template.md +72 -72
  62. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -109
  63. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -55
  64. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -113
  65. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -68
  66. package/src/resources/skills/mandu-performance/SKILL.md +85 -85
  67. package/src/resources/skills/mandu-performance/metadata.json +14 -14
  68. package/src/resources/skills/mandu-performance/rules/_sections.md +31 -31
  69. package/src/resources/skills/mandu-performance/rules/_template.md +64 -64
  70. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -103
  71. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -95
  72. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -124
  73. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -125
  74. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -80
  75. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -145
  76. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -98
  77. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -154
  78. package/src/resources/skills/mandu-security/SKILL.md +87 -87
  79. package/src/resources/skills/mandu-security/metadata.json +13 -13
  80. package/src/resources/skills/mandu-security/rules/_sections.md +31 -31
  81. package/src/resources/skills/mandu-security/rules/_template.md +74 -74
  82. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -127
  83. package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -133
  84. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -148
  85. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -146
  86. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -138
  87. package/src/resources/skills/mandu-slot/SKILL.md +85 -85
  88. package/src/resources/skills/mandu-slot/metadata.json +12 -12
  89. package/src/resources/skills/mandu-slot/rules/_sections.md +36 -36
  90. package/src/resources/skills/mandu-slot/rules/_template.md +63 -63
  91. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -38
  92. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -56
  93. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -59
  94. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -64
  95. package/src/resources/skills/mandu-styling/SKILL.md +154 -154
  96. package/src/resources/skills/mandu-styling/_sections.md +43 -43
  97. package/src/resources/skills/mandu-styling/_template.md +32 -32
  98. package/src/resources/skills/mandu-styling/metadata.json +15 -15
  99. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -235
  100. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -255
  101. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -205
  102. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -272
  103. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -167
  104. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -221
  105. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -209
  106. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -192
  107. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -162
  108. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -164
  109. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +170 -170
  110. package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +179 -179
  111. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -229
  112. package/src/resources/skills/mandu-testing/SKILL.md +99 -99
  113. package/src/resources/skills/mandu-testing/metadata.json +13 -13
  114. package/src/resources/skills/mandu-testing/rules/_sections.md +26 -26
  115. package/src/resources/skills/mandu-testing/rules/_template.md +65 -65
  116. package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -195
  117. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -196
  118. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -219
  119. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -192
  120. package/src/resources/skills/mandu-ui/SKILL.md +117 -117
  121. package/src/resources/skills/mandu-ui/_sections.md +23 -23
  122. package/src/resources/skills/mandu-ui/_template.md +32 -32
  123. package/src/resources/skills/mandu-ui/metadata.json +13 -13
  124. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -232
  125. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -238
  126. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -259
  127. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -258
  128. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -213
  129. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -209
  130. package/src/resources/skills/recipes.ts +932 -932
  131. package/src/server.ts +3 -3
  132. package/src/tools/ate-exemplar.ts +92 -92
  133. package/src/tools/ate-flakes.ts +90 -90
  134. package/src/tools/ate-mutate.ts +103 -103
  135. package/src/tools/ate-mutation-report.ts +64 -64
  136. package/src/tools/ate-oracle-pending.ts +49 -49
  137. package/src/tools/ate-oracle-replay.ts +44 -44
  138. package/src/tools/ate-oracle-verdict.ts +70 -70
  139. package/src/tools/ate-prompt.ts +146 -146
  140. package/src/tools/brain.ts +3 -3
  141. package/src/tools/deploy-plan.ts +378 -378
  142. package/src/tools/deploy-preview.ts +316 -316
  143. package/src/tools/design.ts +825 -825
  144. package/src/tools/docs.ts +350 -350
  145. package/src/tools/kitchen.ts +109 -23
  146. package/src/tools/lint.ts +226 -226
  147. package/src/tools/loop-close.ts +175 -175
  148. package/src/tools/negotiate.ts +263 -263
  149. package/src/tools/run-tests.ts +424 -424
  150. package/src/tools/runtime.ts +1 -1
  151. package/src/tools/slot-validation.ts +199 -199
  152. package/src/tx-lock.ts +73 -73
  153. package/src/utils/runtime-control.ts +52 -52
package/src/server.ts CHANGED
@@ -28,8 +28,8 @@ import { mcpToolRegistry } from "./registry/mcp-tool-registry.js";
28
28
  import { registerBuiltinTools, getToolsSummary } from "./tools/index.js";
29
29
 
30
30
  // DNA-007: 에러 처리
31
-
32
- import type { ToolExecutor} from "./executor/tool-executor.js";
31
+
32
+ import type { ToolExecutor} from "./executor/tool-executor.js";
33
33
  import { createToolExecutor } from "./executor/tool-executor.js";
34
34
 
35
35
  // DNA-008: 로깅 통합
@@ -50,7 +50,7 @@ import { manduResourceDefinitions, manduResourceHandlers } from "./new-resources
50
50
  // 기존 컴포넌트
51
51
  import { resourceHandlers, resourceDefinitions } from "./resources/handlers.js";
52
52
  import { findProjectRoot } from "./utils/project.js";
53
-
53
+
54
54
  import { ActivityMonitor } from "./activity-monitor.js";
55
55
  import { type McpProfile, isValidProfile } from "./profiles.js";
56
56
 
@@ -1,92 +1,92 @@
1
- /**
2
- * `mandu_ate_exemplar` — Phase A.3 exemplar browser.
3
- *
4
- * See `docs/ate/roadmap-v2-agent-native.md` §4.3. Returns the
5
- * `@ate-exemplar:` tagged tests for a given kind so an agent can
6
- * few-shot against them without paying the "compose the whole prompt"
7
- * token cost.
8
- *
9
- * Snake_case tool name (§11 decision #4). Read-only.
10
- */
11
-
12
- import type { Tool } from "@modelcontextprotocol/sdk/types.js";
13
- import { scanExemplars, type Exemplar } from "@mandujs/ate";
14
-
15
- export const ateExemplarToolDefinitions: Tool[] = [
16
- {
17
- name: "mandu_ate_exemplar",
18
- annotations: {
19
- readOnlyHint: true,
20
- },
21
- description:
22
- "Phase A.3 agent-native exemplar browser. Returns up to `limit` tests " +
23
- "tagged with `@ate-exemplar: kind=<kind>` from the repo. Each entry " +
24
- "carries the file path, start/end line, tags, and the full source of the " +
25
- "test() / it() / describe() call that follows the tag. Set " +
26
- "includeAnti:true to also surface `@ate-exemplar-anti:` (DO-NOT-do-this) " +
27
- "cases. Exemplars are manually curated (roadmap §11 decision 2) — no " +
28
- "auto-heuristic. Use this when you want few-shot examples without paying " +
29
- "for the full composed prompt.",
30
- inputSchema: {
31
- type: "object",
32
- properties: {
33
- repoRoot: {
34
- type: "string",
35
- description: "Absolute path to the Mandu project root.",
36
- },
37
- kind: {
38
- type: "string",
39
- description:
40
- "Match against the tag's `kind=` attribute. Examples: filling_unit, filling_integration, e2e_playwright.",
41
- },
42
- limit: {
43
- type: "number",
44
- description: "Max entries to return. Default 5.",
45
- },
46
- includeAnti: {
47
- type: "boolean",
48
- description:
49
- "Also include @ate-exemplar-anti markers (default false — only positive exemplars).",
50
- },
51
- },
52
- required: ["repoRoot", "kind"],
53
- },
54
- },
55
- ];
56
-
57
- export function ateExemplarTools(_projectRoot: string) {
58
- return {
59
- mandu_ate_exemplar: async (args: Record<string, unknown>) => {
60
- const repoRoot = args.repoRoot as string | undefined;
61
- const kind = args.kind as string | undefined;
62
- const limit = typeof args.limit === "number" ? args.limit : 5;
63
- const includeAnti = args.includeAnti === true;
64
-
65
- if (!repoRoot || typeof repoRoot !== "string") {
66
- return { ok: false, error: "'repoRoot' is required" };
67
- }
68
- if (!kind || typeof kind !== "string") {
69
- return { ok: false, error: "'kind' is required" };
70
- }
71
-
72
- try {
73
- const all = await scanExemplars(repoRoot);
74
- const filtered = all.filter((e) => e.kind === kind);
75
- const selected: Exemplar[] = [];
76
- const positives = filtered.filter((e) => !e.anti).slice(0, limit);
77
- selected.push(...positives);
78
- if (includeAnti) {
79
- // Reserve up to half the limit for antis so positives aren't crowded out.
80
- const antiBudget = Math.max(1, Math.floor(limit / 2));
81
- const antis = filtered.filter((e) => e.anti).slice(0, antiBudget);
82
- selected.push(...antis);
83
- }
84
-
85
- return { ok: true, exemplars: selected, total: filtered.length };
86
- } catch (err) {
87
- const msg = err instanceof Error ? err.message : String(err);
88
- return { ok: false, error: msg };
89
- }
90
- },
91
- };
92
- }
1
+ /**
2
+ * `mandu_ate_exemplar` — Phase A.3 exemplar browser.
3
+ *
4
+ * See `docs/ate/roadmap-v2-agent-native.md` §4.3. Returns the
5
+ * `@ate-exemplar:` tagged tests for a given kind so an agent can
6
+ * few-shot against them without paying the "compose the whole prompt"
7
+ * token cost.
8
+ *
9
+ * Snake_case tool name (§11 decision #4). Read-only.
10
+ */
11
+
12
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
13
+ import { scanExemplars, type Exemplar } from "@mandujs/ate";
14
+
15
+ export const ateExemplarToolDefinitions: Tool[] = [
16
+ {
17
+ name: "mandu_ate_exemplar",
18
+ annotations: {
19
+ readOnlyHint: true,
20
+ },
21
+ description:
22
+ "Phase A.3 agent-native exemplar browser. Returns up to `limit` tests " +
23
+ "tagged with `@ate-exemplar: kind=<kind>` from the repo. Each entry " +
24
+ "carries the file path, start/end line, tags, and the full source of the " +
25
+ "test() / it() / describe() call that follows the tag. Set " +
26
+ "includeAnti:true to also surface `@ate-exemplar-anti:` (DO-NOT-do-this) " +
27
+ "cases. Exemplars are manually curated (roadmap §11 decision 2) — no " +
28
+ "auto-heuristic. Use this when you want few-shot examples without paying " +
29
+ "for the full composed prompt.",
30
+ inputSchema: {
31
+ type: "object",
32
+ properties: {
33
+ repoRoot: {
34
+ type: "string",
35
+ description: "Absolute path to the Mandu project root.",
36
+ },
37
+ kind: {
38
+ type: "string",
39
+ description:
40
+ "Match against the tag's `kind=` attribute. Examples: filling_unit, filling_integration, e2e_playwright.",
41
+ },
42
+ limit: {
43
+ type: "number",
44
+ description: "Max entries to return. Default 5.",
45
+ },
46
+ includeAnti: {
47
+ type: "boolean",
48
+ description:
49
+ "Also include @ate-exemplar-anti markers (default false — only positive exemplars).",
50
+ },
51
+ },
52
+ required: ["repoRoot", "kind"],
53
+ },
54
+ },
55
+ ];
56
+
57
+ export function ateExemplarTools(_projectRoot: string) {
58
+ return {
59
+ mandu_ate_exemplar: async (args: Record<string, unknown>) => {
60
+ const repoRoot = args.repoRoot as string | undefined;
61
+ const kind = args.kind as string | undefined;
62
+ const limit = typeof args.limit === "number" ? args.limit : 5;
63
+ const includeAnti = args.includeAnti === true;
64
+
65
+ if (!repoRoot || typeof repoRoot !== "string") {
66
+ return { ok: false, error: "'repoRoot' is required" };
67
+ }
68
+ if (!kind || typeof kind !== "string") {
69
+ return { ok: false, error: "'kind' is required" };
70
+ }
71
+
72
+ try {
73
+ const all = await scanExemplars(repoRoot);
74
+ const filtered = all.filter((e) => e.kind === kind);
75
+ const selected: Exemplar[] = [];
76
+ const positives = filtered.filter((e) => !e.anti).slice(0, limit);
77
+ selected.push(...positives);
78
+ if (includeAnti) {
79
+ // Reserve up to half the limit for antis so positives aren't crowded out.
80
+ const antiBudget = Math.max(1, Math.floor(limit / 2));
81
+ const antis = filtered.filter((e) => e.anti).slice(0, antiBudget);
82
+ selected.push(...antis);
83
+ }
84
+
85
+ return { ok: true, exemplars: selected, total: filtered.length };
86
+ } catch (err) {
87
+ const msg = err instanceof Error ? err.message : String(err);
88
+ return { ok: false, error: msg };
89
+ }
90
+ },
91
+ };
92
+ }
@@ -1,90 +1,90 @@
1
- /**
2
- * `mandu_ate_flakes` — Phase A.2 flake detector surface.
3
- *
4
- * Returns every spec whose rolling pass/fail transition ratio exceeds
5
- * `minScore` (default 0.1) within the last `windowSize` runs
6
- * (default 20). Agents use this to prioritize stabilization work.
7
- *
8
- * Data source: `.mandu/ate-run-history.jsonl`, appended to by
9
- * `runSpec`. When no history is present we return an empty array —
10
- * not an error.
11
- *
12
- * Snake_case naming per §11 decision 4.
13
- */
14
- import type { Tool } from "@modelcontextprotocol/sdk/types.js";
15
- import { summarizeFlakes } from "@mandujs/ate";
16
-
17
- export const ateFlakesToolDefinitions: Tool[] = [
18
- {
19
- name: "mandu_ate_flakes",
20
- annotations: {
21
- readOnlyHint: true,
22
- },
23
- description:
24
- "Phase A.2 flake detector. Reads `.mandu/ate-run-history.jsonl` and returns specs " +
25
- "whose pass/fail status flips often within the rolling window. `flakeScore` = " +
26
- "status_transitions / (N - 1) over last `windowSize` non-skipped runs. " +
27
- "Pure-pass PPPPP = 0.0 (stable), pure-fail FFFFF = 0.0 (broken, NOT flaky), " +
28
- "alternating PFPF = 1.0. Returns an empty list when history is empty or no spec " +
29
- "clears `minScore`. Use this to prioritize which flaky tests to fix first — feed " +
30
- "a specPath from the result into mandu_ate_run for a re-run + full failure.v1 " +
31
- "diagnostic.",
32
- inputSchema: {
33
- type: "object",
34
- properties: {
35
- repoRoot: {
36
- type: "string",
37
- description: "Absolute path to the Mandu project root",
38
- },
39
- windowSize: {
40
- type: "number",
41
- minimum: 2,
42
- description: "Rolling window size. Default: 20.",
43
- },
44
- minScore: {
45
- type: "number",
46
- minimum: 0,
47
- maximum: 1,
48
- description: "Filter threshold for flakeScore. Default: 0.1.",
49
- },
50
- },
51
- required: ["repoRoot"],
52
- },
53
- },
54
- ];
55
-
56
- export function ateFlakesTools(_projectRoot: string) {
57
- return {
58
- mandu_ate_flakes: async (args: Record<string, unknown>) => {
59
- const { repoRoot, windowSize, minScore } = args as {
60
- repoRoot: string;
61
- windowSize?: number;
62
- minScore?: number;
63
- };
64
- if (!repoRoot || typeof repoRoot !== "string") {
65
- return { ok: false, error: "repoRoot is required" };
66
- }
67
- if (typeof windowSize === "number" && windowSize < 2) {
68
- return { ok: false, error: "windowSize must be >= 2" };
69
- }
70
- if (
71
- typeof minScore === "number" &&
72
- (minScore < 0 || minScore > 1 || !Number.isFinite(minScore))
73
- ) {
74
- return { ok: false, error: "minScore must be in [0, 1]" };
75
- }
76
- try {
77
- const flakyTests = summarizeFlakes(repoRoot, {
78
- windowSize,
79
- minScore,
80
- });
81
- return { ok: true, flakyTests };
82
- } catch (err) {
83
- return {
84
- ok: false,
85
- error: `summarizeFlakes failed: ${err instanceof Error ? err.message : String(err)}`,
86
- };
87
- }
88
- },
89
- };
90
- }
1
+ /**
2
+ * `mandu_ate_flakes` — Phase A.2 flake detector surface.
3
+ *
4
+ * Returns every spec whose rolling pass/fail transition ratio exceeds
5
+ * `minScore` (default 0.1) within the last `windowSize` runs
6
+ * (default 20). Agents use this to prioritize stabilization work.
7
+ *
8
+ * Data source: `.mandu/ate-run-history.jsonl`, appended to by
9
+ * `runSpec`. When no history is present we return an empty array —
10
+ * not an error.
11
+ *
12
+ * Snake_case naming per §11 decision 4.
13
+ */
14
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
15
+ import { summarizeFlakes } from "@mandujs/ate";
16
+
17
+ export const ateFlakesToolDefinitions: Tool[] = [
18
+ {
19
+ name: "mandu_ate_flakes",
20
+ annotations: {
21
+ readOnlyHint: true,
22
+ },
23
+ description:
24
+ "Phase A.2 flake detector. Reads `.mandu/ate-run-history.jsonl` and returns specs " +
25
+ "whose pass/fail status flips often within the rolling window. `flakeScore` = " +
26
+ "status_transitions / (N - 1) over last `windowSize` non-skipped runs. " +
27
+ "Pure-pass PPPPP = 0.0 (stable), pure-fail FFFFF = 0.0 (broken, NOT flaky), " +
28
+ "alternating PFPF = 1.0. Returns an empty list when history is empty or no spec " +
29
+ "clears `minScore`. Use this to prioritize which flaky tests to fix first — feed " +
30
+ "a specPath from the result into mandu_ate_run for a re-run + full failure.v1 " +
31
+ "diagnostic.",
32
+ inputSchema: {
33
+ type: "object",
34
+ properties: {
35
+ repoRoot: {
36
+ type: "string",
37
+ description: "Absolute path to the Mandu project root",
38
+ },
39
+ windowSize: {
40
+ type: "number",
41
+ minimum: 2,
42
+ description: "Rolling window size. Default: 20.",
43
+ },
44
+ minScore: {
45
+ type: "number",
46
+ minimum: 0,
47
+ maximum: 1,
48
+ description: "Filter threshold for flakeScore. Default: 0.1.",
49
+ },
50
+ },
51
+ required: ["repoRoot"],
52
+ },
53
+ },
54
+ ];
55
+
56
+ export function ateFlakesTools(_projectRoot: string) {
57
+ return {
58
+ mandu_ate_flakes: async (args: Record<string, unknown>) => {
59
+ const { repoRoot, windowSize, minScore } = args as {
60
+ repoRoot: string;
61
+ windowSize?: number;
62
+ minScore?: number;
63
+ };
64
+ if (!repoRoot || typeof repoRoot !== "string") {
65
+ return { ok: false, error: "repoRoot is required" };
66
+ }
67
+ if (typeof windowSize === "number" && windowSize < 2) {
68
+ return { ok: false, error: "windowSize must be >= 2" };
69
+ }
70
+ if (
71
+ typeof minScore === "number" &&
72
+ (minScore < 0 || minScore > 1 || !Number.isFinite(minScore))
73
+ ) {
74
+ return { ok: false, error: "minScore must be in [0, 1]" };
75
+ }
76
+ try {
77
+ const flakyTests = summarizeFlakes(repoRoot, {
78
+ windowSize,
79
+ minScore,
80
+ });
81
+ return { ok: true, flakyTests };
82
+ } catch (err) {
83
+ return {
84
+ ok: false,
85
+ error: `summarizeFlakes failed: ${err instanceof Error ? err.message : String(err)}`,
86
+ };
87
+ }
88
+ },
89
+ };
90
+ }
@@ -1,103 +1,103 @@
1
- /**
2
- * `mandu_ate_mutate` — Phase C.2 contract-semantic mutation runner.
3
- *
4
- * Runs up to 9 mutation operators on a single target file and executes
5
- * the repo's test command against each mutation. Classifies results as
6
- * killed / survived / timeout / error and persists
7
- * `.mandu/ate-mutations/last-run.json` for `mandu_ate_mutation_report`.
8
- *
9
- * Spec: docs/ate/phase-c-spec.md §C.2.
10
- */
11
-
12
- import type { Tool } from "@modelcontextprotocol/sdk/types.js";
13
- import { runMutations } from "@mandujs/ate";
14
-
15
- export const ateMutateToolDefinitions: Tool[] = [
16
- {
17
- name: "mandu_ate_mutate",
18
- annotations: {
19
- readOnlyHint: false,
20
- },
21
- description:
22
- "Phase C.2 — run contract-semantic mutation testing on a target file. " +
23
- "9 operators: remove_required_field, narrow_type, widen_enum, flip_nullable, " +
24
- "rename_field, swap_sibling_type, skip_middleware, early_return, bypass_validation. " +
25
- "Each mutation is written to the target file, the repo's test command runs " +
26
- "against it, and the result is classified killed / survived / timeout / error. " +
27
- "Default cap 50 mutations per invocation; pass `--all` or maxMutations to lift. " +
28
- "The original file is always restored. Persists .mandu/ate-mutations/last-run.json.",
29
- inputSchema: {
30
- type: "object",
31
- properties: {
32
- repoRoot: {
33
- type: "string",
34
- description: "Absolute path to the Mandu project root.",
35
- },
36
- targetFile: {
37
- type: "string",
38
- description:
39
- "Absolute or repo-relative path to the file to mutate (contract, handler, or filling).",
40
- },
41
- testCommand: {
42
- type: "array",
43
- items: { type: "string" },
44
- description:
45
- "Optional override for the test command (argv form). Default: resolved from spec-indexer.",
46
- },
47
- timeoutMs: {
48
- type: "number",
49
- description: "Per-mutation timeout in ms. Default 120000.",
50
- },
51
- maxMutations: {
52
- type: "number",
53
- description: "Cap on the number of mutations executed. Default 50.",
54
- },
55
- operators: {
56
- type: "array",
57
- items: { type: "string" },
58
- description:
59
- "Optional subset of operator names. Default = all 9. Pass [] to skip execution.",
60
- },
61
- },
62
- required: ["repoRoot", "targetFile"],
63
- },
64
- },
65
- ];
66
-
67
- export function ateMutateTools(_projectRoot: string) {
68
- return {
69
- mandu_ate_mutate: async (args: Record<string, unknown>) => {
70
- const repoRoot = args.repoRoot as string | undefined;
71
- const targetFile = args.targetFile as string | undefined;
72
- if (!repoRoot || typeof repoRoot !== "string") {
73
- return { ok: false, error: "repoRoot is required" };
74
- }
75
- if (!targetFile || typeof targetFile !== "string") {
76
- return { ok: false, error: "targetFile is required" };
77
- }
78
- try {
79
- const result = await runMutations({
80
- repoRoot,
81
- targetFile,
82
- ...(Array.isArray(args.testCommand) ? { testCommand: args.testCommand as string[] } : {}),
83
- ...(typeof args.timeoutMs === "number" ? { timeoutMs: args.timeoutMs } : {}),
84
- ...(typeof args.maxMutations === "number" ? { maxMutations: args.maxMutations } : {}),
85
- ...(Array.isArray(args.operators) ? { operators: args.operators as never } : {}),
86
- });
87
- return {
88
- ok: true,
89
- targetFile: result.targetFile,
90
- totalGenerated: result.totalGenerated,
91
- totalExecuted: result.totalExecuted,
92
- reportPath: result.reportPath,
93
- results: result.results,
94
- };
95
- } catch (err) {
96
- return {
97
- ok: false,
98
- error: err instanceof Error ? err.message : String(err),
99
- };
100
- }
101
- },
102
- };
103
- }
1
+ /**
2
+ * `mandu_ate_mutate` — Phase C.2 contract-semantic mutation runner.
3
+ *
4
+ * Runs up to 9 mutation operators on a single target file and executes
5
+ * the repo's test command against each mutation. Classifies results as
6
+ * killed / survived / timeout / error and persists
7
+ * `.mandu/ate-mutations/last-run.json` for `mandu_ate_mutation_report`.
8
+ *
9
+ * Spec: docs/ate/phase-c-spec.md §C.2.
10
+ */
11
+
12
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
13
+ import { runMutations } from "@mandujs/ate";
14
+
15
+ export const ateMutateToolDefinitions: Tool[] = [
16
+ {
17
+ name: "mandu_ate_mutate",
18
+ annotations: {
19
+ readOnlyHint: false,
20
+ },
21
+ description:
22
+ "Phase C.2 — run contract-semantic mutation testing on a target file. " +
23
+ "9 operators: remove_required_field, narrow_type, widen_enum, flip_nullable, " +
24
+ "rename_field, swap_sibling_type, skip_middleware, early_return, bypass_validation. " +
25
+ "Each mutation is written to the target file, the repo's test command runs " +
26
+ "against it, and the result is classified killed / survived / timeout / error. " +
27
+ "Default cap 50 mutations per invocation; pass `--all` or maxMutations to lift. " +
28
+ "The original file is always restored. Persists .mandu/ate-mutations/last-run.json.",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {
32
+ repoRoot: {
33
+ type: "string",
34
+ description: "Absolute path to the Mandu project root.",
35
+ },
36
+ targetFile: {
37
+ type: "string",
38
+ description:
39
+ "Absolute or repo-relative path to the file to mutate (contract, handler, or filling).",
40
+ },
41
+ testCommand: {
42
+ type: "array",
43
+ items: { type: "string" },
44
+ description:
45
+ "Optional override for the test command (argv form). Default: resolved from spec-indexer.",
46
+ },
47
+ timeoutMs: {
48
+ type: "number",
49
+ description: "Per-mutation timeout in ms. Default 120000.",
50
+ },
51
+ maxMutations: {
52
+ type: "number",
53
+ description: "Cap on the number of mutations executed. Default 50.",
54
+ },
55
+ operators: {
56
+ type: "array",
57
+ items: { type: "string" },
58
+ description:
59
+ "Optional subset of operator names. Default = all 9. Pass [] to skip execution.",
60
+ },
61
+ },
62
+ required: ["repoRoot", "targetFile"],
63
+ },
64
+ },
65
+ ];
66
+
67
+ export function ateMutateTools(_projectRoot: string) {
68
+ return {
69
+ mandu_ate_mutate: async (args: Record<string, unknown>) => {
70
+ const repoRoot = args.repoRoot as string | undefined;
71
+ const targetFile = args.targetFile as string | undefined;
72
+ if (!repoRoot || typeof repoRoot !== "string") {
73
+ return { ok: false, error: "repoRoot is required" };
74
+ }
75
+ if (!targetFile || typeof targetFile !== "string") {
76
+ return { ok: false, error: "targetFile is required" };
77
+ }
78
+ try {
79
+ const result = await runMutations({
80
+ repoRoot,
81
+ targetFile,
82
+ ...(Array.isArray(args.testCommand) ? { testCommand: args.testCommand as string[] } : {}),
83
+ ...(typeof args.timeoutMs === "number" ? { timeoutMs: args.timeoutMs } : {}),
84
+ ...(typeof args.maxMutations === "number" ? { maxMutations: args.maxMutations } : {}),
85
+ ...(Array.isArray(args.operators) ? { operators: args.operators as never } : {}),
86
+ });
87
+ return {
88
+ ok: true,
89
+ targetFile: result.targetFile,
90
+ totalGenerated: result.totalGenerated,
91
+ totalExecuted: result.totalExecuted,
92
+ reportPath: result.reportPath,
93
+ results: result.results,
94
+ };
95
+ } catch (err) {
96
+ return {
97
+ ok: false,
98
+ error: err instanceof Error ? err.message : String(err),
99
+ };
100
+ }
101
+ },
102
+ };
103
+ }