@smmachine/launcher 0.6.20 → 0.6.21

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 (154) hide show
  1. package/apps/mcp/dist/bin.cjs +1561 -1184
  2. package/apps/mcp/dist/bin.cjs.map +1 -1
  3. package/apps/mcp/dist/index.cjs +1575 -1182
  4. package/apps/mcp/dist/index.cjs.map +1 -1
  5. package/apps/mcp/dist/index.d.ts +111 -14
  6. package/apps/webapp/.next/BUILD_ID +1 -1
  7. package/apps/webapp/.next/build-manifest.json +3 -3
  8. package/apps/webapp/.next/fallback-build-manifest.json +3 -3
  9. package/apps/webapp/.next/next-minimal-server.js.nft.json +1 -1
  10. package/apps/webapp/.next/next-server.js.nft.json +1 -1
  11. package/apps/webapp/.next/prerender-manifest.json +3 -3
  12. package/apps/webapp/.next/server/app/_global-error/page.js.nft.json +1 -1
  13. package/apps/webapp/.next/server/app/_global-error.html +1 -1
  14. package/apps/webapp/.next/server/app/_global-error.rsc +1 -1
  15. package/apps/webapp/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  16. package/apps/webapp/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  17. package/apps/webapp/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/apps/webapp/.next/server/app/_not-found/page.js.nft.json +1 -1
  19. package/apps/webapp/.next/server/app/_not-found.html +1 -1
  20. package/apps/webapp/.next/server/app/_not-found.rsc +1 -1
  21. package/apps/webapp/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  22. package/apps/webapp/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/apps/webapp/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  24. package/apps/webapp/.next/server/app/api/source-code/big-o/file/route.js.nft.json +1 -1
  25. package/apps/webapp/.next/server/app/dashboard/architecture/page/server-reference-manifest.json +2 -2
  26. package/apps/webapp/.next/server/app/dashboard/architecture/page.js.nft.json +1 -1
  27. package/apps/webapp/.next/server/app/dashboard/architecture/page_client-reference-manifest.js +1 -1
  28. package/apps/webapp/.next/server/app/dashboard/change-requests/page/server-reference-manifest.json +2 -2
  29. package/apps/webapp/.next/server/app/dashboard/change-requests/page.js.nft.json +1 -1
  30. package/apps/webapp/.next/server/app/dashboard/change-requests/page_client-reference-manifest.js +1 -1
  31. package/apps/webapp/.next/server/app/dashboard/engineering-health/page/server-reference-manifest.json +2 -2
  32. package/apps/webapp/.next/server/app/dashboard/engineering-health/page.js.nft.json +1 -1
  33. package/apps/webapp/.next/server/app/dashboard/engineering-health/page_client-reference-manifest.js +1 -1
  34. package/apps/webapp/.next/server/app/dashboard/insights/page/server-reference-manifest.json +2 -2
  35. package/apps/webapp/.next/server/app/dashboard/insights/page.js.nft.json +1 -1
  36. package/apps/webapp/.next/server/app/dashboard/insights/page_client-reference-manifest.js +1 -1
  37. package/apps/webapp/.next/server/app/dashboard/page/server-reference-manifest.json +2 -2
  38. package/apps/webapp/.next/server/app/dashboard/page.js.nft.json +1 -1
  39. package/apps/webapp/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  40. package/apps/webapp/.next/server/app/dashboard/pipelines/page/server-reference-manifest.json +2 -2
  41. package/apps/webapp/.next/server/app/dashboard/pipelines/page.js.nft.json +1 -1
  42. package/apps/webapp/.next/server/app/dashboard/pipelines/page_client-reference-manifest.js +1 -1
  43. package/apps/webapp/.next/server/app/dashboard/references/page/server-reference-manifest.json +2 -2
  44. package/apps/webapp/.next/server/app/dashboard/references/page.js.nft.json +1 -1
  45. package/apps/webapp/.next/server/app/dashboard/references/page_client-reference-manifest.js +1 -1
  46. package/apps/webapp/.next/server/app/dashboard/settings/page/server-reference-manifest.json +2 -2
  47. package/apps/webapp/.next/server/app/dashboard/settings/page.js.nft.json +1 -1
  48. package/apps/webapp/.next/server/app/dashboard/settings/page_client-reference-manifest.js +1 -1
  49. package/apps/webapp/.next/server/app/dashboard/sonarqube/page/server-reference-manifest.json +2 -2
  50. package/apps/webapp/.next/server/app/dashboard/sonarqube/page.js.nft.json +1 -1
  51. package/apps/webapp/.next/server/app/dashboard/sonarqube/page_client-reference-manifest.js +1 -1
  52. package/apps/webapp/.next/server/app/dashboard/source-code/page/server-reference-manifest.json +2 -2
  53. package/apps/webapp/.next/server/app/dashboard/source-code/page.js.nft.json +1 -1
  54. package/apps/webapp/.next/server/app/dashboard/source-code/page_client-reference-manifest.js +1 -1
  55. package/apps/webapp/.next/server/app/engineering-health/page/server-reference-manifest.json +4 -4
  56. package/apps/webapp/.next/server/app/engineering-health/page.js.nft.json +1 -1
  57. package/apps/webapp/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  58. package/apps/webapp/.next/server/app/page/server-reference-manifest.json +2 -2
  59. package/apps/webapp/.next/server/app/page.js.nft.json +1 -1
  60. package/apps/webapp/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/apps/webapp/.next/server/app/reports/[id]/page/server-reference-manifest.json +4 -4
  62. package/apps/webapp/.next/server/app/reports/[id]/page.js.nft.json +1 -1
  63. package/apps/webapp/.next/server/app/reports/page/server-reference-manifest.json +4 -4
  64. package/apps/webapp/.next/server/app/reports/page.js.nft.json +1 -1
  65. package/apps/webapp/.next/server/app/reports/page_client-reference-manifest.js +1 -1
  66. package/apps/webapp/.next/server/chunks/ssr/044u_webapp__next-internal_server_app_dashboard_architecture_page_actions_0auf06l.js +1 -1
  67. package/apps/webapp/.next/server/chunks/ssr/044u_webapp__next-internal_server_app_dashboard_architecture_page_actions_0auf06l.js.map +1 -1
  68. package/apps/webapp/.next/server/chunks/ssr/044u_webapp__next-internal_server_app_dashboard_change-requests_page_actions_0m2phod.js +1 -1
  69. package/apps/webapp/.next/server/chunks/ssr/044u_webapp__next-internal_server_app_dashboard_change-requests_page_actions_0m2phod.js.map +1 -1
  70. package/apps/webapp/.next/server/chunks/ssr/0ha2__next-internal_server_app_dashboard_engineering-health_page_actions_0rdrmai.js +1 -1
  71. package/apps/webapp/.next/server/chunks/ssr/0ha2__next-internal_server_app_dashboard_engineering-health_page_actions_0rdrmai.js.map +1 -1
  72. package/apps/webapp/.next/server/chunks/ssr/{0zs2_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1u81xgy._.js → 0zs2_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1979eh7._.js} +1 -1
  73. package/apps/webapp/.next/server/chunks/ssr/{1crg_mermaid_dist_chunks_mermaid_core_1l4_vc-._.js → 1crg_mermaid_dist_chunks_mermaid_core_05hsnop._.js} +1 -1
  74. package/apps/webapp/.next/server/chunks/ssr/_0-7db18._.js +1 -1
  75. package/apps/webapp/.next/server/chunks/ssr/{_1lkjcrk._.js → _0aww5qt._.js} +2 -2
  76. package/apps/webapp/.next/server/chunks/ssr/_0dh0zlo._.js +1 -1
  77. package/apps/webapp/.next/server/chunks/ssr/_0imzkd7._.js +1 -1
  78. package/apps/webapp/.next/server/chunks/ssr/_0imzkd7._.js.map +1 -1
  79. package/apps/webapp/.next/server/chunks/ssr/_0xozcio._.js +1 -1
  80. package/apps/webapp/.next/server/chunks/ssr/_0xozcio._.js.map +1 -1
  81. package/apps/webapp/.next/server/chunks/ssr/_1wn-x3t._.js +1 -1
  82. package/apps/webapp/.next/server/chunks/ssr/_1wn-x3t._.js.map +1 -1
  83. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_insights_page_actions_195xpz5.js +1 -1
  84. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_insights_page_actions_195xpz5.js.map +1 -1
  85. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_page_actions_0ise39g.js +1 -1
  86. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_page_actions_0ise39g.js.map +1 -1
  87. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_pipelines_page_actions_0ifxarm.js +1 -1
  88. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_pipelines_page_actions_0ifxarm.js.map +1 -1
  89. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_references_page_actions_04n4jxm.js +1 -1
  90. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_references_page_actions_04n4jxm.js.map +1 -1
  91. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_settings_page_actions_1q57mfh.js +1 -1
  92. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_settings_page_actions_1q57mfh.js.map +1 -1
  93. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_sonarqube_page_actions_0od5kyp.js +1 -1
  94. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_sonarqube_page_actions_0od5kyp.js.map +1 -1
  95. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_source-code_page_actions_1hadxb7.js +1 -1
  96. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_dashboard_source-code_page_actions_1hadxb7.js.map +1 -1
  97. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_engineering-health_page_actions_0612tpe.js +1 -1
  98. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_engineering-health_page_actions_0612tpe.js.map +1 -1
  99. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_page_actions_1vgymff.js +1 -1
  100. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_page_actions_1vgymff.js.map +1 -1
  101. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_reports_[id]_page_actions_0xht0eq.js +1 -1
  102. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_reports_[id]_page_actions_0xht0eq.js.map +1 -1
  103. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_reports_page_actions_14i5qzx.js +1 -1
  104. package/apps/webapp/.next/server/chunks/ssr/apps_webapp__next-internal_server_app_reports_page_actions_14i5qzx.js.map +1 -1
  105. package/apps/webapp/.next/server/chunks/ssr/apps_webapp_app_dashboard_dashboard-frame_tsx_0rxse94._.js +1 -1
  106. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_14ywl9a._.js → node_modules__pnpm_03oelvl._.js} +1 -1
  107. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1ei4o1o._.js → node_modules__pnpm_04gpfm9._.js} +1 -1
  108. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_0c4yd05._.js → node_modules__pnpm_0ayyphf._.js} +1 -1
  109. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1um53cy._.js → node_modules__pnpm_0ey76w6._.js} +1 -1
  110. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_15b6v2q._.js → node_modules__pnpm_0hi_fgb._.js} +1 -1
  111. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1m6h1wj._.js → node_modules__pnpm_0mc-9iz._.js} +1 -1
  112. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_072ul8x._.js → node_modules__pnpm_0n0ha9r._.js} +1 -1
  113. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_196bbqt._.js → node_modules__pnpm_11y7nzs._.js} +1 -1
  114. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_012ijp_._.js → node_modules__pnpm_1fqj1mn._.js} +1 -1
  115. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_079-9vu._.js → node_modules__pnpm_1qs51iy._.js} +1 -1
  116. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1hvzm0p._.js → node_modules__pnpm_1ty2y-3._.js} +1 -1
  117. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1-7b_gi._.js → node_modules__pnpm_1vuz70r._.js} +1 -1
  118. package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1810k5h._.js → node_modules__pnpm_1xi8cq1._.js} +1 -1
  119. package/apps/webapp/.next/server/middleware-build-manifest.js +3 -3
  120. package/apps/webapp/.next/server/pages/404.html +1 -1
  121. package/apps/webapp/.next/server/pages/500.html +1 -1
  122. package/apps/webapp/.next/server/server-reference-manifest.js +1 -1
  123. package/apps/webapp/.next/server/server-reference-manifest.json +3 -3
  124. package/apps/webapp/.next/static/chunks/0cf9jy9nycczh.js +28 -0
  125. package/apps/webapp/.next/static/chunks/0ohb9yul5znlo.js +1 -0
  126. package/apps/webapp/.next/static/chunks/{2xa1cgv72bxza.js → 0s89ck6xylv6o.js} +1 -1
  127. package/apps/webapp/.next/static/chunks/1s98b4qcsotps.js +1 -0
  128. package/dist/index.cjs +1514 -1114
  129. package/dist/index.cjs.map +1 -1
  130. package/dist/rest/main.cjs +12 -2
  131. package/dist/rest/main.cjs.map +1 -1
  132. package/package.json +7 -5
  133. package/apps/webapp/.next/static/chunks/0c0szaea20j4u.js +0 -28
  134. package/apps/webapp/.next/static/chunks/0ger-8w6hogr3.js +0 -1
  135. package/apps/webapp/.next/static/chunks/1xd-2-h2y0pmk.js +0 -1
  136. /package/apps/webapp/.next/server/chunks/ssr/{0zs2_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1u81xgy._.js.map → 0zs2_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1979eh7._.js.map} +0 -0
  137. /package/apps/webapp/.next/server/chunks/ssr/{1crg_mermaid_dist_chunks_mermaid_core_1l4_vc-._.js.map → 1crg_mermaid_dist_chunks_mermaid_core_05hsnop._.js.map} +0 -0
  138. /package/apps/webapp/.next/server/chunks/ssr/{_1lkjcrk._.js.map → _0aww5qt._.js.map} +0 -0
  139. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_14ywl9a._.js.map → node_modules__pnpm_03oelvl._.js.map} +0 -0
  140. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1ei4o1o._.js.map → node_modules__pnpm_04gpfm9._.js.map} +0 -0
  141. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_0c4yd05._.js.map → node_modules__pnpm_0ayyphf._.js.map} +0 -0
  142. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1um53cy._.js.map → node_modules__pnpm_0ey76w6._.js.map} +0 -0
  143. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_15b6v2q._.js.map → node_modules__pnpm_0hi_fgb._.js.map} +0 -0
  144. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1m6h1wj._.js.map → node_modules__pnpm_0mc-9iz._.js.map} +0 -0
  145. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_072ul8x._.js.map → node_modules__pnpm_0n0ha9r._.js.map} +0 -0
  146. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_196bbqt._.js.map → node_modules__pnpm_11y7nzs._.js.map} +0 -0
  147. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_012ijp_._.js.map → node_modules__pnpm_1fqj1mn._.js.map} +0 -0
  148. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_079-9vu._.js.map → node_modules__pnpm_1qs51iy._.js.map} +0 -0
  149. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1hvzm0p._.js.map → node_modules__pnpm_1ty2y-3._.js.map} +0 -0
  150. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1-7b_gi._.js.map → node_modules__pnpm_1vuz70r._.js.map} +0 -0
  151. /package/apps/webapp/.next/server/chunks/ssr/{node_modules__pnpm_1810k5h._.js.map → node_modules__pnpm_1xi8cq1._.js.map} +0 -0
  152. /package/apps/webapp/.next/static/{1QJj5turQ_zLZgMb8ee_E → 42A-yEAAQq6m65gKOQyX1}/_buildManifest.js +0 -0
  153. /package/apps/webapp/.next/static/{1QJj5turQ_zLZgMb8ee_E → 42A-yEAAQq6m65gKOQyX1}/_clientMiddlewareManifest.js +0 -0
  154. /package/apps/webapp/.next/static/{1QJj5turQ_zLZgMb8ee_E → 42A-yEAAQq6m65gKOQyX1}/_ssgManifest.js +0 -0
