rubydex 0.2.8 → 0.3.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -3
  3. data/THIRD_PARTY_LICENSES.html +168 -1381
  4. data/exe/rdx +136 -34
  5. data/ext/rubydex/declaration.c +1 -1
  6. data/ext/rubydex/definition.c +32 -4
  7. data/ext/rubydex/extconf.rb +0 -8
  8. data/ext/rubydex/graph.c +29 -18
  9. data/ext/rubydex/query.c +105 -0
  10. data/ext/rubydex/query.h +8 -0
  11. data/ext/rubydex/reference.c +60 -0
  12. data/ext/rubydex/rubydex.c +2 -0
  13. data/ext/rubydex/utils.c +12 -0
  14. data/ext/rubydex/utils.h +5 -0
  15. data/lib/rubydex/mcp_server/protocol.rb +156 -0
  16. data/lib/rubydex/mcp_server/tools/base_tool.rb +109 -0
  17. data/lib/rubydex/mcp_server/tools/codebase_stats_tool.rb +30 -0
  18. data/lib/rubydex/mcp_server/tools/find_constant_references_tool.rb +46 -0
  19. data/lib/rubydex/mcp_server/tools/get_declaration_tool.rb +68 -0
  20. data/lib/rubydex/mcp_server/tools/get_descendants_tool.rb +46 -0
  21. data/lib/rubydex/mcp_server/tools/get_file_declarations_tool.rb +55 -0
  22. data/lib/rubydex/mcp_server/tools/search_declarations_tool.rb +55 -0
  23. data/lib/rubydex/mcp_server.rb +219 -0
  24. data/lib/rubydex/version.rb +1 -1
  25. data/rbi/rubydex.rbi +26 -4
  26. data/rust/Cargo.lock +5 -552
  27. data/rust/Cargo.toml +0 -1
  28. data/rust/rubydex/Cargo.toml +1 -0
  29. data/rust/rubydex/benches/graph_memory.rs +22 -4
  30. data/rust/rubydex/src/compile_assertions.rs +15 -0
  31. data/rust/rubydex/src/config.rs +54 -34
  32. data/rust/rubydex/src/diagnostic.rs +1 -1
  33. data/rust/rubydex/src/indexing/rbs_indexer.rs +14 -2
  34. data/rust/rubydex/src/indexing/ruby_indexer.rs +49 -58
  35. data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +72 -16
  36. data/rust/rubydex/src/listing.rs +159 -102
  37. data/rust/rubydex/src/main.rs +3 -125
  38. data/rust/rubydex/src/model/declaration.rs +0 -11
  39. data/rust/rubydex/src/model/definitions.rs +27 -26
  40. data/rust/rubydex/src/model/document.rs +43 -7
  41. data/rust/rubydex/src/model/graph.rs +47 -35
  42. data/rust/rubydex/src/model/id.rs +55 -0
  43. data/rust/rubydex/src/model/ids.rs +21 -9
  44. data/rust/rubydex/src/model/name.rs +35 -7
  45. data/rust/rubydex/src/model/references.rs +16 -13
  46. data/rust/rubydex/src/operation/applier.rs +0 -2
  47. data/rust/rubydex/src/operation/ruby_builder.rs +48 -59
  48. data/rust/rubydex/src/query/cypher/schema.rs +790 -0
  49. data/rust/rubydex/src/query/cypher/schema_info.rs +161 -0
  50. data/rust/rubydex/src/query/cypher/tests.rs +228 -0
  51. data/rust/rubydex/src/query/cypher.rs +57 -0
  52. data/rust/rubydex/src/query.rs +2 -0
  53. data/rust/rubydex/src/resolution.rs +248 -227
  54. data/rust/rubydex/src/resolution_tests.rs +263 -65
  55. data/rust/rubydex-sys/src/declaration_api.rs +6 -3
  56. data/rust/rubydex-sys/src/definition_api.rs +27 -7
  57. data/rust/rubydex-sys/src/graph_api.rs +175 -27
  58. data/rust/rubydex-sys/src/reference_api.rs +58 -12
  59. metadata +17 -10
  60. data/exe/rubydex_mcp +0 -17
  61. data/lib/rubydex/bin/rubydex_mcp.exe +0 -0
  62. data/rust/rubydex-mcp/Cargo.toml +0 -34
  63. data/rust/rubydex-mcp/src/main.rs +0 -48
  64. data/rust/rubydex-mcp/src/server.rs +0 -1148
  65. data/rust/rubydex-mcp/src/tools.rs +0 -49
  66. data/rust/rubydex-mcp/tests/mcp.rs +0 -302
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b27fe66d59bdafd3b040278baaca0607a87861d132d70cc7ad65f9edb75c049
4
- data.tar.gz: 1036e909678edd8183e1359ba9b45323d1e7a26ad99847d3382583a3f97d1f61
3
+ metadata.gz: cf823835a70dee735f2dc0e898eb1d47be47e4ab635a6be4de5677ceaf6bbe53
4
+ data.tar.gz: 663389c429d729bf8d9191f54b7eafe92b8ecb8e0c0a32e5b3f6adba3365f3fa
5
5
  SHA512:
6
- metadata.gz: 884a896d38505cdb97ddc2a83b96364dc918f7f449349bf37e0d54675d630750300856df10dc6ab13e80b20d03979cbef5122ca2cc7ed20a160e64cf8ec421bd
7
- data.tar.gz: cfd66ff47db6ac89e6f5514d307e48dcb5f252c5132eeb17328cf067365c1d764b6f9f87609483135815bf5760502992a9de107322e9445b2a99deacc9dcf7a5
6
+ metadata.gz: aa17ed0f03e392c4ad1a2bf256d3472057d7a78a2baca596bb72f80c06d1fe36d7fa80878ddfabe740ca0b8d23f961d01afe9ab0211219e2f41b36b4587b819d
7
+ data.tar.gz: 86d70527d4bcee2b8e90bbebb33912e1f5a6bf1f7fe9ce6e1435e7fff918829ae2a8de692072ab34fca42a199f5cfce5a12e18f77b6f08d5b8ca274c3e8f83f4
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  This project is a high-performance static analysis toolkit for the Ruby language. The goal is to be a solid
4
4
  foundation to power a variety of tools, such as type checkers, linters, language servers and more.
5
5
 
6
+ [Ruby API Documentation](https://shopify.github.io/rubydex/)
7
+
6
8
  ## Usage
7
9
 
8
10
  Both Ruby and Rust APIs are made available through a gem and a crate, respectively. Here's a simple example
@@ -77,6 +79,70 @@ diagnostic.message
77
79
  diagnostic.location
78
80
  ```
79
81
 
82
+ ## Ractor Safety
83
+
84
+ A resolved `Rubydex::Graph` can be shared across Ractors without copying:
85
+
86
+ ```ruby
87
+ graph = Rubydex::Graph.new
88
+ graph.index_workspace
89
+ graph.resolve
90
+ Ractor.make_shareable(graph)
91
+
92
+ # Worker Ractors can now read the graph in parallel
93
+ ractor = Ractor.new(graph) { |g| g["Foo"]&.name }
94
+ ractor.value
95
+ ```
96
+
97
+ Thread safety comes from an `RwLock` on the Rust side, **not** from Ruby's
98
+ `freeze`. This is a deliberate, but potentially surprising, choice:
99
+
100
+ - A frozen (or `make_shareable`'d) graph **can still be mutated** — methods like
101
+ `index_source`, `resolve`, `exclude_patterns`, and `encoding=` work on a frozen
102
+ graph. This supports interactive use cases (LSP/MCP) that need incremental
103
+ edits while worker Ractors read concurrently.
104
+ - Because the same underlying allocation is shared, callers are responsible for
105
+ ordering concurrent writes and reads, as with any shared mutable state across
106
+ Ractors.
107
+ - Graphs cannot be `dup`'d or `clone`'d; both raise `RuntimeError` to avoid
108
+ aliasing the Rust allocation (which would double-free on GC) or ballooning
109
+ memory with a deep copy.
110
+
111
+ ## Querying with Cypher
112
+
113
+ Rubydex exposes the indexed graph through a read-only subset of the
114
+ [Cypher](https://opencypher.org/) query language. Only read clauses (`MATCH`,
115
+ `WHERE`, `RETURN`, ...) are supported; there is no way to mutate the graph.
116
+
117
+ From the command line:
118
+
119
+ ```bash
120
+ # Run a query against the current workspace
121
+ bundle exec rdx query "MATCH (c:Class)-[:DEFINES]->(m:Method) RETURN c.name, m.name"
122
+
123
+ # Render results as JSON instead of a table
124
+ bundle exec rdx query "MATCH (c:Class) RETURN c.name" --format json
125
+
126
+ # Describe the queryable schema (node labels and relationship types) without indexing
127
+ bundle exec rdx query --schema
128
+ ```
129
+
130
+ From Ruby:
131
+
132
+ ```ruby
133
+ graph = Rubydex::Graph.new
134
+ graph.index_workspace
135
+ graph.resolve
136
+
137
+ # Parse once, render against a graph as a table or JSON string
138
+ query = Rubydex::Query.parse("MATCH (c:Class) RETURN c.name")
139
+ puts query.render(graph, "table")
140
+ puts query.render(graph, "json")
141
+
142
+ # Describe the schema
143
+ puts Rubydex::Query.schema("table")
144
+ ```
145
+
80
146
  ## MCP Server (Experimental)
81
147
 
82
148
  Rubydex can run as an MCP (Model Context Protocol) server, enabling AI assistants
@@ -94,16 +160,16 @@ like Claude to semantically query your Ruby codebase.
94
160
  bundle install
95
161
  ```
96
162
 
97
- 3. Configure your MCP client to run `bundle exec rubydex_mcp`.
163
+ 3. Configure your MCP client to run `bundle exec rdx mcp`.
98
164
 
99
165
  Using Claude Code as an example:
100
166
  ```bash
101
- claude mcp add --scope project rubydex -- bundle exec rubydex_mcp
167
+ claude mcp add --scope project rubydex -- bundle exec rdx mcp
102
168
  ```
103
169
 
104
170
  Using Codex as an example:
105
171
  ```bash
106
- codex mcp add rubydex -- bundle exec rubydex_mcp
172
+ codex mcp add rubydex -- bundle exec rdx mcp
107
173
  ```
108
174
 
109
175
  Start your MCP client from that project directory. The MCP server indexes