neuroplex 0.2.0 → 0.4.0

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 (64) hide show
  1. package/dist/brain/build.d.ts +4 -0
  2. package/dist/brain/build.js +16 -4
  3. package/dist/brain/build.js.map +1 -1
  4. package/dist/brain/local.d.ts +2 -0
  5. package/dist/brain/local.js.map +1 -1
  6. package/dist/brain/obsidian.d.ts +26 -0
  7. package/dist/brain/obsidian.js +411 -0
  8. package/dist/brain/obsidian.js.map +1 -0
  9. package/dist/cli/index.js +144 -23
  10. package/dist/cli/index.js.map +1 -1
  11. package/dist/config/config.d.ts +21 -0
  12. package/dist/config/config.js +52 -1
  13. package/dist/config/config.js.map +1 -1
  14. package/dist/config/edit.d.ts +1 -1
  15. package/dist/config/edit.js +1 -0
  16. package/dist/config/edit.js.map +1 -1
  17. package/dist/enrich/index.js +7 -2
  18. package/dist/enrich/index.js.map +1 -1
  19. package/dist/enrich/tasks.d.ts +6 -0
  20. package/dist/enrich/tasks.js +7 -1
  21. package/dist/enrich/tasks.js.map +1 -1
  22. package/dist/graph/schema.d.ts +2 -1
  23. package/dist/graph/schema.js +1 -0
  24. package/dist/graph/schema.js.map +1 -1
  25. package/dist/mcp/http.d.ts +33 -0
  26. package/dist/mcp/http.js +171 -0
  27. package/dist/mcp/http.js.map +1 -0
  28. package/dist/mcp/server.d.ts +24 -3
  29. package/dist/mcp/server.js +47 -27
  30. package/dist/mcp/server.js.map +1 -1
  31. package/dist/query/cli.d.ts +19 -0
  32. package/dist/query/cli.js +119 -0
  33. package/dist/query/cli.js.map +1 -0
  34. package/dist/query/queries.js +3 -3
  35. package/dist/query/queries.js.map +1 -1
  36. package/dist/scan/assemble.d.ts +15 -0
  37. package/dist/scan/assemble.js +240 -15
  38. package/dist/scan/assemble.js.map +1 -1
  39. package/dist/scan/discover.js +8 -0
  40. package/dist/scan/discover.js.map +1 -1
  41. package/dist/scan/extract.js +8 -1
  42. package/dist/scan/extract.js.map +1 -1
  43. package/dist/scan/extractors/csharp.d.ts +4 -0
  44. package/dist/scan/extractors/csharp.js +565 -0
  45. package/dist/scan/extractors/csharp.js.map +1 -0
  46. package/dist/scan/extractors/python.js +170 -15
  47. package/dist/scan/extractors/python.js.map +1 -1
  48. package/dist/scan/extractors/typescript.js +405 -23
  49. package/dist/scan/extractors/typescript.js.map +1 -1
  50. package/dist/scan/parser.js +1 -0
  51. package/dist/scan/parser.js.map +1 -1
  52. package/dist/scan/repos.d.ts +38 -0
  53. package/dist/scan/repos.js +155 -0
  54. package/dist/scan/repos.js.map +1 -0
  55. package/dist/scan/scan.d.ts +15 -0
  56. package/dist/scan/scan.js +26 -16
  57. package/dist/scan/scan.js.map +1 -1
  58. package/dist/scan/types.d.ts +36 -1
  59. package/dist/scan/types.js +2 -1
  60. package/dist/scan/types.js.map +1 -1
  61. package/dist/sync/sync.js +37 -16
  62. package/dist/sync/sync.js.map +1 -1
  63. package/package.json +1 -1
  64. package/skills/neuroplex/SKILL.md +15 -2
@@ -17,6 +17,7 @@ const EXTENSIONS = {
17
17
  '.jsx': 'javascript',
18
18
  '.py': 'python',
19
19
  '.pyi': 'python',
20
+ '.cs': 'csharp',
20
21
  '.md': 'markdown',
21
22
  '.mdx': 'markdown',
22
23
  };
