Class: SimpleCov::Formatter::AIFormatter

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/simplecov-ai.rb,
lib/simplecov-ai/version.rb,
lib/simplecov-ai/constants.rb,
lib/simplecov-ai/line_span.rb,
lib/simplecov-ai/ast_resolver.rb,
lib/simplecov-ai/configuration.rb,
lib/simplecov-ai/markdown_builder.rb,
lib/simplecov-ai/ast_resolver/node_children.rb,
lib/simplecov-ai/ast_resolver/semantic_node.rb,
lib/simplecov-ai/ast_resolver/bypass_scanner.rb,
lib/simplecov-ai/ast_resolver/parser_backend.rb,
lib/simplecov-ai/ast_resolver/node_classifier.rb,
lib/simplecov-ai/markdown_builder/inline_code.rb,
lib/simplecov-ai/ast_resolver/lenient_literals.rb,
lib/simplecov-ai/markdown_builder/decode_guard.rb,
lib/simplecov-ai/markdown_builder/skip_regions.rb,
lib/simplecov-ai/markdown_builder/source_lines.rb,
lib/simplecov-ai/ast_resolver/receiver_resolver.rb,
lib/simplecov-ai/markdown_builder/deficit_group.rb,
lib/simplecov-ai/markdown_builder/report_budget.rb,
lib/simplecov-ai/ast_resolver/metaclass_resolver.rb,
lib/simplecov-ai/markdown_builder/section_writer.rb,
lib/simplecov-ai/markdown_builder/branch_enricher.rb,
lib/simplecov-ai/markdown_builder/bypass_compiler.rb,
lib/simplecov-ai/markdown_builder/deficit_grouper.rb,
lib/simplecov-ai/markdown_builder/deficit_compiler.rb,
lib/simplecov-ai/markdown_builder/deficit_formatter.rb,
lib/simplecov-ai/markdown_builder/snippet_formatter.rb,
lib/simplecov-ai/ast_resolver/dynamic_method_resolver.rb

Overview

Transforms raw simplecov coverage results into an AI-optimized markdown digest. It addresses the context window limitations of LLMs by emitting token-efficient reports and relying on AST-based semantic mapping to pinpoint exact methods or classes with deficient coverage.

Defined Under Namespace

Modules: Constants, LineSpan Classes: ASTResolver, Configuration, MarkdownBuilder

Constant Summary collapse

WRITTEN_MESSAGE =

STDOUT notice printed after the report is written, unless the digest itself is echoed

T.let('AI coverage digest written to %s', String)
WRITE_FAILED_MESSAGE =

STDERR notice printed when the report cannot be written, naming the path and the error

T.let('AI coverage digest could not be written to %s (%s)', String)
VERSION =

The semantic version identifier for the gem, used for dependency resolution and enforcing compatibility across upgrades.

T.let('0.11.0', String)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configurationObject



37
38
39
# File 'lib/simplecov-ai.rb', line 37

def self.configuration
  @configuration ||= T.let(Configuration.new, T.nilable(Configuration))
end

.configure(&blk) ⇒ Object



57
58
59
# File 'lib/simplecov-ai.rb', line 57

def self.configure(&blk)
  blk&.call(configuration)
end

.reset_configuration!Object



47
48
49
# File 'lib/simplecov-ai.rb', line 47

def self.reset_configuration!
  @configuration = nil
end

Instance Method Details

#format(coverage_metrics) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/simplecov-ai.rb', line 71

def format(coverage_metrics)
  config = self.class.configuration
  digest = MarkdownBuilder.new(coverage_metrics, config).build

  path = report_destination(config)
  write_report(path, digest) { puts Kernel.format(WRITTEN_MESSAGE, path) unless config.output_to_console }
  puts digest if config.output_to_console
end