neuroplex 0.0.1 → 0.2.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 (112) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +11 -11
  3. package/dist/brain/build.d.ts +21 -0
  4. package/dist/brain/build.js +172 -0
  5. package/dist/brain/build.js.map +1 -0
  6. package/dist/brain/local.d.ts +12 -0
  7. package/dist/brain/local.js +23 -0
  8. package/dist/brain/local.js.map +1 -0
  9. package/dist/brain/stats.d.ts +23 -0
  10. package/dist/brain/stats.js +37 -0
  11. package/dist/brain/stats.js.map +1 -0
  12. package/dist/brain/status.d.ts +24 -0
  13. package/dist/brain/status.js +30 -0
  14. package/dist/brain/status.js.map +1 -0
  15. package/dist/cli/index.d.ts +2 -0
  16. package/dist/cli/index.js +269 -0
  17. package/dist/cli/index.js.map +1 -0
  18. package/dist/config/config.d.ts +64 -0
  19. package/dist/config/config.js +147 -0
  20. package/dist/config/config.js.map +1 -0
  21. package/dist/config/edit.d.ts +9 -0
  22. package/dist/config/edit.js +45 -0
  23. package/dist/config/edit.js.map +1 -0
  24. package/dist/enrich/index.d.ts +8 -0
  25. package/dist/enrich/index.js +13 -0
  26. package/dist/enrich/index.js.map +1 -0
  27. package/dist/enrich/tasks.d.ts +52 -0
  28. package/dist/enrich/tasks.js +339 -0
  29. package/dist/enrich/tasks.js.map +1 -0
  30. package/dist/enrich/write.d.ts +45 -0
  31. package/dist/enrich/write.js +228 -0
  32. package/dist/enrich/write.js.map +1 -0
  33. package/dist/graph/graph.d.ts +42 -0
  34. package/dist/graph/graph.js +174 -0
  35. package/dist/graph/graph.js.map +1 -0
  36. package/dist/graph/ids.d.ts +42 -0
  37. package/dist/graph/ids.js +104 -0
  38. package/dist/graph/ids.js.map +1 -0
  39. package/dist/graph/jsonl.d.ts +31 -0
  40. package/dist/graph/jsonl.js +121 -0
  41. package/dist/graph/jsonl.js.map +1 -0
  42. package/dist/graph/schema.d.ts +89 -0
  43. package/dist/graph/schema.js +73 -0
  44. package/dist/graph/schema.js.map +1 -0
  45. package/dist/index.d.ts +22 -0
  46. package/dist/index.js +22 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/install/claude.d.ts +37 -0
  49. package/dist/install/claude.js +104 -0
  50. package/dist/install/claude.js.map +1 -0
  51. package/dist/mcp/config.d.ts +20 -0
  52. package/dist/mcp/config.js +51 -0
  53. package/dist/mcp/config.js.map +1 -0
  54. package/dist/mcp/serve.d.ts +6 -0
  55. package/dist/mcp/serve.js +29 -0
  56. package/dist/mcp/serve.js.map +1 -0
  57. package/dist/mcp/server.d.ts +9 -0
  58. package/dist/mcp/server.js +248 -0
  59. package/dist/mcp/server.js.map +1 -0
  60. package/dist/query/brain.d.ts +21 -0
  61. package/dist/query/brain.js +51 -0
  62. package/dist/query/brain.js.map +1 -0
  63. package/dist/query/queries.d.ts +116 -0
  64. package/dist/query/queries.js +224 -0
  65. package/dist/query/queries.js.map +1 -0
  66. package/dist/query/search.d.ts +43 -0
  67. package/dist/query/search.js +329 -0
  68. package/dist/query/search.js.map +1 -0
  69. package/dist/scan/assemble.d.ts +20 -0
  70. package/dist/scan/assemble.js +255 -0
  71. package/dist/scan/assemble.js.map +1 -0
  72. package/dist/scan/discover.d.ts +21 -0
  73. package/dist/scan/discover.js +119 -0
  74. package/dist/scan/discover.js.map +1 -0
  75. package/dist/scan/extract.d.ts +3 -0
  76. package/dist/scan/extract.js +11 -0
  77. package/dist/scan/extract.js.map +1 -0
  78. package/dist/scan/extractors/python.d.ts +4 -0
  79. package/dist/scan/extractors/python.js +303 -0
  80. package/dist/scan/extractors/python.js.map +1 -0
  81. package/dist/scan/extractors/typescript.d.ts +6 -0
  82. package/dist/scan/extractors/typescript.js +509 -0
  83. package/dist/scan/extractors/typescript.js.map +1 -0
  84. package/dist/scan/git.d.ts +17 -0
  85. package/dist/scan/git.js +45 -0
  86. package/dist/scan/git.js.map +1 -0
  87. package/dist/scan/merge.d.ts +14 -0
  88. package/dist/scan/merge.js +57 -0
  89. package/dist/scan/merge.js.map +1 -0
  90. package/dist/scan/parser.d.ts +23 -0
  91. package/dist/scan/parser.js +57 -0
  92. package/dist/scan/parser.js.map +1 -0
  93. package/dist/scan/resolve.d.ts +23 -0
  94. package/dist/scan/resolve.js +131 -0
  95. package/dist/scan/resolve.js.map +1 -0
  96. package/dist/scan/scan.d.ts +41 -0
  97. package/dist/scan/scan.js +104 -0
  98. package/dist/scan/scan.js.map +1 -0
  99. package/dist/scan/types.d.ts +86 -0
  100. package/dist/scan/types.js +20 -0
  101. package/dist/scan/types.js.map +1 -0
  102. package/dist/sync/sync.d.ts +57 -0
  103. package/dist/sync/sync.js +192 -0
  104. package/dist/sync/sync.js.map +1 -0
  105. package/dist/version.d.ts +2 -0
  106. package/dist/version.js +5 -0
  107. package/dist/version.js.map +1 -0
  108. package/package.json +40 -6
  109. package/skills/neuroplex/SKILL.md +95 -0
  110. package/skills/neuroplex-update/SKILL.md +37 -0
  111. package/bin/neuroplex.js +0 -8
  112. package/index.js +0 -7
