@reinteractive/rails-insight 1.0.3 → 1.0.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reinteractive/rails-insight",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Rails-aware codebase indexer — MCP server for AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,8 +18,9 @@ export const ROUTE_PATTERNS = {
18
18
  member: /^\s*member\s+do/m,
19
19
  collection: /^\s*collection\s+do/m,
20
20
  draw: /^\s*draw\s*\(?:?(\w+)\)?/m,
21
- only: /only:\s*\[([^\]]+)\]/,
22
- except: /except:\s*\[([^\]]+)\]/,
21
+ only: /only:\s*(?:\[([^\]]+)\]|:([\w]+))/,
22
+ except: /except:\s*(?:\[([^\]]+)\]|:([\w]+))/,
23
+ httpVerbSymbol: /^\s*(?:get|post|put|patch|delete)\s+:(\w+)/m,
23
24
  defaults: /defaults:\s*\{([^}]+)\}/,
24
25
  healthCheck: /^\s*get\s+['"]up['"]/m,
25
26
  direct: /^\s*direct\s*\(:(\w+)\)/m,
@@ -112,7 +112,8 @@ function parseRouteContent(content, result, provider, namespaceStack) {
112
112
  let actions = ['show', 'new', 'create', 'edit', 'update', 'destroy']
113
113
  const onlyMatch = options.match(ROUTE_PATTERNS.only)
114
114
  if (onlyMatch) {
115
- actions = onlyMatch[1].match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
115
+ const raw = onlyMatch[1] ?? `:${onlyMatch[2]}`
116
+ actions = raw.match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
116
117
  }
117
118
 
118
119
  const entry = {
@@ -151,12 +152,13 @@ function parseRouteContent(content, result, provider, namespaceStack) {
151
152
  ]
152
153
  const onlyMatch = options.match(ROUTE_PATTERNS.only)
153
154
  if (onlyMatch) {
154
- actions = onlyMatch[1].match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
155
+ const raw = onlyMatch[1] ?? `:${onlyMatch[2]}`
156
+ actions = raw.match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
155
157
  }
156
158
  const exceptMatch = options.match(ROUTE_PATTERNS.except)
157
159
  if (exceptMatch) {
158
- const except =
159
- exceptMatch[1].match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
160
+ const raw = exceptMatch[1] ?? `:${exceptMatch[2]}`
161
+ const except = raw.match(/:(\w+)/g)?.map((a) => a.slice(1)) || []
160
162
  actions = actions.filter((a) => !except.includes(a))
161
163
  }
162
164
 
@@ -208,6 +210,20 @@ function parseRouteContent(content, result, provider, namespaceStack) {
208
210
  continue
209
211
  }
210
212
 
213
+ // Symbol-form verb routes inside member/collection blocks: `get :action_name`
214
+ if (inMember || inCollection) {
215
+ const symbolVerbMatch = trimmed.match(ROUTE_PATTERNS.httpVerbSymbol)
216
+ if (symbolVerbMatch) {
217
+ const action = symbolVerbMatch[1]
218
+ const currentResource = resourceStack[resourceStack.length - 1]
219
+ if (currentResource) {
220
+ if (inMember) currentResource.member_routes.push(action)
221
+ else currentResource.collection_routes.push(action)
222
+ }
223
+ continue
224
+ }
225
+ }
226
+
211
227
  // HTTP verb routes
212
228
  const verbMatch = trimmed.match(ROUTE_PATTERNS.httpVerb)
213
229
  if (verbMatch) {