rubydex 0.2.9 → 0.4.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +110 -6
  3. data/THIRD_PARTY_LICENSES.html +271 -2
  4. data/exe/rdx +2 -73
  5. data/ext/rubydex/config.c +140 -0
  6. data/ext/rubydex/config.h +16 -0
  7. data/ext/rubydex/declaration.c +1 -1
  8. data/ext/rubydex/definition.c +32 -4
  9. data/ext/rubydex/diagnostic.c +75 -1
  10. data/ext/rubydex/diagnostic.h +2 -0
  11. data/ext/rubydex/graph.c +27 -48
  12. data/ext/rubydex/graph.h +6 -0
  13. data/ext/rubydex/query.c +487 -0
  14. data/ext/rubydex/query.h +8 -0
  15. data/ext/rubydex/reference.c +60 -0
  16. data/ext/rubydex/rubydex.c +4 -0
  17. data/ext/rubydex/utils.c +23 -4
  18. data/ext/rubydex/utils.h +5 -0
  19. data/lib/ruby_lsp/rubydex/addon.rb +211 -0
  20. data/lib/rubydex/cli/command/console.rb +55 -0
  21. data/lib/rubydex/cli/command/lint/explain.rb +74 -0
  22. data/lib/rubydex/cli/command/lint.rb +202 -0
  23. data/lib/rubydex/cli/command/mcp.rb +30 -0
  24. data/lib/rubydex/cli/command/query.rb +70 -0
  25. data/lib/rubydex/cli/command/skill.rb +69 -0
  26. data/lib/rubydex/cli/command.rb +168 -0
  27. data/lib/rubydex/cli.rb +93 -0
  28. data/lib/rubydex/config.rb +59 -0
  29. data/lib/rubydex/diagnostic.rb +12 -3
  30. data/lib/rubydex/errors.rb +42 -1
  31. data/lib/rubydex/graph.rb +10 -3
  32. data/lib/rubydex/linter/custom_rule.rb +97 -0
  33. data/lib/rubydex/linter/helpers/path_helpers.rb +78 -0
  34. data/lib/rubydex/linter/helpers/source_access_helpers.rb +31 -0
  35. data/lib/rubydex/linter/rule_loader.rb +36 -0
  36. data/lib/rubydex/linter/rule_test_case.rb +343 -0
  37. data/lib/rubydex/linter/runner.rb +56 -0
  38. data/lib/rubydex/linter.rb +19 -0
  39. data/lib/rubydex/location.rb +3 -0
  40. data/lib/rubydex/mcp_server.rb +1 -2
  41. data/lib/rubydex/related_information.rb +17 -0
  42. data/lib/rubydex/rule.rb +33 -0
  43. data/lib/rubydex/severity.rb +70 -0
  44. data/lib/rubydex/skill.rb +88 -0
  45. data/lib/rubydex/skill_registry.rb +62 -0
  46. data/lib/rubydex/version.rb +1 -1
  47. data/lib/rubydex.rb +6 -0
  48. data/lib/rubydex_linter/rules/rule_structure.rb +125 -0
  49. data/rbi/rubydex.rbi +578 -15
  50. data/rust/Cargo.lock +7 -0
  51. data/rust/rubydex/Cargo.toml +1 -0
  52. data/rust/rubydex/benches/graph_memory.rs +20 -4
  53. data/rust/rubydex/src/compile_assertions.rs +15 -0
  54. data/rust/rubydex/src/config.rs +538 -157
  55. data/rust/rubydex/src/diagnostic.rs +66 -40
  56. data/rust/rubydex/src/errors.rs +0 -1
  57. data/rust/rubydex/src/indexing/local_graph.rs +6 -5
  58. data/rust/rubydex/src/indexing/rbs_indexer.rs +284 -8
  59. data/rust/rubydex/src/indexing/ruby_indexer.rs +59 -70
  60. data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +195 -86
  61. data/rust/rubydex/src/lib.rs +1 -0
  62. data/rust/rubydex/src/listing.rs +26 -1
  63. data/rust/rubydex/src/main.rs +9 -128
  64. data/rust/rubydex/src/model/declaration.rs +301 -229
  65. data/rust/rubydex/src/model/definitions.rs +27 -26
  66. data/rust/rubydex/src/model/document.rs +43 -7
  67. data/rust/rubydex/src/model/graph.rs +67 -68
  68. data/rust/rubydex/src/model/id.rs +55 -0
  69. data/rust/rubydex/src/model/ids.rs +21 -9
  70. data/rust/rubydex/src/model/name.rs +88 -19
  71. data/rust/rubydex/src/model/references.rs +16 -13
  72. data/rust/rubydex/src/operation/ruby_builder.rs +78 -104
  73. data/rust/rubydex/src/path_helpers.rs +77 -0
  74. data/rust/rubydex/src/query/cypher/schema.rs +853 -0
  75. data/rust/rubydex/src/query/cypher/schema_info.rs +161 -0
  76. data/rust/rubydex/src/query/cypher/tests.rs +253 -0
  77. data/rust/rubydex/src/query/cypher.rs +54 -0
  78. data/rust/rubydex/src/query.rs +125 -43
  79. data/rust/rubydex/src/resolution.rs +368 -395
  80. data/rust/rubydex/src/resolution_tests.rs +504 -78
  81. data/rust/rubydex/src/test_utils/context.rs +2 -1
  82. data/rust/rubydex/src/test_utils/graph_test.rs +26 -12
  83. data/rust/rubydex/src/test_utils/local_graph_test.rs +19 -0
  84. data/rust/rubydex/tests/cli.rs +4 -4
  85. data/rust/rubydex-sys/src/config_api.rs +205 -0
  86. data/rust/rubydex-sys/src/cypher_api.rs +791 -0
  87. data/rust/rubydex-sys/src/declaration_api.rs +6 -3
  88. data/rust/rubydex-sys/src/definition_api.rs +27 -7
  89. data/rust/rubydex-sys/src/diagnostic_api.rs +77 -8
  90. data/rust/rubydex-sys/src/graph_api.rs +31 -68
  91. data/rust/rubydex-sys/src/lib.rs +2 -0
  92. data/rust/rubydex-sys/src/name_api.rs +2 -6
  93. data/rust/rubydex-sys/src/reference_api.rs +58 -12
  94. data/rust/rubydex-sys/src/utils.rs +37 -0
  95. data/skills/send-private-method/SKILL.md +133 -0
  96. metadata +37 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73a4ef87ec062ac40a438143ac91edf1388543ff336a45bc875582886dc5259b