package/dist/index.cjs CHANGED
@@ -24006,7 +24006,7 @@ var require_sonarqube_fetch_metrics_repository_json = __commonJS({
24006
24006
  }
24007
24007
  async fetchComponentTree(options) {
24008
24008
  try {
24009
- this.logger.debug(`Fetching component tree: ${JSON.stringify(options)}`);
24009
+ this.logger.debug(`Fetching component tree: ${this.describeOptions(options)}`);
24010
24010
  const componentTree = await this.sonarqubeClient.fetchComponentTree({
24011
24011
  component: options?.component,
24012
24012
  depth: options?.depth,
@@ -24021,7 +24021,7 @@ var require_sonarqube_fetch_metrics_repository_json = __commonJS({
24021
24021
  }
24022
24022
  async fetchHistoricalMeasures(options) {
24023
24023
  try {
24024
- this.logger.debug(`Fetching historical measures: ${JSON.stringify(options)}`);
24024
+ this.logger.debug(`Fetching historical measures: ${this.describeOptions(options)}`);
24025
24025
  const fromDisk = await this.historicalMeasuresJsonRepository.load();
24026
24026
  const cachedData = (0, types_1.extractLatestData)(fromDisk);
24027
24027
  const cached = Array.isArray(cachedData) ? cachedData : [];
@@ -24065,6 +24065,16 @@ var require_sonarqube_fetch_metrics_repository_json = __commonJS({
24065
24065
  if (timestamps.length === 0) return (/* @__PURE__ */ new Date(0)).toISOString();
24066
24066
  return new Date(Math.max(...timestamps)).toISOString();
24067
24067
  }
24068
+ /**
24069
+ * Formats fetch options for debug logging. When no options are provided the
24070
+ * call is expected: the client falls back to default metrics and date ranges.
24071
+ */
24072
+ describeOptions(options) {
24073
+ if (options === void 0) {
24074
+ return "no options provided \u2014 defaults will be applied";
24075
+ }
24076
+ return JSON.stringify(options);
24077
+ }
24068
24078
  mergeHistoricalMeasures(existing, incoming) {
24069
24079
  const key = /* @__PURE__ */ __name((m) => `${m.metric ?? ""}_${m.timestamp ?? ""}`, "key");
24070
24080
  const map = /* @__PURE__ */ new Map();
@@ -40748,8 +40758,8 @@ var require_dist4 = __commonJS({
40748
40758
  try {
40749
40759
  const dt = (0, date_fns_1.parseISO)(date);
40750
40760
  return (0, date_fns_1.format)(dt, "dd MMM yyyy, HH:mm");
40751
- } catch (error2) {
40752
- console.warn(`Failed to parse date: ${date}`, error2);
40761
+ } catch (error) {
40762
+ console.warn(`Failed to parse date: ${date}`, error);
40753
40763
  return date;
40754
40764
  }
40755
40765
  }
@@ -40869,11 +40879,11 @@ var require_dist4 = __commonJS({
40869
40879
  warn(message, data) {
40870
40880
  this.write("WARN", message, data, console.warn);
40871
40881
  }
40872
- error(message, error2) {
40873
- this.write("ERROR", message, error2, console.error);
40882
+ error(message, error) {
40883
+ this.write("ERROR", message, error, console.error);
40874
40884
  }
40875
- critical(message, error2) {
40876
- this.write("CRITICAL", message, error2, console.error);
40885
+ critical(message, error) {
40886
+ this.write("CRITICAL", message, error, console.error);
40877
40887
  }
40878
40888
  setLevel(level) {
40879
40889
  this.level = level;
@@ -40928,8 +40938,8 @@ var require_dist4 = __commonJS({
40928
40938
  function parseJson(json) {
40929
40939
  try {
40930
40940
  return JSON.parse(json);
40931
- } catch (error2) {
40932
- throw new Error(`Failed to parse JSON: ${error2 instanceof Error ? error2.message : String(error2)}`);
40941
+ } catch (error) {
40942
+ throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`);
40933
40943
  }
40934
40944
  }
40935
40945
  __name(parseJson, "parseJson");
@@ -40937,10 +40947,10 @@ var require_dist4 = __commonJS({
40937
40947
  function safeJsonStringify(value) {
40938
40948
  try {
40939
40949
  return JSON.stringify(value, null, 2);
40940
- } catch (error2) {
40950
+ } catch (error) {
40941
40951
  return JSON.stringify({
40942
40952
  error: "Failed to serialize",
40943
- message: error2 instanceof Error ? error2.message : String(error2)
40953
+ message: error instanceof Error ? error.message : String(error)
40944
40954
  }, null, 2);
40945
40955
  }
40946
40956
  }
@@ -42431,9 +42441,9 @@ var require_dist4 = __commonJS({
42431
42441
  this.saveGenericRecords(db, items);
42432
42442
  }
42433
42443
  db.exec("COMMIT");
42434
- } catch (error2) {
42444
+ } catch (error) {
42435
42445
  db.exec("ROLLBACK");
42436
- throw error2;
42446
+ throw error;
42437
42447
  }
42438
42448
  } finally {
42439
42449
  db.close();
@@ -42782,9 +42792,9 @@ var require_dist4 = __commonJS({
42782
42792
  await fs7.mkdir(path8.dirname(this.dbPath), {
42783
42793
  recursive: true
42784
42794
  });
42785
- } catch (error2) {
42786
- if (error2.code !== "EEXIST") {
42787
- throw error2;
42795
+ } catch (error) {
42796
+ if (error.code !== "EEXIST") {
42797
+ throw error;
42788
42798
  }
42789
42799
  }
42790
42800
  }
@@ -43434,9 +43444,9 @@ var require_dist4 = __commonJS({
43434
43444
  this.logger.info("Fetching SonarQube quality metrics...");
43435
43445
  try {
43436
43446
  return await this.sonarqubeRepository.loadAll();
43437
- } catch (error2) {
43438
- this.logger.error("Error fetching SonarQube metrics:", error2);
43439
- throw error2;
43447
+ } catch (error) {
43448
+ this.logger.error("Error fetching SonarQube metrics:", error);
43449
+ throw error;
43440
43450
  }
43441
43451
  }
43442
43452
  };
@@ -44474,10 +44484,10 @@ var require_dist4 = __commonJS({
44474
44484
  startDate: options?.startDate,
44475
44485
  endDate: options?.endDate
44476
44486
  };
44477
- } catch (error2) {
44478
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44487
+ } catch (error) {
44488
+ const errorMsg = error instanceof Error ? error.message : String(error);
44479
44489
  this.logger.error(`Failed to read code churn: ${errorMsg}`);
44480
- throw error2;
44490
+ throw error;
44481
44491
  }
44482
44492
  }
44483
44493
  async getCodeChurnHistory(options) {
@@ -44540,10 +44550,10 @@ var require_dist4 = __commonJS({
44540
44550
  }
44541
44551
  this.logger.info(`Parsed ${data.length} author churn records`);
44542
44552
  return data;
44543
- } catch (error2) {
44544
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44553
+ } catch (error) {
44554
+ const errorMsg = error instanceof Error ? error.message : String(error);
44545
44555
  this.logger.error(`Failed to read author churn: ${errorMsg}`);
44546
- throw error2;
44556
+ throw error;
44547
44557
  }
44548
44558
  }
44549
44559
  async getFileCoupling(options) {
@@ -44598,10 +44608,10 @@ var require_dist4 = __commonJS({
44598
44608
  this.logger.info(`Parsed ${coupleData.length} file coupling relationships`);
44599
44609
  const sorted = options?.sortBy === "degree" ? coupleData.sort((a, b) => b.degree - a.degree) : coupleData;
44600
44610
  return this.limitRows(sorted, options?.top);
44601
- } catch (error2) {
44602
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44611
+ } catch (error) {
44612
+ const errorMsg = error instanceof Error ? error.message : String(error);
44603
44613
  this.logger.error(`Failed to read file coupling: ${errorMsg}`);
44604
- throw error2;
44614
+ throw error;
44605
44615
  }
44606
44616
  }
44607
44617
  async getFileCouplingHistory(options) {
@@ -44622,10 +44632,10 @@ var require_dist4 = __commonJS({
44622
44632
  averageRevs: this.toNumber(record["average-revs"] || record.average_revs)
44623
44633
  })).filter((row) => row.entity.length > 0 && row.coupled.length > 0).filter((row) => this.matchesCouplingFilters(row.entity, row.coupled, options)).sort((a, b) => b.degree - a.degree);
44624
44634
  return this.limitRows(coupledData, options?.top);
44625
- } catch (error2) {
44626
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44635
+ } catch (error) {
44636
+ const errorMsg = error instanceof Error ? error.message : String(error);
44627
44637
  this.logger.error(`Failed to read layered coupling: ${errorMsg}`);
44628
- throw error2;
44638
+ throw error;
44629
44639
  }
44630
44640
  }
44631
44641
  async getLayeredCouplingHistory(options) {
@@ -44684,10 +44694,10 @@ var require_dist4 = __commonJS({
44684
44694
  };
44685
44695
  this.logger.info("CodeMaat analysis completed");
44686
44696
  return result;
44687
- } catch (error2) {
44688
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44697
+ } catch (error) {
44698
+ const errorMsg = error instanceof Error ? error.message : String(error);
44689
44699
  this.logger.error(`CodeMaat analysis failed: ${errorMsg}`);
44690
- throw error2;
44700
+ throw error;
44691
44701
  }
44692
44702
  }
44693
44703
  async getEntityChurn(options) {
@@ -44699,10 +44709,10 @@ var require_dist4 = __commonJS({
44699
44709
  deleted: this.toNumber(record.deleted),
44700
44710
  commits: this.toNumber(record.commits)
44701
44711
  })).filter((row) => row.entity.length > 0).filter((row) => this.matchesEntityFilters(row.entity, options)).sort((a, b) => b.added + b.deleted - (a.added + a.deleted)).slice(0, this.resolveLimit(options?.top, Number.POSITIVE_INFINITY));
44702
- } catch (error2) {
44703
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44712
+ } catch (error) {
44713
+ const errorMsg = error instanceof Error ? error.message : String(error);
44704
44714
  this.logger.error(`Failed to read entity churn: ${errorMsg}`);
44705
- throw error2;
44715
+ throw error;
44706
44716
  }
44707
44717
  }
44708
44718
  async getEntityChurnHistory(options) {
@@ -44727,10 +44737,10 @@ var require_dist4 = __commonJS({
44727
44737
  entity,
44728
44738
  "total-revs": totalRevs
44729
44739
  })).sort((a, b) => b["total-revs"] - a["total-revs"]).slice(0, this.resolveLimit(options?.top, Number.POSITIVE_INFINITY));
44730
- } catch (error2) {
44731
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44740
+ } catch (error) {
44741
+ const errorMsg = error instanceof Error ? error.message : String(error);
44732
44742
  this.logger.error(`Failed to read entity effort: ${errorMsg}`);
44733
- throw error2;
44743
+ throw error;
44734
44744
  }
44735
44745
  }
44736
44746
  async getEntityEffortHistory(options) {
@@ -44757,10 +44767,10 @@ var require_dist4 = __commonJS({
44757
44767
  return Array.from(new Set(rows.map((row) => row.author).filter((author) => author.length > 0))).sort((a, b) => a.localeCompare(b));
44758
44768
  }
44759
44769
  return rows.slice(0, this.resolveLimit(options?.top, Number.POSITIVE_INFINITY));
44760
- } catch (error2) {
44761
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
44770
+ } catch (error) {
44771
+ const errorMsg = error instanceof Error ? error.message : String(error);
44762
44772
  this.logger.error(`Failed to read entity ownership: ${errorMsg}`);
44763
- throw error2;
44773
+ throw error;
44764
44774
  }
44765
44775
  }
44766
44776
  async getEntityOwnershipHistory(options) {
@@ -45566,9 +45576,9 @@ var require_dist4 = __commonJS({
45566
45576
  const imported = this.importCodeChurn(db, fetchedAt, dataDirectory) + this.importAuthorChurn(db, fetchedAt, dataDirectory) + this.importFileCoupling(db, fetchedAt, dataDirectory) + this.importLayeredCoupling(db, fetchedAt, dataDirectory) + this.importEntityChurn(db, fetchedAt, dataDirectory) + this.importEntityEffort(db, fetchedAt, dataDirectory) + this.importEntityOwnership(db, fetchedAt, dataDirectory);
45567
45577
  db.exec("COMMIT");
45568
45578
  return imported;
45569
- } catch (error2) {
45579
+ } catch (error) {
45570
45580
  db.exec("ROLLBACK");
45571
- throw error2;
45581
+ throw error;
45572
45582
  }
45573
45583
  } finally {
45574
45584
  db.close();
@@ -46461,24 +46471,24 @@ var require_dist4 = __commonJS({
46461
46471
  this.rateLimitManager.updateFromHeaders(response.headers);
46462
46472
  }
46463
46473
  return response;
46464
- } catch (error2) {
46465
- if (this.isRateLimitError(error2)) {
46474
+ } catch (error) {
46475
+ if (this.isRateLimitError(error)) {
46466
46476
  if (attempt < maxRetries - 1 && this.rateLimitManager) {
46467
46477
  await this.rateLimitManager.waitForReset(attempt);
46468
46478
  continue;
46469
46479
  }
46470
- this.logger.error(`Rate limit error after ${maxRetries} retries: ${error2.response?.status}`);
46471
- throw error2;
46480
+ this.logger.error(`Rate limit error after ${maxRetries} retries: ${error.response?.status}`);
46481
+ throw error;
46472
46482
  }
46473
- if (this.isRetryableNetworkError(error2)) {
46483
+ if (this.isRetryableNetworkError(error)) {
46474
46484
  if (attempt < maxRetries - 1) {
46475
46485
  await this.waitForRetry(attempt);
46476
46486
  continue;
46477
46487
  }
46478
- this.logger.error(`Network error after ${maxRetries} retries: ${error2.message}`);
46479
- throw error2;
46488
+ this.logger.error(`Network error after ${maxRetries} retries: ${error.message}`);
46489
+ throw error;
46480
46490
  }
46481
- throw error2;
46491
+ throw error;
46482
46492
  }
46483
46493
  }
46484
46494
  throw new Error("rateLimitedGet: unexpected exit from retry loop");
@@ -46488,8 +46498,8 @@ var require_dist4 = __commonJS({
46488
46498
  * Acts as a type guard so callers can access `AxiosError` properties
46489
46499
  * without casting.
46490
46500
  */
46491
- isRateLimitError(error2) {
46492
- return axios_1.default.isAxiosError(error2) && (error2.response?.status === 429 || error2.response?.status === 403);
46501
+ isRateLimitError(error) {
46502
+ return axios_1.default.isAxiosError(error) && (error.response?.status === 429 || error.response?.status === 403);
46493
46503
  }
46494
46504
  /**
46495
46505
  * Check if the error is a transient network error that can be retried.
@@ -46505,11 +46515,11 @@ var require_dist4 = __commonJS({
46505
46515
  * Acts as a type guard so callers can access `AxiosError` properties
46506
46516
  * without casting.
46507
46517
  */
46508
- isRetryableNetworkError(error2) {
46509
- if (!axios_1.default.isAxiosError(error2)) {
46518
+ isRetryableNetworkError(error) {
46519
+ if (!axios_1.default.isAxiosError(error)) {
46510
46520
  return false;
46511
46521
  }
46512
- if (!error2.response) {
46522
+ if (!error.response) {
46513
46523
  const retryableCodes = [
46514
46524
  "ECONNRESET",
46515
46525
  "ECONNABORTED",
@@ -46518,14 +46528,14 @@ var require_dist4 = __commonJS({
46518
46528
  "ENOTFOUND",
46519
46529
  "ERR_NETWORK"
46520
46530
  ];
46521
- if (error2.code && retryableCodes.includes(error2.code)) {
46531
+ if (error.code && retryableCodes.includes(error.code)) {
46522
46532
  return true;
46523
46533
  }
46524
- if (error2.message && /socket hang up|network error/i.test(error2.message)) {
46534
+ if (error.message && /socket hang up|network error/i.test(error.message)) {
46525
46535
  return true;
46526
46536
  }
46527
46537
  }
46528
- if (error2.response && (error2.response.status === 502 || error2.response.status === 503)) {
46538
+ if (error.response && (error.response.status === 502 || error.response.status === 503)) {
46529
46539
  return true;
46530
46540
  }
46531
46541
  return false;
@@ -46670,15 +46680,15 @@ var require_dist4 = __commonJS({
46670
46680
  }
46671
46681
  this.logger.info(`Fetched ${allPRs.length} PRs total`);
46672
46682
  return allPRs;
46673
- } catch (error2) {
46674
- if (axios_1.default.isAxiosError(error2)) {
46675
- this.logger.error(`GitHub API error fetching PRs: ${error2.response?.status} - ${error2.response?.statusText}`);
46676
- if (error2.response?.status === 401) {
46683
+ } catch (error) {
46684
+ if (axios_1.default.isAxiosError(error)) {
46685
+ this.logger.error(`GitHub API error fetching PRs: ${error.response?.status} - ${error.response?.statusText}`);
46686
+ if (error.response?.status === 401) {
46677
46687
  throw new Error("GitHub authentication failed - invalid token");
46678
46688
  }
46679
- throw new Error(`Failed to fetch PRs: ${error2.message}`);
46689
+ throw new Error(`Failed to fetch PRs: ${error.message}`);
46680
46690
  }
46681
- throw error2;
46691
+ throw error;
46682
46692
  }
46683
46693
  }
46684
46694
  async fetchPRComments(prNumber) {
@@ -46706,12 +46716,12 @@ var require_dist4 = __commonJS({
46706
46716
  }
46707
46717
  this.logger.info(`Fetched ${allComments.length} comments for PR #${prNumber} total`);
46708
46718
  return allComments;
46709
- } catch (error2) {
46710
- if (axios_1.default.isAxiosError(error2)) {
46711
- this.logger.error(`GitHub API error fetching PR comments: ${error2.message}`);
46712
- throw new Error(`Failed to fetch PR comments: ${error2.message}`);
46719
+ } catch (error) {
46720
+ if (axios_1.default.isAxiosError(error)) {
46721
+ this.logger.error(`GitHub API error fetching PR comments: ${error.message}`);
46722
+ throw new Error(`Failed to fetch PR comments: ${error.message}`);
46713
46723
  }
46714
- throw error2;
46724
+ throw error;
46715
46725
  }
46716
46726
  }
46717
46727
  };
@@ -46865,15 +46875,15 @@ var require_dist4 = __commonJS({
46865
46875
  }
46866
46876
  this.logger.info(`Fetched ${allRuns.length} workflow runs total`);
46867
46877
  return allRuns;
46868
- } catch (error2) {
46869
- if (axios_1.default.isAxiosError(error2)) {
46870
- this.logger.error(`GitHub API error fetching workflows: ${error2.response?.status} - ${error2.response?.statusText}`);
46871
- if (error2.response?.status === 401) {
46878
+ } catch (error) {
46879
+ if (axios_1.default.isAxiosError(error)) {
46880
+ this.logger.error(`GitHub API error fetching workflows: ${error.response?.status} - ${error.response?.statusText}`);
46881
+ if (error.response?.status === 401) {
46872
46882
  throw new Error("GitHub authentication failed - invalid token");
46873
46883
  }
46874
- throw new Error(`Failed to fetch workflows: ${error2.message}`);
46884
+ throw new Error(`Failed to fetch workflows: ${error.message}`);
46875
46885
  }
46876
- throw error2;
46886
+ throw error;
46877
46887
  }
46878
46888
  }
46879
46889
  async fetchWorkflowsForDay(startDate, endDate, rawFilters) {
@@ -47682,8 +47692,8 @@ var require_dist4 = __commonJS({
47682
47692
  ...pipeline,
47683
47693
  ...details
47684
47694
  };
47685
- } catch (error2) {
47686
- this.logger.error(`Failed to fetch GitLab pipeline ${pipeline.id} details`, error2);
47695
+ } catch (error) {
47696
+ this.logger.error(`Failed to fetch GitLab pipeline ${pipeline.id} details`, error);
47687
47697
  return pipeline;
47688
47698
  }
47689
47699
  }
@@ -48015,19 +48025,19 @@ var require_dist4 = __commonJS({
48015
48025
  }
48016
48026
  this.logger.info(`Fetched ${allIssues.length} Jira issues total`);
48017
48027
  return allIssues;
48018
- } catch (error2) {
48019
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48028
+ } catch (error) {
48029
+ const errorMsg = error instanceof Error ? error.message : String(error);
48020
48030
  this.logger.error(`Failed to fetch Jira issues: ${errorMsg}`);
48021
- if (axios_1.default.isAxiosError(error2)) {
48022
- if (error2.response?.status === 401) {
48031
+ if (axios_1.default.isAxiosError(error)) {
48032
+ if (error.response?.status === 401) {
48023
48033
  throw new Error("Jira authentication failed. Check email and token.");
48024
- } else if (error2.response?.status === 404) {
48034
+ } else if (error.response?.status === 404) {
48025
48035
  throw new Error("Jira project not found or API endpoint not accessible.");
48026
- } else if (error2.code === "ECONNABORTED") {
48036
+ } else if (error.code === "ECONNABORTED") {
48027
48037
  throw new Error("Jira API request timeout (30s).");
48028
48038
  }
48029
48039
  }
48030
- throw error2;
48040
+ throw error;
48031
48041
  }
48032
48042
  }
48033
48043
  async fetchIssueChanges(issueKey) {
@@ -48041,15 +48051,15 @@ var require_dist4 = __commonJS({
48041
48051
  const changelog = response.data.changelog?.histories || [];
48042
48052
  this.logger.info(`Fetched ${changelog.length} changelog entries for ${issueKey}`);
48043
48053
  return changelog;
48044
- } catch (error2) {
48045
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48054
+ } catch (error) {
48055
+ const errorMsg = error instanceof Error ? error.message : String(error);
48046
48056
  this.logger.error(`Failed to fetch changelog for ${issueKey}: ${errorMsg}`);
48047
- if (axios_1.default.isAxiosError(error2)) {
48048
- if (error2.response?.status === 404) {
48057
+ if (axios_1.default.isAxiosError(error)) {
48058
+ if (error.response?.status === 404) {
48049
48059
  throw new Error(`Jira issue ${issueKey} not found.`);
48050
48060
  }
48051
48061
  }
48052
- throw error2;
48062
+ throw error;
48053
48063
  }
48054
48064
  }
48055
48065
  async fetchIssueComments(issueKey) {
@@ -48059,15 +48069,15 @@ var require_dist4 = __commonJS({
48059
48069
  const comments = response.data.comments || [];
48060
48070
  this.logger.info(`Fetched ${comments.length} comments for ${issueKey}`);
48061
48071
  return comments;
48062
- } catch (error2) {
48063
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48072
+ } catch (error) {
48073
+ const errorMsg = error instanceof Error ? error.message : String(error);
48064
48074
  this.logger.error(`Failed to fetch comments for ${issueKey}: ${errorMsg}`);
48065
- if (axios_1.default.isAxiosError(error2)) {
48066
- if (error2.response?.status === 404) {
48075
+ if (axios_1.default.isAxiosError(error)) {
48076
+ if (error.response?.status === 404) {
48067
48077
  throw new Error(`Jira issue ${issueKey} not found.`);
48068
48078
  }
48069
48079
  }
48070
- throw error2;
48080
+ throw error;
48071
48081
  }
48072
48082
  }
48073
48083
  };
@@ -48156,21 +48166,21 @@ var require_dist4 = __commonJS({
48156
48166
  }
48157
48167
  this.logger.info(`Fetched ${(component.measures || []).length} metrics for project ${this.projectKey}`);
48158
48168
  return component;
48159
- } catch (error2) {
48160
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48169
+ } catch (error) {
48170
+ const errorMsg = error instanceof Error ? error.message : String(error);
48161
48171
  this.logger.error(`Failed to fetch SonarQube measures: ${errorMsg}`);
48162
- if (axios_1.default.isAxiosError(error2)) {
48163
- if (error2.response?.status === 401) {
48172
+ if (axios_1.default.isAxiosError(error)) {
48173
+ if (error.response?.status === 401) {
48164
48174
  throw new Error("SonarQube authentication failed. Check token.");
48165
- } else if (error2.response?.status === 403) {
48175
+ } else if (error.response?.status === 403) {
48166
48176
  throw new Error(`SonarQube access denied for project ${this.projectKey}. Ensure the token user has Browse permission for this project.`);
48167
- } else if (error2.response?.status === 404) {
48177
+ } else if (error.response?.status === 404) {
48168
48178
  throw new Error(`SonarQube project ${this.projectKey} not found.`);
48169
- } else if (error2.code === "ECONNABORTED") {
48179
+ } else if (error.code === "ECONNABORTED") {
48170
48180
  throw new Error("SonarQube API request timeout (30s).");
48171
48181
  }
48172
48182
  }
48173
- throw error2;
48183
+ throw error;
48174
48184
  }
48175
48185
  }
48176
48186
  async fetchHistoricalMeasures(options) {
@@ -48236,19 +48246,19 @@ var require_dist4 = __commonJS({
48236
48246
  }
48237
48247
  this.logger.info(`Fetched ${flatMeasures.length} historical measurements for project ${this.projectKey}`);
48238
48248
  return flatMeasures;
48239
- } catch (error2) {
48240
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48249
+ } catch (error) {
48250
+ const errorMsg = error instanceof Error ? error.message : String(error);
48241
48251
  this.logger.error(`Failed to fetch SonarQube historical measures: ${errorMsg}`);
48242
- if (axios_1.default.isAxiosError(error2)) {
48243
- if (error2.response?.status === 401) {
48252
+ if (axios_1.default.isAxiosError(error)) {
48253
+ if (error.response?.status === 401) {
48244
48254
  throw new Error("SonarQube authentication failed. Check token.");
48245
- } else if (error2.response?.status === 403) {
48255
+ } else if (error.response?.status === 403) {
48246
48256
  throw new Error(`SonarQube access denied for project ${this.projectKey}. Ensure the token user has Browse permission for this project.`);
48247
- } else if (error2.code === "ECONNABORTED") {
48257
+ } else if (error.code === "ECONNABORTED") {
48248
48258
  throw new Error("SonarQube API request timeout (30s).");
48249
48259
  }
48250
48260
  }
48251
- throw error2;
48261
+ throw error;
48252
48262
  }
48253
48263
  }
48254
48264
  async fetchComponentTree(options) {
@@ -48305,21 +48315,21 @@ var require_dist4 = __commonJS({
48305
48315
  ] : allComponents;
48306
48316
  this.logger.info(`Fetched component tree with ${result.length} components for ${component}`);
48307
48317
  return result;
48308
- } catch (error2) {
48309
- const errorMsg = error2 instanceof Error ? error2.message : String(error2);
48318
+ } catch (error) {
48319
+ const errorMsg = error instanceof Error ? error.message : String(error);
48310
48320
  this.logger.error(`Failed to fetch SonarQube component tree: ${errorMsg}`);
48311
- if (axios_1.default.isAxiosError(error2)) {
48312
- if (error2.response?.status === 401) {
48321
+ if (axios_1.default.isAxiosError(error)) {
48322
+ if (error.response?.status === 401) {
48313
48323
  throw new Error("SonarQube authentication failed. Check token.");
48314
- } else if (error2.response?.status === 403) {
48324
+ } else if (error.response?.status === 403) {
48315
48325
  throw new Error(`SonarQube access denied for component ${options?.component || this.projectKey}. Ensure the token user has Browse permission for this project/component.`);
48316
- } else if (error2.response?.status === 404) {
48326
+ } else if (error.response?.status === 404) {
48317
48327
  throw new Error(`SonarQube component ${options?.component || this.projectKey} not found.`);
48318
- } else if (error2.code === "ECONNABORTED") {
48328
+ } else if (error.code === "ECONNABORTED") {
48319
48329
  throw new Error("SonarQube API request timeout (30s).");
48320
48330
  }
48321
48331
  }
48322
- throw error2;
48332
+ throw error;
48323
48333
  }
48324
48334
  }
48325
48335
  };
@@ -48364,7 +48374,7 @@ var require_dist4 = __commonJS({
48364
48374
  }
48365
48375
  async fetchComponentTree(options) {
48366
48376
  try {
48367
- this.logger.debug(`Fetching component tree: ${JSON.stringify(options)}`);
48377
+ this.logger.debug(`Fetching component tree: ${this.describeOptions(options)}`);
48368
48378
  const componentTree = await this.sonarqubeClient.fetchComponentTree({
48369
48379
  component: options?.component,
48370
48380
  depth: options?.depth,
@@ -48372,14 +48382,14 @@ var require_dist4 = __commonJS({
48372
48382
  });
48373
48383
  await this.appendTimestampedEntry(this.componentTreeJsonRepository, componentTree);
48374
48384
  return componentTree;
48375
- } catch (error2) {
48376
- this.logger.error(`Failed to fetch component tree: ${error2}`, error2 instanceof Error ? error2.stack : "");
48377
- throw new Error(`Failed to fetch component tree: ${error2 instanceof Error ? error2.message : String(error2)}`);
48385
+ } catch (error) {
48386
+ this.logger.error(`Failed to fetch component tree: ${error}`, error instanceof Error ? error.stack : "");
48387
+ throw new Error(`Failed to fetch component tree: ${error instanceof Error ? error.message : String(error)}`);
48378
48388
  }
48379
48389
  }
48380
48390
  async fetchHistoricalMeasures(options) {
48381
48391
  try {
48382
- this.logger.debug(`Fetching historical measures: ${JSON.stringify(options)}`);
48392
+ this.logger.debug(`Fetching historical measures: ${this.describeOptions(options)}`);
48383
48393
  const fromDisk = await this.historicalMeasuresJsonRepository.load();
48384
48394
  const cachedData = (0, types_1.extractLatestData)(fromDisk);
48385
48395
  const cached = Array.isArray(cachedData) ? cachedData : [];
@@ -48413,9 +48423,9 @@ var require_dist4 = __commonJS({
48413
48423
  const historical = await this.sonarqubeClient.fetchHistoricalMeasures(options);
48414
48424
  await this.appendTimestampedEntry(this.historicalMeasuresJsonRepository, historical);
48415
48425
  return historical;
48416
- } catch (error2) {
48417
- this.logger.error(`Failed to fetch historical measures: ${error2}`, error2 instanceof Error ? error2.stack : "");
48418
- throw new Error(`Failed to fetch historical measures: ${error2 instanceof Error ? error2.message : String(error2)}`);
48426
+ } catch (error) {
48427
+ this.logger.error(`Failed to fetch historical measures: ${error}`, error instanceof Error ? error.stack : "");
48428
+ throw new Error(`Failed to fetch historical measures: ${error instanceof Error ? error.message : String(error)}`);
48419
48429
  }
48420
48430
  }
48421
48431
  findLatestDateInMeasures(measures) {
@@ -48423,6 +48433,16 @@ var require_dist4 = __commonJS({
48423
48433
  if (timestamps.length === 0) return (/* @__PURE__ */ new Date(0)).toISOString();
48424
48434
  return new Date(Math.max(...timestamps)).toISOString();
48425
48435
  }
48436
+ /**
48437
+ * Formats fetch options for debug logging. When no options are provided the
48438
+ * call is expected: the client falls back to default metrics and date ranges.
48439
+ */
48440
+ describeOptions(options) {
48441
+ if (options === void 0) {
48442
+ return "no options provided \u2014 defaults will be applied";
48443
+ }
48444
+ return JSON.stringify(options);
48445
+ }
48426
48446
  mergeHistoricalMeasures(existing, incoming) {
48427
48447
  const key = /* @__PURE__ */ __name2((m) => `${m.metric ?? ""}_${m.timestamp ?? ""}`, "key");
48428
48448
  const map = /* @__PURE__ */ new Map();
@@ -51673,12 +51693,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
51673
51693
  };
51674
51694
  ee.Ignore = Ae;
51675
51695
  });
51676
- var Fs = R((z) => {
51696
+ var Fs = R((z2) => {
51677
51697
  "use strict";
51678
- Object.defineProperty(z, "__esModule", {
51698
+ Object.defineProperty(z2, "__esModule", {
51679
51699
  value: true
51680
51700
  });
51681
- z.Processor = z.SubWalks = z.MatchRecord = z.HasWalkedCache = void 0;
51701
+ z2.Processor = z2.SubWalks = z2.MatchRecord = z2.HasWalkedCache = void 0;
51682
51702
  var Ds = H(), se = class n {
51683
51703
  static {
51684
51704
  __name(this, "n");
@@ -51703,7 +51723,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
51703
51723
  ]));
51704
51724
  }
51705
51725
  };
51706
- z.HasWalkedCache = se;
51726
+ z2.HasWalkedCache = se;
51707
51727
  var ie = class {
51708
51728
  static {
51709
51729
  __name(this, "ie");
@@ -51726,7 +51746,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
51726
51746
  ]);
51727
51747
  }
51728
51748
  };
51729
- z.MatchRecord = ie;
51749
+ z2.MatchRecord = ie;
51730
51750
  var re = class {
51731
51751
  static {
51732
51752
  __name(this, "re");
@@ -51759,7 +51779,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
51759
51779
  ].filter((t) => t.canReaddir());
51760
51780
  }
51761
51781
  };
51762
- z.SubWalks = re;
51782
+ z2.SubWalks = re;
51763
51783
  var Me = class n {
51764
51784
  static {
51765
51785
  __name(this, "n");
@@ -51849,7 +51869,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
51849
51869
  t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
51850
51870
  }
51851
51871
  };
51852
- z.Processor = Me;
51872
+ z2.Processor = Me;
51853
51873
  });
51854
51874
  var Ls = R((X) => {
51855
51875
  "use strict";
@@ -53569,8 +53589,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
53569
53589
  this.logger.info(`\u{1F9F9} Removing existing local SonarQube data at "${this.localDataFilePath}" to ensure clean state.`);
53570
53590
  try {
53571
53591
  (0, node_fs_1.unlinkSync)(this.localDataFilePath);
53572
- } catch (error2) {
53573
- this.logger.warn(`Failed to clear local SonarQube data at "${this.localDataFilePath}". You may want to delete this file manually: ${error2}`);
53592
+ } catch (error) {
53593
+ this.logger.warn(`Failed to clear local SonarQube data at "${this.localDataFilePath}". You may want to delete this file manually: ${error}`);
53574
53594
  }
53575
53595
  }
53576
53596
  }
@@ -53758,12 +53778,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
53758
53778
  pairedCommits,
53759
53779
  commits: filtered
53760
53780
  };
53761
- } catch (error2) {
53762
- if (error2 instanceof Error) {
53763
- this.logger.error(`Error traversing commits: ${error2.message}`);
53764
- throw new Error(`Failed to traverse commits: ${error2.message}`);
53781
+ } catch (error) {
53782
+ if (error instanceof Error) {
53783
+ this.logger.error(`Error traversing commits: ${error.message}`);
53784
+ throw new Error(`Failed to traverse commits: ${error.message}`);
53765
53785
  }
53766
- throw error2;
53786
+ throw error;
53767
53787
  }
53768
53788
  }
53769
53789
  /**
@@ -53799,12 +53819,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
53799
53819
  });
53800
53820
  const commits = this.parseCommitOutput(output.toString());
53801
53821
  return commits;
53802
- } catch (error2) {
53803
- if (error2 instanceof Error) {
53804
- this.logger.error(`Git command failed: ${error2.message}`);
53805
- throw error2;
53822
+ } catch (error) {
53823
+ if (error instanceof Error) {
53824
+ this.logger.error(`Git command failed: ${error.message}`);
53825
+ throw error;
53806
53826
  }
53807
- throw error2;
53827
+ throw error;
53808
53828
  }
53809
53829
  }
53810
53830
  /**
@@ -59839,8 +59859,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
59839
59859
  await this.writeJson(progressPath, {
59840
59860
  page
59841
59861
  });
59842
- } catch (error2) {
59843
- if (this.isUnprocessableEntityError(error2)) {
59862
+ } catch (error) {
59863
+ if (this.isUnprocessableEntityError(error)) {
59844
59864
  this.logger.info(`GitHub returned 422 while fetching workflows page ${page}; treating as pagination end.`);
59845
59865
  await this.writeJson(incompletedPath, runs);
59846
59866
  await this.writeJson(progressPath, {
@@ -59852,7 +59872,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
59852
59872
  await this.writeJson(progressPath, {
59853
59873
  page
59854
59874
  });
59855
- throw error2;
59875
+ throw error;
59856
59876
  }
59857
59877
  }
59858
59878
  await this.deleteFile(progressPath);
@@ -59880,11 +59900,11 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
59880
59900
  try {
59881
59901
  const contents = await fs7.readFile(filePath, "utf-8");
59882
59902
  return JSON.parse(contents);
59883
- } catch (error2) {
59884
- if (error2.code === "ENOENT") {
59903
+ } catch (error) {
59904
+ if (error.code === "ENOENT") {
59885
59905
  return fallback;
59886
59906
  }
59887
- throw error2;
59907
+ throw error;
59888
59908
  }
59889
59909
  }
59890
59910
  async writeJson(filePath, value) {
@@ -59896,17 +59916,17 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
59896
59916
  async deleteFile(filePath) {
59897
59917
  try {
59898
59918
  await fs7.unlink(filePath);
59899
- } catch (error2) {
59900
- if (error2.code !== "ENOENT") {
59901
- throw error2;
59919
+ } catch (error) {
59920
+ if (error.code !== "ENOENT") {
59921
+ throw error;
59902
59922
  }
59903
59923
  }
59904
59924
  }
59905
- isUnprocessableEntityError(error2) {
59906
- if (!error2 || typeof error2 !== "object") {
59925
+ isUnprocessableEntityError(error) {
59926
+ if (!error || typeof error !== "object") {
59907
59927
  return false;
59908
59928
  }
59909
- const maybeError = error2;
59929
+ const maybeError = error;
59910
59930
  return maybeError.status === 422 || maybeError.response?.status === 422;
59911
59931
  }
59912
59932
  };
@@ -60155,8 +60175,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
60155
60175
  partial: null
60156
60176
  });
60157
60177
  break;
60158
- } catch (error2) {
60159
- const statusCode = this.getHttpStatusCode(error2);
60178
+ } catch (error) {
60179
+ const statusCode = this.getHttpStatusCode(error);
60160
60180
  if (statusCode === 404 || statusCode === 502) {
60161
60181
  this.logger.error(`Skipping workflow run ${runId} at page ${page}: jobs endpoint returned ${statusCode}. This run will be marked as processed to avoid blocking the pipeline, but its jobs will not be included.`);
60162
60182
  processedRunIds.add(runId);
@@ -60175,7 +60195,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
60175
60195
  page
60176
60196
  }
60177
60197
  });
60178
- throw error2;
60198
+ throw error;
60179
60199
  }
60180
60200
  }
60181
60201
  }
@@ -60203,11 +60223,11 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
60203
60223
  try {
60204
60224
  const contents = await fs7.readFile(filePath, "utf-8");
60205
60225
  return JSON.parse(contents);
60206
- } catch (error2) {
60207
- if (error2.code === "ENOENT") {
60226
+ } catch (error) {
60227
+ if (error.code === "ENOENT") {
60208
60228
  return fallback;
60209
60229
  }
60210
- throw error2;
60230
+ throw error;
60211
60231
  }
60212
60232
  }
60213
60233
  async writeJson(filePath, value) {
@@ -60219,14 +60239,14 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
60219
60239
  async deleteFile(filePath) {
60220
60240
  try {
60221
60241
  await fs7.unlink(filePath);
60222
- } catch (error2) {
60223
- if (error2.code !== "ENOENT") {
60224
- throw error2;
60242
+ } catch (error) {
60243
+ if (error.code !== "ENOENT") {
60244
+ throw error;
60225
60245
  }
60226
60246
  }
60227
60247
  }
60228
- getHttpStatusCode(error2) {
60229
- const err = error2;
60248
+ getHttpStatusCode(error) {
60249
+ const err = error;
60230
60250
  return err?.status ?? err?.response?.status;
60231
60251
  }
60232
60252
  toDateBoundary(dateValue, boundary = "start") {
@@ -64283,12 +64303,14 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64283
64303
  buildIssueMetricsInputSchema: /* @__PURE__ */ __name(() => buildIssueMetricsInputSchema, "buildIssueMetricsInputSchema"),
64284
64304
  buildMetricsInputSchema: /* @__PURE__ */ __name(() => buildMetricsInputSchema, "buildMetricsInputSchema"),
64285
64305
  buildPipelineDashboardInputSchema: /* @__PURE__ */ __name(() => buildPipelineDashboardInputSchema, "buildPipelineDashboardInputSchema"),
64306
+ buildSavedFilterGetInputSchema: /* @__PURE__ */ __name(() => buildSavedFilterGetInputSchema, "buildSavedFilterGetInputSchema"),
64307
+ buildSavedFilterListInputSchema: /* @__PURE__ */ __name(() => buildSavedFilterListInputSchema, "buildSavedFilterListInputSchema"),
64286
64308
  buildSonarqubeComponentTreeInputSchema: /* @__PURE__ */ __name(() => buildSonarqubeComponentTreeInputSchema, "buildSonarqubeComponentTreeInputSchema"),
64287
64309
  configureMcpLogging: /* @__PURE__ */ __name(() => configureMcpLogging, "configureMcpLogging"),
64288
64310
  createMcpMetricsReader: /* @__PURE__ */ __name(() => createMcpMetricsReader, "createMcpMetricsReader"),
64311
+ createMcpServer: /* @__PURE__ */ __name(() => createMcpServer, "createMcpServer"),
64289
64312
  findTool: /* @__PURE__ */ __name(() => findTool, "findTool"),
64290
64313
  getPrompt: /* @__PURE__ */ __name(() => getPrompt, "getPrompt"),
64291
- handleRequest: /* @__PURE__ */ __name(() => handleRequest, "handleRequest"),
64292
64314
  listEngineeringHealthMetricCatalog: /* @__PURE__ */ __name(() => listEngineeringHealthMetricCatalog, "listEngineeringHealthMetricCatalog"),
64293
64315
  listResourceTemplates: /* @__PURE__ */ __name(() => listResourceTemplates, "listResourceTemplates"),
64294
64316
  listResources: /* @__PURE__ */ __name(() => listResources, "listResources"),
@@ -64306,18 +64328,25 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64306
64328
  parseIssueMetricsArguments: /* @__PURE__ */ __name(() => parseIssueMetricsArguments, "parseIssueMetricsArguments"),
64307
64329
  parseMetricsToolArguments: /* @__PURE__ */ __name(() => parseMetricsToolArguments, "parseMetricsToolArguments"),
64308
64330
  parsePipelineDashboardArguments: /* @__PURE__ */ __name(() => parsePipelineDashboardArguments, "parsePipelineDashboardArguments"),
64331
+ parseSavedFilterGetArguments: /* @__PURE__ */ __name(() => parseSavedFilterGetArguments, "parseSavedFilterGetArguments"),
64332
+ parseSavedFilterListArguments: /* @__PURE__ */ __name(() => parseSavedFilterListArguments, "parseSavedFilterListArguments"),
64309
64333
  parseSonarqubeComponentTreeArguments: /* @__PURE__ */ __name(() => parseSonarqubeComponentTreeArguments, "parseSonarqubeComponentTreeArguments"),
64310
64334
  prompts: /* @__PURE__ */ __name(() => prompts, "prompts"),
64311
64335
  readResource: /* @__PURE__ */ __name(() => readResource, "readResource"),
64312
64336
  readString: /* @__PURE__ */ __name(() => readString, "readString"),
64313
64337
  redactSecrets: /* @__PURE__ */ __name(() => redactSecrets, "redactSecrets"),
64314
64338
  redirectConsoleToStderr: /* @__PURE__ */ __name(() => redirectConsoleToStderr, "redirectConsoleToStderr"),
64339
+ registerAll: /* @__PURE__ */ __name(() => registerAll, "registerAll"),
64340
+ registerPrompts: /* @__PURE__ */ __name(() => registerPrompts, "registerPrompts"),
64341
+ registerResources: /* @__PURE__ */ __name(() => registerResources, "registerResources"),
64342
+ registerTools: /* @__PURE__ */ __name(() => registerTools, "registerTools"),
64315
64343
  resolveMcpLogLevel: /* @__PURE__ */ __name(() => resolveMcpLogLevel, "resolveMcpLogLevel"),
64316
64344
  startMcpServer: /* @__PURE__ */ __name(() => startMcpServer2, "startMcpServer"),
64317
64345
  tools: /* @__PURE__ */ __name(() => tools, "tools")
64318
64346
  });
64319
64347
  module2.exports = __toCommonJS2(src_exports2);
64320
- var import_node_readline2 = require("node:readline");
64348
+ var import_server2 = require("@modelcontextprotocol/server");
64349
+ var import_stdio = require("@modelcontextprotocol/server/stdio");
64321
64350
  var import_utils52 = __toESM2(require_dist5());
64322
64351
  var import_core42 = __toESM2(require_dist22());
64323
64352
  var import_utils9 = __toESM2(require_dist5());
@@ -64396,216 +64425,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64396
64425
  var toolLogger = new import_utils9.Logger("SmmMcpTool", mcpLogLevel);
64397
64426
  var resourceLogger = new import_utils9.Logger("SmmMcpResource", mcpLogLevel);
64398
64427
  var promptLogger = new import_utils9.Logger("SmmMcpPrompt", mcpLogLevel);
64399
- var prompts = [
64400
- {
64401
- name: "smm_sprint_health_review",
64402
- description: "Review engineering health for the current sprint and highlight metrics that need attention.",
64403
- arguments: [
64404
- {
64405
- name: "project",
64406
- description: "Optional github_repository project name from smm_config.json.",
64407
- required: false
64408
- },
64409
- {
64410
- name: "startDate",
64411
- description: "Current window start date (YYYY-MM-DD).",
64412
- required: false
64413
- },
64414
- {
64415
- name: "endDate",
64416
- description: "Current window end date (YYYY-MM-DD).",
64417
- required: false
64418
- }
64419
- ]
64420
- },
64421
- {
64422
- name: "smm_compare_windows",
64423
- description: "Compare engineering health between two time windows and summarise what improved or regressed.",
64424
- arguments: [
64425
- {
64426
- name: "project",
64427
- description: "Optional github_repository project name from smm_config.json.",
64428
- required: false
64429
- },
64430
- {
64431
- name: "startDate",
64432
- description: "Current window start date (YYYY-MM-DD).",
64433
- required: true
64434
- },
64435
- {
64436
- name: "endDate",
64437
- description: "Current window end date (YYYY-MM-DD).",
64438
- required: true
64439
- },
64440
- {
64441
- name: "compareStartDate",
64442
- description: "Previous window start date (YYYY-MM-DD).",
64443
- required: true
64444
- },
64445
- {
64446
- name: "compareEndDate",
64447
- description: "Previous window end date (YYYY-MM-DD).",
64448
- required: true
64449
- }
64450
- ]
64451
- },
64452
- {
64453
- name: "smm_dora_summary",
64454
- description: "Summarise DORA metrics for a project, including deployment frequency and failure rate.",
64455
- arguments: [
64456
- {
64457
- name: "project",
64458
- description: "Optional github_repository project name from smm_config.json.",
64459
- required: false
64460
- },
64461
- {
64462
- name: "startDate",
64463
- description: "Optional window start date (YYYY-MM-DD).",
64464
- required: false
64465
- },
64466
- {
64467
- name: "endDate",
64468
- description: "Optional window end date (YYYY-MM-DD).",
64469
- required: false
64470
- }
64471
- ]
64472
- },
64473
- {
64474
- name: "smm_code_hotspots",
64475
- description: "Identify code hotspots (high churn and high coupling files) and pair-programming gaps for a project.",
64476
- arguments: [
64477
- {
64478
- name: "project",
64479
- description: "Optional github_repository project name from smm_config.json.",
64480
- required: false
64481
- },
64482
- {
64483
- name: "startDate",
64484
- description: "Optional window start date (YYYY-MM-DD).",
64485
- required: false
64486
- },
64487
- {
64488
- name: "endDate",
64489
- description: "Optional window end date (YYYY-MM-DD).",
64490
- required: false
64491
- }
64492
- ]
64493
- }
64494
- ];
64495
- function getArg(values, name) {
64496
- const value = values[name];
64497
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
64498
- }
64499
- __name(getArg, "getArg");
64500
- __name2(getArg, "getArg");
64501
- function optional(value) {
64502
- return value ? value : "<not provided>";
64503
- }
64504
- __name(optional, "optional");
64505
- __name2(optional, "optional");
64506
- async function getPrompt(name, argumentsValue) {
64507
- promptLogger.debug(`Building prompt ${name}`, {
64508
- arguments: argumentsValue
64509
- });
64510
- const values = argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue) ? argumentsValue : {};
64511
- const project = getArg(values, "project");
64512
- const startDate = getArg(values, "startDate");
64513
- const endDate = getArg(values, "endDate");
64514
- const compareStartDate = getArg(values, "compareStartDate");
64515
- const compareEndDate = getArg(values, "compareEndDate");
64516
- const messages = [];
64517
- switch (name) {
64518
- case "smm_sprint_health_review":
64519
- messages.push({
64520
- role: "user",
64521
- content: {
64522
- type: "text",
64523
- text: [
64524
- "You are acting as a software engineering coach.",
64525
- "Use the Software Metrics Machine MCP tools to evaluate the engineering health of the project.",
64526
- "",
64527
- `Project: ${optional(project)}`,
64528
- `Current window: ${optional(startDate)} to ${optional(endDate)}`,
64529
- "",
64530
- "Steps:",
64531
- "1. Call smm_get_engineering_health with the filters above.",
64532
- '2. Highlight any metric whose recommendation level is "watch" or "critical".',
64533
- "3. Suggest one concrete action for each degraded metric, grounded in the data returned."
64534
- ].join("\n")
64535
- }
64536
- });
64537
- break;
64538
- case "smm_compare_windows":
64539
- messages.push({
64540
- role: "user",
64541
- content: {
64542
- type: "text",
64543
- text: [
64544
- "You are acting as a software engineering coach.",
64545
- "Use the Software Metrics Machine MCP tools to compare two windows.",
64546
- "",
64547
- `Project: ${optional(project)}`,
64548
- `Current window: ${optional(startDate)} to ${optional(endDate)}`,
64549
- `Previous window: ${optional(compareStartDate)} to ${optional(compareEndDate)}`,
64550
- "",
64551
- "Steps:",
64552
- "1. Call smm_get_engineering_health with startDate, endDate, compareStartDate, and compareEndDate.",
64553
- "2. For each metric, summarise whether the trend is improving, stable, or degrading.",
64554
- "3. Produce a short before/after table and a prioritised list of follow-up actions."
64555
- ].join("\n")
64556
- }
64557
- });
64558
- break;
64559
- case "smm_dora_summary":
64560
- messages.push({
64561
- role: "user",
64562
- content: {
64563
- type: "text",
64564
- text: [
64565
- "You are acting as a DORA metrics analyst.",
64566
- "Use the Software Metrics Machine MCP tools to report DORA metrics.",
64567
- "",
64568
- `Project: ${optional(project)}`,
64569
- `Window: ${optional(startDate)} to ${optional(endDate)}`,
64570
- "",
64571
- "Steps:",
64572
- "1. Call smm_get_dora_metrics with the filters above.",
64573
- "2. Report deployment frequency, failure rate signals, and pipeline duration.",
64574
- "3. Classify the project against the DORA tiers (elite, high, medium, low) where possible."
64575
- ].join("\n")
64576
- }
64577
- });
64578
- break;
64579
- case "smm_code_hotspots":
64580
- messages.push({
64581
- role: "user",
64582
- content: {
64583
- type: "text",
64584
- text: [
64585
- "You are acting as a code health reviewer.",
64586
- "Use the Software Metrics Machine MCP tools to surface code hotspots.",
64587
- "",
64588
- `Project: ${optional(project)}`,
64589
- `Window: ${optional(startDate)} to ${optional(endDate)}`,
64590
- "",
64591
- "Steps:",
64592
- "1. Call smm_get_code_metrics to retrieve churn, coupling, and pairing data.",
64593
- "2. Identify files with the highest churn and strongest coupling.",
64594
- "3. Cross-reference pairing gaps and propose concrete refactoring or pairing actions."
64595
- ].join("\n")
64596
- }
64597
- });
64598
- break;
64599
- default:
64600
- throw new Error(`Unknown MCP prompt: ${name}`);
64601
- }
64602
- return {
64603
- description: prompts.find((prompt2) => prompt2.name === name)?.description,
64604
- messages
64605
- };
64606
- }
64607
- __name(getPrompt, "getPrompt");
64608
- __name2(getPrompt, "getPrompt");
64428
+ var import_server = require("@modelcontextprotocol/server");
64429
+ var import_zod = require("zod");
64609
64430
  var import_core22 = __toESM2(require_dist22());
64610
64431
  var import_utils32 = __toESM2(require_dist5());
64611
64432
  var import_core21 = __toESM2(require_dist22());
@@ -64795,6 +64616,13 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64795
64616
  "include",
64796
64617
  "flag",
64797
64618
  "exclude"
64619
+ ]),
64620
+ rawFilters: readString(args.rawFilters, "rawFilters"),
64621
+ filter: readString(args.filter, "filter"),
64622
+ period: readEnum(args.period, "period", [
64623
+ "day",
64624
+ "week",
64625
+ "month"
64798
64626
  ])
64799
64627
  };
64800
64628
  }
@@ -64837,7 +64665,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64837
64665
  "include",
64838
64666
  "flag",
64839
64667
  "exclude"
64840
- ])
64668
+ ]),
64669
+ rawFilters: readString(args.rawFilters, "rawFilters"),
64670
+ filter: readString(args.filter, "filter")
64841
64671
  };
64842
64672
  }
64843
64673
  __name(parseChangeRequestMetricsArguments, "parseChangeRequestMetricsArguments");
@@ -64866,6 +64696,13 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64866
64696
  "include",
64867
64697
  "flag",
64868
64698
  "exclude"
64699
+ ]),
64700
+ rawFilters: readString(args.rawFilters, "rawFilters"),
64701
+ filter: readString(args.filter, "filter"),
64702
+ period: readEnum(args.period, "period", [
64703
+ "day",
64704
+ "week",
64705
+ "month"
64869
64706
  ])
64870
64707
  };
64871
64708
  }
@@ -64881,7 +64718,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64881
64718
  ignorePatterns: readString(args.ignorePatterns, "ignorePatterns"),
64882
64719
  includePatterns: readString(args.includePatterns, "includePatterns"),
64883
64720
  top: readNumber(args.top, "top"),
64884
- authors: readString(args.authors, "authors")
64721
+ authors: readString(args.authors, "authors"),
64722
+ minCoupling: readNumber(args.minCoupling, "minCoupling"),
64723
+ entity: readString(args.entity, "entity")
64885
64724
  };
64886
64725
  }
64887
64726
  __name(parseCodeEntityArguments, "parseCodeEntityArguments");
@@ -64891,7 +64730,11 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64891
64730
  if (!args) {
64892
64731
  return {};
64893
64732
  }
64894
- return parseMetricsToolArguments(args);
64733
+ return {
64734
+ ...parseMetricsToolArguments(args),
64735
+ authors: readString(args.authors, "authors"),
64736
+ minShared: readNumber(args.minShared, "minShared")
64737
+ };
64895
64738
  }
64896
64739
  __name(parseCodeHistoryArguments, "parseCodeHistoryArguments");
64897
64740
  __name2(parseCodeHistoryArguments, "parseCodeHistoryArguments");
@@ -64976,6 +64819,42 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
64976
64819
  }
64977
64820
  __name(parseHealthCheckArguments, "parseHealthCheckArguments");
64978
64821
  __name2(parseHealthCheckArguments, "parseHealthCheckArguments");
64822
+ function parseSavedFilterListArguments(argumentsValue) {
64823
+ const args = readObject(argumentsValue);
64824
+ if (!args) {
64825
+ return {};
64826
+ }
64827
+ return {
64828
+ project: readString(args.project, "project"),
64829
+ section: readEnum(args.section, "section", [
64830
+ "insights",
64831
+ "pipelines",
64832
+ "change-requests",
64833
+ "source-code",
64834
+ "engineering-health",
64835
+ "architecture",
64836
+ "sonarqube"
64837
+ ])
64838
+ };
64839
+ }
64840
+ __name(parseSavedFilterListArguments, "parseSavedFilterListArguments");
64841
+ __name2(parseSavedFilterListArguments, "parseSavedFilterListArguments");
64842
+ function parseSavedFilterGetArguments(argumentsValue) {
64843
+ const args = readObject(argumentsValue);
64844
+ if (!args) {
64845
+ throw new Error("name is required");
64846
+ }
64847
+ const name = readString(args.name, "name");
64848
+ if (!name) {
64849
+ throw new Error("name is required");
64850
+ }
64851
+ return {
64852
+ project: readString(args.project, "project"),
64853
+ name
64854
+ };
64855
+ }
64856
+ __name(parseSavedFilterGetArguments, "parseSavedFilterGetArguments");
64857
+ __name2(parseSavedFilterGetArguments, "parseSavedFilterGetArguments");
64979
64858
  function buildMetricsInputSchema(description) {
64980
64859
  return {
64981
64860
  type: "object",
@@ -65192,6 +65071,23 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65192
65071
  "exclude"
65193
65072
  ],
65194
65073
  description: "Outlier handling mode. Defaults to include."
65074
+ },
65075
+ rawFilters: {
65076
+ type: "string",
65077
+ description: "Optional raw provider filter string (e.g. status=success,branch=main). Passed through to the provider."
65078
+ },
65079
+ filter: {
65080
+ type: "string",
65081
+ description: "Optional saved filter name or id. When set, missing filter fields are filled from the saved filter."
65082
+ },
65083
+ period: {
65084
+ type: "string",
65085
+ enum: [
65086
+ "day",
65087
+ "week",
65088
+ "month"
65089
+ ],
65090
+ description: "Optional DORA rating period: day (elite), week (high), month (medium). Defaults to week."
65195
65091
  }
65196
65092
  }
65197
65093
  };
@@ -65311,6 +65207,56 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65311
65207
  }
65312
65208
  __name(buildHealthCheckInputSchema, "buildHealthCheckInputSchema");
65313
65209
  __name2(buildHealthCheckInputSchema, "buildHealthCheckInputSchema");
65210
+ function buildSavedFilterListInputSchema() {
65211
+ return {
65212
+ type: "object",
65213
+ description: "Saved filters list filters.",
65214
+ additionalProperties: false,
65215
+ properties: {
65216
+ project: {
65217
+ type: "string",
65218
+ description: "Optional github_repository project name from smm_config.json."
65219
+ },
65220
+ section: {
65221
+ type: "string",
65222
+ enum: [
65223
+ "insights",
65224
+ "pipelines",
65225
+ "change-requests",
65226
+ "source-code",
65227
+ "engineering-health",
65228
+ "architecture",
65229
+ "sonarqube"
65230
+ ],
65231
+ description: "Optional dashboard section filter. Only saved filters in this section are returned."
65232
+ }
65233
+ }
65234
+ };
65235
+ }
65236
+ __name(buildSavedFilterListInputSchema, "buildSavedFilterListInputSchema");
65237
+ __name2(buildSavedFilterListInputSchema, "buildSavedFilterListInputSchema");
65238
+ function buildSavedFilterGetInputSchema() {
65239
+ return {
65240
+ type: "object",
65241
+ description: "Saved filter lookup by name or id.",
65242
+ additionalProperties: false,
65243
+ required: [
65244
+ "name"
65245
+ ],
65246
+ properties: {
65247
+ project: {
65248
+ type: "string",
65249
+ description: "Optional github_repository project name from smm_config.json."
65250
+ },
65251
+ name: {
65252
+ type: "string",
65253
+ description: "Required saved filter name or id to look up."
65254
+ }
65255
+ }
65256
+ };
65257
+ }
65258
+ __name(buildSavedFilterGetInputSchema, "buildSavedFilterGetInputSchema");
65259
+ __name2(buildSavedFilterGetInputSchema, "buildSavedFilterGetInputSchema");
65314
65260
  function buildEvaluationInputSchema(description) {
65315
65261
  return {
65316
65262
  type: "object",
@@ -65417,6 +65363,14 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65417
65363
  "exclude"
65418
65364
  ],
65419
65365
  description: "Optional outlier handling mode."
65366
+ },
65367
+ rawFilters: {
65368
+ type: "string",
65369
+ description: "Optional raw provider filter string (e.g. status=draft,author=john). Passed through to the provider."
65370
+ },
65371
+ filter: {
65372
+ type: "string",
65373
+ description: "Optional saved filter name or id. When set, missing filter fields are filled from the saved filter."
65420
65374
  }
65421
65375
  }
65422
65376
  };
@@ -65497,6 +65451,23 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65497
65451
  "exclude"
65498
65452
  ],
65499
65453
  description: "Optional outlier handling mode."
65454
+ },
65455
+ rawFilters: {
65456
+ type: "string",
65457
+ description: "Optional raw provider filter string (e.g. status=success,branch=main). Passed through to the provider."
65458
+ },
65459
+ filter: {
65460
+ type: "string",
65461
+ description: "Optional saved filter name or id. When set, missing filter fields are filled from the saved filter."
65462
+ },
65463
+ period: {
65464
+ type: "string",
65465
+ enum: [
65466
+ "day",
65467
+ "week",
65468
+ "month"
65469
+ ],
65470
+ description: "Optional aggregation period for runs_by time series. Defaults to day (raw per-day)."
65500
65471
  }
65501
65472
  }
65502
65473
  };