@@ -25,6 +26,8 @@ const LANGUAGE_GROUPS = {
25
26
  typescript: ['typescript', 'tsx'],
26
27
  javascript: ['javascript'],
27
28
  python: ['python'],
29
+ csharp: ['csharp'],
30
+ 'c#': ['csharp'],
28
31
  markdown: ['markdown'],
29
32
  };
30
33
  /** Always skipped, even outside git or when not git-ignored. */
@@ -32,6 +35,11 @@ const ALWAYS_EXCLUDE = [
32
35
  '**/node_modules/**',
33
36
  '**/.git/**',
34
37
  '**/.neuroplex/**',
38
+ // Assistant/editor tooling (e.g. the Neuroplex skills installed into .claude/skills) is not project content.
39
+ '**/.claude/**',
40
+ '**/.cursor/**',
41
+ '**/.vscode/**',
42
+ '**/.idea/**',
35
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,EAAE,CAAC,CAAC;QAC5E,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC1D,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;oBAAE,SAAS;gBAC9F,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { extractCSharp } from './extractors/csharp.js';
1
2
  import { extractPython } from './extractors/python.js';
2
3
  import { extractTypeScript } from './extractors/typescript.js';
3
4
  import { withTree } from './parser.js';
@@ -6,6 +7,12 @@ import { emptyExtraction } from './types.js';
6
7
  export async function extractSource(source, lang) {
7
8
  if (lang === 'markdown')
8
9
  return emptyExtraction(); // documents are file nodes only
9
- return withTree(source, lang, (root) => lang === 'python' ? extractPython(root) : extractTypeScript(root, lang));
10
+ return withTree(source, lang, (root) => {
11
+ if (lang === 'python')
12
+ return extractPython(root);
13
+ if (lang === 'csharp')
14
+ return extractCSharp(root);
15
+ return extractTypeScript(root, lang);
16
+ });
10
17
  }
11
18
  //# sourceMappingURL=extract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/scan/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAwC,MAAM,YAAY,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,IAAgB;IAClE,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,eAAe,EAAE,CAAC,CAAC,gCAAgC;IACnF,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CACrC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CACxE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/scan/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAwC,MAAM,YAAY,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,IAAgB;IAClE,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,eAAe,EAAE,CAAC,CAAC,gCAAgC;IACnF,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;QACrC,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type SyntaxNode } from '../parser.js';
2
+ import { type FileExtraction } from '../types.js';
3
+ /** Extracts symbols, imports, calls, heritage and HTTP routes from a C# tree. */
4
+ export declare function extractCSharp(root: SyntaxNode): FileExtraction;
@@ -0,0 +1,565 @@
1
+ import { lineRange, namedChildren } from '../parser.js';
2
+ import { emptyExtraction } from '../types.js';
3
+ const TYPE_KINDS = new Map([
4
+ ['class_declaration', 'class'],
5
+ ['record_declaration', 'class'],
6
+ ['struct_declaration', 'class'],
7
+ ['interface_declaration', 'interface'],
8
+ ['enum_declaration', 'type'],
9
+ ]);
10
+ /** Members whose parameters and locals form one variable scope; their calls go to the type. */
11
+ const MEMBER_SCOPES = new Set([
12
+ 'constructor_declaration',
13
+ 'destructor_declaration',
14
+ 'property_declaration',
15
+ 'indexer_declaration',
16
+ 'operator_declaration',
17
+ 'conversion_operator_declaration',
18
+ 'event_declaration',
19
+ ]);
20
+ const VERB_ATTRIBUTES = new Map([
21
+ ['HttpGet', 'GET'],
22
+ ['HttpPost', 'POST'],
23
+ ['HttpPut', 'PUT'],
24
+ ['HttpPatch', 'PATCH'],
25
+ ['HttpDelete', 'DELETE'],
26
+ ['HttpHead', 'HEAD'],
27
+ ['HttpOptions', 'OPTIONS'],
28
+ ]);
29
+ const MINIMAL_API = new Map([
30
+ ['MapGet', 'GET'],
31
+ ['MapPost', 'POST'],
32
+ ['MapPut', 'PUT'],
33
+ ['MapPatch', 'PATCH'],
34
+ ['MapDelete', 'DELETE'],
35
+ ['MapMethods', 'ANY'],
36
+ ]);
37
+ const CLIENT_METHODS = new Map([
38
+ ['GetAsync', 'GET'],
39
+ ['GetFromJsonAsync', 'GET'],
40
+ ['GetStringAsync', 'GET'],
41
+ ['GetStreamAsync', 'GET'],
42
+ ['GetByteArrayAsync', 'GET'],
43
+ ['PostAsync', 'POST'],
44
+ ['PostAsJsonAsync', 'POST'],
45
+ ['PutAsync', 'PUT'],
46
+ ['PutAsJsonAsync', 'PUT'],
47
+ ['PatchAsync', 'PATCH'],
48
+ ['PatchAsJsonAsync', 'PATCH'],
49
+ ['DeleteAsync', 'DELETE'],
50
+ ['DeleteFromJsonAsync', 'DELETE'],
51
+ ]);
52
+ const HANDLER_TYPES = new Set(['lambda_expression', 'anonymous_method_expression', 'identifier', 'member_access_expression']);
53
+ const STRING_TYPES = new Set([
54
+ 'string_literal',
55
+ 'verbatim_string_literal',
56
+ 'raw_string_literal',
57
+ 'interpolated_string_expression',
58
+ ]);
59
+ /** Parents that continue a method chain (`app.MapGet(...).WithName(...)`, `await x.Y()`). */
60
+ const CHAIN_PARENTS = new Set([
61
+ 'invocation_expression',
62
+ 'member_access_expression',
63
+ 'await_expression',
64
+ 'parenthesized_expression',
65
+ ]);
66
+ const INTERFACE_NAME = /^I[A-Z]/;
67
+ /** Extracts symbols, imports, calls, heritage and HTTP routes from a C# tree. */
68
+ export function extractCSharp(root) {
69
+ return new CSharpExtractor().run(root);
70
+ }
71
+ class CSharpExtractor {
72
+ out = emptyExtraction();
73
+ names = new Set();
74
+ seenCalls = new Set();
75
+ /** `var api = app.MapGroup("/api")` → `api` → `/api`. */
76
+ groups = new Map();
77
+ run(root) {
78
+ this.walk(root, {
79
+ owner: undefined,
80
+ type: undefined,
81
+ typeExported: false,
82
+ inInterface: false,
83
+ controller: undefined,
84
+ scopes: [],
85
+ });
86
+ return this.out;
87
+ }
88
+ walk(node, ctx) {
89
+ switch (node.type) {
90
+ case 'ERROR':
91
+ case 'attribute_list':
92
+ return;
93
+ case 'using_directive':
94
+ this.addUsing(node);
95
+ return;
96
+ case 'method_declaration':
97
+ this.visitMethod(node, ctx);
98
+ return;
99
+ case 'invocation_expression':
100
+ this.visitInvocation(node, ctx);
101
+ return;
102
+ case 'object_creation_expression':
103
+ this.visitCreation(node, ctx);
104
+ break;
105
+ case 'variable_declarator':
106
+ this.trackGroup(node);
107
+ break;
108
+ default:
109
+ if (TYPE_KINDS.has(node.type)) {
110
+ this.visitType(node, ctx);
111
+ return;
112
+ }
113
+ if (MEMBER_SCOPES.has(node.type))
114
+ ctx = withScope(ctx, memberScope(node));
115
+ }
116
+ this.walkChildren(node, ctx);
117
+ }
118
+ walkChildren(node, ctx) {
119
+ for (const child of namedChildren(node))
120
+ this.walk(child, ctx);
121
+ }
122
+ // ---- symbols ----
123
+ visitType(node, ctx) {
124
+ const id = node.childForFieldName('name')?.text;
125
+ const kind = TYPE_KINDS.get(node.type);
126
+ if (!id || !kind) {
127
+ this.walkChildren(node, ctx);
128
+ return;
129
+ }
130
+ const name = ctx.type ? `${ctx.type}.${id}` : id;
131
+ // Top-level types default to `internal`; nested ones to `private` (public inside interfaces).
132
+ const exported = ctx.type
133
+ ? ctx.typeExported && isAccessible(node, ctx.inInterface)
134
+ : isAccessible(node, true);
135
+ this.addSymbol(name, kind, node, exported);
136
+ this.addHeritage(name, node);
137
+ const prefix = attributes(node).find((a) => a.name === 'Route' || a.name === 'RoutePrefix')?.template;
138
+ this.walkChildren(node, {
139
+ owner: name,
140
+ type: name,
141
+ typeExported: exported,
142
+ inInterface: node.type === 'interface_declaration',
143
+ controller: { name: id.replace(/Controller$/, ''), prefix: prefix ?? '' },
144
+ scopes: [{ member: false, types: typeScope(node) }, ...ctx.scopes],
145
+ });
146
+ }
147
+ visitMethod(node, ctx) {
148
+ const id = node.childForFieldName('name')?.text;
149
+ if (!id || !ctx.type) {
150
+ this.walkChildren(node, ctx);
151
+ return;
152
+ }
153
+ const name = `${ctx.type}.${id}`;
154
+ const exported = ctx.typeExported && isAccessible(node, ctx.inInterface);
155
+ const http = ctx.controller ? actionRoute(node, id, ctx.controller) : undefined;
156
+ this.addSymbol(name, http ? 'route' : 'method', node, exported, http);
157
+ this.walkChildren(node, { ...withScope(ctx, memberScope(node)), owner: name });
158
+ }
159
+ addSymbol(name, kind, node, exported, http) {
160
+ if (this.names.has(name))
161
+ return;
162
+ this.names.add(name);
163
+ this.out.symbols.push({ name, kind, range: lineRange(node), exported, ...(http ? { http } : {}) });
164
+ }
165
+ /** `name`, or `name (2)`, `name (3)`... when already taken in this file. */
166
+ uniqueName(name) {
167
+ if (!this.names.has(name))
168
+ return name;
169
+ let n = 2;
170
+ while (this.names.has(`${name} (${n})`))
171
+ n++;
172
+ return `${name} (${n})`;
173
+ }
174
+ // ---- imports ----
175
+ addUsing(node) {
176
+ if (node.childForFieldName('name'))
177
+ return; // `using A = B;` aliases
178
+ const target = namedChildren(node).find((c) => c.type === 'qualified_name' || c.type === 'identifier');
179
+ if (target)
180
+ this.out.imports.push({ specifier: target.text, bindings: [], line: line(node) });
181
+ }
182
+ // ---- calls, minimal APIs and requests ----
183
+ visitInvocation(node, ctx) {
184
+ const fn = node.childForFieldName('function');
185
+ const target = fn ? callTarget(fn) : undefined;
186
+ if (target && ctx.owner)
187
+ this.addCall(ctx, target, node);
188
+ // Any receiver counts for client calls (`_factory.CreateClient().GetAsync(...)`).
189
+ const member = fn ? memberName(fn) : undefined;
190
+ const method = member ? CLIENT_METHODS.get(member) : undefined;
191
+ const url = method ? firstStringArg(node) : undefined;
192
+ if (method && url !== undefined)
193
+ this.addRequest(ctx, method, url, node);
194
+ const handler = this.addMinimalRoute(node, fn, member);
195
+ for (const child of namedChildren(node)) {
196
+ if (child.type !== 'argument_list') {
197
+ this.walk(child, ctx);
198
+ continue;
199
+ }
200
+ for (const arg of namedChildren(child)) {
201
+ const value = argValue(arg);
202
+ if (handler && value?.id === handler.node.id) {
203
+ this.walk(value, { ...withScope(ctx, memberScope(value)), owner: handler.name });
204
+ }
205
+ else {
206
+ this.walk(arg, ctx);
207
+ }
208
+ }
209
+ }
210
+ }
211
+ visitCreation(node, ctx) {
212
+ const type = node.childForFieldName('type');
213
+ const callee = type ? typeName(type) : undefined;
214
+ if (!callee || !ctx.owner)
215
+ return;
216
+ this.addCall(ctx, { callee }, node);
217
+ if (callee !== 'HttpRequestMessage')
218
+ return;
219
+ // `new HttpRequestMessage(HttpMethod.Post, "url")`
220
+ const [methodArg, urlArg] = callArgs(node);
221
+ const url = urlArg ? stringValue(urlArg) : undefined;
222
+ if (url !== undefined)
223
+ this.addRequest(ctx, methodArg ? requestMethod(methodArg) : 'GET', url, node);
224
+ }
225
+ addCall(ctx, target, node) {
226
+ const caller = ctx.owner;
227
+ if (!caller)
228
+ return;
229
+ const key = `${caller}\0${target.callee}\0${target.object ?? ''}`;
230
+ if (this.seenCalls.has(key))
231
+ return;
232
+ this.seenCalls.add(key);
233
+ const objectType = target.object !== undefined && target.object !== 'this'
234
+ ? lookupType(ctx.scopes, target.object, target.viaThis === true)
235
+ : undefined;
236
+ this.out.calls.push({
237
+ caller,
238
+ callee: target.callee,
239
+ ...(target.object !== undefined ? { object: target.object } : {}),
240
+ ...(objectType !== undefined ? { objectType } : {}),
241
+ line: line(node),
242
+ });
243
+ }
244
+ addRequest(ctx, method, url, node) {
245
+ if (ctx.owner)
246
+ this.out.requests.push({ caller: ctx.owner, method, url, line: line(node) });
247
+ }
248
+ /** `app.MapGet("/x", handler)` → a `GET /x` route symbol; returns the handler that owns its calls. */
249
+ addMinimalRoute(node, fn, callee) {
250
+ const method = callee ? MINIMAL_API.get(callee) : undefined;
251
+ const receiver = memberReceiver(fn);
252
+ const args = callArgs(node);
253
+ const template = args[0] ? stringValue(args[0]) : undefined;
254
+ const handler = args.at(-1);
255
+ if (!method || !receiver || template === undefined || args.length < 2 || !handler)
256
+ return undefined;
257
+ if (!HANDLER_TYPES.has(handler.type))
258
+ return undefined;
259
+ const path = joinPath(this.groupPrefix(receiver), template);
260
+ const name = this.uniqueName(`${method} ${path}`);
261
+ this.addSymbol(name, 'route', statementOf(node), false, { method, path });
262
+ return { name, node: handler };
263
+ }
264
+ trackGroup(declarator) {
265
+ const name = declarator.childForFieldName('name')?.text;
266
+ const value = namedChildren(declarator).at(-1);
267
+ if (!name || value?.type !== 'invocation_expression')
268
+ return;
269
+ const prefix = this.groupPrefix(value);
270
+ if (prefix)
271
+ this.groups.set(name, prefix);
272
+ }
273
+ /** Route prefix of a `MapGroup` receiver: a tracked variable or a `x.MapGroup("/p")` call. */
274
+ groupPrefix(node) {
275
+ if (node.type === 'identifier')
276
+ return this.groups.get(node.text) ?? '';
277
+ if (node.type !== 'invocation_expression')
278
+ return '';
279
+ const fn = node.childForFieldName('function');
280
+ if (fn?.type !== 'member_access_expression' || fn.childForFieldName('name')?.text !== 'MapGroup')
281
+ return '';
282
+ const first = callArgs(node)[0];
283
+ const prefix = first ? stringValue(first) : undefined;
284
+ const receiver = fn.childForFieldName('expression');
285
+ if (prefix === undefined || !receiver)
286
+ return '';
287
+ return joinPath(this.groupPrefix(receiver), prefix);
288
+ }
289
+ // ---- heritage ----
290
+ addHeritage(symbol, node) {
291
+ const bases = namedChildren(node).find((c) => c.type === 'base_list');
292
+ if (!bases)
293
+ return;
294
+ for (const base of namedChildren(bases)) {
295
+ const target = typeName(base);
296
+ if (!target)
297
+ continue;
298
+ const relation = node.type !== 'interface_declaration' && INTERFACE_NAME.test(target) ? 'implements' : 'extends';
299
+ this.out.heritage.push({ symbol, relation, target });
300
+ }
301
+ }
302
+ }
303
+ // ---- helpers ----
304
+ function line(node) {
305
+ return node.startPosition.row + 1;
306
+ }
307
+ function withScope(ctx, types) {
308
+ return { ...ctx, scopes: [{ member: true, types }, ...ctx.scopes] };
309
+ }
310
+ function modifiers(node) {
311
+ return namedChildren(node)
312
+ .filter((c) => c.type === 'modifier')
313
+ .map((c) => c.text);
314
+ }
315
+ /** `public`/`internal` → true; `private`/`protected` → false; no access modifier → `fallback`. */
316
+ function isAccessible(node, fallback) {
317
+ const mods = modifiers(node);
318
+ if (mods.includes('public') || mods.includes('internal'))
319
+ return true;
320
+ if (mods.includes('private') || mods.includes('protected'))
321
+ return false;
322
+ return fallback;
323
+ }
324
+ /** Simple type name: generics, nullability and namespace qualification dropped. */
325
+ function typeName(node) {
326
+ switch (node.type) {
327
+ case 'identifier':
328
+ case 'predefined_type':
329
+ return node.text;
330
+ case 'generic_name':
331
+ return namedChildren(node).find((c) => c.type === 'identifier')?.text;
332
+ case 'qualified_name':
333
+ case 'alias_qualified_name': {
334
+ const name = node.childForFieldName('name');
335
+ return name ? typeName(name) : undefined;
336
+ }
337
+ case 'nullable_type':
338
+ case 'primary_constructor_base_type': {
339
+ const inner = node.childForFieldName('type') ?? namedChildren(node)[0];
340
+ return inner ? typeName(inner) : undefined;
341
+ }
342
+ default:
343
+ return undefined;
344
+ }
345
+ }
346
+ function addTyped(types, typeNode, nameNode) {
347
+ if (!typeNode || nameNode?.type !== 'identifier' || types.has(nameNode.text))
348
+ return;
349
+ const type = typeName(typeNode);
350
+ if (type)
351
+ types.set(nameNode.text, type);
352
+ }
353
+ /** Variables declared in a variable_declaration (`Foo a, b;`); `var` gives no type. */
354
+ function addDeclaration(types, declaration) {
355
+ const type = declaration.childForFieldName('type');
356
+ if (!type || type.type === 'implicit_type')
357
+ return;
358
+ for (const declarator of namedChildren(declaration)) {
359
+ if (declarator.type === 'variable_declarator')
360
+ addTyped(types, type, declarator.childForFieldName('name'));
361
+ }
362
+ }
363
+ /** Fields, properties and primary-constructor parameters of a type. */
364
+ function typeScope(node) {
365
+ const types = new Map();
366
+ for (const param of namedChildren(namedChildren(node).find((c) => c.type === 'parameter_list') ?? node)) {
367
+ if (param.type === 'parameter')
368
+ addTyped(types, param.childForFieldName('type'), param.childForFieldName('name'));
369
+ }
370
+ const body = node.childForFieldName('body');
371
+ for (const member of body ? namedChildren(body) : []) {
372
+ if (member.type === 'property_declaration') {
373
+ addTyped(types, member.childForFieldName('type'), member.childForFieldName('name'));
374
+ }
375
+ else if (member.type === 'field_declaration') {
376
+ const declaration = namedChildren(member).find((c) => c.type === 'variable_declaration');
377
+ if (declaration)
378
+ addDeclaration(types, declaration);
379
+ }
380
+ }
381
+ return types;
382
+ }
383
+ /** Parameters and explicitly typed locals anywhere inside a member, lambda or local function. */
384
+ function memberScope(node) {
385
+ const types = new Map();
386
+ const visit = (n) => {
387
+ if (n.type === 'parameter' || n.type === 'declaration_expression') {
388
+ addTyped(types, n.childForFieldName('type'), n.childForFieldName('name'));
389
+ }
390
+ else if (n.type === 'variable_declaration') {
391
+ addDeclaration(types, n);
392
+ }
393
+ else if (n.type === 'foreach_statement') {
394
+ const type = n.childForFieldName('type');
395
+ if (type?.type !== 'implicit_type')
396
+ addTyped(types, type, n.childForFieldName('left'));
397
+ }
398
+ for (const child of namedChildren(n))
399
+ visit(child);
400
+ };
401
+ visit(node);
402
+ return types;
403
+ }
404
+ /** Declared type of `name`: locals and parameters first, then fields (only fields for `this.x`). */
405
+ function lookupType(scopes, name, fieldsOnly) {
406
+ for (const scope of scopes) {
407
+ if (fieldsOnly && scope.member)
408
+ continue;
409
+ const type = scope.types.get(name);
410
+ if (type)
411
+ return type;
412
+ }
413
+ return undefined;
414
+ }
415
+ /** `Foo()`, `obj.Bar()`, `this.Bar()`, `this._x.Bar()`, `obj?.Bar()`; undefined for other shapes. */
416
+ function callTarget(fn) {
417
+ if (fn.type === 'identifier')
418
+ return fn.text === 'nameof' ? undefined : { callee: fn.text };
419
+ if (fn.type === 'generic_name')
420
+ return simpleCallee(fn);
421
+ const receiver = fn.type === 'member_access_expression'
422
+ ? fn.childForFieldName('expression')
423
+ : fn.type === 'conditional_access_expression'
424
+ ? fn.childForFieldName('condition')
425
+ : null;
426
+ const callee = memberName(fn);
427
+ if (!callee || !receiver)
428
+ return undefined;
429
+ if (receiver.type === 'identifier' || receiver.type === 'this')
430
+ return { callee, object: receiver.text };
431
+ if (receiver.type === 'member_access_expression' && receiver.childForFieldName('expression')?.type === 'this') {
432
+ const field = receiver.childForFieldName('name');
433
+ if (field?.type === 'identifier')
434
+ return { callee, object: field.text, viaThis: true };
435
+ }
436
+ return undefined; // base.M(), a.b.C(), F().G()...
437
+ }
438
+ /** Member name of `x.Name(...)` / `x?.Name(...)`, generic arguments dropped. */
439
+ function memberName(fn) {
440
+ const nameNode = fn.type === 'member_access_expression'
441
+ ? fn.childForFieldName('name')
442
+ : fn.type === 'conditional_access_expression'
443
+ ? namedChildren(fn).find((c) => c.type === 'member_binding_expression')?.childForFieldName('name')
444
+ : undefined;
445
+ return nameNode ? simpleCallee(nameNode)?.callee : undefined;
446
+ }
447
+ function simpleCallee(node) {
448
+ const name = node.type === 'generic_name' ? namedChildren(node).find((c) => c.type === 'identifier') : node;
449
+ return name?.type === 'identifier' ? { callee: name.text } : undefined;
450
+ }
451
+ /** Receiver of a member call (`app` in `app.MapGet(...)`). */
452
+ function memberReceiver(fn) {
453
+ if (fn?.type !== 'member_access_expression')
454
+ return undefined;
455
+ return fn.childForFieldName('expression') ?? undefined;
456
+ }
457
+ /** Expression of an `argument` node (skipping `name:` labels and `ref`/`out`). */
458
+ function argValue(arg) {
459
+ return namedChildren(arg).at(-1);
460
+ }
461
+ function callArgs(call) {
462
+ const list = call.childForFieldName('arguments') ?? namedChildren(call).find((c) => c.type === 'argument_list');
463
+ if (!list)
464
+ return [];
465
+ return namedChildren(list)
466
+ .filter((a) => a.type === 'argument')
467
+ .map(argValue)
468
+ .filter((v) => v !== undefined);
469
+ }
470
+ function firstStringArg(call) {
471
+ const first = callArgs(call)[0];
472
+ return first ? stringValue(first) : undefined;
473
+ }
474
+ /** Content of a string literal; interpolations become `{}`. Undefined for non-literals. */
475
+ function stringValue(node) {
476
+ if (!STRING_TYPES.has(node.type))
477
+ return undefined;
478
+ if (node.type === 'string_literal')
479
+ return node.text.slice(1, -1);
480
+ if (node.type === 'verbatim_string_literal')
481
+ return node.text.slice(2, -1);
482
+ if (node.type === 'raw_string_literal')
483
+ return node.text.replace(/^"+/, '').replace(/"+$/, '');
484
+ let text = '';
485
+ for (const child of node.children) {
486
+ if (!child)
487
+ continue;
488
+ if (child.type === 'interpolation')
489
+ text += '{}';
490
+ else if (child.isNamed && child.type !== 'interpolation_start' && child.type !== 'interpolation_quote') {
491
+ text += child.text;
492
+ }
493
+ }
494
+ return text;
495
+ }
496
+ /** `HttpMethod.Post` → `POST`; `new HttpMethod("PATCH")` → `PATCH`; otherwise `GET`. */
497
+ function requestMethod(node) {
498
+ if (node.type === 'member_access_expression') {
499
+ return node.childForFieldName('name')?.text.toUpperCase() ?? 'GET';
500
+ }
501
+ if (node.type === 'object_creation_expression') {
502
+ const first = callArgs(node)[0];
503
+ const literal = first ? stringValue(first) : undefined;
504
+ if (literal)
505
+ return literal.toUpperCase();
506
+ }
507
+ return 'GET';
508
+ }
509
+ /** The statement holding a call chain, or the call itself when it is not a statement. */
510
+ function statementOf(call) {
511
+ let top = call;
512
+ while (top.parent && CHAIN_PARENTS.has(top.parent.type))
513
+ top = top.parent;
514
+ return top.parent?.type === 'expression_statement' ? top.parent : call;
515
+ }
516
+ function attributes(node) {
517
+ const result = [];
518
+ for (const list of namedChildren(node)) {
519
+ if (list.type !== 'attribute_list')
520
+ continue;
521
+ for (const attr of namedChildren(list)) {
522
+ const nameNode = attr.childForFieldName('name');
523
+ const name = nameNode ? typeName(nameNode)?.replace(/Attribute$/, '') : undefined;
524
+ if (!name)
525
+ continue;
526
+ const template = attributeTemplate(attr);
527
+ result.push({ name, ...(template !== undefined ? { template } : {}) });
528
+ }
529
+ }
530
+ return result;
531
+ }
532
+ function attributeTemplate(attr) {
533
+ const args = namedChildren(attr).find((c) => c.type === 'attribute_argument_list');
534
+ for (const arg of args ? namedChildren(args) : []) {
535
+ const parts = namedChildren(arg);
536
+ const value = parts.at(-1);
537
+ if (!value || value.type === 'assignment_expression')
538
+ continue; // `Name = "x"`, `Order = 1`
539
+ // `template: "x"` names its argument; other labels are not the template.
540
+ if (parts.length > 1 && parts[0]?.text !== 'template')
541
+ continue;
542
+ return stringValue(value);
543
+ }
544
+ return undefined;
545
+ }
546
+ /** HTTP endpoint of a controller action from its `[HttpX]` / `[Route]` attributes. */
547
+ function actionRoute(node, action, controller) {
548
+ const attrs = attributes(node);
549
+ const verb = attrs.find((a) => VERB_ATTRIBUTES.has(a.name));
550
+ const route = attrs.find((a) => a.name === 'Route');
551
+ if (!verb && !route)
552
+ return undefined;
553
+ const method = verb ? (VERB_ATTRIBUTES.get(verb.name) ?? 'ANY') : 'ANY';
554
+ const template = verb?.template ?? route?.template ?? '';
555
+ const absolute = template.startsWith('/') || template.startsWith('~/');
556
+ const raw = absolute ? template.replace(/^~/, '') : joinPath(controller.prefix, template);
557
+ const path = raw.replace(/\[controller\]/gi, controller.name).replace(/\[action\]/gi, action);
558
+ return { method, path: joinPath(path, '') };
559
+ }
560
+ /** Joins route segments: leading `/`, collapsed slashes, no trailing slash (root stays `/`). */
561
+ function joinPath(prefix, template) {
562
+ const path = `/${prefix}/${template}`.replace(/\/+/g, '/');
563
+ return path.length > 1 ? path.replace(/\/$/, '') : path;
564
+ }
565
+ //# sourceMappingURL=csharp.js.map