akbo-cli 0.0.0-stage → 1.9.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.
Files changed (66) hide show
  1. package/README.md +706 -2
  2. package/dist/catalog_store.d.ts +78 -0
  3. package/dist/catalog_store.js +375 -0
  4. package/dist/cleaner.d.ts +11 -0
  5. package/dist/cleaner.js +92 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +1596 -0
  8. package/dist/extractors/base.d.ts +35 -0
  9. package/dist/extractors/base.js +17 -0
  10. package/dist/extractors/custom_extractor.d.ts +55 -0
  11. package/dist/extractors/custom_extractor.js +198 -0
  12. package/dist/extractors/dotnet_extractor.d.ts +11 -0
  13. package/dist/extractors/dotnet_extractor.js +579 -0
  14. package/dist/extractors/golang_extractor.d.ts +11 -0
  15. package/dist/extractors/golang_extractor.js +73 -0
  16. package/dist/extractors/index.d.ts +14 -0
  17. package/dist/extractors/index.js +30 -0
  18. package/dist/extractors/jvm_extractor.d.ts +11 -0
  19. package/dist/extractors/jvm_extractor.js +319 -0
  20. package/dist/extractors/node_extractor.d.ts +11 -0
  21. package/dist/extractors/node_extractor.js +306 -0
  22. package/dist/extractors/proto_graphql_extractor.d.ts +11 -0
  23. package/dist/extractors/proto_graphql_extractor.js +125 -0
  24. package/dist/extractors/python_extractor.d.ts +11 -0
  25. package/dist/extractors/python_extractor.js +298 -0
  26. package/dist/extractors/rust_extractor.d.ts +11 -0
  27. package/dist/extractors/rust_extractor.js +66 -0
  28. package/dist/graph_builder.d.ts +87 -0
  29. package/dist/graph_builder.js +1498 -0
  30. package/dist/harvester.d.ts +38 -0
  31. package/dist/harvester.js +461 -0
  32. package/dist/hook_generator.d.ts +26 -0
  33. package/dist/hook_generator.js +203 -0
  34. package/dist/importers/skill_importer.d.ts +43 -0
  35. package/dist/importers/skill_importer.js +470 -0
  36. package/dist/index.d.ts +17 -0
  37. package/dist/index.js +17 -0
  38. package/dist/indexer.d.ts +19 -0
  39. package/dist/indexer.js +108 -0
  40. package/dist/init_service.d.ts +37 -0
  41. package/dist/init_service.js +246 -0
  42. package/dist/mcp_server.d.ts +10 -0
  43. package/dist/mcp_server.js +632 -0
  44. package/dist/pool_resolver.d.ts +40 -0
  45. package/dist/pool_resolver.js +84 -0
  46. package/dist/provider.d.ts +135 -0
  47. package/dist/provider.js +880 -0
  48. package/dist/query_service.d.ts +33 -0
  49. package/dist/query_service.js +161 -0
  50. package/dist/schema_generator.d.ts +236 -0
  51. package/dist/schema_generator.js +264 -0
  52. package/dist/standards_loader.d.ts +7 -0
  53. package/dist/standards_loader.js +33 -0
  54. package/dist/types.d.ts +265 -0
  55. package/dist/types.js +105 -0
  56. package/dist/unit_synthesizer.d.ts +22 -0
  57. package/dist/unit_synthesizer.js +196 -0
  58. package/dist/validator.d.ts +13 -0
  59. package/dist/validator.js +152 -0
  60. package/dist/version.d.ts +6 -0
  61. package/dist/version.js +16 -0
  62. package/dist/watcher.d.ts +38 -0
  63. package/dist/watcher.js +132 -0
  64. package/package.json +56 -6
  65. package/schemas/index-schema.json +98 -0
  66. package/schemas/knowledge-unit.json +154 -0