@@ -65532,6 +65503,22 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65532
65503
  authors: {
65533
65504
  type: "string",
65534
65505
  description: "Optional comma-separated authors filter (entity ownership only)."
65506
+ },
65507
+ minCoupling: {
65508
+ type: "number",
65509
+ description: "Optional minimum coupling threshold (0-100). Filters coupling relationships below this degree."
65510
+ },
65511
+ entity: {
65512
+ type: "string",
65513
+ description: "Optional entity/file substring filter. Only entities containing this string are returned."
65514
+ },
65515
+ startDate: {
65516
+ type: "string",
65517
+ description: "Optional ISO 8601 start date."
65518
+ },
65519
+ endDate: {
65520
+ type: "string",
65521
+ description: "Optional ISO 8601 end date."
65535
65522
  }
65536
65523
  }
65537
65524
  };
@@ -65559,6 +65546,14 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65559
65546
  endDate: {
65560
65547
  type: "string",
65561
65548
  description: "Optional ISO 8601 end date."
65549
+ },
65550
+ authors: {
65551
+ type: "string",
65552
+ description: "Optional comma-separated authors filter. When set on code churn, returns per-author churn."
65553
+ },
65554
+ minShared: {
65555
+ type: "number",
65556
+ description: "Optional minimum shared commits for pairing index. Defaults to 0 (all pairs included)."
65562
65557
  }