4
- data.tar.gz: 5ba4364ae655fe44edd6897e6c53d95aaff4b970316076f9b538dbd52a6c936b
3
+ metadata.gz: c097d20f2e7fbb252e1a0a9e802986b51c951caec785d9a8a22e41779928f2ce
4
+ data.tar.gz: 8d987121c97c13ffcf3258830c612d5447a7c5efd4a572f6a9ce37de3669e881
5
5
  SHA512:
6
- metadata.gz: c4575cfb038c95e6e86460f5dd832a79224428e05d7f39b9431b50ec4c10029e719862be06acf4fc974a15e210a6a6272de1e5d1193aeb4a0e5a390e7c48d5af
7
- data.tar.gz: d44dce9ff4da7f9332ce1c340087a87fc2655c3bc35ba33f76ad78fbe13774973b99c287aca0b92a65492b77b5b7425147144b1edbd0708f6047c19859ef71a7
6
+ metadata.gz: b978a10b5fe6fe5f76dc916abda86c019bee6b7d36d4b9aa1af4bdb6da88053dc8bceb60d271c559230c16fb2661361bb73f4cbd8dffb4f4fd317b210683c466
7
+ data.tar.gz: c90b49725da1efb7597eb15855f829e7a897feb3d7be4cfb5c59543b346965e3485c06fb7358620b4c36674a453ccc9c66f7182c959508c21324eba4af14d354
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
@@ -73,16 +75,110 @@ location.path
73
75
  # Diagnostics