@@ -0,0 +1,579 @@
1
+ import path from 'node:path';
2
+ import { cleanClientUrl } from './base.js';
3
+ export class DotnetExtractor {
4
+ name = 'dotnet';
5
+ canExtractManifest(filePath) {
6
+ const lower = path.basename(filePath).toLowerCase();
7
+ return (lower.endsWith('.sln') ||
8
+ lower.endsWith('.csproj') ||
9
+ lower.endsWith('.fsproj') ||
10
+ lower === 'directory.build.props' ||
11
+ lower === 'directory.packages.props' ||
12
+ lower === 'packages.config' ||
13
+ lower === 'web.config');
14
+ }
15
+ extractManifest(filePath, content) {
16
+ const filename = path.basename(filePath);
17
+ const lower = filename.toLowerCase();
18
+ const normalized = filePath.replace(/\\/g, '/');
19
+ // 1. Solution files (*.sln)
20
+ if (lower.endsWith('.sln')) {
21
+ const projectMatches = Array.from(content.matchAll(/Project\("[^"]+"\)\s*=\s*"([^"]+)",\s*"([^"]+)"/g));
22
+ const projects = projectMatches.map(m => ({
23
+ name: m[1],
24
+ path: m[2].replace(/\\/g, '/')
25
+ }));
26
+ return {
27
+ path: normalized,
28
+ type: 'dotnet',
29
+ contentSummary: {
30
+ kind: 'solution',
31
+ projectCount: projects.length,
32
+ projects
33
+ }
34
+ };
35
+ }
36
+ // 2. C# / F# Project files (*.csproj, *.fsproj)
37
+ if (lower.endsWith('.csproj') || lower.endsWith('.fsproj')) {
38
+ const tfMatch = content.match(/<TargetFramework>(.*?)<\/TargetFramework>/i) ||
39
+ content.match(/<TargetFrameworks>(.*?)<\/TargetFrameworks>/i) ||
40
+ content.match(/<TargetFrameworkVersion>(.*?)<\/TargetFrameworkVersion>/i);
41
+ const targetFramework = tfMatch ? tfMatch[1].trim() : undefined;
42
+ const packages = Array.from(content.matchAll(/<PackageReference\s+[^>]*Include="([^"]+)"/gi)).map(m => m[1]);
43
+ const legacyReferences = Array.from(content.matchAll(/<Reference\s+[^>]*Include="([^",\s]+)[^"]*"/gi))
44
+ .map(m => m[1])
45
+ .filter(r => !['System', 'System.Core', 'System.Data', 'System.Drawing', 'System.Xml', 'System.Xml.Linq', 'mscorlib'].includes(r));
46
+ const allPackages = [...new Set([...packages, ...legacyReferences])];
47
+ const projectRefs = Array.from(content.matchAll(/<ProjectReference\s+[^>]*Include="([^"]+)"/gi))
48
+ .map(m => path.basename(m[1].replace(/\\/g, '/')));
49
+ return {
50
+ path: normalized,
51
+ type: 'dotnet',
52
+ contentSummary: {
53
+ kind: 'project',
54
+ targetFramework,
55
+ packageReferences: allPackages,
56
+ projectReferences: projectRefs
57
+ }
58
+ };
59
+ }
60
+ // 3. packages.config (NuGet in legacy .NET Framework)
61
+ if (lower === 'packages.config') {
62
+ const packages = Array.from(content.matchAll(/<package\s+[^>]*id="([^"]+)"(?:\s+[^>]*version="([^"]+)")?/gi))
63
+ .map(m => m[2] ? `${m[1]}@${m[2]}` : m[1]);
64
+ return {
65
+ path: normalized,
66
+ type: 'dotnet',
67
+ contentSummary: {
68
+ kind: 'packages.config',
69
+ packageCount: packages.length,
70
+ packages
71
+ }
72
+ };
73
+ }
74
+ // 4. web.config (ASP.NET configuration)
75
+ if (lower === 'web.config') {
76
+ const connStrMatches = Array.from(content.matchAll(/<add\s+[^>]*name="([^"]+)"[^>]*connectionString="([^"]*)"/gi)).map(m => m[1]);
77
+ const authMatch = content.match(/<authentication\s+mode="([^"]+)"/i);
78
+ return {
79
+ path: normalized,
80
+ type: 'dotnet',
81
+ contentSummary: {
82
+ kind: 'web.config',
83
+ connectionStrings: connStrMatches,
84
+ authMode: authMatch ? authMatch[1] : undefined
85
+ }
86
+ };
87
+ }
88
+ // 5. Directory.Build.props / Directory.Packages.props
89
+ if (lower.includes('directory.') && lower.endsWith('.props')) {
90
+ const packages = Array.from(content.matchAll(/<PackageVersion\s+[^>]*Include="([^"]+)"/gi)).map(m => m[1]);
91
+ const tfMatch = content.match(/<TargetFramework>(.*?)<\/TargetFramework>/i) ||
92
+ content.match(/<TargetFrameworkVersion>(.*?)<\/TargetFrameworkVersion>/i);
93
+ return {
94
+ path: normalized,
95
+ type: 'dotnet',
96
+ contentSummary: {
97
+ kind: 'directory_props',
98
+ targetFramework: tfMatch ? tfMatch[1].trim() : undefined,
99
+ centralPackageVersions: packages.slice(0, 30)
100
+ }
101
+ };
102
+ }
103
+ return null;
104
+ }
105
+ canExtractSchema(filePath) {
106
+ const lower = filePath.toLowerCase();
107
+ return lower.endsWith('.cs') || lower.endsWith('.edmx');
108
+ }
109
+ extractSchemas(filePath, content) {
110
+ const schemas = [];
111
+ const normalized = filePath.replace(/\\/g, '/');
112
+ // EDMX schemas
113
+ if (normalized.endsWith('.edmx')) {
114
+ const entityTypeMatches = Array.from(content.matchAll(/<EntityType\s+Name="([^"]+)"/gi)).map(m => m[1]);
115
+ const entitySetMatches = Array.from(content.matchAll(/<EntitySet\s+Name="([^"]+)"/gi)).map(m => m[1]);
116
+ const allModels = [...new Set([...entityTypeMatches, ...entitySetMatches])];
117
+ if (allModels.length > 0) {
118
+ schemas.push({
119
+ file: normalized,
120
+ type: 'edmx',
121
+ tablesOrModels: allModels
122
+ });
123
+ }
124
+ return schemas;
125
+ }
126
+ // C# schemas (EF Core, Dapper, WCF, FluentValidation)
127
+ if (normalized.endsWith('.cs')) {
128
+ const dbContextMatches = Array.from(content.matchAll(/class\s+([\p{L}\p{N}_]+)\s*:\s*(?:[\p{L}\p{N}_]*DbContext|IdentityDbContext)\b/gu)).map(m => m[1]);
129
+ const dbSetMatches = Array.from(content.matchAll(/public\s+(?:virtual\s+)?DbSet<([\p{L}\p{N}_]+)>/gu)).map(m => m[1]);
130
+ const entityConfigMatches = Array.from(content.matchAll(/IEntityTypeConfiguration<([\p{L}\p{N}_]+)>/gu)).map(m => m[1]);
131
+ const toTableMatches = Array.from(content.matchAll(/builder\.ToTable\(\s*["']([^"']+)["']\s*\)/g)).map(m => m[1]);
132
+ const allEfModels = [...new Set([...dbSetMatches, ...entityConfigMatches, ...toTableMatches])];
133
+ if (dbContextMatches.length > 0 || allEfModels.length > 0) {
134
+ schemas.push({
135
+ file: normalized,
136
+ type: 'efcore',
137
+ tablesOrModels: allEfModels.length > 0 ? allEfModels : dbContextMatches
138
+ });
139
+ }
140
+ // Resolve in-file const string declarations for interpolated SQL strings (e.g. private const string cTableOrders = "sales.orders";)
141
+ const constMap = new Map();
142
+ const constRegex = /(?:const\s+string|string\s+const)\s+([\p{L}\p{N}_]+)\s*=\s*["']([^"']+)["']/gu;
143
+ for (const m of content.matchAll(constRegex)) {
144
+ constMap.set(m[1], m[2]);
145
+ }
146
+ // Interpolate constants inside curly braces {cTableFoo}
147
+ const expandedContent = constMap.size > 0
148
+ ? content.replace(/\{([\p{L}\p{N}_]+)\}/gu, (match, varName) => constMap.get(varName) || match)
149
+ : content;
150
+ // SQL extraction: standard SQL verbs (SELECT, INSERT, UPDATE, DELETE) and standard ADO.NET / Dapper methods
151
+ const hasSqlVerbs = /(?:SELECT[^\n"']*\bFROM|INSERT\s+INTO|UPDATE\s+|DELETE\s+FROM)\s+(?:[\p{L}\p{N}_]+\.)?[\p{L}\p{N}_]+/iu.test(expandedContent);
152
+ const hasDataServiceCalls = content.includes('ExecuteReader') ||
153
+ content.includes('ExecuteNonQuery') ||
154
+ content.includes('ExecuteScalar') ||
155
+ content.includes('Query<') ||
156
+ content.includes('QueryAsync<') ||
157
+ content.includes('QueryFirst') ||
158
+ content.includes('QuerySingle') ||
159
+ content.includes('Execute<') ||
160
+ content.includes('ExecuteAsync<');
161
+ if (hasSqlVerbs || hasDataServiceCalls) {
162
+ // Dapper and ADO.NET generic model extraction: .Query<Foo>, .QueryAsync<Foo>, etc.
163
+ const dapperModelMatches = Array.from(expandedContent.matchAll(/\.(?:Query|QueryAsync|QueryFirst|QueryFirstOrDefault|QuerySingle|QuerySingleOrDefault|Execute|ExecuteAsync)<([\p{L}\p{N}_]+)>/gu)).map(m => m[1]);
164
+ // Schema-qualified or standard table names: schema.Table, dbo.Orders, Orders
165
+ const dapperSqlMatches = Array.from(expandedContent.matchAll(/(?:SELECT[^\n"']*\bFROM|INSERT\s+INTO|UPDATE|DELETE\s+FROM)\s+((?:[\p{L}\p{N}_]+\.)?[\p{L}\p{N}_]+)/giu)).map(m => m[1].trim());
166
+ const sqlReservedWords = new Set([
167
+ 'select', 'where', 'set', 'values', 'join', 'inner', 'left', 'right', 'outer', 'on', 'group', 'order', 'by',
168
+ 'int', 'string', 'bool', 'guid', 'long', 'object', 'dynamic', 'void', 'task'
169
+ ]);
170
+ const allSqlEntities = [...new Set([...dapperModelMatches, ...dapperSqlMatches])]
171
+ .filter(name => {
172
+ const lower = name.toLowerCase();
173
+ return !sqlReservedWords.has(lower) && !sqlReservedWords.has(lower.split('.').pop() || '');
174
+ });
175
+ if (allSqlEntities.length > 0) {
176
+ const isDapper = content.includes('Query<') || content.includes('QueryAsync<') || (content.includes('Dapper') && (content.includes('Execute<') || content.includes('ExecuteAsync<')));
177
+ schemas.push({
178
+ file: normalized,
179
+ type: isDapper ? 'dapper' : 'sql',
180
+ tablesOrModels: allSqlEntities
181
+ });
182
+ }
183
+ }
184
+ // WCF DataContract models
185
+ if (content.includes('[DataContract')) {
186
+ const dataContracts = Array.from(content.matchAll(/\[DataContract(?:\([^)]*\))?\]\s*(?:\[[^\]]+\]\s*)*(?:public\s+)?(?:class|struct)\s+([\p{L}\p{N}_]+)/gu)).map(m => m[1]);
187
+ if (dataContracts.length > 0) {
188
+ schemas.push({
189
+ file: normalized,
190
+ type: 'wcf',
191
+ tablesOrModels: dataContracts
192
+ });
193
+ }
194
+ }
195
+ // FluentValidation models
196
+ if (content.includes('AbstractValidator<')) {
197
+ const valModels = Array.from(content.matchAll(/AbstractValidator<([\p{L}\p{N}_]+)>/gu)).map(m => m[1]);
198
+ if (valModels.length > 0) {
199
+ schemas.push({
200
+ file: normalized,
201
+ type: 'fluentvalidation',
202
+ tablesOrModels: valModels
203
+ });
204
+ }
205
+ }
206
+ }
207
+ return schemas;
208
+ }
209
+ canExtractRoutes(filePath) {
210
+ return filePath.endsWith('.cs');
211
+ }
212
+ extractRoutesAndCommands(filePath, content) {
213
+ const items = [];
214
+ const normalized = filePath.replace(/\\/g, '/');
215
+ // 1. Controller routes (Unicode-safe for Spanish, German, French, Chinese, etc.)
216
+ if (content.includes('Controller') || content.includes('Kontroller')) {
217
+ const controllerClassMatch = content.match(/class\s+([\p{L}\p{N}_]+?)(?:Controller|Kontroller)\s*:\s*([\p{L}\p{N}_]+)/u);
218
+ if (controllerClassMatch) {
219
+ const controllerName = controllerClassMatch[1];
220
+ const baseClass = controllerClassMatch[2];
221
+ const isAspNetCore = content.includes('Microsoft.AspNetCore') || content.includes('[ApiController]') || baseClass === 'ControllerBase';
222
+ const isWebApi = (baseClass === 'ApiController' || content.includes('System.Web.Http')) && !isAspNetCore;
223
+ const isMvc = (baseClass === 'Controller' || baseClass === 'AsyncController') && !isAspNetCore && !isWebApi;
224
+ const routePrefixMatch = content.match(/\[RoutePrefix\(\s*["']([^"']+)["']\s*\)\]/);
225
+ const routeMatch = content.match(/\[Route\(\s*["']([^"']+)["']\s*\)\]/);
226
+ let baseRoute = routePrefixMatch ? routePrefixMatch[1] : (routeMatch ? routeMatch[1] : '');
227
+ if (baseRoute) {
228
+ baseRoute = baseRoute.replace(/\[controller\]/gi, controllerName.toLowerCase());
229
+ }
230
+ if (isWebApi) {
231
+ const apiBase = baseRoute ? `/${baseRoute.replace(/^\//, '')}` : `/api/${controllerName.toLowerCase()}`;
232
+ const webApiMethodRegex = /(?:\[Http(Get|Post|Put|Delete|Patch)(?:\(\s*["']?([^"']*)["']?\s*\))?\]\s*)?(?:\[Route\(\s*["']?([^"']*)["']?\s*\)\]\s*)?(?:\[[^\]]+\]\s*)*public\s+(?!(?:class|record|interface|struct)\b)(?:async\s+)?(?:Task<)?(?:IHttpActionResult|HttpResponseMessage|[\p{L}\p{N}_<>, ]+)>?\s+([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
233
+ for (const match of content.matchAll(webApiMethodRegex)) {
234
+ if (match[0].includes('[NonAction]'))
235
+ continue;
236
+ const explicitVerb = match[1]?.toUpperCase();
237
+ const explicitSub = match[2];
238
+ const routeAttr = match[3];
239
+ const methodName = match[4];
240
+ const params = match[5]?.trim() || '';
241
+ let httpMethod = explicitVerb;
242
+ if (!httpMethod) {
243
+ if (methodName.startsWith('Get'))
244
+ httpMethod = 'GET';
245
+ else if (methodName.startsWith('Post'))
246
+ httpMethod = 'POST';
247
+ else if (methodName.startsWith('Put'))
248
+ httpMethod = 'PUT';
249
+ else if (methodName.startsWith('Delete'))
250
+ httpMethod = 'DELETE';
251
+ else if (methodName.startsWith('Patch'))
252
+ httpMethod = 'PATCH';
253
+ }
254
+ if (httpMethod) {
255
+ const subRoute = explicitSub || routeAttr ? `/${(explicitSub || routeAttr).replace(/^\//, '')}` : '';
256
+ const fullRoute = subRoute ? `${apiBase}${subRoute}` : apiBase;
257
+ items.push({
258
+ file: normalized,
259
+ framework: 'ASP.NET Web API',
260
+ method: httpMethod,
261
+ identifier: methodName,
262
+ signature: `${httpMethod} ${fullRoute} -> ${methodName}(${params})`
263
+ });
264
+ }
265
+ }
266
+ }
267
+ else if (isMvc) {
268
+ const mvcBase = baseRoute ? `/${baseRoute.replace(/^\//, '')}` : `/${controllerName.toLowerCase()}`;
269
+ const mvcActionRegex = /(?:\[Http(Get|Post|Put|Delete|Patch)(?:\(\s*["']?([^"']*)["']?\s*\))?\]\s*)?(?:\[Route\(\s*["']?([^"']*)["']?\s*\)\]\s*)?(?:\[[^\]]+\]\s*)*public\s+(?!(?:class|record|interface|struct)\b)(?:async\s+)?(?:Task<)?(?:ActionResult|ViewResult|JsonResult|PartialViewResult|ContentResult|FileResult|RedirectToRouteResult|RedirectResult|EmptyResult|[\p{L}\p{N}_<>, ]+)>?\s+([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
270
+ for (const match of content.matchAll(mvcActionRegex)) {
271
+ if (match[0].includes('[NonAction]'))
272
+ continue;
273
+ const explicitVerb = match[1]?.toUpperCase();
274
+ const explicitSub = match[2];
275
+ const routeAttr = match[3];
276
+ const methodName = match[4];
277
+ const params = match[5]?.trim() || '';
278
+ const httpMethod = explicitVerb || 'GET';
279
+ const subRoute = explicitSub || routeAttr
280
+ ? `/${(explicitSub || routeAttr).replace(/^\//, '')}`
281
+ : `/${methodName}`;
282
+ const fullRoute = (explicitSub || routeAttr)
283
+ ? (baseRoute ? `${mvcBase}${subRoute}` : subRoute)
284
+ : `${mvcBase}${subRoute}`;
285
+ items.push({
286
+ file: normalized,
287
+ framework: 'ASP.NET MVC',
288
+ method: httpMethod,
289
+ identifier: methodName,
290
+ signature: `${httpMethod} ${fullRoute} -> ${methodName}(${params})`
291
+ });
292
+ }
293
+ }
294
+ else {
295
+ // ASP.NET Core Controller
296
+ const methodRegex = /\[Http(Get|Post|Put|Delete|Patch)(?:\(\s*["']?([^"']*)["']?\s*\))?\]\s*(?:\[[^\]]+\]\s*)*(?:public\s+)?(?!(?:class|record|interface|struct)\b)(?:async\s+)?(?:Task<)?(?:IActionResult|ActionResult|[\p{L}\p{N}_<>, ]+)>?\s+([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
297
+ const actionMatches = Array.from(content.matchAll(methodRegex));
298
+ for (const match of actionMatches) {
299
+ const httpMethod = match[1].toUpperCase();
300
+ const rawSubRoute = match[2] ? `/${match[2].replace(/^\//, '')}` : '';
301
+ const methodName = match[3];
302
+ const params = match[4].trim();
303
+ const subRoute = rawSubRoute
304
+ .replace(/\[controller\]/gi, controllerName.toLowerCase())
305
+ .replace(/\[action\]/gi, methodName.toLowerCase());
306
+ const resolvedBase = baseRoute
307
+ .replace(/\[controller\]/gi, controllerName.toLowerCase())
308
+ .replace(/\[action\]/gi, methodName.toLowerCase());
309
+ const fullRoute = resolvedBase ? `/${resolvedBase.replace(/^\//, '')}${subRoute}` : (subRoute || '/');
310
+ const publishedEvents = [];
311
+ const pubRegex = /\b(?:Publish|Send)\s*(?:<([\p{L}\p{N}_]+)>|\(\s*new\s+([\p{L}\p{N}_]+))/gu;
312
+ for (const pm of content.matchAll(pubRegex)) {
313
+ const evt = pm[1] || pm[2];
314
+ if (evt && !publishedEvents.includes(evt) && !['Task', 'IActionResult', 'ActionResult', 'bool', 'int', 'string'].includes(evt)) {
315
+ publishedEvents.push(evt);
316
+ }
317
+ }
318
+ const pubSuffix = publishedEvents.length > 0 ? ` [publishes: ${publishedEvents.join(', ')}]` : '';
319
+ items.push({
320
+ file: normalized,
321
+ framework: 'ASP.NET Core/Controller',
322
+ method: httpMethod,
323
+ identifier: methodName,
324
+ signature: `${httpMethod} ${fullRoute} -> ${methodName}(${params})${pubSuffix}`
325
+ });
326
+ }
327
+ }
328
+ }
329
+ }
330
+ // 2. Minimal APIs: app.MapGet("/users", ...)
331
+ const minimalApiRegex = /(?:app|endpoints|routes|group)\.(MapGet|MapPost|MapPut|MapDelete|MapPatch)\s*\(\s*["']([^"']+)["']/g;
332
+ const minimalMatches = Array.from(content.matchAll(minimalApiRegex));
333
+ for (const match of minimalMatches) {
334
+ const httpMethod = match[1].replace('Map', '').toUpperCase();
335
+ const routePath = match[2];
336
+ items.push({
337
+ file: normalized,
338
+ framework: 'ASP.NET Core/MinimalAPI',
339
+ method: httpMethod,
340
+ identifier: routePath,
341
+ signature: `${httpMethod} ${routePath}`
342
+ });
343
+ }
344
+ // 3. MediatR Request Handlers & Notifications
345
+ const mediatrReqRegex = /public\s+(?:record|class)\s+([\p{L}\p{N}_]+)\s*(?:\([^)]*\))?\s*:\s*(?:[^{]*\b)?IRequest(?:<([^>]+)>)?/gu;
346
+ for (const match of content.matchAll(mediatrReqRegex)) {
347
+ const commandName = match[1];
348
+ const returnType = match[2] ? match[2].trim() : 'void';
349
+ items.push({
350
+ file: normalized,
351
+ framework: 'MediatR',
352
+ identifier: commandName,
353
+ signature: `${commandName} : IRequest<${returnType}>`
354
+ });
355
+ }
356
+ const mediatrNotifRegex = /public\s+(?:record|class)\s+([\p{L}\p{N}_]+)\s*(?:\([^)]*\))?\s*:\s*(?:[^{]*\b)?INotification\b/gu;
357
+ for (const match of content.matchAll(mediatrNotifRegex)) {
358
+ const eventName = match[1];
359
+ items.push({
360
+ file: normalized,
361
+ framework: 'MediatR',
362
+ identifier: eventName,
363
+ signature: `${eventName} : INotification`
364
+ });
365
+ }
366
+ // 4. MassTransit Consumers: public class OrderConsumer : IConsumer<SubmitOrder>
367
+ const massTransitRegex = /public\s+(?:abstract\s+)?class\s+([\p{L}\p{N}_]+)\s*:\s*(?:[^{]*\b)?IConsumer<([^>]+)>/gu;
368
+ for (const match of content.matchAll(massTransitRegex)) {
369
+ const consumerName = match[1];
370
+ const messageType = match[2].trim();
371
+ items.push({
372
+ file: normalized,
373
+ framework: 'MassTransit',
374
+ identifier: consumerName,
375
+ signature: `${consumerName} : IConsumer<${messageType}>`
376
+ });
377
+ }
378
+ // 5. NServiceBus Message Handlers: public class OrderHandler : IHandleMessages<ProcessOrder>
379
+ const nserviceBusRegex = /public\s+(?:abstract\s+)?class\s+([\p{L}\p{N}_]+)\s*:\s*(?:[^{]*\b)?IHandleMessages<([^>]+)>/gu;
380
+ for (const match of content.matchAll(nserviceBusRegex)) {
381
+ const handlerName = match[1];
382
+ const messageType = match[2].trim();
383
+ items.push({
384
+ file: normalized,
385
+ framework: 'NServiceBus',
386
+ identifier: handlerName,
387
+ signature: `${handlerName} : IHandleMessages<${messageType}>`
388
+ });
389
+ }
390
+ // 6. Wolverine Message Handlers: public class OrderHandler { public void Handle(CreateOrder cmd) }
391
+ // Requires an actual Wolverine marker in the file (using Wolverine, [WolverineHandler], IMessageBus)
392
+ const hasWolverineMarker = content.includes('using Wolverine') ||
393
+ content.includes('[WolverineHandler]') ||
394
+ content.includes('IMessageBus') ||
395
+ content.includes('Wolverine.') ||
396
+ content.includes('WolverineFx') ||
397
+ content.includes('Wolverine');
398
+ if (hasWolverineMarker) {
399
+ const wolverineRegex = /public\s+(?:static\s+)?(?:async\s+)?(?:Task(?:<[^>]+>)?|void)\s+([\p{L}\p{N}_]+)\s*\(\s*([\p{L}\p{N}_]+)\s+([\p{L}\p{N}_]+)/gu;
400
+ for (const match of content.matchAll(wolverineRegex)) {
401
+ const action = match[1];
402
+ const messageType = match[2];
403
+ const paramName = match[3];
404
+ if (content.includes(`IHandleMessages<${messageType}>`) || content.includes(`IConsumer<${messageType}>`)) {
405
+ continue;
406
+ }
407
+ // Only conventional handler methods (Handle, Handles, Consume, Consumes) or explicit [WolverineHandler]
408
+ const isConventionalMethod = /^(?:Handle|Handles|Consume|Consumes)$/.test(action) || content.includes('[WolverineHandler]');
409
+ if (!isConventionalMethod) {
410
+ continue;
411
+ }
412
+ if (!['Exception', 'HttpContext', 'CancellationToken', 'string', 'int', 'object', 'IServiceProvider'].includes(messageType)) {
413
+ items.push({
414
+ file: normalized,
415
+ framework: 'Wolverine',
416
+ identifier: `${action}(${messageType})`,
417
+ signature: `${action}(${messageType} ${paramName})`
418
+ });
419
+ }
420
+ }
421
+ }
422
+ // 7. gRPC C# Service Implementations: public class GreeterService : Greeter.GreeterBase
423
+ if (content.includes('GrpcBase') || content.includes('ServerCallContext')) {
424
+ const grpcServiceMatch = content.match(/public\s+class\s+(\w+)\s*:\s*(?:[A-Za-z0-9_.]+\.)?([A-Za-z0-9_]+Base)\b/);
425
+ if (grpcServiceMatch) {
426
+ const className = grpcServiceMatch[1];
427
+ const methodRegex = /public\s+override\s+(?:async\s+)?Task<([A-Za-z0-9_]+)>\s+(\w+)\s*\(\s*([A-Za-z0-9_]+)\s+request,\s*ServerCallContext\s+context\s*\)/g;
428
+ for (const m of content.matchAll(methodRegex)) {
429
+ const returnType = m[1];
430
+ const methodName = m[2];
431
+ const requestType = m[3];
432
+ items.push({
433
+ file: normalized,
434
+ framework: 'gRPC/.NET',
435
+ method: 'RPC',
436
+ identifier: methodName,
437
+ signature: `rpc ${className}.${methodName}(${requestType}) : Task<${returnType}>`
438
+ });
439
+ }
440
+ }
441
+ }
442
+ // 8. FluentValidation: public class CreateInvoiceValidator : AbstractValidator<CreateInvoiceCommand>
443
+ if (content.includes('AbstractValidator<')) {
444
+ const validatorRegex = /public\s+(?:abstract\s+)?class\s+([\p{L}\p{N}_]+)\s*:\s*(?:[^{]*\b)?AbstractValidator<([\p{L}\p{N}_]+)>/gu;
445
+ for (const match of content.matchAll(validatorRegex)) {
446
+ const validatorName = match[1];
447
+ const targetModel = match[2];
448
+ const ruleMatches = Array.from(content.matchAll(/RuleFor\s*\(\s*[^)]+\)\s*\.([\p{L}\p{N}_().<>]+)/gu)).map(m => m[1]);
449
+ const ruleSummary = ruleMatches.slice(0, 5).join(', ');
450
+ items.push({
451
+ file: normalized,
452
+ framework: 'FluentValidation',
453
+ identifier: validatorName,
454
+ signature: `${validatorName} : AbstractValidator<${targetModel}>${ruleSummary ? ` [${ruleSummary}]` : ''}`
455
+ });
456
+ }
457
+ }
458
+ // 9. Azure Functions Triggers: [FunctionName("...")] or [Function("...")]
459
+ if (content.includes('[FunctionName(') || content.includes('[Function(')) {
460
+ const funcRegex = /\[Function(?:Name)?\(\s*["']([^"']+)["']\s*\)\]\s*(?:\[[^\]]+\]\s*)*public\s+(?:static\s+)?(?:async\s+)?(?:Task(?:<[^>]+>)?|void|IActionResult|[\p{L}\p{N}_]+)\s+([\p{L}\p{N}_]+)\s*\(([^)]*)\)/gu;
461
+ for (const match of content.matchAll(funcRegex)) {
462
+ const functionName = match[1];
463
+ const methodName = match[2];
464
+ const params = match[3];
465
+ let triggerType = 'Function';
466
+ let triggerDetail = functionName;
467
+ let method = 'TRIGGER';
468
+ if (params.includes('HttpTrigger')) {
469
+ triggerType = 'HttpTrigger';
470
+ const verbMatch = params.match(/HttpTrigger\([^)]*?["'](GET|POST|PUT|DELETE|PATCH)["']/i);
471
+ const routeMatch = params.match(/Route\s*=\s*["']([^"']+)["']/i);
472
+ const httpVerb = verbMatch ? verbMatch[1].toUpperCase() : 'HTTP';
473
+ method = httpVerb;
474
+ const route = routeMatch ? `/${routeMatch[1].replace(/^\//, '')}` : `/${functionName.toLowerCase()}`;
475
+ triggerDetail = `${httpVerb} ${route}`;
476
+ }
477
+ else if (params.includes('ServiceBusTrigger')) {
478
+ triggerType = 'ServiceBusTrigger';
479
+ const sbMatch = params.match(/\[ServiceBusTrigger\(\s*["']([^"']+)["']/);
480
+ if (sbMatch)
481
+ triggerDetail = `ServiceBus:${sbMatch[1]}`;
482
+ }
483
+ else if (params.includes('QueueTrigger')) {
484
+ triggerType = 'QueueTrigger';
485
+ const qMatch = params.match(/\[QueueTrigger\(\s*["']([^"']+)["']/);
486
+ if (qMatch)
487
+ triggerDetail = `Queue:${qMatch[1]}`;
488
+ }
489
+ else if (params.includes('BlobTrigger')) {
490
+ triggerType = 'BlobTrigger';
491
+ const bMatch = params.match(/\[BlobTrigger\(\s*["']([^"']+)["']/);
492
+ if (bMatch)
493
+ triggerDetail = `Blob:${bMatch[1]}`;
494
+ }
495
+ else if (params.includes('CosmosDBTrigger')) {
496
+ triggerType = 'CosmosDBTrigger';
497
+ const cMatch = params.match(/\[CosmosDBTrigger\(\s*["']([^"']+)["']/);
498
+ if (cMatch)
499
+ triggerDetail = `CosmosDB:${cMatch[1]}`;
500
+ }
501
+ else if (params.includes('TimerTrigger')) {
502
+ triggerType = 'TimerTrigger';
503
+ const tMatch = params.match(/\[TimerTrigger\(\s*["']([^"']+)["']/);
504
+ if (tMatch)
505
+ triggerDetail = `Timer:${tMatch[1]}`;
506
+ }
507
+ items.push({
508
+ file: normalized,
509
+ framework: 'AzureFunctions',
510
+ method,
511
+ identifier: functionName,
512
+ signature: `${triggerType} ${triggerDetail} -> ${methodName}`
513
+ });
514
+ }
515
+ }
516
+ // 10. WCF Service Contracts: [ServiceContract] interface IService { [OperationContract] ... }
517
+ if (content.includes('[ServiceContract')) {
518
+ const serviceContractRegex = /\[ServiceContract(?:\([^)]*\))?\]\s*(?:\[[^\]]+\]\s*)*(?:public\s+)?interface\s+([\p{L}\p{N}_]+)/gu;
519
+ for (const match of content.matchAll(serviceContractRegex)) {
520
+ const interfaceName = match[1];
521
+ const operationRegex = /\[OperationContract(?:\([^)]*\))?\]\s*(?:\[[^\]]+\]\s*)*(?:[^\n;]+)\s+([\p{L}\p{N}_]+)\s*\(([^)]*)\);/gu;
522
+ for (const opMatch of content.matchAll(operationRegex)) {
523
+ const opName = opMatch[1];
524
+ const opParams = opMatch[2].trim();
525
+ items.push({
526
+ file: normalized,
527
+ framework: 'WCF',
528
+ method: 'RPC',
529
+ identifier: `${interfaceName}.${opName}`,
530
+ signature: `WCF ${interfaceName}.${opName}(${opParams})`
531
+ });
532
+ }
533
+ }
534
+ }
535
+ // 11. .NET HTTP Client calls: _httpClient.GetAsync(...), etc.
536
+ const dotnetHttpRegex = /(?:\b(?:_httpClient|_client|httpClient|client|http))\s*\.\s*(GetAsync|PostAsync|PutAsync|DeleteAsync|PatchAsync|GetStringAsync|GetFromJsonAsync|PostAsJsonAsync|PutAsJsonAsync|SendAsync)\s*(?:<[^>]+>)?\s*\(\s*[\$]?["']([^"']+)["']/gu;
537
+ for (const match of content.matchAll(dotnetHttpRegex)) {
538
+ const rawMethod = match[1];
539
+ let verb = 'GET';
540
+ if (rawMethod.startsWith('Post'))
541
+ verb = 'POST';
542
+ else if (rawMethod.startsWith('Put'))
543
+ verb = 'PUT';
544
+ else if (rawMethod.startsWith('Delete'))
545
+ verb = 'DELETE';
546
+ else if (rawMethod.startsWith('Patch'))
547
+ verb = 'PATCH';
548
+ else if (rawMethod === 'SendAsync')
549
+ verb = 'ANY';
550
+ const cleanPath = cleanClientUrl(match[2]);
551
+ if (cleanPath) {
552
+ items.push({
553
+ file: normalized,
554
+ framework: 'HttpClient',
555
+ method: verb,
556
+ identifier: cleanPath,
557
+ signature: `${verb} ${cleanPath} [HTTP Client]`
558
+ });
559
+ }
560
+ }
561
+ // 12. .NET gRPC Client calls: _client.CreateInvoiceAsync(...)
562
+ const dotnetGrpcRegex = /(?:\b(?:_client|_grpcClient|grpcClient|stub|invoiceClient|userClient|orderClient|[A-Za-z0-9_]+Client))\s*\.\s*([A-Za-z0-9_]+?)(?:Async)?\s*\(/gu;
563
+ for (const match of content.matchAll(dotnetGrpcRegex)) {
564
+ const method = match[1];
565
+ if (!['Get', 'Post', 'Put', 'Delete', 'Patch', 'GetString', 'GetFromJson', 'PostAsJson', 'PutAsJson', 'Send', 'ToString', 'Dispose', 'Equals', 'GetHashCode', 'GetType', 'Wait'].includes(method)) {
566
+ if (/^[A-Z]/.test(method) && (content.includes('Grpc') || content.includes('Proto') || content.includes('Client'))) {
567
+ items.push({
568
+ file: normalized,
569
+ framework: 'GrpcClient',
570
+ method: 'RPC',
571
+ identifier: method,
572
+ signature: `rpc client: ${method}`
573
+ });
574
+ }
575
+ }
576
+ }
577
+ return items;
578
+ }
579
+ }
@@ -0,0 +1,11 @@
1
+ import type { CodebaseExtractor } from './base.js';
2
+ import type { ManifestSummary, SchemaSummary, RouteOrSignature } from '../types.js';
3
+ export declare class GolangExtractor implements CodebaseExtractor {
4
+ readonly name = "golang";
5
+ canExtractManifest(filePath: string): boolean;
6
+ extractManifest(filePath: string, content: string): ManifestSummary | null;
7
+ canExtractSchema(filePath: string): boolean;
8
+ extractSchemas(filePath: string, content: string): SchemaSummary[];
9
+ canExtractRoutes(filePath: string): boolean;
10
+ extractRoutesAndCommands(filePath: string, content: string): RouteOrSignature[];
11
+ }
@@ -0,0 +1,73 @@
1
+ import path from 'node:path';
2
+ export class GolangExtractor {
3
+ name = 'golang';
4
+ canExtractManifest(filePath) {
5
+ return path.basename(filePath).toLowerCase() === 'go.mod';
6
+ }
7
+ extractManifest(filePath, content) {
8
+ const normalized = filePath.replace(/\\/g, '/');
9
+ const deps = [];
10
+ const lines = content.split('\n');
11
+ let inRequire = false;
12
+ for (const line of lines) {
13
+ const trimmed = line.trim();
14
+ if (trimmed === 'require (' || trimmed === 'require(') {
15
+ inRequire = true;
16
+ continue;
17
+ }
18
+ if (inRequire && trimmed === ')') {
19
+ inRequire = false;
20
+ continue;
21
+ }
22
+ if (inRequire && trimmed && !trimmed.startsWith('//')) {
23
+ const dep = trimmed.split(/\s+/)[0];
24
+ if (dep)
25
+ deps.push(dep);
26
+ }
27
+ else if (trimmed.startsWith('require ') && !trimmed.includes('(')) {
28
+ const dep = trimmed.replace('require', '').trim().split(/\s+/)[0];
29
+ if (dep)
30
+ deps.push(dep);
31
+ }
32
+ }
33
+ return {
34
+ path: normalized,
35
+ type: 'go',
36
+ contentSummary: {
37
+ dependencies: deps.slice(0, 30)
38
+ }
39
+ };
40
+ }
41
+ canExtractSchema(filePath) {
42
+ return filePath.endsWith('.go');
43
+ }
44
+ extractSchemas(filePath, content) {
45
+ const schemas = [];
46
+ const normalized = filePath.replace(/\\/g, '/');
47
+ if (content.includes('gorm.Model') || content.includes('gorm:"') || normalized.includes('models/')) {
48
+ const structs = Array.from(content.matchAll(/type\s+([A-Z]\w*)\s+struct\b/g)).map(m => m[1]);
49
+ if (structs.length > 0) {
50
+ schemas.push({ file: normalized, type: 'gorm', tablesOrModels: [...new Set(structs)] });
51
+ }
52
+ }
53
+ return schemas;
54
+ }
55
+ canExtractRoutes(filePath) {
56
+ return filePath.endsWith('.go');
57
+ }
58
+ extractRoutesAndCommands(filePath, content) {
59
+ const items = [];
60
+ const normalized = filePath.replace(/\\/g, '/');
61
+ const goRouteMatches = Array.from(content.matchAll(/(?:r|router|api|v1|v2|app|e|group|server|mux)\.(GET|POST|PUT|DELETE|PATCH|Handle|HandleFunc)\s*\(\s*["']([^"']+)["']/g));
62
+ for (const match of goRouteMatches) {
63
+ items.push({
64
+ file: normalized,
65
+ framework: 'Go/HTTP',
66
+ method: match[1].toUpperCase(),
67
+ identifier: match[2],
68
+ signature: `${match[1].toUpperCase()} ${match[2]}`
69
+ });
70
+ }
71
+ return items;
72
+ }
73
+ }