65563
65558
  }
65564
65559
  };
@@ -65701,13 +65696,13 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65701
65696
  durationMs: Date.now() - startedAt
65702
65697
  });
65703
65698
  return result;
65704
- } catch (error2) {
65699
+ } catch (error) {
65705
65700
  operationLogger.warn(`Failed ${operation}`, {
65706
65701
  ...details,
65707
65702
  durationMs: Date.now() - startedAt,
65708
- error: error2 instanceof Error ? error2.message : String(error2)
65703
+ error: error instanceof Error ? error.message : String(error)
65709
65704
  });
65710
- throw error2;
65705
+ throw error;
65711
65706
  }
65712
65707
  }
65713
65708
  __name(traceOperation, "traceOperation");
@@ -65729,11 +65724,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65729
65724
  return {
65730
65725
  startDate: args.startDate,
65731
65726
  endDate: args.endDate,
65732
- authors: args.authors,
65733
- excludeAuthors: args.excludeAuthors,
65734
- excludeCommenters: args.excludeCommenters,
65735
- labels: args.labels,
65727
+ authors: args.authors ? parseCsvList2(args.authors, "authors") : void 0,
65728
+ excludeAuthors: args.excludeAuthors ? parseCsvList2(args.excludeAuthors, "excludeAuthors") : void 0,
65729
+ excludeCommenters: args.excludeCommenters ? parseCsvList2(args.excludeCommenters, "excludeCommenters") : void 0,
65730
+ labels: args.labels ? parseCsvList2(args.labels, "labels") : void 0,
65736
65731
  state: args.status,
65732
+ rawFilters: args.rawFilters,
65737
65733
  cleaning
65738
65734
  };
65739
65735
  }
@@ -65754,6 +65750,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65754
65750
  jobName: args.jobName,
65755
65751
  jobConclusion: args.jobConclusion,
65756
65752
  event: args.event,
65753
+ rawFilters: args.rawFilters,
65757
65754
  method: args.method,
65758
65755
  cleaning
65759
65756
  };
@@ -65765,7 +65762,10 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65765
65762
  ignorePatterns: args.ignorePatterns,
65766
65763
  includePatterns: args.includePatterns,
65767
65764
  top: args.top,
65768
- authors: args.authors
65765
+ authors: args.authors,
65766
+ minCoupling: args.minCoupling,
65767
+ startDate: args.startDate,
65768
+ endDate: args.endDate
65769
65769
  };
65770
65770
  }
65771
65771
  __name(buildCodeEntityFilterOptions, "buildCodeEntityFilterOptions");
@@ -65778,6 +65778,71 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65778
65778
  }
65779
65779
  __name(buildCodeChurnOptions, "buildCodeChurnOptions");
65780
65780
  __name2(buildCodeChurnOptions, "buildCodeChurnOptions");