@@ -0,0 +1,509 @@
1
+ import { lineRange, namedChildren } from '../parser.js';
2
+ import { emptyExtraction, } from '../types.js';
3
+ const FUNCTION_DECLARATIONS = new Set(['function_declaration', 'generator_function_declaration', 'function_signature']);
4
+ const CLASS_DECLARATIONS = new Set(['class_declaration', 'abstract_class_declaration', 'class']);
5
+ const FUNCTION_VALUES = new Set(['arrow_function', 'function_expression', 'function', 'generator_function']);
6
+ const METHOD_MEMBERS = new Set(['method_definition', 'method_signature', 'abstract_method_signature']);
7
+ const FIELD_MEMBERS = new Set(['public_field_definition', 'field_definition']);
8
+ const JSX_TYPES = new Set(['jsx_element', 'jsx_self_closing_element', 'jsx_fragment']);
9
+ const DOTTED_NAME = /^[\w$]+(\.[\w$]+)*$/;
10
+ const MCP_REGISTRATIONS = new Map([
11
+ ['registerTool', 'tool'],
12
+ ['tool', 'tool'],
13
+ ['registerResource', 'resource'],
14
+ ['resource', 'resource'],
15
+ ['registerPrompt', 'prompt'],
16
+ ['prompt', 'prompt'],
17
+ ]);
18
+ const HTTP_VERBS = new Set(['get', 'post', 'put', 'patch', 'delete', 'all', 'options', 'head']);
19
+ /** Parents that continue a method chain (`a.b().c()`, `await a.b()`). */
20
+ const CHAIN_PARENTS = new Set(['call_expression', 'member_expression', 'await_expression', 'parenthesized_expression']);
21
+ /** Extracts symbols, imports, calls and heritage from a TypeScript/TSX/JavaScript tree. */
22
+ export function extractTypeScript(root, lang) {
23
+ return new TsExtractor(root, lang).run();
24
+ }
25
+ class TsExtractor {
26
+ root;
27
+ lang;
28
+ out = emptyExtraction();
29
+ names = new Set();
30
+ /** Declaration node id → qualified name of the symbol whose calls it holds. */
31
+ owners = new Map();
32
+ /** Names exported through a local `export { a, b as c }` or `export default a`. */
33
+ clauseExports = new Set();
34
+ seenCalls = new Set();
35
+ constructor(root, lang) {
36
+ this.root = root;
37
+ this.lang = lang;
38
+ }
39
+ run() {
40
+ for (const stmt of namedChildren(this.root))
41
+ this.collectClauseExports(stmt);
42
+ for (const stmt of namedChildren(this.root))
43
+ this.visitTopLevel(stmt);
44
+ this.applyClauseExports();
45
+ this.walk(this.root, undefined);
46
+ return this.out;
47
+ }
48
+ // ---- symbols ----
49
+ visitTopLevel(stmt) {
50
+ if (stmt.type === 'export_statement') {
51
+ this.visitExport(stmt);
52
+ }
53
+ else if (stmt.type === 'import_statement') {
54
+ this.addImportStatement(stmt);
55
+ }
56
+ else if (stmt.type === 'ambient_declaration') {
57
+ for (const inner of namedChildren(stmt))
58
+ this.visitDeclaration(inner, stmt, false);
59
+ }
60
+ else {
61
+ this.visitDeclaration(stmt, stmt, false);
62
+ }
63
+ }
64
+ visitExport(stmt) {
65
+ const source = stmt.childForFieldName('source');
66
+ if (source) {
67
+ this.addReexport(stmt, source);
68
+ return;
69
+ }
70
+ const declaration = stmt.childForFieldName('declaration');
71
+ if (declaration) {
72
+ this.visitDeclaration(declaration, stmt, true);
73
+ return;
74
+ }
75
+ // `export default <expr>`: anonymous functions/classes are named `default`.
76
+ const value = stmt.childForFieldName('value');
77
+ if (!value)
78
+ return;
79
+ if (FUNCTION_VALUES.has(value.type)) {
80
+ this.addFunction('default', value, stmt, true);
81
+ }
82
+ else if (CLASS_DECLARATIONS.has(value.type)) {
83
+ this.addClass(nameOf(value) ?? 'default', value, stmt, true);
84
+ }
85
+ }
86
+ /** `range` covers `outer`, the full statement (including `export` when present). */
87
+ visitDeclaration(node, outer, exported) {
88
+ const name = nameOf(node);
89
+ if (FUNCTION_DECLARATIONS.has(node.type)) {
90
+ this.addFunction(name ?? 'default', node, outer, exported);
91
+ }
92
+ else if (CLASS_DECLARATIONS.has(node.type)) {
93
+ this.addClass(name ?? 'default', node, outer, exported);
94
+ }
95
+ else if (node.type === 'interface_declaration' && name) {
96
+ this.addSymbol(name, 'interface', outer, exported, node);
97
+ this.addInterfaceHeritage(name, node);
98
+ }
99
+ else if ((node.type === 'type_alias_declaration' || node.type === 'enum_declaration') && name) {
100
+ this.addSymbol(name, 'type', outer, exported, node);
101
+ }
102
+ else if (node.type === 'lexical_declaration' || node.type === 'variable_declaration') {
103
+ for (const declarator of namedChildren(node)) {
104
+ if (declarator.type === 'variable_declarator')
105
+ this.visitDeclarator(declarator, outer, exported);
106
+ }
107
+ }
108
+ }
109
+ visitDeclarator(declarator, outer, exported) {
110
+ const nameNode = declarator.childForFieldName('name');
111
+ if (nameNode?.type !== 'identifier')
112
+ return; // destructuring patterns are not symbols
113
+ const value = declarator.childForFieldName('value');
114
+ if (value && FUNCTION_VALUES.has(value.type)) {
115
+ this.addFunction(nameNode.text, value, outer, exported);
116
+ }
117
+ else if (exported || this.clauseExports.has(nameNode.text)) {
118
+ this.addSymbol(nameNode.text, 'variable', outer, exported, declarator);
119
+ }
120
+ }
121
+ addFunction(name, fn, outer, exported) {
122
+ this.addSymbol(name, this.isComponent(name, fn) ? 'component' : 'function', outer, exported, fn);
123
+ }
124
+ addClass(name, node, outer, exported) {
125
+ this.addSymbol(name, 'class', outer, exported, node);
126
+ this.addClassHeritage(name, node);
127
+ const body = node.childForFieldName('body');
128
+ if (!body)
129
+ return;
130
+ for (const member of namedChildren(body)) {
131
+ const memberName = member.childForFieldName('name') ?? member.childForFieldName('property');
132
+ if (!memberName || memberName.text === 'constructor')
133
+ continue;
134
+ const value = member.childForFieldName('value');
135
+ const isMethod = METHOD_MEMBERS.has(member.type) ||
136
+ (FIELD_MEMBERS.has(member.type) && value !== null && FUNCTION_VALUES.has(value.type));
137
+ if (isMethod)
138
+ this.addSymbol(`${name}.${memberName.text}`, 'method', member, exported, member);
139
+ }
140
+ }
141
+ addSymbol(name, kind, rangeNode, exported, owner) {
142
+ // Calls inside a repeated declaration (e.g. an overload's implementation) still belong to `name`.
143
+ this.owners.set(owner.id, name);
144
+ if (this.names.has(name))
145
+ return;
146
+ this.names.add(name);
147
+ this.out.symbols.push({ name, kind, range: lineRange(rangeNode), exported });
148
+ }
149
+ isComponent(name, fn) {
150
+ if (this.lang === 'typescript' || !/^[A-Z]/.test(name))
151
+ return false;
152
+ const body = fn.childForFieldName('body');
153
+ return body !== null && containsJsx(body);
154
+ }
155
+ // ---- exports ----
156
+ collectClauseExports(stmt) {
157
+ if (stmt.type !== 'export_statement' || stmt.childForFieldName('source'))
158
+ return;
159
+ const value = stmt.childForFieldName('value');
160
+ if (value?.type === 'identifier')
161
+ this.clauseExports.add(value.text);
162
+ for (const clause of namedChildren(stmt)) {
163
+ if (clause.type !== 'export_clause')
164
+ continue;
165
+ for (const spec of namedChildren(clause)) {
166
+ const local = spec.childForFieldName('name');
167
+ if (local)
168
+ this.clauseExports.add(local.text);
169
+ }
170
+ }
171
+ }
172
+ applyClauseExports() {
173
+ const exportedClasses = new Set();
174
+ for (const symbol of this.out.symbols) {
175
+ if (symbol.name.includes('.'))
176
+ continue;
177
+ if (this.clauseExports.has(symbol.name))
178
+ symbol.exported = true;
179
+ if (symbol.kind === 'class' && symbol.exported)
180
+ exportedClasses.add(symbol.name);
181
+ }
182
+ for (const symbol of this.out.symbols) {
183
+ const owner = symbol.name.split('.')[0] ?? '';
184
+ if (symbol.kind === 'method' && exportedClasses.has(owner))
185
+ symbol.exported = true;
186
+ }
187
+ }
188
+ // ---- imports ----
189
+ addImportStatement(stmt) {
190
+ const source = stmt.childForFieldName('source');
191
+ const bindings = [];
192
+ const typeFlags = [];
193
+ let specifier = source ? stringContent(source) : undefined;
194
+ for (const child of namedChildren(stmt)) {
195
+ if (child.type === 'import_require_clause') {
196
+ // `import x = require('m')`
197
+ const local = namedChildren(child).find((c) => c.type === 'identifier');
198
+ const req = child.childForFieldName('source');
199
+ if (req)
200
+ specifier = stringContent(req);
201
+ if (local)
202
+ bindings.push({ local: local.text, imported: '*' });
203
+ }
204
+ if (child.type !== 'import_clause')
205
+ continue;
206
+ for (const part of namedChildren(child)) {
207
+ if (part.type === 'identifier') {
208
+ bindings.push({ local: part.text, imported: 'default' });
209
+ typeFlags.push(false);
210
+ }
211
+ else if (part.type === 'namespace_import') {
212
+ const local = namedChildren(part)[0];
213
+ if (local)
214
+ bindings.push({ local: local.text, imported: '*' });
215
+ typeFlags.push(false);
216
+ }
217
+ else if (part.type === 'named_imports') {
218
+ for (const spec of namedChildren(part)) {
219
+ const binding = specifierBinding(spec, 'name', 'alias');
220
+ if (!binding)
221
+ continue;
222
+ bindings.push({ local: binding.alias, imported: binding.name });
223
+ typeFlags.push(hasTypeKeyword(spec));
224
+ }
225
+ }
226
+ }
227
+ }
228
+ if (specifier === undefined)
229
+ return;
230
+ const typeOnly = hasTypeKeyword(stmt) || (typeFlags.length > 0 && typeFlags.every(Boolean));
231
+ this.pushImport({ specifier, bindings, line: line(stmt), ...(typeOnly ? { typeOnly } : {}) });
232
+ }
233
+ addReexport(stmt, source) {
234
+ const bindings = [];
235
+ const typeFlags = [];
236
+ for (const child of namedChildren(stmt)) {
237
+ if (child.type === 'namespace_export') {
238
+ // `export * as ns from 'm'`
239
+ const local = namedChildren(child)[0];
240
+ if (local)
241
+ bindings.push({ local: local.text, imported: '*' });
242
+ typeFlags.push(false);
243
+ }
244
+ if (child.type !== 'export_clause')
245
+ continue;
246
+ for (const spec of namedChildren(child)) {
247
+ const binding = specifierBinding(spec, 'name', 'alias');
248
+ if (!binding)
249
+ continue;
250
+ bindings.push({ local: binding.alias, imported: binding.name });
251
+ typeFlags.push(hasTypeKeyword(spec));
252
+ }
253
+ }
254
+ const typeOnly = hasTypeKeyword(stmt) || (typeFlags.length > 0 && typeFlags.every(Boolean));
255
+ this.pushImport({
256
+ specifier: stringContent(source),
257
+ bindings,
258
+ line: line(stmt),
259
+ ...(typeOnly ? { typeOnly } : {}),
260
+ reexport: true,
261
+ });
262
+ }
263
+ /** `require('m')` and `import('m')` with a string literal argument, anywhere in the file. */
264
+ addDynamicImport(call) {
265
+ const fn = call.childForFieldName('function');
266
+ const isRequire = fn?.type === 'identifier' && fn.text === 'require';
267
+ if (!isRequire && fn?.type !== 'import')
268
+ return false;
269
+ const arg = call.childForFieldName('arguments');
270
+ const literal = arg ? namedChildren(arg)[0] : undefined;
271
+ if (literal?.type !== 'string')
272
+ return isRequire;
273
+ const declarator = call.parent;
274
+ const bindings = isRequire && declarator?.type === 'variable_declarator' && declarator.childForFieldName('value')?.id === call.id
275
+ ? requireBindings(declarator.childForFieldName('name'))
276
+ : [];
277
+ const stmt = isRequire && declarator?.type === 'variable_declarator' ? (declarator.parent ?? call) : call;
278
+ this.pushImport({ specifier: stringContent(literal), bindings, line: line(stmt) });
279
+ return true;
280
+ }
281
+ pushImport(entry) {
282
+ this.out.imports.push(entry);
283
+ }
284
+ // ---- calls ----
285
+ walk(node, caller) {
286
+ const owner = this.owners.get(node.id) ?? caller;
287
+ if (node.type === 'call_expression') {
288
+ this.addRouteHandler(node);
289
+ const isImport = this.addDynamicImport(node);
290
+ if (!isImport && owner)
291
+ this.addCall(owner, node.childForFieldName('function'), node);
292
+ }
293
+ else if (node.type === 'new_expression' && owner) {
294
+ this.addCall(owner, node.childForFieldName('constructor'), node);
295
+ }
296
+ for (const child of namedChildren(node))
297
+ this.walk(child, owner);
298
+ }
299
+ /**
300
+ * Anonymous entry-point callbacks (CLI commands, MCP tools, HTTP routes) become
301
+ * `route` symbols that own the calls made inside the callback.
302
+ */
303
+ addRouteHandler(call) {
304
+ const route = routeOf(call);
305
+ if (!route)
306
+ return;
307
+ this.addSymbol(this.uniqueName(route.name), 'route', statementOf(call), false, route.handler);
308
+ }
309
+ /** `name`, or `name (2)`, `name (3)`... when already taken in this file. */
310
+ uniqueName(name) {
311
+ if (!this.names.has(name))
312
+ return name;
313
+ let n = 2;
314
+ while (this.names.has(`${name} (${n})`))
315
+ n++;
316
+ return `${name} (${n})`;
317
+ }
318
+ addCall(caller, target, node) {
319
+ if (!target)
320
+ return;
321
+ let callee;
322
+ let object;
323
+ if (target.type === 'identifier') {
324
+ callee = target.text;
325
+ }
326
+ else if (target.type === 'member_expression') {
327
+ const receiver = target.childForFieldName('object');
328
+ const property = target.childForFieldName('property');
329
+ if (!receiver || !property || (receiver.type !== 'identifier' && receiver.type !== 'this'))
330
+ return;
331
+ callee = property.text;
332
+ object = receiver.text;
333
+ }
334
+ else {
335
+ return; // super(), f().g(), arr[0]()...
336
+ }
337
+ const key = `${caller}\0${callee}\0${object ?? ''}`;
338
+ if (this.seenCalls.has(key))
339
+ return;
340
+ this.seenCalls.add(key);
341
+ this.out.calls.push({ caller, callee, ...(object !== undefined ? { object } : {}), line: line(node) });
342
+ }
343
+ // ---- heritage ----
344
+ addClassHeritage(symbol, node) {
345
+ const heritage = namedChildren(node).find((c) => c.type === 'class_heritage');
346
+ if (!heritage)
347
+ return;
348
+ for (const clause of namedChildren(heritage)) {
349
+ if (clause.type === 'extends_clause') {
350
+ for (const value of namedChildren(clause))
351
+ this.addHeritage(symbol, 'extends', value);
352
+ }
353
+ else if (clause.type === 'implements_clause') {
354
+ for (const type of namedChildren(clause))
355
+ this.addHeritage(symbol, 'implements', type);
356
+ }
357
+ else {
358
+ // JavaScript grammar: `class_heritage` holds the base expression directly.
359
+ this.addHeritage(symbol, 'extends', clause);
360
+ }
361
+ }
362
+ }
363
+ addInterfaceHeritage(symbol, node) {
364
+ const clause = namedChildren(node).find((c) => c.type === 'extends_type_clause');
365
+ if (!clause)
366
+ return;
367
+ for (const type of namedChildren(clause))
368
+ this.addHeritage(symbol, 'extends', type);
369
+ }
370
+ addHeritage(symbol, relation, node) {
371
+ const target = heritageTarget(node);
372
+ if (target)
373
+ this.out.heritage.push({ symbol, relation, target });
374
+ }
375
+ }
376
+ // ---- helpers ----
377
+ function nameOf(node) {
378
+ return node.childForFieldName('name')?.text;
379
+ }
380
+ function line(node) {
381
+ return node.startPosition.row + 1;
382
+ }
383
+ /** Text of a string literal without its quotes. */
384
+ function stringContent(node) {
385
+ return node.text.slice(1, -1);
386
+ }
387
+ /** True when `node` has an anonymous `type` keyword child (`import type`, `type a` specifiers). */
388
+ function hasTypeKeyword(node) {
389
+ for (let i = 0; i < node.childCount; i++) {
390
+ const child = node.child(i);
391
+ if (child && !child.isNamed && child.type === 'type')
392
+ return true;
393
+ }
394
+ return false;
395
+ }
396
+ function specifierBinding(spec, nameField, aliasField) {
397
+ const name = spec.childForFieldName(nameField)?.text;
398
+ if (!name)
399
+ return undefined;
400
+ return { name, alias: spec.childForFieldName(aliasField)?.text ?? name };
401
+ }
402
+ function requireBindings(pattern) {
403
+ if (pattern?.type === 'identifier')
404
+ return [{ local: pattern.text, imported: '*' }];
405
+ if (pattern?.type !== 'object_pattern')
406
+ return [];
407
+ const bindings = [];
408
+ for (const prop of namedChildren(pattern)) {
409
+ if (prop.type === 'shorthand_property_identifier_pattern') {
410
+ bindings.push({ local: prop.text, imported: prop.text });
411
+ }
412
+ else if (prop.type === 'pair_pattern') {
413
+ const key = prop.childForFieldName('key');
414
+ const value = prop.childForFieldName('value');
415
+ if (key && value?.type === 'identifier')
416
+ bindings.push({ local: value.text, imported: key.text });
417
+ }
418
+ }
419
+ return bindings;
420
+ }
421
+ /** Recognises `x.command('n').action(fn)`, `x.registerTool('n', ..., fn)`, `app.get('/p', ..., fn)`... */
422
+ function routeOf(call) {
423
+ const fn = call.childForFieldName('function');
424
+ if (fn?.type !== 'member_expression')
425
+ return undefined;
426
+ const method = fn.childForFieldName('property')?.text;
427
+ const receiver = fn.childForFieldName('object');
428
+ const args = callArguments(call);
429
+ // The last function argument is the handler; earlier ones are middleware.
430
+ const handler = args.findLast((arg) => FUNCTION_VALUES.has(arg.type));
431
+ if (!method || !receiver || !handler)
432
+ return undefined;
433
+ if (method === 'action') {
434
+ const command = commandInChain(receiver);
435
+ return command ? { name: `command:${command}`, handler } : undefined;
436
+ }
437
+ const first = args[0] ? literalText(args[0]) : undefined;
438
+ if (!first)
439
+ return undefined;
440
+ if (method === 'command') {
441
+ const word = firstWord(first);
442
+ return word ? { name: `command:${word}`, handler } : undefined;
443
+ }
444
+ const mcpKind = MCP_REGISTRATIONS.get(method);
445
+ if (mcpKind)
446
+ return { name: `${mcpKind}:${first}`, handler };
447
+ if (HTTP_VERBS.has(method) && receiver.type === 'identifier' && first.startsWith('/')) {
448
+ return { name: `${method.toUpperCase()} ${first}`, handler };
449
+ }
450
+ return undefined;
451
+ }
452
+ /** First word of the nearest `.command('<literal>')` call in a method chain. */
453
+ function commandInChain(node) {
454
+ let current = node;
455
+ while (current?.type === 'call_expression') {
456
+ const fn = current.childForFieldName('function');
457
+ if (fn?.type !== 'member_expression')
458
+ return undefined;
459
+ if (fn.childForFieldName('property')?.text === 'command') {
460
+ const arg = callArguments(current)[0];
461
+ const literal = arg ? literalText(arg) : undefined;
462
+ return literal === undefined ? undefined : firstWord(literal);
463
+ }
464
+ current = fn.childForFieldName('object');
465
+ }
466
+ return undefined;
467
+ }
468
+ function callArguments(call) {
469
+ const args = call.childForFieldName('arguments');
470
+ return args?.type === 'arguments' ? namedChildren(args).filter((a) => a.type !== 'comment') : [];
471
+ }
472
+ /** Content of a string literal or substitution-free template literal; undefined otherwise. */
473
+ function literalText(node) {
474
+ if (node.type === 'string')
475
+ return stringContent(node);
476
+ if (node.type !== 'template_string')
477
+ return undefined;
478
+ if (namedChildren(node).some((c) => c.type === 'template_substitution'))
479
+ return undefined;
480
+ return stringContent(node);
481
+ }
482
+ function firstWord(text) {
483
+ return text.trim().split(/\s+/)[0] || undefined;
484
+ }
485
+ /** The statement holding a call chain, or the call itself when it is not a statement. */
486
+ function statementOf(call) {
487
+ let top = call;
488
+ while (top.parent && CHAIN_PARENTS.has(top.parent.type))
489
+ top = top.parent;
490
+ return top.parent?.type === 'expression_statement' ? top.parent : call;
491
+ }
492
+ function containsJsx(node) {
493
+ if (JSX_TYPES.has(node.type))
494
+ return true;
495
+ return namedChildren(node).some(containsJsx);
496
+ }
497
+ /** Base name as written (`B`, `ns.B`), generic arguments dropped; undefined for other expressions. */
498
+ function heritageTarget(node) {
499
+ if (node.type === 'type_arguments')
500
+ return undefined;
501
+ const base = node.type === 'generic_type' ? node.childForFieldName('name') : node;
502
+ if (!base)
503
+ return undefined;
504
+ const readable = ['identifier', 'type_identifier', 'member_expression', 'nested_type_identifier'];
505
+ if (!readable.includes(base.type) || !DOTTED_NAME.test(base.text))
506
+ return undefined;
507
+ return base.text;
508
+ }
509
+ //# sourceMappingURL=typescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/scan/extractors/typescript.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,eAAe,GAKhB,MAAM,aAAa,CAAC;AAIrB,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,gCAAgC,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACxH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,mBAAmB,EAAE,4BAA4B,EAAE,OAAO,CAAC,CAAC,CAAC;AACjG,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAA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AC;QAAE,OAAO,SAAS,CAAC;IACpF,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Runs `git -C <dir> ...args` and returns trimmed stdout, or `undefined` if git fails. */
2
+ export declare function git(dir: string, ...args: string[]): Promise<string | undefined>;
3
+ export interface GitInfo {
4
+ /** Absolute path of the repository root. */
5
+ root: string;
6
+ head?: string;
7
+ branch?: string;
8
+ remote?: string;
9
+ /** Default branch of `origin` (from `refs/remotes/origin/HEAD`), e.g. `main`. */
10
+ defaultBranch?: string;
11
+ /** True when the working tree has uncommitted changes. */
12
+ dirty: boolean;
13
+ }
14
+ /** Git facts about `dir`, or `undefined` when it is not inside a git repository. */
15
+ export declare function gitInfo(dir: string): Promise<GitInfo | undefined>;
16
+ /** Number of commits in `from..to`, or `undefined` if either commit is unknown. */
17
+ export declare function countCommits(dir: string, from: string, to: string): Promise<number | undefined>;
@@ -0,0 +1,45 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const exec = promisify(execFile);
4
+ /** Runs `git -C <dir> ...args` and returns trimmed stdout, or `undefined` if git fails. */
5
+ export async function git(dir, ...args) {
6
+ try {
7
+ const { stdout } = await exec('git', ['-C', dir, ...args], {
8
+ maxBuffer: 256 * 1024 * 1024,
9
+ windowsHide: true,
10
+ });
11
+ return stdout.trim();
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ /** Git facts about `dir`, or `undefined` when it is not inside a git repository. */
18
+ export async function gitInfo(dir) {
19
+ const root = await git(dir, 'rev-parse', '--show-toplevel');
20
+ if (!root)
21
+ return undefined;
22
+ const [head, branch, remote, status, originHead] = await Promise.all([
23
+ git(dir, 'rev-parse', 'HEAD'),
24
+ git(dir, 'rev-parse', '--abbrev-ref', 'HEAD'),
25
+ git(dir, 'remote', 'get-url', 'origin'),
26
+ git(dir, 'status', '--porcelain'),
27
+ git(dir, 'symbolic-ref', '--short', 'refs/remotes/origin/HEAD'),
28
+ ]);
29
+ const info = { root, dirty: Boolean(status) };
30
+ if (head)
31
+ info.head = head;
32
+ if (branch && branch !== 'HEAD')
33
+ info.branch = branch;
34
+ if (remote)
35
+ info.remote = remote;
36
+ if (originHead?.startsWith('origin/'))
37
+ info.defaultBranch = originHead.slice('origin/'.length);
38
+ return info;
39
+ }
40
+ /** Number of commits in `from..to`, or `undefined` if either commit is unknown. */
41
+ export async function countCommits(dir, from, to) {
42
+ const out = await git(dir, 'rev-list', '--count', `${from}..${to}`);
43
+ return out === undefined ? undefined : Number(out);
44
+ }
45
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/scan/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEjC,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,GAAW,EAAE,GAAG,IAAc;IACtD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE;YACzD,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;YAC5B,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAcD,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC5D,IAAI,CAAC,IAAI;QAAE,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CAAC;AACrD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Graph } from '../graph/graph.js';
2
+ /**
3
+ * Combines a fresh structural graph with the previous brain:
4
+ *
5
+ * - structural nodes and edges always come from `fresh`;
6
+ * - semantic fields (summary, note, extra tags, semantic provenance) carry over
7
+ * to nodes that still exist, and are flagged `stale` when the node's hash changed;
8
+ * - concept/flow nodes and semantic edges are kept when their endpoints still exist.
9
+ */
10
+ export declare function mergeSemantic(previous: Graph, fresh: Graph): {
11
+ graph: Graph;
12
+ kept: number;
13
+ stale: number;
14
+ };