Commit ae547cd
authored
feat(php): add filesystem walk-up detection for Laravel & WordPress + structured logging
Implements parent-directory walk-up framework detection for deeply nested PHP files:
Laravel detection:
- Walk UP parent dirs looking for `artisan` or `composer.json` with `laravel/framework`
- Results cached per starting directory via `laravelCache` on CodeAnalyzer
- maxWalkUpDepth=10 prevents unbounded traversal
WordPress detection:
- Walk UP parent dirs looking for `wp-config.php`, `wp-content`, `wp-includes`, `wp-admin`
- Plugin/theme header detection reads only first 4KB (`readFilePrefix`)
- maxWalkUpDepth=10 prevents unbounded traversal
Structured logging:
- Replaced all `fmt.Fprintf(os.Stderr, ...)` with `logger.Instance.{Debug,Info,Warn,Error}`
- Per-file enrichment logs set to Debug to avoid log flooding during indexing
- Startup/registration logs remain at Info level
Review fixes (PR #44 Copilot review - all 10 comments addressed):
- Added maxDepth limit to both WP and Laravel walk-up functions
- Limited file reads to 4KB prefix for header detection
- Fixed isLaravelByFilesystem caching (cache starting dir, not just root)
- Removed unused `wordpressCache` field from CodeAnalyzer
- Added 16 unit tests (8 WordPress + 8 Laravel filesystem walk-up)
Version bump: 2.1.8610 files changed
Lines changed: 675 additions & 24 deletions
File tree
- cmd/rag-code-mcp
- pkg/parser/php
- laravel
- wordpress
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | | - | |
| 87 | + | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | | - | |
| 92 | + | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
139 | | - | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | | - | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | | - | |
| 150 | + | |
146 | 151 | | |
147 | 152 | | |
148 | 153 | | |
| |||
1198 | 1203 | | |
1199 | 1204 | | |
1200 | 1205 | | |
| 1206 | + | |
1201 | 1207 | | |
1202 | | - | |
1203 | 1208 | | |
1204 | 1209 | | |
1205 | 1210 | | |
1206 | 1211 | | |
1207 | 1212 | | |
1208 | | - | |
1209 | | - | |
1210 | 1213 | | |
1211 | 1214 | | |
1212 | 1215 | | |
| |||
1216 | 1219 | | |
1217 | 1220 | | |
1218 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
1219 | 1288 | | |
1220 | 1289 | | |
1221 | 1290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
18 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
20 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
21 | 95 | | |
22 | 96 | | |
23 | 97 | | |
24 | 98 | | |
| 99 | + | |
| 100 | + | |
25 | 101 | | |
26 | 102 | | |
27 | 103 | | |
28 | 104 | | |
| 105 | + | |
29 | 106 | | |
30 | 107 | | |
31 | 108 | | |
32 | 109 | | |
33 | 110 | | |
34 | | - | |
| 111 | + | |
35 | 112 | | |
| 113 | + | |
36 | 114 | | |
37 | 115 | | |
38 | 116 | | |
39 | 117 | | |
40 | 118 | | |
| 119 | + | |
41 | 120 | | |
| 121 | + | |
| 122 | + | |
42 | 123 | | |
43 | 124 | | |
44 | 125 | | |
| 126 | + | |
45 | 127 | | |
46 | 128 | | |
0 commit comments