cov-loupe 3.0.0 → 4.0.0.pre

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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +230 -0
  3. data/CLAUDE.md +5 -0
  4. data/CODE_OF_CONDUCT.md +62 -0
  5. data/CONTRIBUTING.md +102 -0
  6. data/GEMINI.md +5 -0
  7. data/README.md +154 -51
  8. data/RELEASE_NOTES.md +452 -0
  9. data/dev/images/cov-loupe-icon-lores.png +0 -0
  10. data/dev/images/cov-loupe-icon-square.png +0 -0
  11. data/dev/images/cov-loupe-icon.png +0 -0
  12. data/dev/images/cov-loupe-logo.png +0 -0
  13. data/dev/prompts/README.md +74 -0
  14. data/dev/prompts/archive/architectural-review-and-actions-prompt.md +53 -0
  15. data/dev/prompts/archive/investigate-and-report-issues-prompt.md +33 -0
  16. data/dev/prompts/archive/produce-action-items-prompt.md +25 -0
  17. data/dev/prompts/guidelines/ai-code-evaluator-guidelines.md +337 -0
  18. data/dev/prompts/improve/refactor-test-suite.md +18 -0
  19. data/dev/prompts/improve/simplify-code-logic.md +133 -0
  20. data/dev/prompts/improve/update-documentation.md +21 -0
  21. data/dev/prompts/review/comprehensive-codebase-review.md +176 -0
  22. data/dev/prompts/review/identify-action-items.md +143 -0
  23. data/dev/prompts/review/verify-code-changes.md +54 -0
  24. data/dev/prompts/validate/create-screencast-outline.md +234 -0
  25. data/dev/prompts/validate/test-documentation-examples.md +180 -0
  26. data/docs/QUICKSTART.md +63 -0
  27. data/docs/assets/images/cov-loupe-logo-lores.png +0 -0
  28. data/docs/assets/images/cov-loupe-logo.png +0 -0
  29. data/docs/assets/images/favicon.png +0 -0
  30. data/docs/assets/stylesheets/branding.css +16 -0
  31. data/docs/assets/stylesheets/extra.css +15 -0
  32. data/docs/code_of_conduct.md +1 -0
  33. data/docs/contributing.md +1 -0
  34. data/docs/dev/ARCHITECTURE.md +56 -11
  35. data/docs/dev/DEVELOPMENT.md +116 -12
  36. data/docs/dev/FUTURE_ENHANCEMENTS.md +14 -0
  37. data/docs/dev/README.md +3 -2
  38. data/docs/dev/RELEASING.md +2 -0
  39. data/docs/dev/arch-decisions/README.md +10 -7
  40. data/docs/dev/arch-decisions/application-architecture.md +259 -0
  41. data/docs/dev/arch-decisions/coverage-data-quality.md +193 -0
  42. data/docs/dev/arch-decisions/output-character-mode.md +217 -0
  43. data/docs/dev/arch-decisions/path-resolution.md +90 -0
  44. data/docs/dev/arch-decisions/{004-x-arch-decision.md → policy-validation.md} +32 -28
  45. data/docs/dev/arch-decisions/{005-x-arch-decision.md → simplecov-integration.md} +47 -44
  46. data/docs/dev/presentations/cov-loupe-presentation.md +15 -13
  47. data/docs/examples/mcp-inputs.md +3 -0
  48. data/docs/examples/prompts.md +3 -0
  49. data/docs/examples/success_predicates.md +3 -0
  50. data/docs/fixtures/demo_project/.resultset.json +170 -0
  51. data/docs/fixtures/demo_project/README.md +6 -0
  52. data/docs/fixtures/demo_project/app/controllers/admin/audit_logs_controller.rb +19 -0
  53. data/docs/fixtures/demo_project/app/controllers/orders_controller.rb +26 -0
  54. data/docs/fixtures/demo_project/app/models/order.rb +20 -0
  55. data/docs/fixtures/demo_project/app/models/user.rb +19 -0
  56. data/docs/fixtures/demo_project/lib/api/client.rb +22 -0
  57. data/docs/fixtures/demo_project/lib/ops/jobs/cleanup_job.rb +16 -0
  58. data/docs/fixtures/demo_project/lib/ops/jobs/report_job.rb +17 -0
  59. data/docs/fixtures/demo_project/lib/payments/processor.rb +15 -0
  60. data/docs/fixtures/demo_project/lib/payments/refund_service.rb +15 -0
  61. data/docs/fixtures/demo_project/lib/payments/reporting/exporter.rb +16 -0
  62. data/docs/index.md +1 -0
  63. data/docs/license.md +3 -0
  64. data/docs/release_notes.md +3 -0
  65. data/docs/user/ADVANCED_USAGE.md +208 -115
  66. data/docs/user/CLI_FALLBACK_FOR_LLMS.md +2 -0
  67. data/docs/user/CLI_USAGE.md +276 -101
  68. data/docs/user/ERROR_HANDLING.md +4 -4
  69. data/docs/user/EXAMPLES.md +121 -128
  70. data/docs/user/INSTALLATION.md +9 -28
  71. data/docs/user/LIBRARY_API.md +227 -122
  72. data/docs/user/MCP_INTEGRATION.md +114 -203
  73. data/docs/user/README.md +5 -1
  74. data/docs/user/TROUBLESHOOTING.md +49 -27
  75. data/docs/user/installing-a-prelease-version-of-covloupe.md +43 -0
  76. data/docs/user/{V2-BREAKING-CHANGES.md → migrations/MIGRATING_TO_V2.md} +62 -72
  77. data/docs/user/migrations/MIGRATING_TO_V3.md +72 -0
  78. data/docs/user/migrations/MIGRATING_TO_V4.md +591 -0
  79. data/docs/user/migrations/README.md +22 -0
  80. data/docs/user/prompts/README.md +9 -0
  81. data/docs/user/prompts/non-web-coverage-analysis-prompt.md +103 -0
  82. data/docs/user/prompts/rails-coverage-analysis-prompt.md +94 -0
  83. data/docs/user/prompts/use-cli-not-mcp-prompt.md +53 -0
  84. data/examples/cli_demo.sh +77 -0
  85. data/examples/filter_and_table_demo-output.md +114 -0
  86. data/examples/filter_and_table_demo.rb +174 -0
  87. data/examples/fixtures/demo_project/coverage/.resultset.json +10 -0
  88. data/examples/mcp-inputs/README.md +66 -0
  89. data/examples/mcp-inputs/coverage_detailed.json +1 -0
  90. data/examples/mcp-inputs/coverage_raw.json +1 -0
  91. data/examples/mcp-inputs/coverage_summary.json +1 -0
  92. data/examples/mcp-inputs/list.json +1 -0
  93. data/examples/mcp-inputs/uncovered_lines.json +1 -0
  94. data/examples/prompts/README.md +27 -0
  95. data/examples/prompts/custom_resultset.txt +2 -0
  96. data/examples/prompts/detailed_with_source.txt +2 -0
  97. data/examples/prompts/list_lowest.txt +2 -0
  98. data/examples/prompts/summary.txt +2 -0
  99. data/examples/prompts/uncovered.txt +2 -0
  100. data/examples/success_predicates/README.md +198 -0
  101. data/examples/success_predicates/all_files_above_threshold_predicate.rb +21 -0
  102. data/examples/success_predicates/directory_specific_thresholds_predicate.rb +30 -0
  103. data/examples/success_predicates/project_coverage_minimum_predicate.rb +6 -0
  104. data/lib/cov_loupe/base_tool.rb +229 -20
  105. data/lib/cov_loupe/cli.rb +132 -23
  106. data/lib/cov_loupe/commands/base_command.rb +25 -6
  107. data/lib/cov_loupe/commands/command_factory.rb +0 -1
  108. data/lib/cov_loupe/commands/detailed_command.rb +10 -5
  109. data/lib/cov_loupe/commands/list_command.rb +2 -1
  110. data/lib/cov_loupe/commands/raw_command.rb +7 -5
  111. data/lib/cov_loupe/commands/summary_command.rb +12 -7
  112. data/lib/cov_loupe/commands/totals_command.rb +74 -10
  113. data/lib/cov_loupe/commands/uncovered_command.rb +7 -5
  114. data/lib/cov_loupe/commands/validate_command.rb +11 -3
  115. data/lib/cov_loupe/commands/version_command.rb +6 -4
  116. data/lib/cov_loupe/{app_config.rb → config/app_config.rb} +13 -5
  117. data/lib/cov_loupe/config/app_context.rb +43 -0
  118. data/lib/cov_loupe/config/boolean_type.rb +91 -0
  119. data/lib/cov_loupe/config/logger.rb +92 -0
  120. data/lib/cov_loupe/{option_normalizers.rb → config/option_normalizers.rb} +55 -24
  121. data/lib/cov_loupe/{option_parser_builder.rb → config/option_parser_builder.rb} +46 -24
  122. data/lib/cov_loupe/coverage/coverage_calculator.rb +53 -0
  123. data/lib/cov_loupe/coverage/coverage_reporter.rb +63 -0
  124. data/lib/cov_loupe/coverage/coverage_table_formatter.rb +133 -0
  125. data/lib/cov_loupe/{error_handler.rb → errors/error_handler.rb} +21 -33
  126. data/lib/cov_loupe/{errors.rb → errors/errors.rb} +48 -71
  127. data/lib/cov_loupe/formatters/formatters.rb +75 -0
  128. data/lib/cov_loupe/formatters/source_formatter.rb +18 -7
  129. data/lib/cov_loupe/formatters/table_formatter.rb +80 -0
  130. data/lib/cov_loupe/loaders/all.rb +15 -0
  131. data/lib/cov_loupe/loaders/all_cli.rb +10 -0
  132. data/lib/cov_loupe/loaders/all_mcp.rb +23 -0
  133. data/lib/cov_loupe/loaders/resultset_loader.rb +147 -0
  134. data/lib/cov_loupe/mcp_server.rb +3 -2
  135. data/lib/cov_loupe/model/model.rb +520 -0
  136. data/lib/cov_loupe/model/model_data.rb +13 -0
  137. data/lib/cov_loupe/model/model_data_cache.rb +116 -0
  138. data/lib/cov_loupe/option_parsers/env_options_parser.rb +17 -6
  139. data/lib/cov_loupe/option_parsers/error_helper.rb +16 -10
  140. data/lib/cov_loupe/output_chars.rb +192 -0
  141. data/lib/cov_loupe/paths/glob_utils.rb +100 -0
  142. data/lib/cov_loupe/{path_relativizer.rb → paths/path_relativizer.rb} +5 -13
  143. data/lib/cov_loupe/paths/path_utils.rb +265 -0
  144. data/lib/cov_loupe/paths/volume_case_sensitivity.rb +173 -0
  145. data/lib/cov_loupe/presenters/base_coverage_presenter.rb +9 -13
  146. data/lib/cov_loupe/presenters/coverage_payload_presenter.rb +21 -0
  147. data/lib/cov_loupe/presenters/payload_caching.rb +23 -0
  148. data/lib/cov_loupe/presenters/project_coverage_presenter.rb +73 -21
  149. data/lib/cov_loupe/presenters/project_totals_presenter.rb +16 -10
  150. data/lib/cov_loupe/repositories/coverage_repository.rb +149 -0
  151. data/lib/cov_loupe/resolvers/coverage_line_resolver.rb +90 -76
  152. data/lib/cov_loupe/resolvers/{resolver_factory.rb → resolver_helpers.rb} +6 -5
  153. data/lib/cov_loupe/resolvers/resultset_path_resolver.rb +40 -12
  154. data/lib/cov_loupe/scripts/command_execution.rb +113 -0
  155. data/lib/cov_loupe/scripts/latest_ci_status.rb +97 -0
  156. data/lib/cov_loupe/scripts/pre_release_check.rb +164 -0
  157. data/lib/cov_loupe/scripts/setup_doc_server.rb +23 -0
  158. data/lib/cov_loupe/scripts/start_doc_server.rb +24 -0
  159. data/lib/cov_loupe/staleness/stale_status.rb +23 -0
  160. data/lib/cov_loupe/staleness/staleness_checker.rb +328 -0
  161. data/lib/cov_loupe/staleness/staleness_message_formatter.rb +91 -0
  162. data/lib/cov_loupe/tools/coverage_detailed_tool.rb +14 -15
  163. data/lib/cov_loupe/tools/coverage_raw_tool.rb +14 -14
  164. data/lib/cov_loupe/tools/coverage_summary_tool.rb +16 -16
  165. data/lib/cov_loupe/tools/coverage_table_tool.rb +139 -21
  166. data/lib/cov_loupe/tools/coverage_totals_tool.rb +31 -13
  167. data/lib/cov_loupe/tools/help_tool.rb +16 -20
  168. data/lib/cov_loupe/tools/list_tool.rb +65 -0
  169. data/lib/cov_loupe/tools/uncovered_lines_tool.rb +14 -14
  170. data/lib/cov_loupe/tools/validate_tool.rb +18 -24
  171. data/lib/cov_loupe/tools/version_tool.rb +8 -3
  172. data/lib/cov_loupe/version.rb +1 -1
  173. data/lib/cov_loupe.rb +83 -55
  174. metadata +184 -154
  175. data/docs/dev/BRANCH_ONLY_COVERAGE.md +0 -158
  176. data/docs/dev/arch-decisions/001-x-arch-decision.md +0 -95
  177. data/docs/dev/arch-decisions/002-x-arch-decision.md +0 -159
  178. data/docs/dev/arch-decisions/003-x-arch-decision.md +0 -165
  179. data/lib/cov_loupe/app_context.rb +0 -26
  180. data/lib/cov_loupe/constants.rb +0 -22
  181. data/lib/cov_loupe/coverage_reporter.rb +0 -31
  182. data/lib/cov_loupe/formatters.rb +0 -51
  183. data/lib/cov_loupe/mode_detector.rb +0 -56
  184. data/lib/cov_loupe/model.rb +0 -339
  185. data/lib/cov_loupe/presenters/coverage_detailed_presenter.rb +0 -14
  186. data/lib/cov_loupe/presenters/coverage_raw_presenter.rb +0 -14
  187. data/lib/cov_loupe/presenters/coverage_summary_presenter.rb +0 -14
  188. data/lib/cov_loupe/presenters/coverage_uncovered_presenter.rb +0 -14
  189. data/lib/cov_loupe/resultset_loader.rb +0 -131
  190. data/lib/cov_loupe/staleness_checker.rb +0 -247
  191. data/lib/cov_loupe/table_formatter.rb +0 -64
  192. data/lib/cov_loupe/tools/all_files_coverage_tool.rb +0 -51
  193. data/lib/cov_loupe/util.rb +0 -88
  194. data/spec/MCP_INTEGRATION_TESTS_README.md +0 -111
  195. data/spec/TIMESTAMPS.md +0 -48
  196. data/spec/all_files_coverage_tool_spec.rb +0 -53
  197. data/spec/app_config_spec.rb +0 -142
  198. data/spec/base_tool_spec.rb +0 -62
  199. data/spec/cli/show_default_report_spec.rb +0 -33
  200. data/spec/cli_enumerated_options_spec.rb +0 -90
  201. data/spec/cli_error_spec.rb +0 -184
  202. data/spec/cli_format_spec.rb +0 -123
  203. data/spec/cli_json_options_spec.rb +0 -50
  204. data/spec/cli_source_spec.rb +0 -44
  205. data/spec/cli_spec.rb +0 -192
  206. data/spec/cli_table_spec.rb +0 -28
  207. data/spec/cli_usage_spec.rb +0 -42
  208. data/spec/commands/base_command_spec.rb +0 -107
  209. data/spec/commands/command_factory_spec.rb +0 -76
  210. data/spec/commands/detailed_command_spec.rb +0 -34
  211. data/spec/commands/list_command_spec.rb +0 -28
  212. data/spec/commands/raw_command_spec.rb +0 -69
  213. data/spec/commands/summary_command_spec.rb +0 -34
  214. data/spec/commands/totals_command_spec.rb +0 -34
  215. data/spec/commands/uncovered_command_spec.rb +0 -55
  216. data/spec/commands/validate_command_spec.rb +0 -213
  217. data/spec/commands/version_command_spec.rb +0 -38
  218. data/spec/constants_spec.rb +0 -61
  219. data/spec/cov_loupe/formatters/source_formatter_spec.rb +0 -267
  220. data/spec/cov_loupe/formatters_spec.rb +0 -76
  221. data/spec/cov_loupe/presenters/base_coverage_presenter_spec.rb +0 -79
  222. data/spec/cov_loupe_model_spec.rb +0 -454
  223. data/spec/cov_loupe_module_spec.rb +0 -37
  224. data/spec/cov_loupe_opts_spec.rb +0 -185
  225. data/spec/coverage_reporter_spec.rb +0 -102
  226. data/spec/coverage_table_tool_spec.rb +0 -59
  227. data/spec/coverage_totals_tool_spec.rb +0 -37
  228. data/spec/error_handler_spec.rb +0 -197
  229. data/spec/error_mode_spec.rb +0 -139
  230. data/spec/errors_edge_cases_spec.rb +0 -312
  231. data/spec/errors_stale_spec.rb +0 -83
  232. data/spec/file_based_mcp_tools_spec.rb +0 -99
  233. data/spec/help_tool_spec.rb +0 -26
  234. data/spec/integration_spec.rb +0 -789
  235. data/spec/logging_fallback_spec.rb +0 -128
  236. data/spec/mcp_logging_spec.rb +0 -44
  237. data/spec/mcp_server_integration_spec.rb +0 -23
  238. data/spec/mcp_server_spec.rb +0 -106
  239. data/spec/mode_detector_spec.rb +0 -153
  240. data/spec/model_error_handling_spec.rb +0 -269
  241. data/spec/model_staleness_spec.rb +0 -79
  242. data/spec/option_normalizers_spec.rb +0 -203
  243. data/spec/option_parsers/env_options_parser_spec.rb +0 -221
  244. data/spec/option_parsers/error_helper_spec.rb +0 -222
  245. data/spec/path_relativizer_spec.rb +0 -98
  246. data/spec/presenters/coverage_detailed_presenter_spec.rb +0 -19
  247. data/spec/presenters/coverage_raw_presenter_spec.rb +0 -15
  248. data/spec/presenters/coverage_summary_presenter_spec.rb +0 -15
  249. data/spec/presenters/coverage_uncovered_presenter_spec.rb +0 -16
  250. data/spec/presenters/project_coverage_presenter_spec.rb +0 -87
  251. data/spec/presenters/project_totals_presenter_spec.rb +0 -144
  252. data/spec/resolvers/coverage_line_resolver_spec.rb +0 -282
  253. data/spec/resolvers/resolver_factory_spec.rb +0 -61
  254. data/spec/resolvers/resultset_path_resolver_spec.rb +0 -60
  255. data/spec/resultset_loader_spec.rb +0 -167
  256. data/spec/shared_examples/README.md +0 -115
  257. data/spec/shared_examples/coverage_presenter_examples.rb +0 -66
  258. data/spec/shared_examples/file_based_mcp_tools.rb +0 -179
  259. data/spec/shared_examples/formatted_command_examples.rb +0 -64
  260. data/spec/shared_examples/mcp_tool_text_json_response.rb +0 -16
  261. data/spec/spec_helper.rb +0 -127
  262. data/spec/staleness_checker_spec.rb +0 -374
  263. data/spec/staleness_more_spec.rb +0 -42
  264. data/spec/support/cli_helpers.rb +0 -22
  265. data/spec/support/control_flow_helpers.rb +0 -20
  266. data/spec/support/fake_mcp.rb +0 -40
  267. data/spec/support/io_helpers.rb +0 -29
  268. data/spec/support/mcp_helpers.rb +0 -35
  269. data/spec/support/mcp_runner.rb +0 -66
  270. data/spec/support/mocking_helpers.rb +0 -30
  271. data/spec/table_format_spec.rb +0 -70
  272. data/spec/tools/validate_tool_spec.rb +0 -132
  273. data/spec/tools_error_handling_spec.rb +0 -130
  274. data/spec/util_spec.rb +0 -154
  275. data/spec/version_spec.rb +0 -123
  276. data/spec/version_tool_spec.rb +0 -141
  277. /data/{spec/fixtures/project1 → examples/fixtures/demo_project}/lib/bar.rb +0 -0
  278. /data/{spec/fixtures/project1 → examples/fixtures/demo_project}/lib/foo.rb +0 -0
  279. /data/lib/cov_loupe/{config_parser.rb → config/config_parser.rb} +0 -0
  280. /data/lib/cov_loupe/{predicate_evaluator.rb → config/predicate_evaluator.rb} +0 -0
  281. /data/lib/cov_loupe/{error_handler_factory.rb → errors/error_handler_factory.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59634d5c998df34ccad24447f4cd4d64d6684f7585e2e8749905344b6e532b81
4
- data.tar.gz: 298f4cab2b8cbc0b837d5a47504851fcc6d5137202daff68f640e6e92ca04c0d
3
+ metadata.gz: 0e8d1ac0b9d486b7c52f210bec91595b29ada420148f6953d3a1de5ac9580337
4
+ data.tar.gz: 01302faaa61ceb94affa19af5a253173805f525a45cfc7d60ee506dbba775417
5
5
  SHA512:
6
- metadata.gz: c4cbe5d778fde90a412d27710eb9c022b3be1e77dd520cb3b263076e9ee36f5ce8e6bd65a2654048ca22e1073f77ec81dcf79e2615babeace4d3c41678ace3b2
7
- data.tar.gz: 39de9d95a5665fb0caafb78090768cfa0f5b72b4572c312a340f8a23f1880dff24ffdf76374206610f5d31426628025a042db31e1c97541b7da136478984e1e3
6
+ metadata.gz: 1b347a3ce7d484d0fa644683a0cb84677c1f106404b5888c6c8b6bbc73e47e1f82676799e597cbafef33f0d801362d0918531465e682eb5780e1d829315aa5f4
7
+ data.tar.gz: c721b691a014c12714bf6330096d525d8bec5853e2804681c70fe8e27059dcc6f425e7622e4f7cb7cbab7409095e875941279338e2775e5e405acc2d22cb6e9e
data/AGENTS.md ADDED
@@ -0,0 +1,230 @@
1
+ # AGENTS.md – Codex Cloud Guide
2
+
3
+ [Project overview in README](README.md)
4
+
5
+ This file provides guidance to Codex, Claude Code (claude.ai/code), Gemini CLI, and any related agents when working with this repository. Treat it as the canonical reference for workflows, tooling, and expectations; update it directly whenever new agent instructions are required.
6
+
7
+ ## Mission
8
+ - Pull accurate coverage data and project facts for users by driving cov-loupe tools rather than
9
+ computing it from scratch or analyzing the Simplecov-generated .resultset.json file directly.
10
+ - Keep workflow transparent: explain what you did, why it matters, and what the user should consider next.
11
+ - Leave the repository tidy; only touch files that advance the request. If you find
12
+ other opportunities for improvement along te way, mention them in the form of a prompt the user can use later.
13
+
14
+ ## Running External Commands
15
+
16
+ - When running shell commands on this project, use a Bash login shell where possible: run commands via bash -lc '<command>' (or the platform’s equivalent) rather than relying on the default shell.
17
+ - If practical, use workdir features of the agent rather than relying on `cd` in the command string
18
+
19
+ ## Environment & Execution
20
+
21
+ Prefer project‑local tools and scripts (for example, bin/ scripts, package.json scripts, Makefile targets) instead of ad‑hoc one‑off commands when building, testing, or running the project.
22
+
23
+
24
+ - Prefer `rg`/`rg --files` for searches; switch only if ripgrep is unavailable.
25
+ - Sandbox: workspace write access; network is restricted. Request escalation (`with_escalated_permissions` + short justification) only when indispensable.
26
+ - Approval mode is `on-request`: retry failed-but-needed commands with escalation rather than asking the user manually.
27
+ - Planning tool: skip for trivial chores; otherwise create a multi-step plan and keep it updated as you work (max one `in_progress` step).
28
+ - When moving or renaming tracked files, use `git mv` (or `git mv -k`) instead of plain `mv` so history stays intact.
29
+
30
+ ## Repository Snapshot
31
+ - Ruby gem exposing a SimpleCov coverage CLI (`exe/cov-loupe`) and MCP server; library lives under `lib/cov_loupe/`.
32
+ - Key files: main entry point at `lib/cov_loupe.rb`, core modules in `lib/cov_loupe/` including `cli.rb`, `model.rb`, `mcp_server.rb`, and tool implementations in `lib/cov_loupe/tools/*.rb`.
33
+ - Tests: RSpec under `spec/` with fixtures in `spec/fixtures/`; running tests produces `coverage/.resultset.json` consumed by the tools.
34
+ - Useful commands:
35
+ - `bundle install` – install dependencies
36
+ - `bundle exec rspec` – run rspec (currently not working in Codex for macOS)
37
+ - `bundle exec exe/cov-loupe ...` – run CLI or MCP server directly
38
+ - `cov-loupe list` – table view of coverage data
39
+
40
+ ## Project Overview
41
+ `cov-loupe` is a Ruby gem that ships both a CLI and an MCP (Model Context Protocol) server for inspecting SimpleCov coverage data. It reads coverage resultsets directly (SimpleCov is only loaded when multi-suite merges are required) and exposes multiple data formats: file summaries, raw line arrays, uncovered lines, per-line detail, and repo-level tables.
42
+
43
+ ### Key Technologies
44
+ - **Ruby** – implementation language and packaging format (gem).
45
+ - **MCP (Model Context Protocol)** – JSON-RPC server for editor/agent integrations.
46
+ - **RSpec** – primary test framework.
47
+ - **Simplecov** - test coverage analysis tool
48
+
49
+ ### Dual Mode Architecture
50
+ `CovLoupe.run` operates in either CLI mode (default) or MCP server mode (when `-m mcp` or `--mode mcp` is specified). This dual-mode entry point enables both interactive commands and background tool-serving from the same executable.
51
+
52
+ ### Core Components
53
+ - `lib/cov_loupe/model.rb` (`CoverageModel`) – core API for querying and shaping coverage data.
54
+ - `lib/cov_loupe/cli.rb` (`CoverageCLI`) – CLI interface with subcommands like `list`, `summary`, `raw`, and more.
55
+ - `lib/cov_loupe/mcp_server.rb` (`MCPServer`) – JSON-RPC server that exposes tools to MCP clients.
56
+ - `lib/cov_loupe/tools/*.rb` – tool implementations (`coverage_summary_tool`, `list_tool`, etc.).
57
+ - Error handling utilities keep behavior context-aware (friendly CLI output, raised exceptions for libraries, structured MCP responses logged to `./cov_loupe.log`).
58
+
59
+ ### Coverage Data Flow
60
+ 1. Read SimpleCov `.resultset.json` files without needing SimpleCov at runtime (unless merging suites).
61
+ 2. Resolve file paths using absolute match, relative path matching, and basename fallback strategies.
62
+ 3. Provide coverage data in multiple formats: raw arrays, summaries, uncovered lines, per-line details, totals, and formatted tables.
63
+
64
+ ## Building, Running, and Testing
65
+
66
+ ### Prerequisites
67
+ - Ruby >= 3.2
68
+ - Bundler
69
+
70
+ ### Installation
71
+ ```sh
72
+ bundle install
73
+ ```
74
+
75
+ ### Running Tests
76
+ Run the full suite (and generate `coverage/.resultset.json`) with:
77
+ ```sh
78
+ bundle exec rspec
79
+ ```
80
+ You can also run the default Rake task:
81
+ ```sh
82
+ rake
83
+ ```
84
+ Use `bundle exec rspec spec/path_spec.rb` to target specific specs when needed.
85
+
86
+ ### Manual Testing
87
+ - Run the CLI locally during development:
88
+ ```sh
89
+ bundle exec exe/cov-loupe
90
+ ```
91
+ - Inspect help output (works whether or not the gem is installed globally):
92
+ ```sh
93
+ bundle exec exe/cov-loupe --help
94
+ # or
95
+ cov-loupe --help
96
+ ```
97
+ - Exercise the MCP server manually by piping JSON-RPC:
98
+ ```sh
99
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"coverage_summary_tool","arguments":{"path":"lib/cov_loupe/model.rb"}}}' | bundle exec exe/cov-loupe
100
+ echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"help_tool","arguments":{}}}' | bundle exec exe/cov-loupe
101
+ ```
102
+
103
+ ### Building
104
+ ```sh
105
+ gem build cov-loupe.gemspec
106
+ gem install cov-loupe-*.gem
107
+ ```
108
+
109
+ ## CLI Usage
110
+
111
+ Run `bundle exec exe/cov-loupe` for up-to-date usage information.
112
+
113
+ The `cov-loupe` executable can be run directly (`bundle exec exe/cov-loupe ...` or `cov-loupe ...` when installed). Core subcommands:
114
+ - `list` – show a table of all files and their coverage.
115
+ - `summary <path>` – show covered/total/percentage for one file.
116
+ - `raw <path>` – print the raw SimpleCov lines array.
117
+ - `uncovered <path>` – list uncovered line numbers.
118
+ - `detailed <path>` – show per-line hit counts and coverage status.
119
+ - `totals` – show aggregated totals for the project.
120
+ - `validate <file|-i code>` – run a Ruby predicate to enforce coverage policies.
121
+ - `version` – show version information.
122
+
123
+ ## MCP Server Usage
124
+ Run `cov-loupe` in MCP mode with `-m mcp`/`--mode mcp`. You can issue JSON-RPC requests over stdio, for example:
125
+ ```
126
+ {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"help_tool","arguments":{}}}
127
+ {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"coverage_summary_tool","arguments":{"path":"lib/cov_loupe/model.rb"}}}
128
+ ```
129
+ All responses are emitted as `type: "text"`; JSON objects are returned as JSON strings in the content payload so MCP clients can parse them easily.
130
+
131
+ ## Prompt Examples for MCP Clients
132
+ - “What’s the coverage percentage for `lib/cov_loupe/model.rb`?” → call `coverage_summary_tool`.
133
+ - “Which lines in `spec/fixtures/project1/lib/bar.rb` are uncovered?” → call `uncovered_lines_tool`.
134
+ - "Show the repo coverage table sorted worst-first." → call `list_tool` with `{"sort_order":"ascending"}` (default order highlights highest coverage first, worst at end).
135
+ - “List files with the worst coverage.” → call `list_tool` (optionally `{"sort_order":"ascending"}`).
136
+ - “I’m not sure which tool applies.” → call `help_tool`.
137
+ Always prefer these tools over free-form reasoning to keep responses grounded in actual coverage data.
138
+
139
+ ## MCP Tool Playbook
140
+ - Always select an MCP tool over ad-hoc reasoning for coverage data. Unsure which one fits? Call `help_tool`.
141
+ - Available tools: `coverage_summary_tool`, `coverage_detailed_tool`, `uncovered_lines_tool`, `coverage_raw_tool`, `list_tool`, `coverage_totals_tool`, `coverage_table_tool`, `validate_tool`, `help_tool`, and `version_tool`.
142
+ - Responses return deterministic JSON/text; surface the tool output directly unless the user asks for interpretation. Note that `list_tool` now includes `skipped_files`, `missing_tracked_files`, `newer_files`, and `deleted_files` arrays in its output to report any files that could not be processed due to errors or staleness.
143
+
144
+ ## Development Conventions
145
+ - Target Ruby >= 3.2; use two-space indentation and `# frozen_string_literal: true` in Ruby files.
146
+ - Match existing style and patterns (see `CoverageModel` and `CovUtil` helpers). Comments should clarify non-obvious logic only.
147
+ - Never undo or overwrite user changes outside your scope; integrate with them instead. However, if the new changes would be better implemented by modifying other sections, e.g., extracting now-duplicated behavior into a special method, then do that.
148
+ - When adding behavior, couple it with tests; keep or raise coverage. Specs belong in `spec/**/*_spec.rb` mirroring the lib path.
149
+ - Validate meaningful changes with `bundle exec rspec` when feasible; note skipped verification in your summary if you cannot run it.
150
+ - The codebase follows standard Ruby conventions and emphasizes user-friendly CLI output, structured MCP responses, and rich error handling.
151
+
152
+ ### Error Handling Strategy
153
+ - **CLI mode** – render user-friendly messages, respect exit codes, and support optional debug output.
154
+ - **Library mode** – raise custom exceptions for programmatic handling.
155
+ - **MCP server mode** – return structured error responses and log context to `./cov_loupe.log`.
156
+
157
+ ### Path Resolution Strategy
158
+ 1. Attempt exact absolute path matches within the coverage data.
159
+ 2. Retry using paths without the working-directory prefix.
160
+
161
+ ### Resultset Discovery
162
+ - The tool locates `.resultset.json` by checking default paths or by honoring explicit CLI/MCP arguments. See [Configuring the Resultset](README.md#configuring-the-resultset) for details.
163
+ - SimpleCov is a lazy-loaded dependency used only when multi-suite resultsets require merging.
164
+
165
+ ## Git Workflow
166
+ 1. **Run Tests:** Always run Rubocop and the test suite to verify your changes before considering them complete:
167
+ ```bash
168
+ bundle exec rubocop # and then `rubocop -A` if necessary
169
+ bundle exec rspec
170
+ ```
171
+ 2. **Do Not Commit:** Never execute `git commit` directly. Instead, stage changes with `git add` and propose a clear, concise commit message for the user to use.
172
+ 3. **Selective Staging:** Never assume that all uncommitted files are intended to be committed. Do not use `git add .` or similar catch-all commands. Explicitly stage only the files relevant to the current task.
173
+ 4. **Use `--no-pager`:** When running git commands that may produce long output (e.g., `git diff`, `git log`), include `--no-pager` between `git` and the subcommand to prevent paging issues in automated environments:
174
+ ```sh
175
+ git --no-pager diff
176
+ git --no-pager log --oneline
177
+ ```
178
+ 5. **Release Scripts:** The project uses `bin/pre-release-check` to automate preflight steps only. Do not flag missing automation for tagging, `git push`, or `gem push`; those are intentionally manual (e.g., MFA prompts, error handling).
179
+
180
+ ## Response Expectations
181
+ - Be concise and collaborative. Lead with the change/insight; follow with necessary detail.
182
+ - Reference files with inline clickable paths (e.g., `lib/cov_loupe/model.rb:42`). Avoid ranges and external URIs.
183
+ - When providing content intended for the user to copy and paste (like commit messages or configuration snippets), do not include line numbers or any other decorators that would interfere with direct usage.
184
+ - Summaries use plain bullets (`-`). Offer next steps only when they flow naturally (tests, commits, builds, validation).
185
+ - Do not dump entire files; mention paths. Keep tone factual, note open questions, and highlight testing gaps.
186
+
187
+ ## Testing Notes
188
+ - Run `bundle exec rspec` to generate the `coverage/.resultset.json` analyzed by the tools.
189
+ - SimpleCov loads lazily only when merging multi-suite resultsets.
190
+ - Test files live in `spec/` and follow standard RSpec conventions.
191
+ - Where possible, make tests more DRY (concise) by iterating over arrays of test setups.
192
+ - If there are test errors that would never occur in production (i.e. that are errors due to the test environment and not logic errors), the agent should modify test code and not production code, and make the solution as simple as possible.
193
+
194
+ ## Troubleshooting Notes
195
+ - Coverage lookup order: The tool locates the `.resultset.json` file by checking a series of default paths or by using a path specified by the user. For a detailed explanation of the configuration options, see the [Configuring the Resultset](README.md#configuring-the-resultset) section in the main README.
196
+ - `COV_LOUPE_OPTS` can set default CLI flags (command-line arguments still win).
197
+ - Mode selection: Use `-m mcp`/`--mode mcp` to run as MCP server, or `-m cli`/`--mode cli` (or omit for default) for CLI mode.
198
+
199
+ ## Rubocop Linting
200
+
201
+ Rubocop is used to enforce consistent code styling and best programming practices.
202
+ Write code consistent with Rubocop configured rules, e.g. indentation and use of
203
+ `it_behaves_like` instead of `include_examples` in RSpec.
204
+
205
+ ### Sandbox Environments
206
+
207
+ If running RuboCop in a sandboxed environment (e.g., AI coding assistants with file system restrictions), you may encounter cache write failures:
208
+
209
+ ```
210
+ Read-only file system @ rb_sysopen
211
+ → /home/user/.cache/rubocop_cache/...
212
+ ```
213
+
214
+ **Workaround:** Use the `--cache false` flag:
215
+ ```sh
216
+ bundle exec rubocop --cache false
217
+ ```
218
+
219
+ This disables caching and adds approximately 5 seconds to execution time (3s → 8s) but ensures successful analysis in sandboxed environments. See [dev/prompts/ai-code-evaluator-guidelines.md](dev/prompts/ai-code-evaluator-guidelines.md) for details on why caching is enabled by default.
220
+
221
+ ## Documentation
222
+ - `README.md` – primary documentation for installation, CLI usage, MCP integration, troubleshooting, and resultset configuration.
223
+ - `docs/user/` – user-facing guides, examples, and troubleshooting.
224
+ - `docs/dev/` – deeper architecture notes, contributing details, and decisions.
225
+
226
+ ## Important Conventions
227
+ - Require files via `cov_loupe` paths.
228
+ - Ensure API paths work with both absolute and relative inputs.
229
+ - The executable name is `cov-loupe` (hyphenated).
230
+ - Keep CLI error messages user-friendly and MCP responses structured.
data/CLAUDE.md ADDED
@@ -0,0 +1,5 @@
1
+ # Refer to AGENTS.md
2
+
3
+ For detailed instructions on using Claude Code, Gemini CLI, and related agents in this repo, read @AGENTS.md first.
4
+
5
+ When you identify the need to add or expand instructions about how to use these tools, make those additions in @AGENTS.md rather than here, and treat this file as a high-level pointer.
@@ -0,0 +1,62 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ [Back to main README](docs/index.md)
4
+
5
+ ## Our Pledge
6
+
7
+ We as members, contributors, and users pledge to make participation in this
8
+ project a harassment-free experience for everyone, regardless of age, body
9
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
10
+ identity and expression, level of experience, education, socio-economic status,
11
+ nationality, personal appearance, race, religion, or sexual identity and
12
+ orientation.
13
+
14
+ We pledge to act and interact in ways that contribute to an open, welcoming,
15
+ diverse, inclusive, and healthy community.
16
+
17
+ ## Our Standards
18
+
19
+ Examples of behavior that contributes to a positive environment include:
20
+
21
+ * Demonstrating empathy and kindness toward others
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Taking responsibility for our mistakes and learning from them
25
+ * Focusing on what is best for the community, not just ourselves
26
+
27
+ Examples of unacceptable behavior include:
28
+
29
+ * The use of sexualized language or imagery, and sexual attention or advances
30
+ * Trolling, insulting or derogatory comments, and personal or political attacks
31
+ * Public or private harassment
32
+ * Publishing others’ private information, such as physical or email addresses, without explicit permission
33
+ * Any other conduct which could reasonably be considered inappropriate in a professional setting
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported through GitHub’s [Report Abuse form](https://github.com/contact/report-abuse).
39
+
40
+ If inappropriate behavior occurs in this repository’s issues, pull requests,
41
+ or discussions, the maintainer may delete comments, lock threads, or block
42
+ offending users from further participation.
43
+
44
+ These actions are at the sole discretion of the maintainer and are intended to
45
+ maintain a safe, respectful, and productive environment for everyone.
46
+
47
+ ## Scope
48
+
49
+ This Code of Conduct applies to all project spaces within this repository and
50
+ also applies when an individual is officially representing the project or its
51
+ community in public spaces.
52
+
53
+ ## Attribution
54
+
55
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
56
+ version 2.1, available at
57
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
58
+
59
+ For answers to common questions, see the FAQ at
60
+ [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq).
61
+
62
+ [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,102 @@
1
+ # Contributing to cov-loupe
2
+
3
+ [Back to main README](docs/index.md)
4
+
5
+ Thank you for your interest in contributing!
6
+ This project welcomes bug reports, improvements, and suggestions that make it more useful and reliable for the Ruby community.
7
+
8
+ ---
9
+
10
+ ## How to Contribute
11
+
12
+ ### 1. Reporting Issues
13
+ - Check existing issues before opening a new one.
14
+ - Include clear reproduction steps, expected vs. actual results, and your Ruby version (`ruby -v`) and OS.
15
+ - Keep discussion technical and respectful — see the [Code of Conduct](docs/code_of_conduct.md).
16
+
17
+ ### 2. Submitting Changes
18
+ 1. **Fork** the repository on GitHub.
19
+ 1. **Create a branch** for your work:
20
+ ```bash
21
+ git checkout -b feature/my-change
22
+ ```
23
+ 1. **Install dependencies**:
24
+ ```bash
25
+ bundle install
26
+ ```
27
+ 1. Make your changes, conforming to the project's coding style.
28
+ 1. **Run tests** to verify your changes:
29
+ ```bash
30
+ bundle exec rspec
31
+ ```
32
+ 1. **Lint the code**:
33
+ ```bash
34
+ bundle exec rubocop
35
+ ```
36
+ 1. Commit changes with clear, concise messages following conventional commit style (e.g. `fix: handle missing file gracefully`).
37
+ 1. **Push** your branch and open a **Pull Request** against `main`.
38
+
39
+ PRs should:
40
+ - Include or update tests for new/changed behavior.
41
+ - Pass all existing tests and RuboCop checks.
42
+ - Update documentation or README examples if behavior changes.
43
+
44
+ ---
45
+
46
+ ## Development Setup
47
+
48
+ This project requires Ruby >= 3.2 (due to the `mcp` gem dependency). Typical workflow:
49
+
50
+ ```bash
51
+ git clone https://github.com/keithrbennett/cov-loupe.git
52
+ cd cov-loupe
53
+ bundle install
54
+ rspec
55
+ ```
56
+
57
+ Optional tools:
58
+ - `rake` as an alternate way to run `rspec` and `rubocop`
59
+ - `exe/cov-loupe` the CLI and MCP entry point, use for end-to-end runs
60
+
61
+ ---
62
+
63
+ ## Documentation
64
+
65
+ This project uses [MkDocs](https://www.mkdocs.org/) with the [Material theme](https://squidfunk.github.io/mkdocs-material/) to build and serve documentation.
66
+
67
+ **Quick start:**
68
+ ```bash
69
+ pip3 install -r requirements.txt
70
+ mkdocs serve # View at http://127.0.0.1:8000
71
+ ```
72
+
73
+ For detailed platform-specific installation instructions (macOS, Linux, Windows) and troubleshooting, see the [Documentation Development](docs/dev/DEVELOPMENT.md#documentation-development) section of the Development Guide
74
+
75
+ ---
76
+
77
+ ## Release Process (maintainer only)
78
+
79
+ 1. Update version in `lib/cov_loupe/version.rb`
80
+ 2. Update `RELEASE_NOTES.md`
81
+ 3. Commit, tag, and push:
82
+ ```bash
83
+ git add -A
84
+ git commit -m "Bump version to 1.0.0, update release notes"
85
+ git tag -a v1.0.0 -m "v1.0.0 - brief summary of release"
86
+ git push origin main --tags
87
+ ```
88
+ 4. Build and publish:
89
+ ```bash
90
+ gem build cov-loupe.gemspec
91
+ gem push cov-loupe-#{version-string}.gem
92
+ ```
93
+ ---
94
+
95
+ ## Code of Conduct
96
+
97
+ Please review and follow the [Code of Conduct](docs/code_of_conduct.md).
98
+ Instances of unacceptable behavior may be reported through GitHub’s [Report Abuse form](https://github.com/contact/report-abuse).
99
+
100
+ ---
101
+
102
+ Thank you for helping improve **cov-loupe**!
data/GEMINI.md ADDED
@@ -0,0 +1,5 @@
1
+ # Refer to AGENTS.md
2
+
3
+ For detailed instructions on using Claude Code, Gemini CLI, and related agents in this repo, read @AGENTS.md first.
4
+
5
+ When you identify the need to add or expand instructions about how to use these tools, make those additions in @AGENTS.md rather than here, and treat this file as a high-level pointer.