65781
+ function toPeriodKey2(inputPeriod, period) {
65782
+ if (period === "day") {
65783
+ return inputPeriod;
65784
+ }
65785
+ const date = new Date(inputPeriod);
65786
+ if (Number.isNaN(date.getTime())) {
65787
+ return inputPeriod;
65788
+ }
65789
+ if (period === "month") {
65790
+ const year = date.getUTCFullYear();
65791
+ const month = String(date.getUTCMonth() + 1).padStart(2, "0");
65792
+ return `${year}-${month}`;
65793
+ }
65794
+ const utcDate = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
65795
+ const dayOfWeek = utcDate.getUTCDay() || 7;
65796
+ utcDate.setUTCDate(utcDate.getUTCDate() + 4 - dayOfWeek);
65797
+ const isoYear = utcDate.getUTCFullYear();
65798
+ const firstDay = new Date(Date.UTC(isoYear, 0, 1));
65799
+ const week = Math.ceil(((utcDate.getTime() - firstDay.getTime()) / 864e5 + 1) / 7);
65800
+ return `${isoYear}-W${String(week).padStart(2, "0")}`;
65801
+ }
65802
+ __name(toPeriodKey2, "toPeriodKey");
65803
+ __name2(toPeriodKey2, "toPeriodKey");
65804
+ function aggregateRunsByPeriod2(metrics, requestedPeriod) {
65805
+ const period = requestedPeriod || "day";
65806
+ if (period === "day") {
65807
+ return metrics;
65808
+ }
65809
+ const grouped = /* @__PURE__ */ new Map();
65810
+ for (const item of metrics) {
65811
+ const normalizedPeriod = toPeriodKey2(item.period, period);
65812
+ const key = `${normalizedPeriod}||${item.workflow}`;
65813
+ grouped.set(key, (grouped.get(key) || 0) + item.runs);
65814
+ }
65815
+ return Array.from(grouped.entries()).map(([key, runs]) => {
65816
+ const [normalizedPeriod, workflow] = key.split("||");
65817
+ return {
65818
+ period: normalizedPeriod,
65819
+ workflow,
65820
+ runs
65821
+ };
65822
+ }).sort((a, b) => {
65823
+ const periodComparison = a.period.localeCompare(b.period);
65824
+ if (periodComparison !== 0) {
65825
+ return periodComparison;
65826
+ }
65827
+ return a.workflow.localeCompare(b.workflow);
65828
+ });
65829
+ }
65830
+ __name(aggregateRunsByPeriod2, "aggregateRunsByPeriod");
65831
+ __name2(aggregateRunsByPeriod2, "aggregateRunsByPeriod");
65832
+ function computeDoraRating(deploymentCounts, period) {
65833
+ if (period === "day" && deploymentCounts.daily_counts >= 1) {
65834
+ return "Elite";
65835
+ }
65836
+ if (period === "week" && deploymentCounts.weekly_counts >= 1) {
65837
+ return "High";
65838
+ }
65839
+ if (period === "month" && deploymentCounts.monthly_counts >= 1) {
65840
+ return "Medium";
65841
+ }
65842
+ return "Low";
65843
+ }
65844
+ __name(computeDoraRating, "computeDoraRating");
65845
+ __name2(computeDoraRating, "computeDoraRating");
65781
65846
  function buildSonarqubeComponentTreeOptions(args) {
65782
65847
  return {
65783
65848
  component: args.component,
@@ -65845,7 +65910,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65845
65910
  project: this.configuration.githubRepository,
65846
65911
  startDate: filters.startDate,
65847
65912
  endDate: filters.endDate,
65848
- authors: filters.authors
65913
+ authors: filters.authors,
65914
+ includePatterns: filters.includePatterns,
65915
+ ignorePatterns: filters.ignorePatterns
65849
65916
  }, async () => {
65850
65917
  const codeRepository = import_core21.CodemaatFactory.create(this.configuration, createLogger(this.configuration, "CodeMetricsRepository"));
65851
65918
  const pairingService = import_core21.PairingFactory.create(this.configuration, createLogger(this.configuration, "PairingService"), this.timeZoneProvider);
@@ -65856,7 +65923,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65856
65923
  operationLogger.debug("getCodeMetrics: retrieving file coupling");
65857
65924
  const coupling = await codeRepository.getFileCoupling({
65858
65925
  authors: filters.authors ? parseCsvList2(filters.authors, "authors") : void 0,
65859
- ...filters
65926
+ includePatterns: filters.includePatterns,
65927
+ ignorePatterns: filters.ignorePatterns
65860
65928
  });
65861
65929
  return {
65862
65930
  pairingIndex: pairing,
@@ -65966,22 +66034,27 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65966
66034
  workflowPath: args.workflowPath,
65967
66035
  branch: args.branch,
65968
66036
  startDate: args.startDate,
65969
- endDate: args.endDate
66037
+ endDate: args.endDate,
66038
+ rawFilters: args.rawFilters,
66039
+ filter: args.filter,
66040
+ period: args.period
65970
66041
  }, async () => {
66042
+ const resolved = await this.resolvePipelineArgs(args);
65971
66043
  const pipelineArtifacts = import_core21.PipelineFactory.create(this.configuration, createLogger(this.configuration, "DoraPipelineRepository"), this.timeZoneProvider);
65972
66044
  const cleaning = (0, import_core21.parseMetricCleaningOptions)({
65973
66045
  weekends: args.weekends,
65974
66046
  outlierMode: args.outlierMode
65975
66047
  });
65976
66048
  const baseFilters = {
65977
- startDate: args.startDate,
65978
- endDate: args.endDate,
65979
- workflowPath: args.workflowPath,
65980
- status: args.status,
65981
- conclusion: args.conclusion,
65982
- targetBranch: args.branch,
65983
- jobName: args.jobName,
65984
- event: args.event,
66049
+ startDate: resolved.startDate ?? args.startDate,
66050
+ endDate: resolved.endDate ?? args.endDate,
66051
+ workflowPath: resolved.workflowPath ?? args.workflowPath,
66052
+ status: resolved.status ?? args.status,
66053
+ conclusion: resolved.conclusion ?? args.conclusion,
66054
+ targetBranch: resolved.branch ?? args.branch,
66055
+ jobName: resolved.jobName ?? args.jobName,
66056
+ event: resolved.event ?? args.event,
66057
+ rawFilters: resolved.rawFilters ?? args.rawFilters,
65985
66058
  cleaning
65986
66059
  };
65987
66060
  const pipelinesService = new import_core21.PipelinesService(pipelineArtifacts.pipelineRepository, this.configuration, createLogger(this.configuration, "DoraPipelinesService"), this.timeZoneProvider);
@@ -65992,9 +66065,15 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
65992
66065
  pipelinesService.getMetrics(baseFilters),
65993
66066
  pipelinesService.getJobMetrics(baseFilters)
65994
66067
  ]);
66068
+ const doraRating = computeDoraRating({
66069
+ daily_counts: deploymentFrequency[0]?.daily_counts ?? 0,
66070
+ weekly_counts: deploymentFrequency[0]?.weekly_counts ?? 0,
66071
+ monthly_counts: deploymentFrequency[0]?.monthly_counts ?? 0
66072
+ }, args.period);
65995
66073
  return {
65996
66074
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
65997
66075
  deploymentFrequency,
66076
+ doraRating,
65998
66077
  pipelineMetrics,
65999
66078
  jobMetrics,
66000
66079
  filters: baseFilters
@@ -66101,25 +66180,31 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66101
66180
  project: this.configuration.githubRepository,
66102
66181
  startDate: filters.startDate,
66103
66182
  endDate: filters.endDate,
66104
- authors: filters.authors
66183
+ authors: filters.authors,
66184
+ includePatterns: filters.includePatterns,
66185
+ ignorePatterns: filters.ignorePatterns
66105
66186
  }, async () => {
66106
66187
  const codeRepository = import_core21.CodemaatFactory.create(this.configuration, createLogger(this.configuration, "CodeMetricsRepository"));
66107
66188
  const pairingService = import_core21.PairingFactory.create(this.configuration, createLogger(this.configuration, "PairingService"), this.timeZoneProvider);
66108
66189
  const bigOService = new import_core21.BigOService(this.configuration);
66109
66190
  const evaluationService = new import_core21.CodeEvaluationService();
66191
+ const entityFilterOptions = {
66192
+ includePatterns: filters.includePatterns,
66193
+ ignorePatterns: filters.ignorePatterns,
66194
+ authors: filters.authors
66195
+ };
66110
66196
  const [entityChurn, coupling, entityEffort, churnResult, entityOwnership, pairing, bigOFiles] = await Promise.all([
66111
- codeRepository.getEntityChurn({}),
66197
+ codeRepository.getEntityChurn(entityFilterOptions),
66112
66198
  codeRepository.getFileCoupling({
66199
+ ...entityFilterOptions,
66113
66200
  sortBy: "degree"
66114
66201
  }),
66115
- codeRepository.getEntityEffort({}),
66202
+ codeRepository.getEntityEffort(entityFilterOptions),
66116
66203
  codeRepository.getCodeChurn({
66117
66204
  startDate: filters.startDate,
66118
66205
  endDate: filters.endDate
66119
66206
  }),
66120
- codeRepository.getEntityOwnership({
66121
- authors: filters.authors
66122
- }),
66207
+ codeRepository.getEntityOwnership(entityFilterOptions),
66123
66208
  pairingService.getPairingIndex(filters).catch(() => null),
66124
66209
  bigOService.listFiles({
66125
66210
  limit: 200
@@ -66322,10 +66407,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66322
66407
  project: this.configuration.githubRepository,
66323
66408
  startDate: args.startDate,
66324
66409
  endDate: args.endDate,
66325
- status: args.status
66410
+ status: args.status,
66411
+ filter: args.filter
66326
66412
  }, async () => {
66413
+ const resolved = await this.resolveChangeRequestArgs(args);
66327
66414
  const service = this.createChangeRequestsService();
66328
- return service.getSummary(buildChangeRequestFiltersFromArgs(args));
66415
+ return service.getSummary(buildChangeRequestFiltersFromArgs(resolved));
66329
66416
  });
66330
66417
  }
66331
66418
  async getChangeRequestThroughTime(args) {
@@ -66333,10 +66420,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66333
66420
  project: this.configuration.githubRepository,
66334
66421
  startDate: args.startDate,
66335
66422
  endDate: args.endDate,
66336
- aggregateBy: args.aggregateBy
66423
+ aggregateBy: args.aggregateBy,
66424
+ filter: args.filter
66337
66425
  }, async () => {
66426
+ const resolved = await this.resolveChangeRequestArgs(args);
66338
66427
  const service = this.createChangeRequestsService();
66339
- return service.getThroughTime(buildChangeRequestFiltersFromArgs(args), args.aggregateBy);
66428
+ return service.getThroughTime(buildChangeRequestFiltersFromArgs(resolved), args.aggregateBy);
66340
66429
  });
66341
66430
  }
66342
66431
  async getChangeRequestByAuthor(args) {
@@ -66356,10 +66445,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66356
66445
  startDate: args.startDate,
66357
66446
  endDate: args.endDate,
66358
66447
  method: args.method,
66359
- top: args.top
66448
+ top: args.top,
66449
+ filter: args.filter
66360
66450
  }, async () => {
66451
+ const resolved = await this.resolveChangeRequestArgs(args);
66361
66452
  const service = this.createChangeRequestsService();
66362
- return service.getReviewTime(buildChangeRequestFiltersFromArgs(args), args.top ?? 10, args.method ?? "average");
66453
+ return service.getReviewTime(buildChangeRequestFiltersFromArgs(resolved), args.top ?? 10, args.method ?? "average");
66363
66454
  });
66364
66455
  }
66365
66456
  async getChangeRequestOpenTime(args) {
@@ -66368,10 +66459,12 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66368
66459
  startDate: args.startDate,
66369
66460
  endDate: args.endDate,
66370
66461
  aggregateBy: args.aggregateBy,
66371
- method: args.method
66462
+ method: args.method,
66463
+ filter: args.filter
66372
66464
  }, async () => {
66465
+ const resolved = await this.resolveChangeRequestArgs(args);
66373
66466
  const service = this.createChangeRequestsService();
66374
- return service.getOpenTimeBy(buildChangeRequestFiltersFromArgs(args), args.aggregateBy, args.method ?? "average");
66467
+ return service.getOpenTimeBy(buildChangeRequestFiltersFromArgs(resolved), args.aggregateBy, args.method ?? "average");
66375
66468
  });
66376
66469
  }
66377
66470
  async getChangeRequestComments(args) {
@@ -66379,10 +66472,19 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66379
66472
  project: this.configuration.githubRepository,
66380
66473
  startDate: args.startDate,
66381
66474
  endDate: args.endDate,
66382
- method: args.method
66475
+ method: args.method,
66476
+ aggregateBy: args.aggregateBy,
66477
+ filter: args.filter
66383
66478
  }, async () => {
66479
+ const resolved = await this.resolveChangeRequestArgs(args);
66384
66480
  const service = this.createChangeRequestsService();
66385
- return service.getMetrics(buildChangeRequestFiltersFromArgs(args), args.method ?? "average");
66481
+ const filters = buildChangeRequestFiltersFromArgs(resolved);
66482
+ const method = args.method ?? "average";
66483
+ if (args.aggregateBy) {
66484
+ const mode = args.aggregateBy.toLowerCase();
66485
+ return mode === "month" ? service.getMetricsByMonth(filters, method) : service.getMetricsByWeek(filters, method);
66486
+ }
66487
+ return service.getMetrics(filters, method);
66386
66488
  });
66387
66489
  }
66388
66490
  async getChangeRequestCommentsByAuthor(args) {
@@ -66408,6 +66510,32 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66408
66510
  return service.getFirstCommentTime(buildChangeRequestFiltersFromArgs(args), args.top ?? 10, args.method ?? "average");
66409
66511
  });
66410
66512
  }
66513
+ async getChangeRequestMetricsByMonth(args) {
66514
+ return traceOperation("getChangeRequestMetricsByMonth", {
66515
+ project: this.configuration.githubRepository,
66516
+ startDate: args.startDate,
66517
+ endDate: args.endDate,
66518
+ method: args.method,
66519
+ filter: args.filter
66520
+ }, async () => {
66521
+ const resolved = await this.resolveChangeRequestArgs(args);
66522
+ const service = this.createChangeRequestsService();
66523
+ return service.getMetricsByMonth(buildChangeRequestFiltersFromArgs(resolved), args.method ?? "average");
66524
+ });
66525
+ }
66526
+ async getChangeRequestMetricsByWeek(args) {
66527
+ return traceOperation("getChangeRequestMetricsByWeek", {
66528
+ project: this.configuration.githubRepository,
66529
+ startDate: args.startDate,
66530
+ endDate: args.endDate,
66531
+ method: args.method,
66532
+ filter: args.filter
66533
+ }, async () => {
66534
+ const resolved = await this.resolveChangeRequestArgs(args);
66535
+ const service = this.createChangeRequestsService();
66536
+ return service.getMetricsByWeek(buildChangeRequestFiltersFromArgs(resolved), args.method ?? "average");
66537
+ });
66538
+ }
66411
66539
  async getPipelineDashboard(args) {
66412
66540
  return traceOperation("getPipelineDashboard", {
66413
66541
  project: this.configuration.githubRepository,
@@ -66415,23 +66543,35 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66415
66543
  endDate: args.endDate,
66416
66544
  workflowPath: args.workflowPath,
66417
66545
  branch: args.branch,
66418
- method: args.method
66546
+ method: args.method,
66547
+ filter: args.filter,
66548
+ period: args.period
66419
66549
  }, async () => {
66550
+ const resolved = await this.resolvePipelineArgs(args);
66420
66551
  const pipelineArtifacts = import_core21.PipelineFactory.create(this.configuration, createLogger(this.configuration, "PipelineDashboardRepository"), this.timeZoneProvider);
66421
66552
  const pipelineImpl = new import_core21.PipelineImplementation(pipelineArtifacts.pipelineRepository, this.configuration.getDeploymentFrequencyTargets(), createLogger(this.configuration, "PipelineDashboardImplementation"), this.timeZoneProvider);
66422
- return pipelineImpl.dashboard(buildPipelineFiltersFromArgs(args));
66553
+ const dashboard = await pipelineImpl.dashboard(buildPipelineFiltersFromArgs(resolved));
66554
+ if (args.period && args.period !== "day") {
66555
+ return {
66556
+ ...dashboard,
66557
+ runs_by: aggregateRunsByPeriod2(dashboard.runs_by, args.period)
66558
+ };
66559
+ }
66560
+ return dashboard;
66423
66561
  });
66424
66562
  }
66425
66563
  async getCodePairingIndex(args) {
66426
66564
  return traceOperation("getCodePairingIndex", {
66427
66565
  project: this.configuration.githubRepository,
66428
66566
  startDate: args.startDate,
66429
- endDate: args.endDate
66567
+ endDate: args.endDate,
66568
+ minShared: args.minShared
66430
66569
  }, async () => {
66431
66570
  const pairingService = import_core21.PairingFactory.create(this.configuration, createLogger(this.configuration, "PairingService"), this.timeZoneProvider);
66432
66571
  return pairingService.getPairingIndex({
66433
66572
  startDate: args.startDate,
66434
- endDate: args.endDate
66573
+ endDate: args.endDate,
66574
+ minShared: args.minShared
66435
66575
  });
66436
66576
  });
66437
66577
  }
@@ -66439,9 +66579,21 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66439
66579
  return traceOperation("getCodeChurn", {
66440
66580
  project: this.configuration.githubRepository,
66441
66581
  startDate: args.startDate,
66442
- endDate: args.endDate
66582
+ endDate: args.endDate,
66583
+ authors: args.authors
66443
66584
  }, async () => {
66444
66585
  const codeRepository = import_core21.CodemaatFactory.create(this.configuration, createLogger(this.configuration, "CodeMetricsRepository"));
66586
+ if (args.authors) {
66587
+ const codemaatService = new import_core21.CodemaatService(codeRepository);
66588
+ const authors = parseCsvList2(args.authors, "authors");
66589
+ return {
66590
+ authorChurn: await codemaatService.getAuthorChurn({
66591
+ startDate: args.startDate,
66592
+ endDate: args.endDate,
66593
+ authors
66594
+ })
66595
+ };
66596
+ }
66445
66597
  return codeRepository.getCodeChurn(buildCodeChurnOptions(args));
66446
66598
  });
66447
66599
  }
@@ -66533,10 +66685,16 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66533
66685
  }
66534
66686
  async getCodeEntityOwnership(args) {
66535
66687
  return traceOperation("getCodeEntityOwnership", {
66536
- project: this.configuration.githubRepository
66688
+ project: this.configuration.githubRepository,
66689
+ entity: args.entity
66537
66690
  }, async () => {
66538
66691
  const codeRepository = import_core21.CodemaatFactory.create(this.configuration, createLogger(this.configuration, "CodeMetricsRepository"));
66539
- return codeRepository.getEntityOwnership(buildCodeEntityFilterOptions(args));
66692
+ const ownership = await codeRepository.getEntityOwnership(buildCodeEntityFilterOptions(args));
66693
+ if (args.entity) {
66694
+ const records = ownership;
66695
+ return records.filter((row) => row.entity.includes(args.entity));
66696
+ }
66697
+ return ownership;
66540
66698
  });
66541
66699
  }
66542
66700
  async getCodeEntityOwnershipHistory(args) {
@@ -66627,17 +66785,17 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66627
66785
  };
66628
66786
  });
66629
66787
  }
66630
- async listSavedFilters() {
66788
+ async listSavedFilters(args) {
66631
66789
  return traceOperation("listSavedFilters", {
66632
- project: this.configuration.githubRepository
66790
+ project: this.configuration.githubRepository,
66791
+ section: args?.section
66633
66792
  }, async () => {
66634
66793
  const baseDir = this.configuration.getBaseDirectory();
66635
66794
  const adapter = new import_core21.FileSystemSavedFiltersAdapter(baseDir);
66636
66795
  const store = new import_core21.SavedFiltersStore(adapter);
66637
- const [filters, reports] = await Promise.all([
66638
- store.getAll(),
66639
- store.getReports()
66640
- ]);
66796
+ const section = args?.section;
66797
+ const filters = section ? await store.getBySection(section) : await store.getAll();
66798
+ const reports = await store.getReports();
66641
66799
  return {
66642
66800
  version: 1,
66643
66801
  filters,
@@ -66645,10 +66803,39 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66645
66803
  };
66646
66804
  });
66647
66805
  }
66806
+ async getSavedFilter(args) {
66807
+ return traceOperation("getSavedFilter", {
66808
+ project: this.configuration.githubRepository,
66809
+ name: args.name
66810
+ }, async () => {
66811
+ const resolver = new import_core21.FilterResolver();
66812
+ const entry = await resolver.showFilter(this.configuration, args.name);
66813
+ if (!entry) {
66814
+ return null;
66815
+ }
66816
+ return entry;
66817
+ });
66818
+ }
66648
66819
  createChangeRequestsService() {
66649
66820
  const repository = import_core21.ChangeRequestFactory.create(this.configuration, createLogger(this.configuration, "ChangeRequestsRepository"), this.timeZoneProvider);
66650
66821
  return new import_core21.ChangeRequestsService(repository, this.timeZoneProvider, createLogger(this.configuration, "ChangeRequestsService"));
66651
66822
  }
66823
+ async resolveChangeRequestArgs(args) {
66824
+ if (!args.filter) {
66825
+ return args;
66826
+ }
66827
+ const resolver = new import_core21.FilterResolver();
66828
+ const merged = await resolver.resolveSavedFilterOptions(this.configuration, "change-requests", args);
66829
+ return merged;
66830
+ }
66831
+ async resolvePipelineArgs(args) {
66832
+ if (!args.filter) {
66833
+ return args;
66834
+ }
66835
+ const resolver = new import_core21.FilterResolver();
66836
+ const merged = await resolver.resolveSavedFilterOptions(this.configuration, "pipelines", args);
66837
+ return merged;
66838
+ }
66652
66839
  };
