yardmcp 0.2.1 → 0.2.2
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/yardmcp/version.rb +1 -1
- data/lib/yardmcp.rb +24 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d10bb618f1bd998034becf18059f3dee35e41437da51f88c88d2647cd8d119bb
|
|
4
|
+
data.tar.gz: 2c14c6fbccd58cac7ec149f401c607ddcbd4c66fbc3f83dada0640b6368d1a04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a872f2d3873ddcd8fe42a9088df79fc5ea939750515c93ddfa40fd49930d57a094b0cb43e0a862a32412918fd577f323450d2fa5291fd059189075bd8c1233ec
|
|
7
|
+
data.tar.gz: 1ff7d77c17dde0652bb185481be516ebe757b4ee0aea1b43527ada6707078b47d2a32537d1410a813fc9f3600b7e252c58fec0c68a96328df7317cf11e4d505f
|
data/lib/yardmcp/version.rb
CHANGED
data/lib/yardmcp.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'singleton'
|
|
|
9
9
|
require_relative 'yardmcp/version'
|
|
10
10
|
|
|
11
11
|
# Utility class for YARD operations
|
|
12
|
-
class YardUtils
|
|
12
|
+
class YardUtils # rubocop:disable Metrics/ClassLength
|
|
13
13
|
include Singleton
|
|
14
14
|
|
|
15
15
|
attr_reader :libraries, :logger, :object_to_gem
|
|
@@ -38,6 +38,7 @@ class YardUtils
|
|
|
38
38
|
raise "Yardoc not found for #{gem_name}" unless yardoc_exists?(dir)
|
|
39
39
|
|
|
40
40
|
YARD::Registry.load_yardoc(dir)
|
|
41
|
+
YARD::Registry.load_all
|
|
41
42
|
@last_loaded_gem = gem_name
|
|
42
43
|
end
|
|
43
44
|
|
|
@@ -54,7 +55,12 @@ class YardUtils
|
|
|
54
55
|
#
|
|
55
56
|
# @return [Array<String>] An array of gem names with .yardoc files.
|
|
56
57
|
def list_gems
|
|
57
|
-
libraries.keys.
|
|
58
|
+
libraries.keys.select do |name|
|
|
59
|
+
lib = libraries[name].first
|
|
60
|
+
ver = "= #{lib.version}"
|
|
61
|
+
dir = YARD::Registry.yardoc_file_for_gem(name, ver)
|
|
62
|
+
dir && File.directory?(dir)
|
|
63
|
+
end.sort
|
|
58
64
|
end
|
|
59
65
|
|
|
60
66
|
# Lists all classes and modules in the loaded YARD registry.
|
|
@@ -160,7 +166,7 @@ class YardUtils
|
|
|
160
166
|
end
|
|
161
167
|
{
|
|
162
168
|
superclass: obj.respond_to?(:superclass) && obj.superclass ? obj.superclass.path : nil,
|
|
163
|
-
included_modules: obj.respond_to?(:
|
|
169
|
+
included_modules: obj.respond_to?(:mixins) ? obj.mixins.map(&:path) : [],
|
|
164
170
|
mixins: obj.respond_to?(:mixins) ? obj.mixins.map(&:path) : []
|
|
165
171
|
}
|
|
166
172
|
end
|
|
@@ -183,7 +189,7 @@ class YardUtils
|
|
|
183
189
|
#
|
|
184
190
|
# @param path [String] The YARD path of the class/module.
|
|
185
191
|
# @return [Hash] A hash with :included_modules, :mixins, :subclasses.
|
|
186
|
-
def related_objects(path)
|
|
192
|
+
def related_objects(path)
|
|
187
193
|
ensure_yardoc_loaded_for_object!(path)
|
|
188
194
|
obj = YARD::Registry.at(path)
|
|
189
195
|
unless obj
|
|
@@ -191,9 +197,10 @@ class YardUtils
|
|
|
191
197
|
return {}
|
|
192
198
|
end
|
|
193
199
|
subclasses = YARD::Registry.all(:class).select { |c| c.superclass && c.superclass.path == obj.path }.map(&:path)
|
|
200
|
+
mixins_list = obj.respond_to?(:mixins) ? obj.mixins.map(&:path) : []
|
|
194
201
|
{
|
|
195
|
-
included_modules:
|
|
196
|
-
mixins:
|
|
202
|
+
included_modules: mixins_list,
|
|
203
|
+
mixins: mixins_list,
|
|
197
204
|
subclasses:
|
|
198
205
|
}
|
|
199
206
|
end
|
|
@@ -329,6 +336,7 @@ end
|
|
|
329
336
|
# Tool: List all gems with .yardoc files
|
|
330
337
|
class ListGemsTool < FastMcp::Tool
|
|
331
338
|
description 'List all installed gems that have a .yardoc file'
|
|
339
|
+
annotations(title: 'List all installed gems', read_only_hint: true)
|
|
332
340
|
|
|
333
341
|
def call
|
|
334
342
|
gems = YardUtils.instance.list_gems
|
|
@@ -339,6 +347,7 @@ end
|
|
|
339
347
|
# Tool: List all classes and modules in the loaded YARD registry
|
|
340
348
|
class ListClassesTool < FastMcp::Tool
|
|
341
349
|
description 'List all classes and modules in the loaded YARD registry'
|
|
350
|
+
annotations(title: 'List all classes and modules', read_only_hint: true)
|
|
342
351
|
arguments do
|
|
343
352
|
required(:gem_name).filled(:string).description('Name of the gem to list classes for')
|
|
344
353
|
end
|
|
@@ -352,6 +361,7 @@ end
|
|
|
352
361
|
# Tool: Fetch documentation for a YARD object
|
|
353
362
|
class GetDocTool < FastMcp::Tool
|
|
354
363
|
description 'Fetch documentation and metadata for a class/module/method from YARD'
|
|
364
|
+
annotations(title: 'Fetch documentation', read_only_hint: true)
|
|
355
365
|
arguments do
|
|
356
366
|
required(:path).filled(:string).description("YARD path (e.g. 'String#upcase')")
|
|
357
367
|
optional(:gem_name).filled(:string).description("Optional gem name to load specific gem's documentation")
|
|
@@ -365,6 +375,7 @@ end
|
|
|
365
375
|
# Tool: List children under a namespace
|
|
366
376
|
class ChildrenTool < FastMcp::Tool
|
|
367
377
|
description 'List children under a namespace (class/module) in YARD'
|
|
378
|
+
annotations(title: 'List children under a namespace', read_only_hint: true)
|
|
368
379
|
arguments do
|
|
369
380
|
required(:path).filled(:string).description('YARD path of the namespace')
|
|
370
381
|
end
|
|
@@ -378,6 +389,7 @@ end
|
|
|
378
389
|
# Tool: List methods for a class/module
|
|
379
390
|
class MethodsListTool < FastMcp::Tool
|
|
380
391
|
description 'List methods for a class/module in YARD'
|
|
392
|
+
annotations(title: 'List methods for a class/module', read_only_hint: true)
|
|
381
393
|
arguments do
|
|
382
394
|
required(:path).filled(:string).description('YARD path of the class/module')
|
|
383
395
|
end
|
|
@@ -391,6 +403,7 @@ end
|
|
|
391
403
|
# Tool: Return inheritance and inclusion info
|
|
392
404
|
class HierarchyTool < FastMcp::Tool
|
|
393
405
|
description 'Return inheritance and inclusion info for a class/module in YARD'
|
|
406
|
+
annotations(title: 'Return inheritance and inclusion info', read_only_hint: true)
|
|
394
407
|
arguments do
|
|
395
408
|
required(:path).filled(:string).description('YARD path of the class/module')
|
|
396
409
|
end
|
|
@@ -403,6 +416,7 @@ end
|
|
|
403
416
|
# Tool: Perform fuzzy/full-text search
|
|
404
417
|
class SearchTool < FastMcp::Tool
|
|
405
418
|
description 'Perform fuzzy/full-text search in YARD registry'
|
|
419
|
+
annotations(title: 'Perform fuzzy/full-text search', read_only_hint: true)
|
|
406
420
|
arguments do
|
|
407
421
|
required(:query).filled(:string).description('Search query')
|
|
408
422
|
end
|
|
@@ -417,6 +431,7 @@ end
|
|
|
417
431
|
# Tool: Fetch source file and line number for a YARD object
|
|
418
432
|
class SourceLocationTool < FastMcp::Tool
|
|
419
433
|
description 'Fetch the source file and line number for a class/module/method from YARD'
|
|
434
|
+
annotations(title: 'Fetch the source file and line number', read_only_hint: true)
|
|
420
435
|
arguments do
|
|
421
436
|
required(:path).filled(:string).description("YARD path (e.g. 'String#upcase')")
|
|
422
437
|
end
|
|
@@ -429,6 +444,7 @@ end
|
|
|
429
444
|
# Tool: Fetch code snippet for a YARD object from installed gems
|
|
430
445
|
class CodeSnippetTool < FastMcp::Tool
|
|
431
446
|
description 'Fetch the code snippet for a class/module/method from installed gems using YARD'
|
|
447
|
+
annotations(title: 'Fetch the code snippet', read_only_hint: true)
|
|
432
448
|
arguments do
|
|
433
449
|
required(:path).filled(:string).description("YARD path (e.g. 'String#upcase')")
|
|
434
450
|
end
|
|
@@ -442,6 +458,7 @@ end
|
|
|
442
458
|
# Tool: Fetch the full ancestor chain (superclasses and included modules) for a class/module in YARD
|
|
443
459
|
class AncestorsTool < FastMcp::Tool
|
|
444
460
|
description 'Fetch the full ancestor chain (superclasses and included modules) for a class/module in YARD'
|
|
461
|
+
annotations(title: 'Fetch the full ancestor chain', read_only_hint: true)
|
|
445
462
|
arguments do
|
|
446
463
|
required(:path).filled(:string).description('YARD path of the class/module')
|
|
447
464
|
end
|
|
@@ -455,6 +472,7 @@ end
|
|
|
455
472
|
# Tool: List related objects: included modules, mixins, and subclasses for a class/module in YARD
|
|
456
473
|
class RelatedObjectsTool < FastMcp::Tool
|
|
457
474
|
description 'List related objects: included modules, mixins, and subclasses for a class/module in YARD'
|
|
475
|
+
annotations(title: 'List related objects', read_only_hint: true)
|
|
458
476
|
arguments do
|
|
459
477
|
required(:path).filled(:string).description('YARD path of the class/module')
|
|
460
478
|
end
|