tidewave 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d75b5659655095637ad8830051ef50f06e018339520d093c51854cec9c320fd7
4
- data.tar.gz: 9325b6a4ea7ac4e1444a677bd1dc785bc6f8046e8492a5d1b70267c9424ca9a3
3
+ metadata.gz: 80a98c944044fd2164929251e642cd2c35713a3bcd2a427485aa9aed5b9c2780
4
+ data.tar.gz: dac0861994231e0cfb23eb9203c43c9ed310f0fbb0041e1d674443df1e592323
5
5
  SHA512:
6
- metadata.gz: 9fe7d353f945a3a3735dfdd56486188df12034736c2ac78561dca478b05b6f15fba9608dd8e8209f3d9a66659f4908c2814ec65ccdf13030f56b1387a9190fde
7
- data.tar.gz: 6782f79c55813d99d5cffeb973812116aaf581570119de0ebcd739d2f65d1aa0fbc3ed3bc1cc1d478ec0b30ac18fbc2ab9db6037df18ec433b8ef50cce7eb947
6
+ metadata.gz: 2e0cd1d84fc3aa6e2f9da2a4c1cd7dcc613e29552ed20f0b73bdcb5770bef22f5555846e290638c77bb1c5df3c1c2d53285b3fb03cd41c127394630f785e60b2
7
+ data.tar.gz: 50ac0f18928027d78246fe69b0c77f552a3b05772875f8b01f016d05cffbbfeca4262359bff6407781ecb7509a99b2955788e3c1080bac110061f950c7afbd37
data/README.md CHANGED
@@ -20,14 +20,6 @@ gem "tidewave", group: :development
20
20
 
21
21
  Now make sure [Tidewave is installed](https://hexdocs.pm/tidewave/installation.html) and you are ready to connect Tidewave to your app.
22
22
 
23
- ## Development
24
-
25
- Run the Minitest suite with:
26
-
27
- ```shell
28
- bundle exec ruby -Itest test/all_test.rb
29
- ```
30
-
31
23
  ## Troubleshooting
32
24
 
33
25
  ### Using multiple hosts/subdomains
@@ -94,10 +86,30 @@ The following config is available:
94
86
  - `project_eval` - evaluates code within the Rails application itself, giving the agent
95
87
  access to your runtime, dependencies, and in-memory data
96
88
 
89
+ > [!NOTE]
90
+ > #### Why no tools for routes, associations, etc?
91
+ >
92
+ > Tidewave does not include tools for listing your routes, associations, etc. because
93
+ > agents are better off reading their respective source files, which gives agents more
94
+ > context and enable them to perform any necessary edit without additional tools calls.
95
+ >
96
+ > Instead, Tidewave aims to fill in missing gaps, such as evaluating code inside your
97
+ > Rails app (without starting new instances) and finding source location, which can be
98
+ > tricky, even with grepping, due to meta-programming and the different places Bundler
99
+ > can install your dependencies.
100
+
97
101
  ## Acknowledgements
98
102
 
99
103
  A thank you to Yorick Jacquin for the initial version of this project.
100
104
 
105
+ ## Development
106
+
107
+ Run the Minitest suite with:
108
+
109
+ ```shell
110
+ bundle exec ruby -Itest test/all_test.rb
111
+ ```
112
+
101
113
  ## License
102
114
 
103
115
  Copyright (c) 2025 Dashbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tidewave
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
data/lib/tidewave.rb CHANGED
@@ -60,7 +60,9 @@ class Tidewave
60
60
 
61
61
  if path[0] == TIDEWAVE_ROUTE
62
62
  return forbidden(INVALID_IP) unless valid_client_ip?(request)
63
- return forbidden(INVALID_ORIGIN) if request.get_header("HTTP_ORIGIN") && path != [ TIDEWAVE_ROUTE ]
63
+ if request.get_header("HTTP_ORIGIN") && !origin_allowed_path?(path)
64
+ return forbidden(INVALID_ORIGIN)
65
+ end
64
66
 
65
67
  case [ request.request_method, path ]
66
68
  when [ "GET", [ TIDEWAVE_ROUTE ] ]
@@ -102,8 +104,8 @@ class Tidewave
102
104
  [ 200, response_headers("text/html", body), [ body ] ]
103
105
  end
104
106
 
105
- def config_endpoint(_request)
106
- json_response(config_data)
107
+ def config_endpoint(request)
108
+ json_response(config_data(request), headers: { "Access-Control-Allow-Origin" => "*" })
107
109
  end
108
110
 
109
111
  def mcp_endpoint(request)
@@ -124,19 +126,20 @@ class Tidewave
124
126
  jsonrpc_error_response(nil, -32603, "Internal error")
125
127
  end
126
128
 
127
- def config_data
129
+ def config_data(request)
128
130
  {
129
131
  "project_name" => @options[:project_name],
130
132
  "framework_type" => @options[:framework_type],
131
133
  "orm_adapter" => @options[:orm_adapter],
132
134
  "team" => @options[:team] || {},
133
- "tidewave_version" => VERSION
135
+ "tidewave_version" => VERSION,
136
+ "local_port" => local_port(request)
134
137
  }
135
138
  end
136
139
 
137
- def json_response(payload, status: 200)
140
+ def json_response(payload, status: 200, headers: {})
138
141
  body = JSON.generate(payload)
139
- [ status, response_headers("application/json", body), [ body ] ]
142
+ [ status, response_headers("application/json", body).merge(headers), [ body ] ]
140
143
  end
141
144
 
142
145
  def forbidden(message)
@@ -159,6 +162,18 @@ class Tidewave
159
162
  }
160
163
  end
161
164
 
165
+ def origin_allowed_path?(path)
166
+ path == [ TIDEWAVE_ROUTE ] || path == [ TIDEWAVE_ROUTE, CONFIG_ROUTE ]
167
+ end
168
+
169
+ def local_port(request)
170
+ sock = request.env["puma.socket"]
171
+ return unless sock
172
+
173
+ addr = sock.respond_to?(:local_address) ? sock.local_address : sock.to_io.local_address
174
+ addr.ip? ? addr.ip_port : nil
175
+ end
176
+
162
177
  def valid_client_ip?(request)
163
178
  return true if @options[:allow_remote_access]
164
179
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tidewave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yorick Jacquin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-05-29 00:00:00.000000000 Z
12
+ date: 2026-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack