simplecov-mcp 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/lib/simple_cov_mcp/tools/all_files_coverage_tool.rb +3 -1
- data/lib/simple_cov_mcp/tools/help_tool.rb +4 -1
- data/lib/simple_cov_mcp/version.rb +1 -1
- data/spec/all_files_coverage_tool_spec.rb +4 -4
- data/spec/help_tool_spec.rb +11 -11
- metadata +5 -6
- data/spec/cli_json_source_spec.rb +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a4d8cde53da2d974436b735011f381362fa7e17e53d3ff587b41a9e66c285a
|
4
|
+
data.tar.gz: d22bf6d5265373c0430499c7fbac6ed249d1786e63bac0b7562964b9d9ae8958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63aceca2e283855ee5ab6aaf16007b70baa4042e5085e976a9eecdc43f1054925d7b7749bc5ac9f4f64bed12392672f3c3f9c6006b3c844bbb5c0bcd9efa4fda
|
7
|
+
data.tar.gz: 599201a717dc571240c0f10b0492e4938428f1b898745dafbfbb6988bbbfb4f5505c7632e91a4d7afe16bd4b1f44876280f635c3323cf23a847441ae3c7049e1
|
@@ -53,7 +53,9 @@ module SimpleCovMcp
|
|
53
53
|
stale_count = files.count { |f| f['stale'] }
|
54
54
|
ok_count = total - stale_count
|
55
55
|
payload = { files: files, counts: { total: total, ok: ok_count, stale: stale_count } }
|
56
|
-
::MCP::Tool::Response.new([
|
56
|
+
::MCP::Tool::Response.new([
|
57
|
+
{ 'type' => 'text', 'text' => JSON.generate(payload) }
|
58
|
+
])
|
57
59
|
rescue => e
|
58
60
|
handle_mcp_error(e, 'AllFilesCoverageTool')
|
59
61
|
end
|
@@ -88,7 +88,10 @@ module SimpleCovMcp
|
|
88
88
|
entries = TOOL_GUIDE.map { |guide| format_entry(guide) }
|
89
89
|
entries = filter_entries(entries, query) if query && !query.strip.empty?
|
90
90
|
|
91
|
-
|
91
|
+
data = { query: query, tools: entries }
|
92
|
+
::MCP::Tool::Response.new([
|
93
|
+
{ 'type' => 'text', 'text' => JSON.generate(data) }
|
94
|
+
])
|
92
95
|
rescue => e
|
93
96
|
handle_mcp_error(e, 'HelpTool')
|
94
97
|
end
|
@@ -28,11 +28,11 @@ RSpec.describe SimpleCovMcp::Tools::AllFilesCoverageTool do
|
|
28
28
|
|
29
29
|
response = described_class.call(root: root, server_context: server_context)
|
30
30
|
entry = response.payload.first
|
31
|
-
json = entry[
|
31
|
+
json = JSON.parse(entry['text'])
|
32
32
|
|
33
|
-
expect(json).to have_key(
|
34
|
-
files = json[
|
35
|
-
counts = json[
|
33
|
+
expect(json).to have_key('files')
|
34
|
+
files = json['files']
|
35
|
+
counts = json['counts']
|
36
36
|
|
37
37
|
expect(files.length).to eq(2)
|
38
38
|
expect(counts).to include('total' => 2).or include(total: 2)
|
data/spec/help_tool_spec.rb
CHANGED
@@ -10,9 +10,9 @@ RSpec.describe SimpleCovMcp::Tools::HelpTool do
|
|
10
10
|
response_class = Class.new do
|
11
11
|
attr_reader :payload, :meta
|
12
12
|
|
13
|
-
def initialize(payload
|
13
|
+
def initialize(payload)
|
14
14
|
@payload = payload
|
15
|
-
@meta =
|
15
|
+
@meta = nil
|
16
16
|
end
|
17
17
|
end
|
18
18
|
stub_const('MCP::Tool::Response', response_class)
|
@@ -20,28 +20,28 @@ RSpec.describe SimpleCovMcp::Tools::HelpTool do
|
|
20
20
|
|
21
21
|
it 'returns guidance for each registered tool' do
|
22
22
|
response = described_class.call(server_context: server_context)
|
23
|
-
expect(response.meta
|
23
|
+
expect(response.meta).to be_nil
|
24
24
|
|
25
25
|
payload = response.payload.first
|
26
|
-
expect(payload[
|
26
|
+
expect(payload['type']).to eq('text')
|
27
27
|
|
28
|
-
data = payload[
|
29
|
-
tool_names = data[
|
28
|
+
data = JSON.parse(payload['text'])
|
29
|
+
tool_names = data['tools'].map { |entry| entry['tool'] }
|
30
30
|
|
31
31
|
expect(tool_names).to include('coverage_summary_tool', 'uncovered_lines_tool', 'all_files_coverage_tool', 'coverage_table_tool', 'version_tool')
|
32
|
-
expect(data[
|
32
|
+
expect(data['tools']).to all(include('use_when', 'avoid_when', 'inputs', 'example'))
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'filters entries when a query is provided' do
|
36
36
|
response = described_class.call(query: 'uncovered', server_context: server_context)
|
37
37
|
payload = response.payload.first
|
38
|
-
data = payload[
|
38
|
+
data = JSON.parse(payload['text'])
|
39
39
|
|
40
|
-
expect(data[
|
41
|
-
expect(data[
|
40
|
+
expect(data['tools']).not_to be_empty
|
41
|
+
expect(data['tools']).to all(satisfy do |entry|
|
42
42
|
combined = [entry['tool'], entry['label'], entry['use_when'], entry['avoid_when']].compact.join(' ').downcase
|
43
43
|
combined.include?('uncovered')
|
44
44
|
end)
|
45
|
-
expect(data[
|
45
|
+
expect(data['tools'].map { |entry| entry['tool'] }).to include('uncovered_lines_tool')
|
46
46
|
end
|
47
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-mcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith R. Bennett
|
@@ -13,16 +13,16 @@ dependencies:
|
|
13
13
|
name: mcp
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '0.
|
18
|
+
version: '0.3'
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
|
-
- - "
|
23
|
+
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '0.
|
25
|
+
version: '0.3'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: awesome_print
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- spec/all_files_coverage_tool_spec.rb
|
107
107
|
- spec/base_tool_spec.rb
|
108
108
|
- spec/cli_error_spec.rb
|
109
|
-
- spec/cli_json_source_spec.rb
|
110
109
|
- spec/cli_source_spec.rb
|
111
110
|
- spec/cli_spec.rb
|
112
111
|
- spec/cli_table_spec.rb
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe SimpleCovMcp::CoverageCLI do
|
6
|
-
let(:root) { (FIXTURES / 'project1').to_s }
|
7
|
-
|
8
|
-
def run_cli_json(*argv)
|
9
|
-
cli = described_class.new
|
10
|
-
out = nil
|
11
|
-
silence_output do |stdout, _stderr|
|
12
|
-
cli.run(argv.flatten)
|
13
|
-
out = stdout.string
|
14
|
-
end
|
15
|
-
JSON.parse(out)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'includes source rows in JSON for summary --source=full' do
|
19
|
-
data = run_cli_json('summary', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--json', '--source=full')
|
20
|
-
expect(data['file']).to eq('lib/foo.rb')
|
21
|
-
expect(data['source']).to be_an(Array)
|
22
|
-
expect(data['source'].first).to include('line', 'code', 'hits', 'covered')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'includes source rows in JSON for uncovered --source=uncovered' do
|
26
|
-
data = run_cli_json('uncovered', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--json', '--source=uncovered', '--source-context', '1')
|
27
|
-
expect(data['file']).to eq('lib/foo.rb')
|
28
|
-
expect(data['source']).to be_an(Array)
|
29
|
-
# Only a subset of lines around uncovered should appear
|
30
|
-
lines = data['source'].map { |h| h['line'] }
|
31
|
-
expect(lines).to include(2) # the uncovered line
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'includes source rows in JSON for detailed --source=full' do
|
35
|
-
data = run_cli_json('detailed', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--json', '--source=full')
|
36
|
-
expect(data['file']).to eq('lib/foo.rb')
|
37
|
-
expect(data['lines']).to be_an(Array)
|
38
|
-
expect(data['source']).to be_an(Array)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'renders uncovered source with various context sizes without error' do
|
42
|
-
[0, -5, 50].each do |ctx|
|
43
|
-
out, err, status = begin
|
44
|
-
cli = described_class.new
|
45
|
-
s = nil
|
46
|
-
o = e = nil
|
47
|
-
silence_output do |stdout, stderr|
|
48
|
-
begin
|
49
|
-
cli.run(['uncovered', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--source=uncovered', '--source-context', ctx.to_s, '--no-color'])
|
50
|
-
s = 0
|
51
|
-
rescue SystemExit => ex
|
52
|
-
s = ex.status
|
53
|
-
end
|
54
|
-
o = stdout.string
|
55
|
-
e = stderr.string
|
56
|
-
end
|
57
|
-
[o, e, s]
|
58
|
-
end
|
59
|
-
expect(status).to eq(0)
|
60
|
-
expect(err).to eq("")
|
61
|
-
expect(out).to include('File: lib/foo.rb')
|
62
|
-
expect(out).to include('Uncovered lines: 2')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'respects --color and --no-color for source rendering' do
|
67
|
-
# Force color on
|
68
|
-
out_color = begin
|
69
|
-
cli = described_class.new
|
70
|
-
silence_output do |stdout, _stderr|
|
71
|
-
cli.run(['summary', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--source', '--color'])
|
72
|
-
stdout.string
|
73
|
-
end
|
74
|
-
end
|
75
|
-
# If source table is rendered, it should contain ANSI escapes when color is on
|
76
|
-
if out_color.include?('Line') && out_color.include?('|')
|
77
|
-
expect(out_color).to match(/\e\[\d+m/)
|
78
|
-
else
|
79
|
-
expect(out_color).to include('[source not available]')
|
80
|
-
end
|
81
|
-
|
82
|
-
# Force color off: expect no ANSI sequences
|
83
|
-
out_nocolor = begin
|
84
|
-
cli = described_class.new
|
85
|
-
silence_output do |stdout, _stderr|
|
86
|
-
cli.run(['summary', 'lib/foo.rb', '--root', root, '--resultset', 'coverage', '--source', '--no-color'])
|
87
|
-
stdout.string
|
88
|
-
end
|
89
|
-
end
|
90
|
-
expect(out_nocolor).not_to match(/\e\[\d+m/)
|
91
|
-
end
|
92
|
-
end
|