74
76
  diagnostic = graph.diagnostics.first
75
77
  diagnostic.rule
78
+ diagnostic.rule.default_severity
76
79
  diagnostic.message
77
80
  diagnostic.location
81
+ diagnostic.related_information
82
+ ```
83
+
84
+ ## Ractor Safety
85
+
86
+ A resolved `Rubydex::Graph` can be shared across Ractors without copying:
87
+
88
+ ```ruby
89
+ graph = Rubydex::Graph.new
90
+ graph.index_workspace
91
+ graph.resolve
92
+ Ractor.make_shareable(graph)
93
+
94
+ # Worker Ractors can now read the graph in parallel
95
+ ractor = Ractor.new(graph) { |g| g["Foo"]&.name }
96
+ ractor.value
97
+ ```
98
+
99
+ Thread safety comes from an `RwLock` on the Rust side, **not** from Ruby's
100
+ `freeze`. This is a deliberate, but potentially surprising, choice:
101
+
102
+ - A frozen (or `make_shareable`'d) graph **can still be mutated** — methods like
103
+ `index_source`, `resolve`, `exclude_patterns`, and `encoding=` work on a frozen
104
+ graph. This supports interactive use cases (LSP/MCP) that need incremental
105
+ edits while worker Ractors read concurrently.
106
+ - Because the same underlying allocation is shared, callers are responsible for
107
+ ordering concurrent writes and reads, as with any shared mutable state across
108
+ Ractors.
109
+ - Graphs cannot be `dup`'d or `clone`'d; both raise `RuntimeError` to avoid
110
+ aliasing the Rust allocation (which would double-free on GC) or ballooning
111
+ memory with a deep copy.
112
+
113
+ ## Tools
114
+
115
+ All built-in tools are experimental. These tools can change without deprecation warnings.
116
+
117
+ ### `rdx query`
118
+
119
+ Rubydex exposes the indexed graph through a read-only subset of the
120
+ [Cypher](https://opencypher.org/) query language. Only read clauses (`MATCH`,
121
+ `WHERE`, `RETURN`, ...) are supported; there is no way to mutate the graph.
122
+
123
+ From the command line:
124
+
125
+ ```bash
126
+ # Run a query against the current workspace
127
+ bundle exec rdx query "MATCH (c:Class)-[:DEFINES]->(m:Method) RETURN c.name, m.name"
128
+
129
+ # Render results as JSON instead of a table
130
+ bundle exec rdx query "MATCH (c:Class) RETURN c.name" --format json
131
+
132
+ # Describe the queryable schema (node labels and relationship types) without indexing
133
+ bundle exec rdx query --schema
134
+ ```
135
+
136
+ From Ruby:
137
+
138
+ ```ruby
139
+ graph = Rubydex::Graph.new
140
+ graph.index_workspace
141
+ graph.resolve
142
+
143
+ # Parse once, then run against a graph. `run` executes the query and returns the result set.
144
+ query = Rubydex::Query.parse("MATCH (c:Class) RETURN c.name")
145
+ result = query.run(graph)
146
+
147
+ # Read the rows as Ruby objects, or render the same result set as a table or JSON string
148
+ result.rows.each { |row| puts row["c.name"] }
149
+ puts result.render("table")
150
+ puts result.render("json")
151
+
152
+ # Describe the schema
153
+ puts Rubydex::Query.schema("table")
154
+ ```
155
+
156
+ ### `rdx lint`
157
+
158
+ Put rule files under `rubydex_linter/rules`. Each rule must inherit from `Rubydex::Linter::CustomRule`.
159
+
160
+ Run the linter:
161
+
162
+ ```bash
163
+ bundle exec rdx lint
78
164
  ```
79
165
 
80
- ## MCP Server (Experimental)
166
+ Rubydex uses the bundle root, or the current directory when no bundle is available.
167
+
168
+ Configure a rule in `rubydex.toml`:
169
+
170
+ ```toml
171
+ [linter.rules.<Rule name>]
172
+ enabled = true
173
+ exclude = ["path_to_skip/**"]
174
+ ```
175
+
176
+ ### `rdx mcp`
81
177
 
82
178
  Rubydex can run as an MCP (Model Context Protocol) server, enabling AI assistants
83
179
  like Claude to semantically query your Ruby codebase.
84
180
 
85
- ### Setup
181
+ #### Setup
86
182
 
87
183
  1. Add Rubydex to the Ruby project you want to index:
88
184
  ```ruby
@@ -94,23 +190,23 @@ like Claude to semantically query your Ruby codebase.
94
190
  bundle install
95
191
  ```
96
192
 
97
- 3. Configure your MCP client to run `bundle exec rdx --mcp`.
193
+ 3. Configure your MCP client to run `bundle exec rdx mcp`.
98
194
 
99
195
  Using Claude Code as an example:
100
196
  ```bash
101
- claude mcp add --scope project rubydex -- bundle exec rdx --mcp
197
+ claude mcp add --scope project rubydex -- bundle exec rdx mcp
102
198
  ```
103
199
 
104
200
  Using Codex as an example:
105
201
  ```bash
106
- codex mcp add rubydex -- bundle exec rdx --mcp
202
+ codex mcp add rubydex -- bundle exec rdx mcp
107
203
  ```
108
204
 
109
205
  Start your MCP client from that project directory. The MCP server indexes
110
206
  the project at startup and provides semantic code intelligence tools through
111
207
  the tools below.
112
208
 
113
- ### Available MCP Tools
209
+ #### Available MCP Tools
114
210
 
115
211
  | Tool | Description |
116
212
  |------|-------------|
@@ -121,6 +217,14 @@ like Claude to semantically query your Ruby codebase.
121
217
  | `get_file_declarations` | List declarations defined in a specific file |
122
218
  | `codebase_stats` | High-level statistics about the indexed codebase |
123
219
 
220
+ ## Skill Library (Experimental)
221
+
222
+ Rubydex ships with a built in skill library. These skills are referenced by id by Rubydex tools (for example: `send-private-method` maps to `skills/send-private-method/SKILL.md`).
223
+
224
+ The intention is for Rubydex to provide deterministic skill loading for agents. If a rule returns a skill id, the agent can then fetch the skill with `rdx skill <id>`.
225
+
226
+ This removes the need for agents to load a large number of possibly unrelated skill descriptions when they may or may not be necessary. The information only surfaces if there is a verified violation to fix, and it only needs to be loaded once, rather than inlining it on every violation in every run of the tool (the common pattern for linters and analyzers).
227
+
124
228
  ## Contributing
125
229
 
126
230
  See [the contributing documentation](CONTRIBUTING.md).
@@ -50,9 +50,9 @@
50
50
 
51
51
  <h2>Overview of licenses:</h2>
52
52
  <ul class="licenses-overview">
53
- <li><a href="#Apache-2.0">Apache License 2.0</a> (116)</li>
53
+ <li><a href="#Apache-2.0">Apache License 2.0</a> (119)</li>
54
54
  <li><a href="#Unicode-3.0">Unicode License v3</a> (19)</li>
55
- <li><a href="#MIT">MIT License</a> (16)</li>
55
+ <li><a href="#MIT">MIT License</a> (17)</li>
56
56
  <li><a href="#BSD-2-Clause">BSD 2-Clause &quot;Simplified&quot; License</a> (2)</li>
57
57
  <li><a href="#BSD-3-Clause">BSD 3-Clause &quot;New&quot; or &quot;Revised&quot; License</a> (1)</li>
58
58
  <li><a href="#BSL-1.0">Boost Software License 1.0</a> (1)</li>
@@ -277,6 +277,242 @@
277
277
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
278
278
  See the License for the specific language governing permissions and
279
279
  limitations under the License.
280
+ </pre>
281
+ </li>
282
+ <li class="license">
283
+ <h3 id="Apache-2.0">Apache License 2.0</h3>
284
+ <h4>Used by:</h4>
285
+ <ul class="license-used-by">
286
+ <li><a
287
+ href=" https://github.com/sunfishcode/linux-raw-sys ">linux-raw-sys
288
+ 0.9.4</a></li>
289
+ <li><a
290
+ href=" https://github.com/bytecodealliance/rustix ">rustix
291
+ 1.0.8</a></li>
292
+ <li><a
293
+ href=" https://github.com/bytecodealliance/wasi-rs ">wasi
294
+ 0.14.2+wasi-0.2.4</a></li>
295
+ </ul>
296
+ <pre class="license-text">
297
+ Apache License
298
+ Version 2.0, January 2004
299
+ http://www.apache.org/licenses/
300
+
301
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
302
+
303
+ 1. Definitions.
304
+
305
+ &quot;License&quot; shall mean the terms and conditions for use, reproduction,
306
+ and distribution as defined by Sections 1 through 9 of this document.
307
+
308
+ &quot;Licensor&quot; shall mean the copyright owner or entity authorized by
309
+ the copyright owner that is granting the License.
310
+
311
+ &quot;Legal Entity&quot; shall mean the union of the acting entity and all
312
+ other entities that control, are controlled by, or are under common
313
+ control with that entity. For the purposes of this definition,
314
+ &quot;control&quot; means (i) the power, direct or indirect, to cause the
315
+ direction or management of such entity, whether by contract or
316
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
317
+ outstanding shares, or (iii) beneficial ownership of such entity.
318
+
319
+ &quot;You&quot; (or &quot;Your&quot;) shall mean an individual or Legal Entity
320
+ exercising permissions granted by this License.
321
+
322
+ &quot;Source&quot; form shall mean the preferred form for making modifications,
323
+ including but not limited to software source code, documentation
324
+ source, and configuration files.
325
+
326
+ &quot;Object&quot; form shall mean any form resulting from mechanical
327
+ transformation or translation of a Source form, including but
328
+ not limited to compiled object code, generated documentation,
329
+ and conversions to other media types.
330
+
331
+ &quot;Work&quot; shall mean the work of authorship, whether in Source or
332
+ Object form, made available under the License, as indicated by a
333
+ copyright notice that is included in or attached to the work
334
+ (an example is provided in the Appendix below).
335
+
336
+ &quot;Derivative Works&quot; shall mean any work, whether in Source or Object
337
+ form, that is based on (or derived from) the Work and for which the
338
+ editorial revisions, annotations, elaborations, or other modifications
339
+ represent, as a whole, an original work of authorship. For the purposes
340
+ of this License, Derivative Works shall not include works that remain
341
+ separable from, or merely link (or bind by name) to the interfaces of,
342
+ the Work and Derivative Works thereof.
343
+
344
+ &quot;Contribution&quot; shall mean any work of authorship, including
345
+ the original version of the Work and any modifications or additions
346
+ to that Work or Derivative Works thereof, that is intentionally
347
+ submitted to Licensor for inclusion in the Work by the copyright owner
348
+ or by an individual or Legal Entity authorized to submit on behalf of
349
+ the copyright owner. For the purposes of this definition, &quot;submitted&quot;
350
+ means any form of electronic, verbal, or written communication sent
351
+ to the Licensor or its representatives, including but not limited to
352
+ communication on electronic mailing lists, source code control systems,
353
+ and issue tracking systems that are managed by, or on behalf of, the
354
+ Licensor for the purpose of discussing and improving the Work, but
355
+ excluding communication that is conspicuously marked or otherwise
356
+ designated in writing by the copyright owner as &quot;Not a Contribution.&quot;
357
+
358
+ &quot;Contributor&quot; shall mean Licensor and any individual or Legal Entity
359
+ on behalf of whom a Contribution has been received by Licensor and
360
+ subsequently incorporated within the Work.
361
+
362
+ 2. Grant of Copyright License. Subject to the terms and conditions of
363
+ this License, each Contributor hereby grants to You a perpetual,
364
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
365
+ copyright license to reproduce, prepare Derivative Works of,
366
+ publicly display, publicly perform, sublicense, and distribute the
367
+ Work and such Derivative Works in Source or Object form.
368
+
369
+ 3. Grant of Patent License. Subject to the terms and conditions of
370
+ this License, each Contributor hereby grants to You a perpetual,
371
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
372
+ (except as stated in this section) patent license to make, have made,
373
+ use, offer to sell, sell, import, and otherwise transfer the Work,
374
+ where such license applies only to those patent claims licensable
375
+ by such Contributor that are necessarily infringed by their
376
+ Contribution(s) alone or by combination of their Contribution(s)
377
+ with the Work to which such Contribution(s) was submitted. If You
378
+ institute patent litigation against any entity (including a
379
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
380
+ or a Contribution incorporated within the Work constitutes direct
381
+ or contributory patent infringement, then any patent licenses
382
+ granted to You under this License for that Work shall terminate
383
+ as of the date such litigation is filed.
384
+
385
+ 4. Redistribution. You may reproduce and distribute copies of the
386
+ Work or Derivative Works thereof in any medium, with or without
387
+ modifications, and in Source or Object form, provided that You
388
+ meet the following conditions:
389
+
390
+ (a) You must give any other recipients of the Work or
391
+ Derivative Works a copy of this License; and
392
+
393
+ (b) You must cause any modified files to carry prominent notices
394
+ stating that You changed the files; and
395
+
396
+ (c) You must retain, in the Source form of any Derivative Works
397
+ that You distribute, all copyright, patent, trademark, and
398
+ attribution notices from the Source form of the Work,
399
+ excluding those notices that do not pertain to any part of
400
+ the Derivative Works; and
401
+
402
+ (d) If the Work includes a &quot;NOTICE&quot; text file as part of its
403
+ distribution, then any Derivative Works that You distribute must
404
+ include a readable copy of the attribution notices contained
405
+ within such NOTICE file, excluding those notices that do not
406
+ pertain to any part of the Derivative Works, in at least one
407
+ of the following places: within a NOTICE text file distributed
408
+ as part of the Derivative Works; within the Source form or
409
+ documentation, if provided along with the Derivative Works; or,
410
+ within a display generated by the Derivative Works, if and
411
+ wherever such third-party notices normally appear. The contents
412
+ of the NOTICE file are for informational purposes only and
413
+ do not modify the License. You may add Your own attribution
414
+ notices within Derivative Works that You distribute, alongside
415
+ or as an addendum to the NOTICE text from the Work, provided
416
+ that such additional attribution notices cannot be construed
417
+ as modifying the License.
418
+
419
+ You may add Your own copyright statement to Your modifications and
420
+ may provide additional or different license terms and conditions
421
+ for use, reproduction, or distribution of Your modifications, or
422
+ for any such Derivative Works as a whole, provided Your use,
423
+ reproduction, and distribution of the Work otherwise complies with
424
+ the conditions stated in this License.
425
+
426
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
427
+ any Contribution intentionally submitted for inclusion in the Work
428
+ by You to the Licensor shall be under the terms and conditions of
429
+ this License, without any additional terms or conditions.
430
+ Notwithstanding the above, nothing herein shall supersede or modify
431
+ the terms of any separate license agreement you may have executed
432
+ with Licensor regarding such Contributions.
433
+
434
+ 6. Trademarks. This License does not grant permission to use the trade
435
+ names, trademarks, service marks, or product names of the Licensor,
436
+ except as required for reasonable and customary use in describing the
437
+ origin of the Work and reproducing the content of the NOTICE file.
438
+
439
+ 7. Disclaimer of Warranty. Unless required by applicable law or
440
+ agreed to in writing, Licensor provides the Work (and each
441
+ Contributor provides its Contributions) on an &quot;AS IS&quot; BASIS,
442
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
443
+ implied, including, without limitation, any warranties or conditions
444
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
445
+ PARTICULAR PURPOSE. You are solely responsible for determining the
446
+ appropriateness of using or redistributing the Work and assume any
447
+ risks associated with Your exercise of permissions under this License.
448
+
449
+ 8. Limitation of Liability. In no event and under no legal theory,
450
+ whether in tort (including negligence), contract, or otherwise,
451
+ unless required by applicable law (such as deliberate and grossly
452
+ negligent acts) or agreed to in writing, shall any Contributor be
453
+ liable to You for damages, including any direct, indirect, special,
454
+ incidental, or consequential damages of any character arising as a
455
+ result of this License or out of the use or inability to use the
456
+ Work (including but not limited to damages for loss of goodwill,
457
+ work stoppage, computer failure or malfunction, or any and all
458
+ other commercial damages or losses), even if such Contributor
459
+ has been advised of the possibility of such damages.
460
+
461
+ 9. Accepting Warranty or Additional Liability. While redistributing
462
+ the Work or Derivative Works thereof, You may choose to offer,
463
+ and charge a fee for, acceptance of support, warranty, indemnity,
464
+ or other liability obligations and/or rights consistent with this
465
+ License. However, in accepting such obligations, You may act only
466
+ on Your own behalf and on Your sole responsibility, not on behalf
467
+ of any other Contributor, and only if You agree to indemnify,
468
+ defend, and hold each Contributor harmless for any liability
469
+ incurred by, or claims asserted against, such Contributor by reason
470
+ of your accepting any such warranty or additional liability.
471
+
472
+ END OF TERMS AND CONDITIONS
473
+
474
+ APPENDIX: How to apply the Apache License to your work.
475
+
476
+ To apply the Apache License to your work, attach the following
477
+ boilerplate notice, with the fields enclosed by brackets &quot;[]&quot;
478
+ replaced with your own identifying information. (Don&#x27;t include
479
+ the brackets!) The text should be enclosed in the appropriate
480
+ comment syntax for the file format. We also recommend that a
481
+ file or class name and description of purpose be included on the
482
+ same &quot;printed page&quot; as the copyright notice for easier
483
+ identification within third-party archives.
484
+
485
+ Copyright [yyyy] [name of copyright owner]
486
+
487
+ Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
488
+ you may not use this file except in compliance with the License.
489
+ You may obtain a copy of the License at
490
+
491
+ http://www.apache.org/licenses/LICENSE-2.0
492
+
493
+ Unless required by applicable law or agreed to in writing, software
494
+ distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
495
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
496
+ See the License for the specific language governing permissions and
497
+ limitations under the License.
498
+
499
+
500
+ --- LLVM Exceptions to the Apache 2.0 License ----
501
+
502
+ As an exception, if, as a result of your compiling your source code, portions
503
+ of this Software are embedded into an Object form of such source code, you
504
+ may redistribute such embedded portions in such Object form without complying
505
+ with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
506
+
507
+ In addition, if you combine or link compiled forms of this Software with
508
+ software that is licensed under the GPLv2 (&quot;Combined Software&quot;) and if a
509
+ court of competent jurisdiction determines that the patent provision (Section
510
+ 3), the indemnity provision (Section 9) or other Section of the License
511
+ conflicts with the conditions of the GPLv2, you may retroactively and
512
+ prospectively choose to deem waived or otherwise exclude such Section(s) of
513
+ the License, but only in their entirety and only with respect to the Combined
514
+ Software.
515
+
280
516
  </pre>
281
517
  </li>
282
518
  <li class="license">
@@ -2802,6 +3038,39 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2802
3038
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2803
3039
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2804
3040
  SOFTWARE.
3041
+ </pre>
3042
+ </li>
3043
+ <li class="license">
3044
+ <h3 id="MIT">MIT License</h3>
3045
+ <h4>Used by:</h4>
3046
+ <ul class="license-used-by">
3047
+ <li><a
3048
+ href=" https://github.com/Shopify/cypher-parser ">cypher-parser
3049
+ 0.8.1</a></li>
3050
+ </ul>
3051
+ <pre class="license-text">The MIT License (MIT)
3052
+
3053
+ Copyright (c) 2025-present, Shopify Inc.
3054
+
3055
+ Permission is hereby granted, free of charge, to any person obtaining a copy
3056
+ of this software and associated documentation files (the &quot;Software&quot;), to deal
3057
+ in the Software without restriction, including without limitation the rights
3058
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3059
+ copies of the Software, and to permit persons to whom the Software is
3060
+ furnished to do so, subject to the following conditions:
3061
+
3062
+ The above copyright notice and this permission notice shall be included in
3063
+ all copies or substantial portions of the Software.
3064
+
3065
+ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3066
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3067
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3068
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3069
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3070
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3071
+ THE SOFTWARE.
3072
+
3073
+ See the generated THIRD_PARTY_LICENSES.html file for third party licenses.
2805
3074
  </pre>
2806
3075
  </li>
2807
3076
  <li class="license">
data/exe/rdx CHANGED
@@ -3,77 +3,6 @@
3
3
 
4
4
  $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
5
5
 
6
- require "optparse"
6
+ require "rubydex/cli"
7
7
 
8
- options = {}
9
-
10
- option_parser = OptionParser.new do |parser|
11
- parser.on("--version", "Print the gem's version") do
12
- require "rubydex/version"
13
- puts "v#{Rubydex::VERSION}"
14
- exit
15
- end
16
-
17
- parser.on("-h", "--help", "Prints this help") do
18
- puts parser
19
- exit
20
- end
21
-
22
- parser.on("-i", "--interactive", "Open an interactive session with a populated graph for the current workspace") do
23
- options[:interactive] = true
24
- end
25
-
26
- parser.on("--mcp", "Run the MCP server for AI assistants") do
27
- options[:mcp] = true
28
- end
29
- end
30
-
31
- begin
32
- arguments = option_parser.parse(ARGV)
33
- rescue OptionParser::ParseError => e
34
- warn("error: #{e.message}")
35
- warn
36
- warn(option_parser)
37
- exit(2)
38
- end
39
-
40
- require "rubydex"
41
-
42
- if options[:mcp]
43
- if arguments.length > 1
44
- warn("error: unexpected argument '#{arguments[1]}' found")
45
- warn
46
- warn(option_parser)
47
- exit(2)
48
- end
49
-
50
- require "rubydex/mcp_server"
51
- Rubydex::MCPServer.run(arguments.fetch(0, Dir.pwd))
52
- exit
53
- end
54
-
55
- def __with_timer(message, &block)
56
- print(message)
57
- start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)
58
- block.call
59
- duration = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond) - start
60
- puts " finished in #{duration.round(2)}ms"
61
- end
62
-
63
- graph = Rubydex::Graph.new
64
- graph.load_config
65
-
66
- __with_timer("Indexing workspace...") { graph.index_workspace }
67
- __with_timer("Resolving graph...") { graph.resolve }
68
-
69
- if options[:interactive]
70
- begin
71
- require "irb"
72
- IRB.setup(nil)
73
- IRB.conf[:IRB_NAME] = "rubydex"
74
- workspace = IRB::WorkSpace.new(binding)
75
- IRB::Irb.new(workspace).run(IRB.conf)
76
- rescue LoadError
77
- abort("Interactive mode requires `irb` to be in the bundle")
78
- end
79
- end
8
+ Rubydex::CLI.start