@reinteractive/rails-insight 1.0.2 → 1.0.3

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.2",
3
+ "version": "1.0.3",
4
4
  "description": "Rails-aware codebase indexer — MCP server for AI agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@ export const SCHEMA_PATTERNS = {
10
10
  /^\s*t\.(?:references|belongs_to)\s+['"]?:?(\w+)['"]?(?:,\s*(.+))?/m,
11
11
  timestamps: /^\s*t\.timestamps/m,
12
12
  index:
13
- /^\s*(?:t\.index|add_index)\s+(?:\[([^\]]+)\]|['"](\w+)['"]),?\s*(.+)?/m,
13
+ /^\s*(?:t\.index|add_index)\s+(?:\[([^\]]+)\]|['"]([^'"]+)['"]),?\s*(.+)?/m,
14
14
  foreignKey:
15
15
  /^\s*add_foreign_key\s+['"](\w+)['"],\s*['"](\w+)['"](?:,\s*(.+))?/m,
16
16
  checkConstraint:
@@ -149,16 +149,22 @@ export function extractSchema(provider) {
149
149
  // Index
150
150
  const indexMatch = trimmed.match(SCHEMA_PATTERNS.index)
151
151
  if (indexMatch) {
152
+ const isExpression = indexMatch[1] === undefined && indexMatch[2] !== undefined && /[^a-zA-Z0-9_]/.test(indexMatch[2])
152
153
  const columns = indexMatch[1]
153
154
  ? indexMatch[1]
154
155
  .match(/['"](\w+)['"]/g)
155
156
  ?.map((c) => c.replace(/['"]/g, '')) || []
156
- : [indexMatch[2]]
157
+ : isExpression
158
+ ? []
159
+ : [indexMatch[2]]
157
160
  const opts = indexMatch[3] || ''
158
161
  currentTable.indexes.push({
159
162
  columns,
163
+ ...(isExpression ? { expression: indexMatch[2] } : {}),
160
164
  unique: /unique:\s*true/.test(opts),
161
165
  name: opts.match(/name:\s*['"]([^'"]+)['"]/)?.[1] || null,
166
+ where: opts.match(/where:\s*['"]([^'"]+)['"]/)?.[1] || null,
167
+ using: opts.match(/using:\s*:(\w+)/)?.[1] || null,
162
168
  })
163
169
  continue
164
170
  }
@@ -15,9 +15,10 @@ export function register(server, state) {
15
15
  const schema = state.index.extractions?.schema || {}
16
16
  const models = state.index.extractions?.models || {}
17
17
 
18
- // Add model ↔ table mapping
18
+ // Add model ↔ table mapping (concrete AR models only, not concerns/modules)
19
19
  const modelTableMap = {}
20
20
  for (const [modelName, modelData] of Object.entries(models)) {
21
+ if (modelData.type === 'concern') continue
21
22
  const tableName = modelData.table_name || toTableName(modelName)
22
23
  modelTableMap[modelName] = tableName
23
24
  }