66653
66840
  function viewToMermaid(view) {
66654
66841
  const lines = [
@@ -66704,491 +66891,60 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
66704
66891
  }
66705
66892
  __name(redactSecrets, "redactSecrets");
66706
66893
  __name2(redactSecrets, "redactSecrets");
66707
- function getConfigurationRepository() {
66708
- return new import_core22.ConfigurationRepository(process.env, void 0, new import_utils32.Logger("SmmMcpServer", "CRITICAL"));
66709
- }
66710
- __name(getConfigurationRepository, "getConfigurationRepository");
66711
- __name2(getConfigurationRepository, "getConfigurationRepository");
66712
- function encodeProject(project) {
66713
- return encodeURIComponent(project);
66714
- }
66715
- __name(encodeProject, "encodeProject");
66716
- __name2(encodeProject, "encodeProject");
66717
- function decodeProject(project) {
66718
- return decodeURIComponent(project);
66719
- }
66720
- __name(decodeProject, "decodeProject");
66721
- __name2(decodeProject, "decodeProject");
66722
- function jsonResource(uri, value) {
66894
+ function asToolResult(value) {
66723
66895
  return {
66724
- contents: [
66896
+ content: [
66725
66897
  {
66726
- uri,
66727
- mimeType: "application/json",
66898
+ type: "text",
66728
66899
  text: JSON.stringify(value, null, 2)
66729
66900
  }
66730
- ]
66901
+ ],
66902
+ structuredContent: value
66731
66903
  };
66732
66904
  }
66733
- __name(jsonResource, "jsonResource");
66734
- __name2(jsonResource, "jsonResource");
66735
- function listResourceTemplates() {
66736
- return [
66737
- {
66738
- uriTemplate: "smm://project/{project}/engineering-health",
66739
- name: "Project engineering health",
66740
- description: "Full engineering health evaluation (delivery, quality, collaboration, architecture) for a project.",
66741
- mimeType: "application/json"
66742
- },
66743
- {
66744
- uriTemplate: "smm://project/{project}/dora",
66745
- name: "Project DORA metrics",
66746
- description: "DORA and pipeline metrics for a project.",
66747
- mimeType: "application/json"
66748
- },
66749
- {
66750
- uriTemplate: "smm://project/{project}/architecture/snapshots",
66751
- name: "Project architecture snapshots",
66752
- description: "List of architecture snapshots stored for a project.",
66753
- mimeType: "application/json"
66754
- },
66755
- {
66756
- uriTemplate: "smm://project/{project}/architecture/summary",
66757
- name: "Project architecture summary",
66758
- description: "Architecture snapshot metadata for the latest snapshot of a project.",
66759
- mimeType: "application/json"
66760
- },
66761
- {
66762
- uriTemplate: "smm://project/{project}/pipeline-dashboard",
66763
- name: "Project pipeline dashboard",
66764
- description: "Full pipeline dashboard for a project.",
66765
- mimeType: "application/json"
66766
- },
66767
- {
66768
- uriTemplate: "smm://project/{project}/evaluation/change-requests",
66769
- name: "Project change request evaluation",
66770
- description: "Change request health evaluation for a project.",
66771
- mimeType: "application/json"
66772
- },
66773
- {
66774
- uriTemplate: "smm://project/{project}/evaluation/pipelines",
66775
- name: "Project pipeline evaluation",
66776
- description: "Pipeline health evaluation for a project.",
66777
- mimeType: "application/json"
66778
- },
66779
- {
66780
- uriTemplate: "smm://project/{project}/evaluation/code",
66781
- name: "Project code evaluation",
66782
- description: "Code health evaluation for a project.",
66783
- mimeType: "application/json"
66784
- },
66785
- {
66786
- uriTemplate: "smm://project/{project}/evaluation/quality",
66787
- name: "Project quality evaluation",
66788
- description: "SonarQube quality evaluation for a project.",
66789
- mimeType: "application/json"
66790
- },
66791
- {
66792
- uriTemplate: "smm://project/{project}/evaluation/architecture",
66793
- name: "Project architecture evaluation",
66794
- description: "Architecture health evaluation for a project.",
66795
- mimeType: "application/json"
66796
- },
66797
- {
66798
- uriTemplate: "smm://project/{project}/big-o",
66799
- name: "Project Big-O files",
66800
- description: "Big-O complexity classification for source files in a project.",
66801
- mimeType: "application/json"
66802
- },
66803
- {
66804
- uriTemplate: "smm://project/{project}/health-check",
66805
- name: "Project health check",
66806
- description: "Dataset health report for a project.",
66807
- mimeType: "application/json"
66808
- },
66809
- {
66810
- uriTemplate: "smm://project/{project}/saved-filters",
66811
- name: "Project saved filters",
66812
- description: "Saved filters and reports for a project.",
66813
- mimeType: "application/json"
66814
- },
66815
- {
66816
- uriTemplate: "smm://project/{project}/sonarqube/measurements",
66817
- name: "Project SonarQube measurements",
66818
- description: "Latest SonarQube measurements for a project.",
66819
- mimeType: "application/json"
66820
- },
66821
- {
66822
- uriTemplate: "smm://project/{project}/sonarqube/measurements/history",
66823
- name: "Project SonarQube measurements history",
66824
- description: "Timestamped SonarQube measurement entries for a project.",
66825
- mimeType: "application/json"
66826
- },
66827
- {
66828
- uriTemplate: "smm://project/{project}/sonarqube/component-tree",
66829
- name: "Project SonarQube component tree",
66830
- description: "SonarQube component tree with metrics for a project.",
66831
- mimeType: "application/json"
66832
- },
66833
- {
66834
- uriTemplate: "smm://project/{project}/sonarqube/component-tree/history",
66835
- name: "Project SonarQube component tree history",
66836
- description: "Timestamped SonarQube component tree entries for a project.",
66837
- mimeType: "application/json"
66838
- }
66839
- ];
66905
+ __name(asToolResult, "asToolResult");
66906
+ __name2(asToolResult, "asToolResult");
66907
+ function getReader(argumentsValue) {
66908
+ const args = parseMetricsToolArguments(argumentsValue);
66909
+ return {
66910
+ args,
66911
+ reader: createMcpMetricsReader({
66912
+ project: args.project,
66913
+ timezone: args.timezone
66914
+ })
66915
+ };
66840
66916
  }
66841
- __name(listResourceTemplates, "listResourceTemplates");
66842
- __name2(listResourceTemplates, "listResourceTemplates");
66843
- function listResources() {
66844
- const repository = getConfigurationRepository();
66845
- const projects = repository.getAllProjectNames();
66846
- return [
66847
- {
66848
- uri: "smm://projects",
66849
- name: "SMM projects",
66850
- description: "Configured Software Metrics Machine projects.",
66851
- mimeType: "application/json"
66917
+ __name(getReader, "getReader");
66918
+ __name2(getReader, "getReader");
66919
+ var tools = [
66920
+ {
66921
+ name: "smm_list_projects",
66922
+ description: "List configured Software Metrics Machine projects from smm_config.json, including git provider and repository.",
66923
+ inputSchema: {
66924
+ type: "object",
66925
+ additionalProperties: false,
66926
+ properties: {}
66852
66927
  },
66853
- {
66854
- uri: "smm://engineering-health/metrics",
66855
- name: "Engineering health metric catalog",
66856
- description: "Metric ids, categories, and labels available for engineering health evaluations.",
66857
- mimeType: "application/json"
66858
- },
66859
- ...projects.flatMap((project) => [
66860
- {
66861
- uri: `smm://project/${encodeProject(project)}/configuration`,
66862
- name: `${project} configuration`,
66863
- description: "Redacted project configuration.",
66864
- mimeType: "application/json"
66865
- },
66866
- {
66867
- uri: `smm://project/${encodeProject(project)}/report`,
66868
- name: `${project} report`,
66869
- description: "Complete metrics report for the project.",
66870
- mimeType: "application/json"
66871
- },
66872
- {
66873
- uri: `smm://project/${encodeProject(project)}/engineering-health`,
66874
- name: `${project} engineering health`,
66875
- description: "Engineering health evaluation for the project.",
66876
- mimeType: "application/json"
66877
- },
66878
- {
66879
- uri: `smm://project/${encodeProject(project)}/dora`,
66880
- name: `${project} DORA metrics`,
66881
- description: "DORA and pipeline metrics for the project.",
66882
- mimeType: "application/json"
66883
- },
66884
- {
66885
- uri: `smm://project/${encodeProject(project)}/architecture/snapshots`,
66886
- name: `${project} architecture snapshots`,
66887
- description: "Architecture snapshots stored for the project.",
66888
- mimeType: "application/json"
66889
- },
66890
- {
66891
- uri: `smm://project/${encodeProject(project)}/evaluation/change-requests`,
66892
- name: `${project} change request evaluation`,
66893
- description: "Change request health evaluation for the project.",
66894
- mimeType: "application/json"
66895
- },
66896
- {
66897
- uri: `smm://project/${encodeProject(project)}/evaluation/pipelines`,
66898
- name: `${project} pipeline evaluation`,
66899
- description: "Pipeline health evaluation for the project.",
66900
- mimeType: "application/json"
66901
- },
66902
- {
66903
- uri: `smm://project/${encodeProject(project)}/evaluation/code`,
66904
- name: `${project} code evaluation`,
66905
- description: "Code health evaluation for the project.",
66906
- mimeType: "application/json"
66907
- },
66908
- {
66909
- uri: `smm://project/${encodeProject(project)}/evaluation/quality`,
66910
- name: `${project} quality evaluation`,
66911
- description: "SonarQube quality evaluation for the project.",
66912
- mimeType: "application/json"
66913
- },
66914
- {
66915
- uri: `smm://project/${encodeProject(project)}/evaluation/architecture`,
66916
- name: `${project} architecture evaluation`,
66917
- description: "Architecture health evaluation for the project.",
66918
- mimeType: "application/json"
66919
- },
66920
- {
66921
- uri: `smm://project/${encodeProject(project)}/big-o`,
66922
- name: `${project} Big-O files`,
66923
- description: "Big-O complexity classification for source files.",
66924
- mimeType: "application/json"
66925
- },
66926
- {
66927
- uri: `smm://project/${encodeProject(project)}/health-check`,
66928
- name: `${project} health check`,
66929
- description: "Dataset health report for the project.",
66930
- mimeType: "application/json"
66931
- },
66932
- {
66933
- uri: `smm://project/${encodeProject(project)}/architecture/summary`,
66934
- name: `${project} architecture summary`,
66935
- description: "Architecture snapshot metadata for the latest snapshot.",
66936
- mimeType: "application/json"
66937
- },
66938
- {
66939
- uri: `smm://project/${encodeProject(project)}/pipeline-dashboard`,
66940
- name: `${project} pipeline dashboard`,
66941
- description: "Full pipeline dashboard for the project.",
66942
- mimeType: "application/json"
66943
- },
66944
- {
66945
- uri: `smm://project/${encodeProject(project)}/saved-filters`,
66946
- name: `${project} saved filters`,
66947
- description: "Saved filters and reports for the project.",
66948
- mimeType: "application/json"
66949
- },
66950
- {
66951
- uri: `smm://project/${encodeProject(project)}/sonarqube/measurements`,
66952
- name: `${project} SonarQube measurements`,
66953
- description: "Latest SonarQube measurements for the project.",
66954
- mimeType: "application/json"
66955
- },
66956
- {
66957
- uri: `smm://project/${encodeProject(project)}/sonarqube/measurements/history`,
66958
- name: `${project} SonarQube measurements history`,
66959
- description: "Timestamped SonarQube measurement entries for the project.",
66960
- mimeType: "application/json"
66961
- },
66962
- {
66963
- uri: `smm://project/${encodeProject(project)}/sonarqube/component-tree`,
66964
- name: `${project} SonarQube component tree`,
66965
- description: "SonarQube component tree with metrics for the project.",
66966
- mimeType: "application/json"
66967
- },
66968
- {
66969
- uri: `smm://project/${encodeProject(project)}/sonarqube/component-tree/history`,
66970
- name: `${project} SonarQube component tree history`,
66971
- description: "Timestamped SonarQube component tree entries for the project.",
66972
- mimeType: "application/json"
66973
- }
66974
- ])
66975
- ];
66976
- }
66977
- __name(listResources, "listResources");
66978
- __name2(listResources, "listResources");
66979
- async function readResource(uri) {
66980
- const resourceStartedAt = Date.now();
66981
- resourceLogger.debug(`Reading resource ${uri}`);
66982
- const repository = getConfigurationRepository();
66983
- if (uri === "smm://projects") {
66984
- resourceLogger.debug("Listing projects for resource smm://projects");
66985
- const result = jsonResource(uri, {
66986
- projects: repository.getAllProjects().map((project2) => ({
66987
- github_repository: project2.github_repository,
66988
- git_provider: project2.git_provider
66989
- }))
66990
- });
66991
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
66992
- return result;
66993
- }
66994
- if (uri === "smm://engineering-health/metrics") {
66995
- resourceLogger.debug("Returning engineering health metric catalog");
66996
- const result = jsonResource(uri, {
66997
- categories: [
66998
- "delivery",
66999
- "quality",
67000
- "collaboration",
67001
- "architecture"
67002
- ],
67003
- metrics: listEngineeringHealthMetricCatalog()
67004
- });
67005
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67006
- return result;
67007
- }
67008
- const match = uri.match(/^smm:\/\/project\/([^/]+)\/(configuration|report|engineering-health|dora|architecture\/snapshots|architecture\/summary|evaluation\/(change-requests|pipelines|code|quality|architecture)|big-o|health-check|pipeline-dashboard|saved-filters|sonarqube\/(measurements|measurements\/history|component-tree|component-tree\/history))$/);
67009
- if (!match) {
67010
- resourceLogger.warn(`Unknown MCP resource requested: ${uri}`);
67011
- throw new Error(`Unknown MCP resource: ${uri}`);
67012
- }
67013
- const projectName = decodeProject(match[1]);
67014
- const resourceType = match[2];
67015
- resourceLogger.debug(`Resolved resource ${uri}`, {
67016
- projectName,
67017
- resourceType
67018
- });
67019
- const project = repository.getProjectByName(projectName);
67020
- if (!project) {
67021
- resourceLogger.warn(`Unknown project for resource ${uri}: ${projectName}`);
67022
- throw new Error(`Unknown project: ${projectName}`);
67023
- }
67024
- if (resourceType === "configuration") {
67025
- resourceLogger.debug(`Returning redacted configuration for ${projectName}`);
67026
- const result = jsonResource(uri, redactSecrets(project));
67027
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67028
- return result;
67029
- }
67030
- const reader = createMcpMetricsReader({
67031
- project: projectName
67032
- });
67033
- if (resourceType === "report") {
67034
- const result = jsonResource(uri, await reader.getFullReport());
67035
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67036
- return result;
67037
- }
67038
- if (resourceType === "engineering-health") {
67039
- const result = jsonResource(uri, await reader.getEngineeringHealthEvaluation({
67040
- project: projectName
67041
- }));
67042
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67043
- return result;
67044
- }
67045
- if (resourceType === "dora") {
67046
- const result = jsonResource(uri, await reader.getDoraMetrics({
67047
- project: projectName
67048
- }));
67049
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67050
- return result;
67051
- }
67052
- if (resourceType === "evaluation/change-requests") {
67053
- const result = jsonResource(uri, await reader.evaluateChangeRequests());
67054
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67055
- return result;
67056
- }
67057
- if (resourceType === "evaluation/pipelines") {
67058
- const result = jsonResource(uri, await reader.evaluatePipelines());
67059
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67060
- return result;
67061
- }
67062
- if (resourceType === "evaluation/code") {
67063
- const result = jsonResource(uri, await reader.evaluateCode());
67064
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67065
- return result;
67066
- }
67067
- if (resourceType === "evaluation/quality") {
67068
- const result = jsonResource(uri, await reader.evaluateQuality());
67069
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67070
- return result;
67071
- }
67072
- if (resourceType === "evaluation/architecture") {
67073
- const result = jsonResource(uri, await reader.evaluateArchitecture({
67074
- project: projectName
67075
- }));
67076
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67077
- return result;
67078
- }
67079
- if (resourceType === "big-o") {
67080
- const result = jsonResource(uri, await reader.listBigOFiles());
67081
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67082
- return result;
67083
- }
67084
- if (resourceType === "health-check") {
67085
- const result = jsonResource(uri, await reader.healthCheck());
67086
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67087
- return result;
67088
- }
67089
- if (resourceType === "architecture/summary") {
67090
- const result = jsonResource(uri, await reader.getArchitectureSummary());
67091
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67092
- return result;
67093
- }
67094
- if (resourceType === "pipeline-dashboard") {
67095
- const result = jsonResource(uri, await reader.getPipelineDashboard({
67096
- project: projectName
67097
- }));
67098
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67099
- return result;
67100
- }
67101
- if (resourceType === "saved-filters") {
67102
- const result = jsonResource(uri, await reader.listSavedFilters());
67103
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67104
- return result;
67105
- }
67106
- if (resourceType === "sonarqube/measurements") {
67107
- const result = jsonResource(uri, await reader.getSonarqubeMeasurements());
67108
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67109
- return result;
67110
- }
67111
- if (resourceType === "sonarqube/measurements/history") {
67112
- const result = jsonResource(uri, await reader.getSonarqubeMeasurementsHistory());
67113
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67114
- return result;
67115
- }
67116
- if (resourceType === "sonarqube/component-tree") {
67117
- const result = jsonResource(uri, await reader.getSonarqubeComponentTree({
67118
- project: projectName
67119
- }));
67120
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67121
- return result;
67122
- }
67123
- if (resourceType === "sonarqube/component-tree/history") {
67124
- const result = jsonResource(uri, await reader.getSonarqubeComponentTreeHistory({
67125
- project: projectName
67126
- }));
67127
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67128
- return result;
67129
- }
67130
- const snapshotsResult = jsonResource(uri, await reader.listArchitectureSnapshots());
67131
- resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67132
- return snapshotsResult;
67133
- }
67134
- __name(readResource, "readResource");
67135
- __name2(readResource, "readResource");
67136
- var import_core32 = __toESM2(require_dist22());
67137
- var import_utils42 = __toESM2(require_dist5());
67138
- function asToolResult(value) {
67139
- return {
67140
- content: [
67141
- {
67142
- type: "text",
67143
- text: JSON.stringify(value, null, 2)
67144
- }
67145
- ],
67146
- structuredContent: value
67147
- };
67148
- }
67149
- __name(asToolResult, "asToolResult");
67150
- __name2(asToolResult, "asToolResult");
67151
- function getReader(argumentsValue) {
67152
- const args = parseMetricsToolArguments(argumentsValue);
67153
- return {
67154
- args,
67155
- reader: createMcpMetricsReader({
67156
- project: args.project,
67157
- timezone: args.timezone
67158
- })
67159
- };
67160
- }
67161
- __name(getReader, "getReader");
67162
- __name2(getReader, "getReader");
67163
- var tools = [
67164
- {
67165
- name: "smm_list_projects",
67166
- description: "List configured Software Metrics Machine projects from smm_config.json, including git provider and repository.",
67167
- inputSchema: {
67168
- type: "object",
67169
- additionalProperties: false,
67170
- properties: {}
67171
- },
67172
- async handler() {
67173
- toolLogger.debug("smm_list_projects: loading project list from smm_config.json");
67174
- const repository = new import_core32.ConfigurationRepository(process.env, void 0, new import_utils42.Logger("SmmMcpServer", "CRITICAL"));
67175
- const projects = repository.getAllProjects().map((project) => ({
67176
- github_repository: project.github_repository,
67177
- git_provider: project.git_provider
67178
- }));
67179
- toolLogger.debug(`smm_list_projects: found ${projects.length} projects`);
67180
- return asToolResult({
67181
- projects
67182
- });
67183
- }
67184
- },
67185
- {
67186
- name: "smm_list_engineering_health_metrics",
67187
- description: "List the available engineering health metric ids, categories, and labels. Use this to discover which metric ids can be passed to smm_get_engineering_health.",
67188
- inputSchema: {
67189
- type: "object",
67190
- additionalProperties: false,
67191
- properties: {}
66928
+ async handler() {
66929
+ toolLogger.debug("smm_list_projects: loading project list from smm_config.json");
66930
+ const repository = new import_core22.ConfigurationRepository(process.env, void 0, new import_utils32.Logger("SmmMcpServer", "CRITICAL"));
66931
+ const projects = repository.getAllProjects().map((project) => ({
66932
+ github_repository: project.github_repository,
66933
+ git_provider: project.git_provider
66934
+ }));
66935
+ toolLogger.debug(`smm_list_projects: found ${projects.length} projects`);
66936
+ return asToolResult({
66937
+ projects
66938
+ });
66939
+ }
66940
+ },
66941
+ {
66942
+ name: "smm_list_engineering_health_metrics",
66943
+ description: "List the available engineering health metric ids, categories, and labels. Use this to discover which metric ids can be passed to smm_get_engineering_health.",
66944
+ inputSchema: {
66945
+ type: "object",
66946
+ additionalProperties: false,
66947
+ properties: {}
67192
66948
  },
67193
66949
  async handler() {
67194
66950
  toolLogger.debug("smm_list_engineering_health_metrics: returning metric catalog");
@@ -67240,7 +66996,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67240
66996
  return asToolResult(await reader.getCodeMetrics({
67241
66997
  startDate: parsed.startDate,
67242
66998
  endDate: parsed.endDate,
67243
- authors: parsed.authors
66999
+ authors: parsed.authors,
67000
+ includePatterns: parsed.includePatterns,
67001
+ ignorePatterns: parsed.ignorePatterns
67244
67002
  }));
67245
67003
  }
67246
67004
  },
@@ -67369,7 +67127,9 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67369
67127
  return asToolResult(await reader.evaluateCode({
67370
67128
  startDate: parsed.startDate,
67371
67129
  endDate: parsed.endDate,
67372
- authors: parsed.authors
67130
+ authors: parsed.authors,
67131
+ includePatterns: parsed.includePatterns,
67132
+ ignorePatterns: parsed.ignorePatterns
67373
67133
  }));
67374
67134
  }
67375
67135
  },
@@ -67458,7 +67218,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67458
67218
  },
67459
67219
  async handler() {
67460
67220
  return asToolResult({
67461
- version: (0, import_utils42.getApplicationVersion)(),
67221
+ version: (0, import_utils32.getApplicationVersion)(),
67462
67222
  name: "software-metrics-machine"
67463
67223
  });
67464
67224
  }
@@ -67469,7 +67229,7 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67469
67229
  inputSchema: buildMetricsInputSchema("Configuration lookup filters."),
67470
67230
  async handler(argumentsValue) {
67471
67231
  const args = parseMetricsToolArguments(argumentsValue);
67472
- const repository = new import_core32.ConfigurationRepository(process.env, args.project, new import_utils42.Logger("SmmMcpServer", "CRITICAL"));
67232
+ const repository = new import_core22.ConfigurationRepository(process.env, args.project, new import_utils32.Logger("SmmMcpServer", "CRITICAL"));
67473
67233
  const project = repository.getProjectByName(args.project || "");
67474
67234
  if (!project) {
67475
67235
  throw new Error(`Unknown project: ${args.project || "<default>"}`);
@@ -67608,6 +67368,32 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67608
67368
  return asToolResult(await reader.getChangeRequestFirstCommentTime(parsed));
67609
67369
  }
67610
67370
  },
67371
+ {
67372
+ name: "smm_get_change_request_metrics_by_month",
67373
+ description: "Get change request metrics (comments, review time, open time) grouped by month, with selectable statistical method.",
67374
+ inputSchema: buildChangeRequestMetricsInputSchema("Change request by-month filters."),
67375
+ async handler(argumentsValue) {
67376
+ const parsed = parseChangeRequestMetricsArguments(argumentsValue);
67377
+ const reader = createMcpMetricsReader({
67378
+ project: parsed.project,
67379
+ timezone: parsed.timezone
67380
+ });
67381
+ return asToolResult(await reader.getChangeRequestMetricsByMonth(parsed));
67382
+ }
67383
+ },
67384
+ {
67385
+ name: "smm_get_change_request_metrics_by_week",
67386
+ description: "Get change request metrics (comments, review time, open time) grouped by week, with selectable statistical method.",
67387
+ inputSchema: buildChangeRequestMetricsInputSchema("Change request by-week filters."),
67388
+ async handler(argumentsValue) {
67389
+ const parsed = parseChangeRequestMetricsArguments(argumentsValue);
67390
+ const reader = createMcpMetricsReader({
67391
+ project: parsed.project,
67392
+ timezone: parsed.timezone
67393
+ });
67394
+ return asToolResult(await reader.getChangeRequestMetricsByWeek(parsed));
67395
+ }
67396
+ },
67611
67397
  {
67612
67398
  name: "smm_get_pipeline_dashboard",
67613
67399
  description: "Get the full pipeline dashboard (summary, runs_duration, runs_by, jobs_time, jobs_summary, job_steps_time, jobs_duration_by_workflow) with rich filtering.",
@@ -67864,14 +67650,26 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67864
67650
  },
67865
67651
  {
67866
67652
  name: "smm_list_saved_filters",
67867
- description: "List saved filters and reports (read-only) for a configured SMM project, including filter id, name, section, repository, and createdAt.",
67868
- inputSchema: buildMetricsInputSchema("Saved filters lookup."),
67653
+ description: "List saved filters and reports (read-only) for a configured SMM project, including filter id, name, section, repository, and createdAt. Optionally filter by dashboard section.",
67654
+ inputSchema: buildSavedFilterListInputSchema(),
67869
67655
  async handler(argumentsValue) {
67870
- const args = parseMetricsToolArguments(argumentsValue);
67656
+ const parsed = parseSavedFilterListArguments(argumentsValue);
67871
67657
  const reader = createMcpMetricsReader({
67872
- project: args.project
67658
+ project: parsed.project
67873
67659
  });
67874
- return asToolResult(await reader.listSavedFilters());
67660
+ return asToolResult(await reader.listSavedFilters(parsed));
67661
+ }
67662
+ },
67663
+ {
67664
+ name: "smm_get_saved_filter",
67665
+ description: "Look up a single saved filter by name or id for a configured SMM project. Returns the full filter entry including section, filters, and repository.",
67666
+ inputSchema: buildSavedFilterGetInputSchema(),
67667
+ async handler(argumentsValue) {
67668
+ const parsed = parseSavedFilterGetArguments(argumentsValue);
67669
+ const reader = createMcpMetricsReader({
67670
+ project: parsed.project
67671
+ });
67672
+ return asToolResult(await reader.getSavedFilter(parsed));
67875
67673
  }
67876
67674
  }
67877
67675
  ];
@@ -67880,180 +67678,811 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
67880
67678
  }
67881
67679
  __name(findTool, "findTool");
67882
67680
  __name2(findTool, "findTool");
67883
- var SERVER_INFO = {
67884
- name: "software-metrics-machine",
67885
- version: (0, import_utils52.getApplicationVersion)()
67886
- };
67887
- var log = /* @__PURE__ */ __name2((message) => transportLogger.info(message), "log");
67888
- function isJsonRpcRequest(value) {
67889
- return typeof value === "object" && value !== null && "jsonrpc" in value && value.jsonrpc === "2.0" && "method" in value && typeof value.method === "string" && // Optional: check id is string, number, null, or undefined
67890
- (!("id" in value) || value.id === void 0 || value.id === null || typeof value.id === "string" || typeof value.id === "number");
67891
- }
67892
- __name(isJsonRpcRequest, "isJsonRpcRequest");
67893
- __name2(isJsonRpcRequest, "isJsonRpcRequest");
67894
- function ok(id, result) {
67681
+ var import_core32 = __toESM2(require_dist22());
67682
+ var import_utils42 = __toESM2(require_dist5());
67683
+ function getConfigurationRepository() {
67684
+ return new import_core32.ConfigurationRepository(process.env, void 0, new import_utils42.Logger("SmmMcpServer", "CRITICAL"));
67685
+ }
67686
+ __name(getConfigurationRepository, "getConfigurationRepository");
67687
+ __name2(getConfigurationRepository, "getConfigurationRepository");
67688
+ function encodeProject(project) {
67689
+ return encodeURIComponent(project);
67690
+ }
67691
+ __name(encodeProject, "encodeProject");
67692
+ __name2(encodeProject, "encodeProject");
67693
+ function decodeProject(project) {
67694
+ return decodeURIComponent(project);
67695
+ }
67696
+ __name(decodeProject, "decodeProject");
67697
+ __name2(decodeProject, "decodeProject");
67698
+ function jsonResource(uri, value) {
67895
67699
  return {
67896
- jsonrpc: "2.0",
67897
- id: id ?? null,
67898
- result
67700
+ contents: [
67701
+ {
67702
+ uri,
67703
+ mimeType: "application/json",
67704
+ text: JSON.stringify(value, null, 2)
67705
+ }
67706
+ ]
67899
67707
  };
67900
67708
  }
67901
- __name(ok, "ok");
67902
- __name2(ok, "ok");
67903
- function error(id, code, message, data) {
67904
- return {
67905
- jsonrpc: "2.0",
67906
- id: id ?? null,
67907
- error: {
67908
- code,
67909
- message,
67910
- data
67709
+ __name(jsonResource, "jsonResource");
67710
+ __name2(jsonResource, "jsonResource");
67711
+ function listResourceTemplates() {
67712
+ return [
67713
+ {
67714
+ uriTemplate: "smm://project/{project}/engineering-health",
67715
+ name: "Project engineering health",
67716
+ description: "Full engineering health evaluation (delivery, quality, collaboration, architecture) for a project.",
67717
+ mimeType: "application/json"
67718
+ },
67719
+ {
67720
+ uriTemplate: "smm://project/{project}/dora",
67721
+ name: "Project DORA metrics",
67722
+ description: "DORA and pipeline metrics for a project.",
67723
+ mimeType: "application/json"
67724
+ },
67725
+ {
67726
+ uriTemplate: "smm://project/{project}/architecture/snapshots",
67727
+ name: "Project architecture snapshots",
67728
+ description: "List of architecture snapshots stored for a project.",
67729
+ mimeType: "application/json"
67730
+ },
67731
+ {
67732
+ uriTemplate: "smm://project/{project}/architecture/summary",
67733
+ name: "Project architecture summary",
67734
+ description: "Architecture snapshot metadata for the latest snapshot of a project.",
67735
+ mimeType: "application/json"
67736
+ },
67737
+ {
67738
+ uriTemplate: "smm://project/{project}/pipeline-dashboard",
67739
+ name: "Project pipeline dashboard",
67740
+ description: "Full pipeline dashboard for a project.",
67741
+ mimeType: "application/json"
67742
+ },
67743
+ {
67744
+ uriTemplate: "smm://project/{project}/evaluation/change-requests",
67745
+ name: "Project change request evaluation",
67746
+ description: "Change request health evaluation for a project.",
67747
+ mimeType: "application/json"
67748
+ },
67749
+ {
67750
+ uriTemplate: "smm://project/{project}/evaluation/pipelines",
67751
+ name: "Project pipeline evaluation",
67752
+ description: "Pipeline health evaluation for a project.",
67753
+ mimeType: "application/json"
67754
+ },
67755
+ {
67756
+ uriTemplate: "smm://project/{project}/evaluation/code",
67757
+ name: "Project code evaluation",
67758
+ description: "Code health evaluation for a project.",
67759
+ mimeType: "application/json"
67760
+ },
67761
+ {
67762
+ uriTemplate: "smm://project/{project}/evaluation/quality",
67763
+ name: "Project quality evaluation",
67764
+ description: "SonarQube quality evaluation for a project.",
67765
+ mimeType: "application/json"
67766
+ },
67767
+ {
67768
+ uriTemplate: "smm://project/{project}/evaluation/architecture",
67769
+ name: "Project architecture evaluation",
67770
+ description: "Architecture health evaluation for a project.",
67771
+ mimeType: "application/json"
67772
+ },
67773
+ {
67774
+ uriTemplate: "smm://project/{project}/big-o",
67775
+ name: "Project Big-O files",
67776
+ description: "Big-O complexity classification for source files in a project.",
67777
+ mimeType: "application/json"
67778
+ },
67779
+ {
67780
+ uriTemplate: "smm://project/{project}/health-check",
67781
+ name: "Project health check",
67782
+ description: "Dataset health report for a project.",
67783
+ mimeType: "application/json"
67784
+ },
67785
+ {
67786
+ uriTemplate: "smm://project/{project}/saved-filters",
67787
+ name: "Project saved filters",
67788
+ description: "Saved filters and reports for a project.",
67789
+ mimeType: "application/json"
67790
+ },
67791
+ {
67792
+ uriTemplate: "smm://project/{project}/sonarqube/measurements",
67793
+ name: "Project SonarQube measurements",
67794
+ description: "Latest SonarQube measurements for a project.",
67795
+ mimeType: "application/json"
67796
+ },
67797
+ {
67798
+ uriTemplate: "smm://project/{project}/sonarqube/measurements/history",
67799
+ name: "Project SonarQube measurements history",
67800
+ description: "Timestamped SonarQube measurement entries for a project.",
67801
+ mimeType: "application/json"
67802
+ },
67803
+ {
67804
+ uriTemplate: "smm://project/{project}/sonarqube/component-tree",
67805
+ name: "Project SonarQube component tree",
67806
+ description: "SonarQube component tree with metrics for a project.",
67807
+ mimeType: "application/json"
67808
+ },
67809
+ {
67810
+ uriTemplate: "smm://project/{project}/sonarqube/component-tree/history",
67811
+ name: "Project SonarQube component tree history",
67812
+ description: "Timestamped SonarQube component tree entries for a project.",
67813
+ mimeType: "application/json"
67911
67814
  }
67815
+ ];
67816
+ }
67817
+ __name(listResourceTemplates, "listResourceTemplates");
67818
+ __name2(listResourceTemplates, "listResourceTemplates");
67819
+ function listResources() {
67820
+ const repository = getConfigurationRepository();
67821
+ const projects = repository.getAllProjectNames();
67822
+ return [
67823
+ {
67824
+ uri: "smm://projects",
67825
+ name: "SMM projects",
67826
+ description: "Configured Software Metrics Machine projects.",
67827
+ mimeType: "application/json"
67828
+ },
67829
+ {
67830
+ uri: "smm://engineering-health/metrics",
67831
+ name: "Engineering health metric catalog",
67832
+ description: "Metric ids, categories, and labels available for engineering health evaluations.",
67833
+ mimeType: "application/json"
67834
+ },
67835
+ ...projects.flatMap((project) => [
67836
+ {
67837
+ uri: `smm://project/${encodeProject(project)}/configuration`,
67838
+ name: `${project} configuration`,
67839
+ description: "Redacted project configuration.",
67840
+ mimeType: "application/json"
67841
+ },
67842
+ {
67843
+ uri: `smm://project/${encodeProject(project)}/report`,
67844
+ name: `${project} report`,
67845
+ description: "Complete metrics report for the project.",
67846
+ mimeType: "application/json"
67847
+ },
67848
+ {
67849
+ uri: `smm://project/${encodeProject(project)}/engineering-health`,
67850
+ name: `${project} engineering health`,
67851
+ description: "Engineering health evaluation for the project.",
67852
+ mimeType: "application/json"
67853
+ },
67854
+ {
67855
+ uri: `smm://project/${encodeProject(project)}/dora`,
67856
+ name: `${project} DORA metrics`,
67857
+ description: "DORA and pipeline metrics for the project.",
67858
+ mimeType: "application/json"
67859
+ },
67860
+ {
67861
+ uri: `smm://project/${encodeProject(project)}/architecture/snapshots`,
67862
+ name: `${project} architecture snapshots`,
67863
+ description: "Architecture snapshots stored for the project.",
67864
+ mimeType: "application/json"
67865
+ },
67866
+ {
67867
+ uri: `smm://project/${encodeProject(project)}/evaluation/change-requests`,
67868
+ name: `${project} change request evaluation`,
67869
+ description: "Change request health evaluation for the project.",
67870
+ mimeType: "application/json"
67871
+ },
67872
+ {
67873
+ uri: `smm://project/${encodeProject(project)}/evaluation/pipelines`,
67874
+ name: `${project} pipeline evaluation`,
67875
+ description: "Pipeline health evaluation for the project.",
67876
+ mimeType: "application/json"
67877
+ },
67878
+ {
67879
+ uri: `smm://project/${encodeProject(project)}/evaluation/code`,
67880
+ name: `${project} code evaluation`,
67881
+ description: "Code health evaluation for the project.",
67882
+ mimeType: "application/json"
67883
+ },
67884
+ {
67885
+ uri: `smm://project/${encodeProject(project)}/evaluation/quality`,
67886
+ name: `${project} quality evaluation`,
67887
+ description: "SonarQube quality evaluation for the project.",
67888
+ mimeType: "application/json"
67889
+ },
67890
+ {
67891
+ uri: `smm://project/${encodeProject(project)}/evaluation/architecture`,
67892
+ name: `${project} architecture evaluation`,
67893
+ description: "Architecture health evaluation for the project.",
67894
+ mimeType: "application/json"
67895
+ },
67896
+ {
67897
+ uri: `smm://project/${encodeProject(project)}/big-o`,
67898
+ name: `${project} Big-O files`,
67899
+ description: "Big-O complexity classification for source files.",
67900
+ mimeType: "application/json"
67901
+ },
67902
+ {
67903
+ uri: `smm://project/${encodeProject(project)}/health-check`,
67904
+ name: `${project} health check`,
67905
+ description: "Dataset health report for the project.",
67906
+ mimeType: "application/json"
67907
+ },
67908
+ {
67909
+ uri: `smm://project/${encodeProject(project)}/architecture/summary`,
67910
+ name: `${project} architecture summary`,
67911
+ description: "Architecture snapshot metadata for the latest snapshot.",
67912
+ mimeType: "application/json"
67913
+ },
67914
+ {
67915
+ uri: `smm://project/${encodeProject(project)}/pipeline-dashboard`,
67916
+ name: `${project} pipeline dashboard`,
67917
+ description: "Full pipeline dashboard for the project.",
67918
+ mimeType: "application/json"
67919
+ },
67920
+ {
67921
+ uri: `smm://project/${encodeProject(project)}/saved-filters`,
67922
+ name: `${project} saved filters`,
67923
+ description: "Saved filters and reports for the project.",
67924
+ mimeType: "application/json"
67925
+ },
67926
+ {
67927
+ uri: `smm://project/${encodeProject(project)}/sonarqube/measurements`,
67928
+ name: `${project} SonarQube measurements`,
67929
+ description: "Latest SonarQube measurements for the project.",
67930
+ mimeType: "application/json"
67931
+ },
67932
+ {
67933
+ uri: `smm://project/${encodeProject(project)}/sonarqube/measurements/history`,
67934
+ name: `${project} SonarQube measurements history`,
67935
+ description: "Timestamped SonarQube measurement entries for the project.",
67936
+ mimeType: "application/json"
67937
+ },
67938
+ {
67939
+ uri: `smm://project/${encodeProject(project)}/sonarqube/component-tree`,
67940
+ name: `${project} SonarQube component tree`,
67941
+ description: "SonarQube component tree with metrics for the project.",
67942
+ mimeType: "application/json"
67943
+ },
67944
+ {
67945
+ uri: `smm://project/${encodeProject(project)}/sonarqube/component-tree/history`,
67946
+ name: `${project} SonarQube component tree history`,
67947
+ description: "Timestamped SonarQube component tree entries for the project.",
67948
+ mimeType: "application/json"
67949
+ }
67950
+ ])
67951
+ ];
67952
+ }
67953
+ __name(listResources, "listResources");
67954
+ __name2(listResources, "listResources");
67955
+ async function readResource(uri) {
67956
+ const resourceStartedAt = Date.now();
67957
+ resourceLogger.debug(`Reading resource ${uri}`);
67958
+ const repository = getConfigurationRepository();
67959
+ if (uri === "smm://projects") {
67960
+ resourceLogger.debug("Listing projects for resource smm://projects");
67961
+ const result = jsonResource(uri, {
67962
+ projects: repository.getAllProjects().map((project2) => ({
67963
+ github_repository: project2.github_repository,
67964
+ git_provider: project2.git_provider
67965
+ }))
67966
+ });
67967
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67968
+ return result;
67969
+ }
67970
+ if (uri === "smm://engineering-health/metrics") {
67971
+ resourceLogger.debug("Returning engineering health metric catalog");
67972
+ const result = jsonResource(uri, {
67973
+ categories: [
67974
+ "delivery",
67975
+ "quality",
67976
+ "collaboration",
67977
+ "architecture"
67978
+ ],
67979
+ metrics: listEngineeringHealthMetricCatalog()
67980
+ });
67981
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
67982
+ return result;
67983
+ }
67984
+ const match = uri.match(/^smm:\/\/project\/([^/]+)\/(configuration|report|engineering-health|dora|architecture\/snapshots|architecture\/summary|evaluation\/(change-requests|pipelines|code|quality|architecture)|big-o|health-check|pipeline-dashboard|saved-filters|sonarqube\/(measurements|measurements\/history|component-tree|component-tree\/history))$/);
67985
+ if (!match) {
67986
+ resourceLogger.warn(`Unknown MCP resource requested: ${uri}`);
67987
+ throw new Error(`Unknown MCP resource: ${uri}`);
67988
+ }
67989
+ const projectName = decodeProject(match[1]);
67990
+ const resourceType = match[2];
67991
+ resourceLogger.debug(`Resolved resource ${uri}`, {
67992
+ projectName,
67993
+ resourceType
67994
+ });
67995
+ const project = repository.getProjectByName(projectName);
67996
+ if (!project) {
67997
+ resourceLogger.warn(`Unknown project for resource ${uri}: ${projectName}`);
67998
+ throw new Error(`Unknown project: ${projectName}`);
67999
+ }
68000
+ if (resourceType === "configuration") {
68001
+ resourceLogger.debug(`Returning redacted configuration for ${projectName}`);
68002
+ const result = jsonResource(uri, redactSecrets(project));
68003
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68004
+ return result;
68005
+ }
68006
+ const reader = createMcpMetricsReader({
68007
+ project: projectName
68008
+ });
68009
+ if (resourceType === "report") {
68010
+ const result = jsonResource(uri, await reader.getFullReport());
68011
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68012
+ return result;
68013
+ }
68014
+ if (resourceType === "engineering-health") {
68015
+ const result = jsonResource(uri, await reader.getEngineeringHealthEvaluation({
68016
+ project: projectName
68017
+ }));
68018
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68019
+ return result;
68020
+ }
68021
+ if (resourceType === "dora") {
68022
+ const result = jsonResource(uri, await reader.getDoraMetrics({
68023
+ project: projectName
68024
+ }));
68025
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68026
+ return result;
68027
+ }
68028
+ if (resourceType === "evaluation/change-requests") {
68029
+ const result = jsonResource(uri, await reader.evaluateChangeRequests());
68030
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68031
+ return result;
68032
+ }
68033
+ if (resourceType === "evaluation/pipelines") {
68034
+ const result = jsonResource(uri, await reader.evaluatePipelines());
68035
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68036
+ return result;
68037
+ }
68038
+ if (resourceType === "evaluation/code") {
68039
+ const result = jsonResource(uri, await reader.evaluateCode());
68040
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68041
+ return result;
68042
+ }
68043
+ if (resourceType === "evaluation/quality") {
68044
+ const result = jsonResource(uri, await reader.evaluateQuality());
68045
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68046
+ return result;
68047
+ }
68048
+ if (resourceType === "evaluation/architecture") {
68049
+ const result = jsonResource(uri, await reader.evaluateArchitecture({
68050
+ project: projectName
68051
+ }));
68052
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68053
+ return result;
68054
+ }
68055
+ if (resourceType === "big-o") {
68056
+ const result = jsonResource(uri, await reader.listBigOFiles());
68057
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68058
+ return result;
68059
+ }
68060
+ if (resourceType === "health-check") {
68061
+ const result = jsonResource(uri, await reader.healthCheck());
68062
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68063
+ return result;
68064
+ }
68065
+ if (resourceType === "architecture/summary") {
68066
+ const result = jsonResource(uri, await reader.getArchitectureSummary());
68067
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68068
+ return result;
68069
+ }
68070
+ if (resourceType === "pipeline-dashboard") {
68071
+ const result = jsonResource(uri, await reader.getPipelineDashboard({
68072
+ project: projectName
68073
+ }));
68074
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68075
+ return result;
68076
+ }
68077
+ if (resourceType === "saved-filters") {
68078
+ const result = jsonResource(uri, await reader.listSavedFilters());
68079
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68080
+ return result;
68081
+ }
68082
+ if (resourceType === "sonarqube/measurements") {
68083
+ const result = jsonResource(uri, await reader.getSonarqubeMeasurements());
68084
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68085
+ return result;
68086
+ }
68087
+ if (resourceType === "sonarqube/measurements/history") {
68088
+ const result = jsonResource(uri, await reader.getSonarqubeMeasurementsHistory());
68089
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68090
+ return result;
68091
+ }
68092
+ if (resourceType === "sonarqube/component-tree") {
68093
+ const result = jsonResource(uri, await reader.getSonarqubeComponentTree({
68094
+ project: projectName
68095
+ }));
68096
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68097
+ return result;
68098
+ }
68099
+ if (resourceType === "sonarqube/component-tree/history") {
68100
+ const result = jsonResource(uri, await reader.getSonarqubeComponentTreeHistory({
68101
+ project: projectName
68102
+ }));
68103
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68104
+ return result;
68105
+ }
68106
+ const snapshotsResult = jsonResource(uri, await reader.listArchitectureSnapshots());
68107
+ resourceLogger.debug(`Read resource ${uri} in ${Date.now() - resourceStartedAt}ms`);
68108
+ return snapshotsResult;
68109
+ }
68110
+ __name(readResource, "readResource");
68111
+ __name2(readResource, "readResource");
68112
+ var prompts = [
68113
+ {
68114
+ name: "smm_sprint_health_review",
68115
+ description: "Review engineering health for the current sprint and highlight metrics that need attention.",
68116
+ arguments: [
68117
+ {
68118
+ name: "project",
68119
+ description: "Optional github_repository project name from smm_config.json.",
68120
+ required: false
68121
+ },
68122
+ {
68123
+ name: "startDate",
68124
+ description: "Current window start date (YYYY-MM-DD).",
68125
+ required: false
68126
+ },
68127
+ {
68128
+ name: "endDate",
68129
+ description: "Current window end date (YYYY-MM-DD).",
68130
+ required: false
68131
+ }
68132
+ ]
68133
+ },
68134
+ {
68135
+ name: "smm_compare_windows",
68136
+ description: "Compare engineering health between two time windows and summarise what improved or regressed.",
68137
+ arguments: [
68138
+ {
68139
+ name: "project",
68140
+ description: "Optional github_repository project name from smm_config.json.",
68141
+ required: false
68142
+ },
68143
+ {
68144
+ name: "startDate",
68145
+ description: "Current window start date (YYYY-MM-DD).",
68146
+ required: true
68147
+ },
68148
+ {
68149
+ name: "endDate",
68150
+ description: "Current window end date (YYYY-MM-DD).",
68151
+ required: true
68152
+ },
68153
+ {
68154
+ name: "compareStartDate",
68155
+ description: "Previous window start date (YYYY-MM-DD).",
68156
+ required: true
68157
+ },
68158
+ {
68159
+ name: "compareEndDate",
68160
+ description: "Previous window end date (YYYY-MM-DD).",
68161
+ required: true
68162
+ }
68163
+ ]
68164
+ },
68165
+ {
68166
+ name: "smm_dora_summary",
68167
+ description: "Summarise DORA metrics for a project, including deployment frequency and failure rate.",
68168
+ arguments: [
68169
+ {
68170
+ name: "project",
68171
+ description: "Optional github_repository project name from smm_config.json.",
68172
+ required: false
68173
+ },
68174
+ {
68175
+ name: "startDate",
68176
+ description: "Optional window start date (YYYY-MM-DD).",
68177
+ required: false
68178
+ },
68179
+ {
68180
+ name: "endDate",
68181
+ description: "Optional window end date (YYYY-MM-DD).",
68182
+ required: false
68183
+ }
68184
+ ]
68185
+ },
68186
+ {
68187
+ name: "smm_code_hotspots",
68188
+ description: "Identify code hotspots (high churn and high coupling files) and pair-programming gaps for a project.",
68189
+ arguments: [
68190
+ {
68191
+ name: "project",
68192
+ description: "Optional github_repository project name from smm_config.json.",
68193
+ required: false
68194
+ },
68195
+ {
68196
+ name: "startDate",
68197
+ description: "Optional window start date (YYYY-MM-DD).",
68198
+ required: false
68199
+ },
68200
+ {
68201
+ name: "endDate",
68202
+ description: "Optional window end date (YYYY-MM-DD).",
68203
+ required: false
68204
+ }
68205
+ ]
68206
+ }
68207
+ ];
68208
+ function getArg(values, name) {
68209
+ const value = values[name];
68210
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
68211
+ }
68212
+ __name(getArg, "getArg");
68213
+ __name2(getArg, "getArg");
68214
+ function optional(value) {
68215
+ return value ? value : "<not provided>";
68216
+ }
68217
+ __name(optional, "optional");
68218
+ __name2(optional, "optional");
68219
+ async function getPrompt(name, argumentsValue) {
68220
+ promptLogger.debug(`Building prompt ${name}`, {
68221
+ arguments: argumentsValue
68222
+ });
68223
+ const values = argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue) ? argumentsValue : {};
68224
+ const project = getArg(values, "project");
68225
+ const startDate = getArg(values, "startDate");
68226
+ const endDate = getArg(values, "endDate");
68227
+ const compareStartDate = getArg(values, "compareStartDate");
68228
+ const compareEndDate = getArg(values, "compareEndDate");
68229
+ const messages = [];
68230
+ switch (name) {
68231
+ case "smm_sprint_health_review":
68232
+ messages.push({
68233
+ role: "user",
68234
+ content: {
68235
+ type: "text",
68236
+ text: [
68237
+ "You are acting as a software engineering coach.",
68238
+ "Use the Software Metrics Machine MCP tools to evaluate the engineering health of the project.",
68239
+ "",
68240
+ `Project: ${optional(project)}`,
68241
+ `Current window: ${optional(startDate)} to ${optional(endDate)}`,
68242
+ "",
68243
+ "Steps:",
68244
+ "1. Call smm_get_engineering_health with the filters above.",
68245
+ '2. Highlight any metric whose recommendation level is "watch" or "critical".',
68246
+ "3. Suggest one concrete action for each degraded metric, grounded in the data returned."
68247
+ ].join("\n")
68248
+ }
68249
+ });
68250
+ break;
68251
+ case "smm_compare_windows":
68252
+ messages.push({
68253
+ role: "user",
68254
+ content: {
68255
+ type: "text",
68256
+ text: [
68257
+ "You are acting as a software engineering coach.",
68258
+ "Use the Software Metrics Machine MCP tools to compare two windows.",
68259
+ "",
68260
+ `Project: ${optional(project)}`,
68261
+ `Current window: ${optional(startDate)} to ${optional(endDate)}`,
68262
+ `Previous window: ${optional(compareStartDate)} to ${optional(compareEndDate)}`,
68263
+ "",
68264
+ "Steps:",
68265
+ "1. Call smm_get_engineering_health with startDate, endDate, compareStartDate, and compareEndDate.",
68266
+ "2. For each metric, summarise whether the trend is improving, stable, or degrading.",
68267
+ "3. Produce a short before/after table and a prioritised list of follow-up actions."
68268
+ ].join("\n")
68269
+ }
68270
+ });
68271
+ break;
68272
+ case "smm_dora_summary":
68273
+ messages.push({
68274
+ role: "user",
68275
+ content: {
68276
+ type: "text",
68277
+ text: [
68278
+ "You are acting as a DORA metrics analyst.",
68279
+ "Use the Software Metrics Machine MCP tools to report DORA metrics.",
68280
+ "",
68281
+ `Project: ${optional(project)}`,
68282
+ `Window: ${optional(startDate)} to ${optional(endDate)}`,
68283
+ "",
68284
+ "Steps:",
68285
+ "1. Call smm_get_dora_metrics with the filters above.",
68286
+ "2. Report deployment frequency, failure rate signals, and pipeline duration.",
68287
+ "3. Classify the project against the DORA tiers (elite, high, medium, low) where possible."
68288
+ ].join("\n")
68289
+ }
68290
+ });
68291
+ break;
68292
+ case "smm_code_hotspots":
68293
+ messages.push({
68294
+ role: "user",
68295
+ content: {
68296
+ type: "text",
68297
+ text: [
68298
+ "You are acting as a code health reviewer.",
68299
+ "Use the Software Metrics Machine MCP tools to surface code hotspots.",
68300
+ "",
68301
+ `Project: ${optional(project)}`,
68302
+ `Window: ${optional(startDate)} to ${optional(endDate)}`,
68303
+ "",
68304
+ "Steps:",
68305
+ "1. Call smm_get_code_metrics to retrieve churn, coupling, and pairing data.",
68306
+ "2. Identify files with the highest churn and strongest coupling.",
68307
+ "3. Cross-reference pairing gaps and propose concrete refactoring or pairing actions."
68308
+ ].join("\n")
68309
+ }
68310
+ });
68311
+ break;
68312
+ default:
68313
+ throw new Error(`Unknown MCP prompt: ${name}`);
68314
+ }
68315
+ return {
68316
+ description: prompts.find((prompt2) => prompt2.name === name)?.description,
68317
+ messages
67912
68318
  };
67913
68319
  }
67914
- __name(error, "error");
67915
- __name2(error, "error");
67916
- function getStringParam(params, fieldName) {
67917
- const value = params?.[fieldName];
67918
- return typeof value === "string" ? value : void 0;
67919
- }
67920
- __name(getStringParam, "getStringParam");
67921
- __name2(getStringParam, "getStringParam");
67922
- async function handleRequest(request) {
67923
- return handleRequestWithLogging(request);
67924
- }
67925
- __name(handleRequest, "handleRequest");
67926
- __name2(handleRequest, "handleRequest");
67927
- async function handleRequestWithLogging(request, log2) {
67928
- if (request.id === void 0 && request.method.startsWith("notifications/")) {
67929
- log2?.(`Received notification: ${request.method}`);
67930
- return void 0;
68320
+ __name(getPrompt, "getPrompt");
68321
+ __name2(getPrompt, "getPrompt");
68322
+ function jsonSchemaPropertyToZod(prop) {
68323
+ if (!prop) {
68324
+ return import_zod.z.unknown();
68325
+ }
68326
+ const description = typeof prop.description === "string" ? prop.description : void 0;
68327
+ if (Array.isArray(prop.enum)) {
68328
+ const values = prop.enum.filter((v) => typeof v === "string");
68329
+ if (values.length > 0) {
68330
+ const literals = values.map((v) => import_zod.z.literal(v));
68331
+ const schema = literals.length === 1 ? literals[0] : import_zod.z.union(literals);
68332
+ return description ? schema.describe(description) : schema;
68333
+ }
68334
+ }
68335
+ switch (prop.type) {
68336
+ case "string":
68337
+ return description ? import_zod.z.string().describe(description) : import_zod.z.string();
68338
+ case "number":
68339
+ return description ? import_zod.z.number().describe(description) : import_zod.z.number();
68340
+ case "boolean":
68341
+ return description ? import_zod.z.boolean().describe(description) : import_zod.z.boolean();
68342
+ default:
68343
+ return import_zod.z.unknown();
67931
68344
  }
67932
- try {
67933
- switch (request.method) {
67934
- case "initialize":
67935
- log2?.("Client initialized MCP session");
67936
- return ok(request.id, {
67937
- protocolVersion: "2025-06-18",
67938
- capabilities: {
67939
- tools: {},
67940
- resources: {
67941
- list: true,
67942
- read: true,
67943
- listChanged: false
67944
- },
67945
- prompts: {
67946
- list: true,
67947
- get: true,
67948
- listChanged: false
67949
- },
67950
- logging: {}
67951
- },
67952
- serverInfo: SERVER_INFO
67953
- });
67954
- case "ping":
67955
- log2?.("Received ping");
67956
- return ok(request.id, {});
67957
- case "tools/list":
67958
- log2?.(`Listing ${tools.length} MCP tools`);
67959
- return ok(request.id, {
67960
- tools: tools.map(({ handler: _handler, ...tool }) => tool)
67961
- });
67962
- case "tools/call": {
67963
- const name = getStringParam(request.params, "name");
67964
- const selectedTool = name ? findTool(name) : void 0;
67965
- if (!selectedTool) {
67966
- log2?.(`Rejected unknown tool call: ${name || "<missing>"}`);
67967
- return error(request.id, -32602, `Unknown tool: ${name || "<missing>"}`);
67968
- }
67969
- const toolStartedAt = Date.now();
67970
- log2?.(`Running tool: ${name}`);
67971
- try {
67972
- const result = await selectedTool.handler(request.params?.arguments);
67973
- log2?.(`Completed tool: ${name} in ${Date.now() - toolStartedAt}ms`);
67974
- return ok(request.id, result);
67975
- } catch (toolError) {
67976
- const toolMessage = toolError instanceof Error ? toolError.message : String(toolError);
67977
- log2?.(`Failed tool: ${name} after ${Date.now() - toolStartedAt}ms (${toolMessage})`);
67978
- throw toolError;
67979
- }
67980
- }
67981
- case "resources/list":
67982
- log2?.("Listing MCP resources");
67983
- return ok(request.id, {
67984
- resources: listResources()
67985
- });
67986
- case "resources/templates/list":
67987
- log2?.("Listing MCP resource templates");
67988
- return ok(request.id, {
67989
- resourceTemplates: listResourceTemplates()
67990
- });
67991
- case "resources/read": {
67992
- const uri = getStringParam(request.params, "uri");
67993
- if (!uri) {
67994
- log2?.("Rejected resources/read request without uri");
67995
- return error(request.id, -32602, "resources/read requires a uri parameter");
67996
- }
67997
- const resourceStartedAt = Date.now();
67998
- log2?.(`Reading resource: ${uri}`);
67999
- try {
68000
- const resourceResult = await readResource(uri);
68001
- log2?.(`Read resource: ${uri} in ${Date.now() - resourceStartedAt}ms`);
68002
- return ok(request.id, resourceResult);
68003
- } catch (resourceError) {
68004
- const resourceMessage = resourceError instanceof Error ? resourceError.message : String(resourceError);
68005
- log2?.(`Failed resource: ${uri} after ${Date.now() - resourceStartedAt}ms (${resourceMessage})`);
68006
- throw resourceError;
68007
- }
68008
- }
68009
- case "prompts/list":
68010
- log2?.(`Listing ${prompts.length} MCP prompts`);
68011
- return ok(request.id, {
68012
- prompts
68013
- });
68014
- case "prompts/get": {
68015
- const name = getStringParam(request.params, "name");
68016
- if (!name) {
68017
- log2?.("Rejected prompts/get request without name");
68018
- return error(request.id, -32602, "prompts/get requires a name parameter");
68019
- }
68020
- const knownPrompt = prompts.find((prompt2) => prompt2.name === name);
68021
- if (!knownPrompt) {
68022
- log2?.(`Rejected unknown prompt: ${name}`);
68023
- return error(request.id, -32602, `Unknown prompt: ${name}`);
68024
- }
68025
- log2?.(`Reading prompt: ${name}`);
68026
- return ok(request.id, await getPrompt(name, request.params?.arguments));
68027
- }
68028
- case "logging/setLevel": {
68029
- const level = getStringParam(request.params, "level");
68030
- if (!level) {
68031
- return error(request.id, -32602, "logging/setLevel requires a level parameter");
68032
- }
68033
- const normalized = level.toLowerCase();
68034
- if (normalized !== "debug" && normalized !== "info" && normalized !== "critical") {
68035
- return error(request.id, -32602, `Invalid log level: ${level}. Must be debug, info, or critical.`);
68036
- }
68037
- log2?.(`Setting MCP log level to ${normalized}`);
68038
- configureMcpLogging(normalized === "debug" ? {
68039
- debug: true
68040
- } : normalized === "critical" ? {
68041
- quiet: true
68042
- } : {});
68043
- return ok(request.id, {});
68345
+ }
68346
+ __name(jsonSchemaPropertyToZod, "jsonSchemaPropertyToZod");
68347
+ __name2(jsonSchemaPropertyToZod, "jsonSchemaPropertyToZod");
68348
+ function jsonSchemaToZodShape(schema) {
68349
+ if (!schema || typeof schema !== "object") {
68350
+ return {};
68351
+ }
68352
+ const properties = schema.properties ?? {};
68353
+ const shape = {};
68354
+ for (const [key, prop] of Object.entries(properties)) {
68355
+ const propSchema = prop;
68356
+ shape[key] = jsonSchemaPropertyToZod(propSchema).optional();
68357
+ }
68358
+ return shape;
68359
+ }
68360
+ __name(jsonSchemaToZodShape, "jsonSchemaToZodShape");
68361
+ __name2(jsonSchemaToZodShape, "jsonSchemaToZodShape");
68362
+ function adaptToolResult(result) {
68363
+ return {
68364
+ content: result.content,
68365
+ ...result.structuredContent !== void 0 ? {
68366
+ structuredContent: result.structuredContent
68367
+ } : {},
68368
+ ...result.isError !== void 0 ? {
68369
+ isError: result.isError
68370
+ } : {}
68371
+ };
68372
+ }
68373
+ __name(adaptToolResult, "adaptToolResult");
68374
+ __name2(adaptToolResult, "adaptToolResult");
68375
+ function registerTools(server) {
68376
+ for (const tool of tools) {
68377
+ const zodShape = jsonSchemaToZodShape(tool.inputSchema);
68378
+ const inputSchema = import_zod.z.object(zodShape);
68379
+ server.registerTool(tool.name, {
68380
+ description: tool.description,
68381
+ inputSchema
68382
+ }, async (args) => {
68383
+ const result = await tool.handler(args);
68384
+ return adaptToolResult(result);
68385
+ });
68386
+ }
68387
+ }
68388
+ __name(registerTools, "registerTools");
68389
+ __name2(registerTools, "registerTools");
68390
+ function registerResources(server) {
68391
+ const staticResources = listResources();
68392
+ for (const resource of staticResources) {
68393
+ server.registerResource(resource.name, resource.uri, {
68394
+ description: resource.description,
68395
+ mimeType: resource.mimeType
68396
+ }, async (uri) => {
68397
+ const result = await readResource(uri.toString());
68398
+ return {
68399
+ contents: result.contents.map((entry) => ({
68400
+ uri: entry.uri,
68401
+ mimeType: entry.mimeType,
68402
+ text: entry.text
68403
+ }))
68404
+ };
68405
+ });
68406
+ }
68407
+ const templates = listResourceTemplates();
68408
+ for (const template of templates) {
68409
+ server.registerResource(template.name, new import_server.ResourceTemplate(template.uriTemplate, {
68410
+ list: void 0
68411
+ }), {
68412
+ description: template.description,
68413
+ mimeType: template.mimeType
68414
+ }, async (uri) => {
68415
+ const result = await readResource(uri.toString());
68416
+ return {
68417
+ contents: result.contents.map((entry) => ({
68418
+ uri: entry.uri,
68419
+ mimeType: entry.mimeType,
68420
+ text: entry.text
68421
+ }))
68422
+ };
68423
+ });
68424
+ }
68425
+ }
68426
+ __name(registerResources, "registerResources");
68427
+ __name2(registerResources, "registerResources");
68428
+ function registerPrompts(server) {
68429
+ for (const prompt2 of prompts) {
68430
+ const argsShape = {};
68431
+ if (prompt2.arguments) {
68432
+ for (const arg of prompt2.arguments) {
68433
+ argsShape[arg.name] = import_zod.z.string().optional().describe(arg.description);
68044
68434
  }
68045
- default:
68046
- log2?.(`Rejected unknown method: ${request.method}`);
68047
- return error(request.id, -32601, `Method not found: ${request.method}`);
68048
68435
  }
68049
- } catch (caught) {
68050
- const message = caught instanceof Error ? caught.message : String(caught);
68051
- log2?.(`Request failed for ${request.method}: ${message}`);
68052
- return error(request.id, -32e3, message);
68436
+ server.registerPrompt(prompt2.name, {
68437
+ description: prompt2.description,
68438
+ argsSchema: argsShape
68439
+ }, async (args) => {
68440
+ const result = await getPrompt(prompt2.name, args);
68441
+ return {
68442
+ ...result.description !== void 0 ? {
68443
+ description: result.description
68444
+ } : {},
68445
+ messages: result.messages.map((message) => ({
68446
+ role: message.role,
68447
+ content: {
68448
+ type: "text",
68449
+ text: message.content.text
68450
+ }
68451
+ }))
68452
+ };
68453
+ });
68053
68454
  }
68054
68455
  }
68055
- __name(handleRequestWithLogging, "handleRequestWithLogging");
68056
- __name2(handleRequestWithLogging, "handleRequestWithLogging");
68456
+ __name(registerPrompts, "registerPrompts");
68457
+ __name2(registerPrompts, "registerPrompts");
68458
+ function registerAll(server) {
68459
+ registerTools(server);
68460
+ registerResources(server);
68461
+ registerPrompts(server);
68462
+ }
68463
+ __name(registerAll, "registerAll");
68464
+ __name2(registerAll, "registerAll");
68465
+ var SERVER_INFO = {
68466
+ name: "software-metrics-machine",
68467
+ version: (0, import_utils52.getApplicationVersion)()
68468
+ };
68469
+ var log = /* @__PURE__ */ __name2((message) => {
68470
+ transportLogger.info(message);
68471
+ }, "log");
68472
+ function createMcpServer() {
68473
+ const server = new import_server2.McpServer(SERVER_INFO, {
68474
+ capabilities: {
68475
+ tools: {},
68476
+ resources: {},
68477
+ prompts: {},
68478
+ logging: {}
68479
+ }
68480
+ });
68481
+ registerAll(server);
68482
+ return server;
68483
+ }
68484
+ __name(createMcpServer, "createMcpServer");
68485
+ __name2(createMcpServer, "createMcpServer");
68057
68486
  async function startMcpServer2(options = {}) {
68058
68487
  redirectConsoleToStderr();
68059
68488
  configureMcpLogging({
@@ -68062,37 +68491,8 @@ globstar while`, t, d, e, u, m), this.matchOne(t.slice(d), e.slice(u), s)) retur
68062
68491
  log(`Starting Software Metrics Machine MCP server v${SERVER_INFO.version} over stdio`);
68063
68492
  log(`Configuration directory: ${(0, import_core42.resolveStoreDataAt)(process.env) || "<not set>"}`);
68064
68493
  log(`Available tools: ${tools.map((tool) => tool.name).join(", ")}`);
68065
- const reader = (0, import_node_readline2.createInterface)({
68066
- input: process.stdin,
68067
- output: process.stdout,
68068
- terminal: false
68069
- });
68070
- reader.on("close", () => {
68071
- log("MCP stdio input closed; server stopped");
68072
- });
68073
- for await (const line of reader) {
68074
- if (!line.trim()) {
68075
- continue;
68076
- }
68077
- let response;
68078
- try {
68079
- const parsed = JSON.parse(line);
68080
- if (!isJsonRpcRequest(parsed)) {
68081
- log("Rejected invalid JSON-RPC request");
68082
- response = error(null, -32600, "Invalid JSON-RPC request");
68083
- } else {
68084
- log(`Received request: ${parsed.method}`);
68085
- response = await handleRequestWithLogging(parsed, log);
68086
- }
68087
- } catch (caught) {
68088
- log(`Failed to parse request: ${caught instanceof Error ? caught.message : "Invalid JSON payload"}`);
68089
- response = error(null, -32700, caught instanceof Error ? caught.message : "Invalid JSON payload");
68090
- }
68091
- if (response) {
68092
- process.stdout.write(`${JSON.stringify(response)}
68093
- `);
68094
- }
68095
- }
68494
+ await (0, import_stdio.serveStdio)(() => createMcpServer());
68495
+ log("MCP server connected to stdio transport");
68096
68496
  }
68097
68497
  __name(startMcpServer2, "startMcpServer");
68098
68498
  __name2(startMcpServer2, "startMcpServer");