@dimassetoid/septum-mcp 0.0.0-stage → 0.3.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 (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -2
  3. package/bin/septum.ts +4 -0
  4. package/package.json +70 -4
  5. package/scripts/postinstall.ts +25 -0
  6. package/src/cli/commands/check.ts +133 -0
  7. package/src/cli/commands/hook.ts +205 -0
  8. package/src/cli/commands/init.ts +570 -0
  9. package/src/cli/commands/serve.ts +5 -0
  10. package/src/cli/commands/sync.ts +39 -0
  11. package/src/cli/hook-payload.ts +43 -0
  12. package/src/cli/index.ts +124 -0
  13. package/src/cli/scaffold/harness-config.ts +661 -0
  14. package/src/cli/templates/hooks.ts +110 -0
  15. package/src/cli/templates/rules.ts +35 -0
  16. package/src/cli/templates/skill.ts +55 -0
  17. package/src/cli/ui/prompts.ts +122 -0
  18. package/src/core/boundary/evaluator.ts +426 -0
  19. package/src/core/boundary/staged-auditor.ts +120 -0
  20. package/src/core/config/domain-ownership.ts +45 -0
  21. package/src/core/config/loader.ts +174 -0
  22. package/src/core/config/schema.ts +59 -0
  23. package/src/core/database/client.ts +60 -0
  24. package/src/core/database/repositories/dependency.repository.ts +733 -0
  25. package/src/core/database/repositories/domain.repository.ts +373 -0
  26. package/src/core/database/repositories/file.repository.ts +117 -0
  27. package/src/core/database/repositories/meta.repository.ts +33 -0
  28. package/src/core/database/repositories/symbol.repository.ts +647 -0
  29. package/src/core/database/repository.ts +358 -0
  30. package/src/core/database/schema.ts +123 -0
  31. package/src/core/discovery/navigation.ts +105 -0
  32. package/src/core/discovery/topology-detector.ts +863 -0
  33. package/src/core/ingestion/hasher.ts +5 -0
  34. package/src/core/ingestion/pipeline.ts +590 -0
  35. package/src/core/parser/behavioral-analyzer.ts +123 -0
  36. package/src/core/parser/boundary-tracker.ts +458 -0
  37. package/src/core/parser/extractors/base.ts +71 -0
  38. package/src/core/parser/extractors/blade.ts +159 -0
  39. package/src/core/parser/extractors/csharp.ts +248 -0
  40. package/src/core/parser/extractors/django-semantic.ts +655 -0
  41. package/src/core/parser/extractors/elysia-semantic.ts +517 -0
  42. package/src/core/parser/extractors/express-semantic.ts +429 -0
  43. package/src/core/parser/extractors/fastapi-semantic.ts +702 -0
  44. package/src/core/parser/extractors/fastify-semantic.ts +759 -0
  45. package/src/core/parser/extractors/flask-semantic.ts +482 -0
  46. package/src/core/parser/extractors/frontend.ts +149 -0
  47. package/src/core/parser/extractors/go-semantic.ts +670 -0
  48. package/src/core/parser/extractors/go.ts +491 -0
  49. package/src/core/parser/extractors/hono-semantic.ts +546 -0
  50. package/src/core/parser/extractors/java.ts +227 -0
  51. package/src/core/parser/extractors/laravel-semantic.ts +1150 -0
  52. package/src/core/parser/extractors/mcp-cli-semantic.ts +367 -0
  53. package/src/core/parser/extractors/nestjs-semantic.ts +527 -0
  54. package/src/core/parser/extractors/php.ts +585 -0
  55. package/src/core/parser/extractors/python.ts +503 -0
  56. package/src/core/parser/extractors/registry.ts +99 -0
  57. package/src/core/parser/extractors/ruby.ts +237 -0
  58. package/src/core/parser/extractors/rust.ts +304 -0
  59. package/src/core/parser/extractors/semantic-extractor.interface.ts +24 -0
  60. package/src/core/parser/extractors/symfony-semantic.ts +321 -0
  61. package/src/core/parser/extractors/typescript.ts +839 -0
  62. package/src/core/parser/implementation-fingerprint.ts +97 -0
  63. package/src/core/parser/language-capabilities.ts +87 -0
  64. package/src/core/parser/schema/providers/laravel-migration-provider.ts +239 -0
  65. package/src/core/parser/schema/schema-provider-registry.ts +41 -0
  66. package/src/core/parser/schema/schema-provider.interface.ts +34 -0
  67. package/src/core/parser/semantic-revision.ts +3 -0
  68. package/src/core/parser/static-string.ts +51 -0
  69. package/src/core/parser/tree-sitter.ts +63 -0
  70. package/src/core/parser/wasm-assets.ts +25 -0
  71. package/src/core/parser/wasm-loader.ts +274 -0
  72. package/src/core/resolver/call-graph-tracer.ts +1033 -0
  73. package/src/core/resolver/import-resolver.ts +365 -0
  74. package/src/core/resolver/interpretation-inputs.ts +7 -0
  75. package/src/core/resolver/languages/go.ts +103 -0
  76. package/src/core/resolver/languages/managed.ts +200 -0
  77. package/src/core/resolver/languages/python.ts +115 -0
  78. package/src/core/resolver/languages/ruby.ts +40 -0
  79. package/src/core/resolver/languages/rust.ts +127 -0
  80. package/src/core/resolver/languages/shared.ts +71 -0
  81. package/src/core/resolver/module-resolver.ts +486 -0
  82. package/src/core/resolver/path-resolver.ts +200 -0
  83. package/src/core/resolver/slice-catalog.ts +79 -0
  84. package/src/core/resolver/slice-format.ts +9 -0
  85. package/src/core/resolver/symbol-impact.ts +381 -0
  86. package/src/core/resolver/symbol-locator.ts +276 -0
  87. package/src/core/resolver/symbol-reference.ts +53 -0
  88. package/src/core/resolver/vertical-slice-tracer.ts +344 -0
  89. package/src/core/resources/ignore.ts +144 -0
  90. package/src/core/resources/limits.ts +14 -0
  91. package/src/core/resources/source-files.ts +185 -0
  92. package/src/core/resources/source-inventory.ts +55 -0
  93. package/src/core/resources/work-queue.ts +74 -0
  94. package/src/core/retrieval/context-page.ts +109 -0
  95. package/src/core/retrieval/context.ts +320 -0
  96. package/src/core/retrieval/resolution-warnings.ts +21 -0
  97. package/src/core/retrieval/symbol-evidence.ts +97 -0
  98. package/src/core/retrieval/typescript-references.ts +262 -0
  99. package/src/core/telemetry/telemetry.ts +142 -0
  100. package/src/index.ts +18 -0
  101. package/src/mcp/schemas.ts +746 -0
  102. package/src/mcp/server.ts +600 -0
  103. package/src/mcp/tools/boundary.ts +17 -0
  104. package/src/mcp/tools/check-boundary.ts +382 -0
  105. package/src/mcp/tools/get-domain-catalog.ts +39 -0
  106. package/src/mcp/tools/get-symbol-impact.ts +104 -0
  107. package/src/mcp/tools/get-symbol.ts +399 -0
  108. package/src/mcp/tools/locate-symbol.ts +236 -0
  109. package/src/mcp/tools/map.ts +26 -0
  110. package/src/mcp/tools/register-domain.ts +113 -0
  111. package/src/mcp/tools/slice.ts +16 -0
  112. package/src/mcp/tools/symbol.ts +95 -0
  113. package/src/mcp/tools/trace-vertical-slice.ts +106 -0
  114. package/src/mcp/workspace-manager.ts +170 -0
  115. package/src/mcp/workspace-watcher.ts +202 -0
  116. package/src/types/index.ts +438 -0
  117. package/src/types/wasm.d.ts +4 -0
  118. package/src/utils/version-check.ts +209 -0
  119. package/src/version.ts +1 -0
@@ -0,0 +1,491 @@
1
+ import { getLanguageCapability } from "../language-capabilities.ts";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import type { ExtractedDependency, ExtractedSymbol, ParsedFileAST, Visibility } from "../../../types/index.ts";
5
+ import { findBraceBlockEnd, calculateControlFlowNesting } from "../boundary-tracker.ts";
6
+ import type { CodeExtractor } from "./base.ts";
7
+
8
+ const GO_STDLIB_PREFIXES = new Set([
9
+ "bufio",
10
+ "bytes",
11
+ "context",
12
+ "crypto",
13
+ "database",
14
+ "encoding",
15
+ "errors",
16
+ "flag",
17
+ "fmt",
18
+ "html",
19
+ "image",
20
+ "io",
21
+ "log",
22
+ "math",
23
+ "mime",
24
+ "net",
25
+ "os",
26
+ "path",
27
+ "plugin",
28
+ "reflect",
29
+ "regexp",
30
+ "runtime",
31
+ "sort",
32
+ "strconv",
33
+ "strings",
34
+ "sync",
35
+ "syscall",
36
+ "testing",
37
+ "text",
38
+ "time",
39
+ "unicode",
40
+ "unsafe",
41
+ ]);
42
+
43
+ import type Parser from "web-tree-sitter";
44
+ import { blankCommentsAndStrings } from "../boundary-tracker.ts";
45
+ import { calculateAstControlFlowNesting, getNodeHeader, parseSourceWithTreeSitter } from "../wasm-loader.ts";
46
+
47
+ const GO_CONTROL_FLOW_NODES = new Set([
48
+ "if_statement",
49
+ "for_statement",
50
+ "expression_switch_statement",
51
+ "type_switch_statement",
52
+ "select_statement",
53
+ ]);
54
+
55
+ const GO_FUNCTION_BOUNDARY_NODES = new Set([
56
+ "function_declaration",
57
+ "method_declaration",
58
+ "func_literal",
59
+ ]);
60
+
61
+ export class GoExtractor implements CodeExtractor {
62
+ public canHandle(filePath: string): boolean {
63
+ return getLanguageCapability(filePath)?.extractor === "go";
64
+ }
65
+
66
+ public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
67
+ const astResult = await parseSourceWithTreeSitter("go", content, (rootNode) =>
68
+ this.extractFromAst(rootNode, filePath, content),
69
+ () => this.extractFallback(filePath, content)
70
+ );
71
+ if (astResult) {
72
+ return astResult;
73
+ }
74
+
75
+ return { ...this.extractFallback(filePath, content), status: "degraded" };
76
+ }
77
+
78
+ private extractFallback(filePath: string, content: string): ParsedFileAST {
79
+ const symbols: ExtractedSymbol[] = [];
80
+ const dependencies: ExtractedDependency[] = [];
81
+
82
+ const lines = content.split("\n");
83
+ const cleanLines = blankCommentsAndStrings(content).split("\n");
84
+
85
+ // 1. Extract Go Imports
86
+ let inImportBlock = false;
87
+
88
+ for (let i = 0; i < lines.length; i++) {
89
+ const line = lines[i];
90
+ const trimmed = line.trim();
91
+ const cleanTrimmed = cleanLines[i].trim();
92
+ const lineNum = i + 1;
93
+
94
+ if (!cleanTrimmed || trimmed.startsWith("//")) continue;
95
+
96
+ if (cleanTrimmed.startsWith("import (")) {
97
+ inImportBlock = true;
98
+ continue;
99
+ }
100
+
101
+ if (inImportBlock) {
102
+ if (cleanTrimmed === ")") {
103
+ inImportBlock = false;
104
+ continue;
105
+ }
106
+
107
+ const blockMatch = /^(?:([\w.]+)\s+)?["'`]([^"'`]+)["'`]/.exec(trimmed);
108
+ if (blockMatch) {
109
+ const alias = blockMatch[1];
110
+ const importPath = blockMatch[2];
111
+ const isExternal = this.isExternalImport(importPath, filePath);
112
+ const pkgSymbol = alias && alias !== "." && alias !== "_" ? alias : importPath.split("/").pop() || importPath;
113
+ dependencies.push({
114
+ target: importPath,
115
+ statement: trimmed,
116
+ line_number: lineNum,
117
+ is_external: isExternal,
118
+ imported_symbols: [pkgSymbol],
119
+ });
120
+ }
121
+ continue;
122
+ }
123
+
124
+ const singleMatch = /^import\s+(?:([\w.]+)\s+)?["'`]([^"'`]+)["'`]/.exec(trimmed);
125
+ if (singleMatch) {
126
+ const alias = singleMatch[1];
127
+ const importPath = singleMatch[2];
128
+ const isExternal = this.isExternalImport(importPath, filePath);
129
+ const pkgSymbol = alias && alias !== "." && alias !== "_" ? alias : importPath.split("/").pop() || importPath;
130
+ dependencies.push({
131
+ target: importPath,
132
+ statement: trimmed,
133
+ line_number: lineNum,
134
+ is_external: isExternal,
135
+ imported_symbols: [pkgSymbol],
136
+ });
137
+ }
138
+ }
139
+
140
+ // 2. Extract Go Types, Structs, Interfaces, Constants, and Functions
141
+ let inConstBlock = false;
142
+ for (let i = 0; i < cleanLines.length; i++) {
143
+ const trimmed = cleanLines[i].trim();
144
+ const rawTrimmed = lines[i].trim();
145
+ const lineNum = i + 1;
146
+
147
+ if (!trimmed) continue;
148
+
149
+ if (trimmed.startsWith("const (")) {
150
+ inConstBlock = true;
151
+ continue;
152
+ }
153
+ if (inConstBlock) {
154
+ if (trimmed === ")") {
155
+ inConstBlock = false;
156
+ continue;
157
+ }
158
+ const constIdMatch = /^([A-Za-z0-9_]+)/.exec(trimmed);
159
+ if (constIdMatch && constIdMatch[1] !== "_") {
160
+ const constName = constIdMatch[1];
161
+ const visibility: Visibility = /^[A-Z]/.test(constName) ? "public" : "private";
162
+ symbols.push({
163
+ name: constName,
164
+ kind: "constant",
165
+ signature: rawTrimmed.replace(/;$/, "").trim(),
166
+ visibility,
167
+ line_start: lineNum,
168
+ line_end: lineNum,
169
+ line_count: 1,
170
+ });
171
+ }
172
+ continue;
173
+ }
174
+
175
+ const singleConstMatch = /^const\s+([A-Za-z0-9_]+)\b/.exec(trimmed);
176
+ if (singleConstMatch) {
177
+ const constName = singleConstMatch[1];
178
+ const visibility: Visibility = /^[A-Z]/.test(constName) ? "public" : "private";
179
+ symbols.push({
180
+ name: constName,
181
+ kind: "constant",
182
+ signature: rawTrimmed.replace(/;$/, "").trim(),
183
+ visibility,
184
+ line_start: lineNum,
185
+ line_end: lineNum,
186
+ line_count: 1,
187
+ });
188
+ continue;
189
+ }
190
+
191
+ const typeMatch = /^type\s+([A-Za-z0-9_]+)(?:\[[^\]]*\])?\s+(struct|interface)\b/.exec(trimmed);
192
+ if (typeMatch) {
193
+ const typeName = typeMatch[1];
194
+ const kind = typeMatch[2] === "interface" ? "interface" : "struct";
195
+ const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
196
+ const endLine = findBraceBlockEnd(cleanLines, i);
197
+
198
+ symbols.push({
199
+ name: typeName,
200
+ kind,
201
+ signature: rawTrimmed.replace(/\{$/, "").trim(),
202
+ visibility,
203
+ line_start: lineNum,
204
+ line_end: endLine,
205
+ line_count: Math.max(1, endLine - lineNum + 1),
206
+ });
207
+ continue;
208
+ }
209
+
210
+ const typeDefMatch = /^type\s+([A-Za-z0-9_]+)(?:\[[^\]]*\])?\s+([A-Za-z0-9_]+|\[\]|map|func)\b/.exec(trimmed);
211
+ if (typeDefMatch) {
212
+ const typeName = typeDefMatch[1];
213
+ const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
214
+ symbols.push({
215
+ name: typeName,
216
+ kind: "type",
217
+ signature: rawTrimmed.replace(/\{$/, "").trim(),
218
+ visibility,
219
+ line_start: lineNum,
220
+ line_end: lineNum,
221
+ line_count: 1,
222
+ });
223
+ continue;
224
+ }
225
+
226
+ const methodMatch = /^func\s*\([^)]+\)\s*([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
227
+ if (methodMatch) {
228
+ const methodName = methodMatch[1];
229
+ const visibility: Visibility = /^[A-Z]/.test(methodName) ? "public" : "private";
230
+ const endLine = findBraceBlockEnd(cleanLines, i);
231
+ const nestingDepth = calculateControlFlowNesting(lines, i, endLine - 1);
232
+
233
+ symbols.push({
234
+ name: methodName,
235
+ kind: "method",
236
+ signature: rawTrimmed.replace(/\{$/, "").trim(),
237
+ visibility,
238
+ line_start: lineNum,
239
+ line_end: endLine,
240
+ line_count: Math.max(1, endLine - lineNum + 1),
241
+ nesting_depth: nestingDepth,
242
+ });
243
+ continue;
244
+ }
245
+
246
+ const funcMatch = /^func\s+([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
247
+ if (funcMatch) {
248
+ const funcName = funcMatch[1];
249
+ const visibility: Visibility = /^[A-Z]/.test(funcName) ? "public" : "private";
250
+ const endLine = findBraceBlockEnd(cleanLines, i);
251
+ const nestingDepth = calculateControlFlowNesting(lines, i, endLine - 1);
252
+
253
+ symbols.push({
254
+ name: funcName,
255
+ kind: "function",
256
+ signature: rawTrimmed.replace(/\{$/, "").trim(),
257
+ visibility,
258
+ line_start: lineNum,
259
+ line_end: endLine,
260
+ line_count: Math.max(1, endLine - lineNum + 1),
261
+ nesting_depth: nestingDepth,
262
+ });
263
+ }
264
+ }
265
+
266
+ return {
267
+ symbols,
268
+ dependencies,
269
+ };
270
+ }
271
+
272
+
273
+ private isExternalImport(importPath: string, filePath?: string): boolean {
274
+ if (importPath.startsWith(".") || importPath.startsWith("/")) return false;
275
+ const modName = this.findGoModuleName(filePath);
276
+ if (modName && (importPath === modName || importPath.startsWith(`${modName}/`))) return false;
277
+ if (this.isGoStdlib(importPath)) return true;
278
+ if (modName) return true;
279
+
280
+ if (
281
+ importPath.includes("/domains/") ||
282
+ importPath.includes("/internal/") ||
283
+ importPath.includes("/pkg/")
284
+ ) {
285
+ return false;
286
+ }
287
+
288
+ if (importPath.includes(".")) {
289
+ return true;
290
+ }
291
+
292
+ return false;
293
+ }
294
+
295
+ private findGoModuleName(filePath?: string): string | null {
296
+ if (!filePath) return null;
297
+ try {
298
+ let currentDir = path.dirname(path.resolve(filePath));
299
+ while (currentDir && currentDir !== path.dirname(currentDir)) {
300
+ const goModPath = path.join(currentDir, "go.mod");
301
+ if (fs.existsSync(goModPath)) {
302
+ const content = fs.readFileSync(goModPath, "utf-8");
303
+ const match = /^module\s+([^\s\r\n]+)/m.exec(content);
304
+ if (match) return match[1];
305
+ }
306
+ currentDir = path.dirname(currentDir);
307
+ }
308
+ } catch {}
309
+ return null;
310
+ }
311
+
312
+ private isGoStdlib(importPath: string): boolean {
313
+ const rootSegment = importPath.split("/")[0];
314
+ return GO_STDLIB_PREFIXES.has(rootSegment);
315
+ }
316
+
317
+ private extractFromAst(
318
+ rootNode: Parser.SyntaxNode,
319
+ filePath: string,
320
+ content: string
321
+ ): ParsedFileAST {
322
+ const symbols: ExtractedSymbol[] = [];
323
+ const dependencies: ExtractedDependency[] = [];
324
+ const lines = content.split("\n");
325
+
326
+ const addImportSpec = (specNode: Parser.SyntaxNode): void => {
327
+ const pathNode =
328
+ specNode.childForFieldName("path") ??
329
+ specNode.namedChildren.find(
330
+ (c) => c.type === "interpreted_string_literal" || c.type === "raw_string_literal"
331
+ );
332
+ if (!pathNode) return;
333
+
334
+ const importPath = pathNode.text.replace(/^["'`]|["'`]$/g, "").trim();
335
+ if (!importPath) return;
336
+
337
+ const nameNode =
338
+ specNode.childForFieldName("name") ??
339
+ specNode.namedChildren.find((c) => c.type === "package_identifier" || c.type === "dot" || c.type === "blank_identifier");
340
+ const alias = nameNode?.text?.trim();
341
+ const pkgSymbol =
342
+ alias && alias !== "." && alias !== "_" ? alias : importPath.split("/").pop() || importPath;
343
+
344
+ dependencies.push({
345
+ target: importPath,
346
+ statement: (lines[specNode.startPosition.row] ?? specNode.text).trim(),
347
+ line_number: specNode.startPosition.row + 1,
348
+ is_external: this.isExternalImport(importPath, filePath),
349
+ imported_symbols: [pkgSymbol],
350
+ });
351
+ };
352
+
353
+ for (const node of rootNode.namedChildren) {
354
+ if (node.type === "import_declaration") {
355
+ for (const child of node.namedChildren) {
356
+ if (child.type === "import_spec") {
357
+ addImportSpec(child);
358
+ } else if (child.type === "import_spec_list") {
359
+ for (const spec of child.namedChildren) {
360
+ if (spec.type === "import_spec") {
361
+ addImportSpec(spec);
362
+ }
363
+ }
364
+ }
365
+ }
366
+ continue;
367
+ }
368
+
369
+ if (node.type === "const_declaration") {
370
+ for (const spec of node.namedChildren) {
371
+ if (spec.type !== "const_spec") continue;
372
+ const nameNodes = spec.namedChildren.filter((c) => c.type === "identifier");
373
+ const lineStart = spec.startPosition.row + 1;
374
+ const lineEnd = Math.max(lineStart, spec.endPosition.row + 1);
375
+ const headerLine = (lines[spec.startPosition.row] ?? "").trim().replace(/;$/, "").trim();
376
+
377
+ for (const nameNode of nameNodes) {
378
+ const constName = nameNode.text;
379
+ const visibility: Visibility = /^[A-Z]/.test(constName) ? "public" : "private";
380
+ symbols.push({
381
+ name: constName,
382
+ kind: "constant",
383
+ signature: headerLine || `const ${constName}`,
384
+ visibility,
385
+ line_start: lineStart,
386
+ line_end: lineEnd,
387
+ line_count: Math.max(1, lineEnd - lineStart + 1),
388
+ });
389
+ }
390
+ }
391
+ continue;
392
+ }
393
+
394
+ if (node.type === "type_declaration") {
395
+ for (const spec of node.namedChildren) {
396
+ if (spec.type !== "type_spec" && spec.type !== "type_alias") continue;
397
+ const nameNode =
398
+ spec.childForFieldName("name") ??
399
+ spec.namedChildren.find((c) => c.type === "type_identifier");
400
+ if (!nameNode) continue;
401
+
402
+ const typeName = nameNode.text;
403
+ const typeVal = spec.childForFieldName("type") ?? spec.namedChildren[1];
404
+ const kind: ExtractedSymbol["kind"] =
405
+ typeVal?.type === "interface_type"
406
+ ? "interface"
407
+ : typeVal?.type === "struct_type"
408
+ ? "struct"
409
+ : "type";
410
+ const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
411
+ const lineStart = spec.startPosition.row + 1;
412
+ const lineEnd = Math.max(lineStart, spec.endPosition.row + 1);
413
+ const headerLine = (lines[spec.startPosition.row] ?? "").trim().replace(/\{$/, "").trim();
414
+
415
+ symbols.push({
416
+ name: typeName,
417
+ kind,
418
+ signature: headerLine || `type ${typeName}`,
419
+ visibility,
420
+ line_start: lineStart,
421
+ line_end: lineEnd,
422
+ line_count: Math.max(1, lineEnd - lineStart + 1),
423
+ });
424
+ }
425
+ continue;
426
+ }
427
+
428
+ if (node.type === "method_declaration") {
429
+ const nameNode =
430
+ node.childForFieldName("name") ??
431
+ node.namedChildren.find((c) => c.type === "field_identifier" || c.type === "identifier");
432
+ if (!nameNode) continue;
433
+
434
+ const methodName = nameNode.text;
435
+ const visibility: Visibility = /^[A-Z]/.test(methodName) ? "public" : "private";
436
+ const lineStart = node.startPosition.row + 1;
437
+ const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
438
+ const headerLine = getNodeHeader(node);
439
+ const nestingDepth = calculateAstControlFlowNesting(
440
+ node,
441
+ GO_CONTROL_FLOW_NODES,
442
+ GO_FUNCTION_BOUNDARY_NODES
443
+ );
444
+
445
+ symbols.push({
446
+ name: methodName,
447
+ kind: "method",
448
+ signature: headerLine || `func ${methodName}()`,
449
+ visibility,
450
+ line_start: lineStart,
451
+ line_end: lineEnd,
452
+ line_count: Math.max(1, lineEnd - lineStart + 1),
453
+ nesting_depth: nestingDepth,
454
+ });
455
+ continue;
456
+ }
457
+
458
+ if (node.type === "function_declaration") {
459
+ const nameNode =
460
+ node.childForFieldName("name") ??
461
+ node.namedChildren.find((c) => c.type === "identifier");
462
+ if (!nameNode) continue;
463
+
464
+ const funcName = nameNode.text;
465
+ const visibility: Visibility = /^[A-Z]/.test(funcName) ? "public" : "private";
466
+ const lineStart = node.startPosition.row + 1;
467
+ const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
468
+ const headerLine = getNodeHeader(node);
469
+ const nestingDepth = calculateAstControlFlowNesting(
470
+ node,
471
+ GO_CONTROL_FLOW_NODES,
472
+ GO_FUNCTION_BOUNDARY_NODES
473
+ );
474
+
475
+ symbols.push({
476
+ name: funcName,
477
+ kind: "function",
478
+ signature: headerLine || `func ${funcName}()`,
479
+ visibility,
480
+ line_start: lineStart,
481
+ line_end: lineEnd,
482
+ line_count: Math.max(1, lineEnd - lineStart + 1),
483
+ nesting_depth: nestingDepth,
484
+ });
485
+ }
486
+ }
487
+
488
+ return { symbols, dependencies };
489
+ }
490
+ }
491
+