@dimassetoid/septum-mcp 0.2.1 → 0.5.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 (161) hide show
  1. package/README.md +46 -45
  2. package/package.json +8 -6
  3. package/src/cli/commands/check.ts +41 -26
  4. package/src/cli/commands/hook.ts +77 -105
  5. package/src/cli/commands/init.ts +35 -9
  6. package/src/cli/commands/stats.ts +33 -0
  7. package/src/cli/commands/sync-progress.ts +71 -0
  8. package/src/cli/commands/sync.ts +35 -9
  9. package/src/cli/hook-payload.ts +43 -0
  10. package/src/cli/index.ts +15 -51
  11. package/src/cli/scaffold/harness-config.ts +48 -8
  12. package/src/cli/templates/hooks.ts +51 -27
  13. package/src/cli/templates/rules.ts +34 -49
  14. package/src/cli/templates/skill.ts +46 -35
  15. package/src/core/boundary/audit.ts +383 -0
  16. package/src/core/boundary/evaluator.ts +299 -178
  17. package/src/core/boundary/staged-auditor.ts +188 -34
  18. package/src/core/config/domain-ownership.ts +47 -0
  19. package/src/core/config/domain-registration.ts +141 -0
  20. package/src/core/config/loader.ts +82 -54
  21. package/src/core/config/schema.ts +24 -46
  22. package/src/core/database/client.ts +2 -0
  23. package/src/core/database/repositories/dependency.repository.ts +326 -543
  24. package/src/core/database/repositories/domain.repository.ts +48 -4
  25. package/src/core/database/repositories/file.repository.ts +10 -0
  26. package/src/core/database/repositories/symbol.repository.ts +97 -259
  27. package/src/core/database/repository.ts +138 -24
  28. package/src/core/database/schema.ts +28 -33
  29. package/src/core/discovery/declarative-routes.ts +69 -0
  30. package/src/core/discovery/framework-detector.ts +149 -0
  31. package/src/core/discovery/navigation.ts +269 -0
  32. package/src/core/discovery/topology-detector.ts +153 -170
  33. package/src/core/errors.ts +19 -0
  34. package/src/core/ingestion/pipeline.ts +378 -212
  35. package/src/core/parser/behavioral-analyzer.ts +26 -22
  36. package/src/core/parser/boundary-tracker.ts +15 -0
  37. package/src/core/parser/extractors/base.ts +16 -4
  38. package/src/core/parser/extractors/csharp.ts +9 -5
  39. package/src/core/parser/extractors/django-routing.ts +163 -0
  40. package/src/core/parser/extractors/django-semantic.ts +400 -516
  41. package/src/core/parser/extractors/elysia-semantic.ts +172 -496
  42. package/src/core/parser/extractors/express-semantic.ts +195 -398
  43. package/src/core/parser/extractors/fastapi-semantic.ts +182 -399
  44. package/src/core/parser/extractors/fastify-semantic.ts +216 -732
  45. package/src/core/parser/extractors/flask-semantic.ts +92 -388
  46. package/src/core/parser/extractors/go-routing.ts +344 -0
  47. package/src/core/parser/extractors/go-semantic.ts +210 -508
  48. package/src/core/parser/extractors/go.ts +6 -3
  49. package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
  50. package/src/core/parser/extractors/hono-semantic.ts +132 -530
  51. package/src/core/parser/extractors/java.ts +7 -5
  52. package/src/core/parser/extractors/laravel-routing.ts +263 -0
  53. package/src/core/parser/extractors/laravel-semantic.ts +169 -333
  54. package/src/core/parser/extractors/manifest-helpers.ts +64 -0
  55. package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
  56. package/src/core/parser/extractors/mcp-cli-semantic.ts +84 -336
  57. package/src/core/parser/extractors/nestjs-semantic.ts +238 -510
  58. package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
  59. package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
  60. package/src/core/parser/extractors/php.ts +17 -1
  61. package/src/core/parser/extractors/python-route-ast.ts +249 -0
  62. package/src/core/parser/extractors/python.ts +9 -8
  63. package/src/core/parser/extractors/registry.ts +28 -5
  64. package/src/core/parser/extractors/route-prefixes.ts +43 -0
  65. package/src/core/parser/extractors/ruby.ts +10 -7
  66. package/src/core/parser/extractors/rust.ts +35 -17
  67. package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
  68. package/src/core/parser/extractors/symfony-routing.ts +114 -0
  69. package/src/core/parser/extractors/symfony-semantic.ts +75 -262
  70. package/src/core/parser/extractors/typescript-bindings.ts +333 -0
  71. package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
  72. package/src/core/parser/extractors/typescript-fallback.ts +207 -0
  73. package/src/core/parser/extractors/typescript-route-context.ts +58 -0
  74. package/src/core/parser/extractors/typescript.ts +36 -216
  75. package/src/core/parser/implementation-fingerprint.ts +97 -0
  76. package/src/core/parser/language-capabilities.ts +23 -7
  77. package/src/core/parser/schema/providers/laravel-migration-provider.ts +77 -51
  78. package/src/core/parser/schema/schema-provider-registry.ts +1 -3
  79. package/src/core/parser/schema/schema-provider.interface.ts +2 -1
  80. package/src/core/parser/semantic-revision.ts +3 -0
  81. package/src/core/parser/static-string.ts +51 -0
  82. package/src/core/parser/wasm-loader.ts +6 -2
  83. package/src/core/resolver/ast-method-tracer.ts +230 -0
  84. package/src/core/resolver/call-graph-helpers.ts +72 -0
  85. package/src/core/resolver/call-graph-tracer.ts +375 -311
  86. package/src/core/resolver/dependency-analysis.ts +593 -0
  87. package/src/core/resolver/import-candidates.ts +120 -0
  88. package/src/core/resolver/import-evidence.ts +88 -0
  89. package/src/core/resolver/import-resolver.ts +162 -181
  90. package/src/core/resolver/interpretation-inputs.ts +65 -0
  91. package/src/core/resolver/languages/go.ts +103 -0
  92. package/src/core/resolver/languages/managed.ts +200 -0
  93. package/src/core/resolver/languages/python.ts +133 -0
  94. package/src/core/resolver/languages/ruby.ts +40 -0
  95. package/src/core/resolver/languages/rust.ts +127 -0
  96. package/src/core/resolver/languages/shared.ts +74 -0
  97. package/src/core/resolver/module-resolver.ts +18 -7
  98. package/src/core/resolver/path-resolver.ts +6 -3
  99. package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
  100. package/src/core/resolver/slice-catalog.ts +94 -0
  101. package/src/core/resolver/slice-format.ts +22 -0
  102. package/src/core/resolver/slice-selection.ts +237 -0
  103. package/src/core/resolver/symbol-impact.ts +477 -0
  104. package/src/core/resolver/symbol-locator.ts +82 -15
  105. package/src/core/resolver/vertical-slice-tracer.ts +57 -278
  106. package/src/core/resources/ignore.ts +21 -1
  107. package/src/core/resources/limits.ts +2 -1
  108. package/src/core/resources/source-files.ts +143 -20
  109. package/src/core/resources/source-inventory.ts +55 -0
  110. package/src/core/resources/work-queue.ts +167 -4
  111. package/src/core/retrieval/context-page.ts +116 -0
  112. package/src/core/retrieval/context.ts +457 -0
  113. package/src/core/retrieval/resolution-warnings.ts +21 -0
  114. package/src/core/retrieval/source-context.ts +448 -0
  115. package/src/core/retrieval/symbol-details.ts +453 -0
  116. package/src/core/retrieval/symbol-evidence.ts +97 -0
  117. package/src/core/retrieval/typescript-references.ts +293 -0
  118. package/src/core/retrieval/universal-context.ts +182 -0
  119. package/src/core/telemetry/summary.ts +114 -0
  120. package/src/core/telemetry/telemetry.ts +225 -37
  121. package/src/index.ts +0 -3
  122. package/src/mcp/formatters/compact-text.ts +439 -0
  123. package/src/mcp/resources-and-prompts.ts +253 -0
  124. package/src/mcp/schemas/boundary.ts +145 -0
  125. package/src/mcp/schemas/map.ts +250 -0
  126. package/src/mcp/schemas/shared.ts +52 -0
  127. package/src/mcp/schemas/slice.ts +60 -0
  128. package/src/mcp/schemas/symbol.ts +268 -0
  129. package/src/mcp/schemas.ts +5 -1105
  130. package/src/mcp/server.ts +263 -597
  131. package/src/mcp/tool-catalog.ts +331 -0
  132. package/src/mcp/tools/boundary.ts +69 -4
  133. package/src/mcp/tools/map.ts +126 -0
  134. package/src/mcp/tools/slice.ts +101 -3
  135. package/src/mcp/tools/symbol.ts +480 -26
  136. package/src/mcp/ui/app-client.ts +899 -0
  137. package/src/mcp/ui/app.html +478 -0
  138. package/src/mcp/workflow-playbooks.ts +181 -0
  139. package/src/mcp/workspace-boundary.ts +50 -0
  140. package/src/mcp/workspace-manager.ts +102 -18
  141. package/src/mcp/workspace-watcher.ts +38 -19
  142. package/src/types/index.ts +47 -53
  143. package/src/cli/commands/topology.ts +0 -161
  144. package/src/core/database/repositories/environment.repository.ts +0 -207
  145. package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
  146. package/src/core/session/session-manager.ts +0 -107
  147. package/src/core/topology/environment-detector.ts +0 -973
  148. package/src/core/topology/types.ts +0 -83
  149. package/src/mcp/tools/check-boundary.ts +0 -387
  150. package/src/mcp/tools/domain.ts +0 -40
  151. package/src/mcp/tools/feature.ts +0 -67
  152. package/src/mcp/tools/get-domain-catalog.ts +0 -226
  153. package/src/mcp/tools/get-environment-topology.ts +0 -138
  154. package/src/mcp/tools/get-feature-context.ts +0 -224
  155. package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
  156. package/src/mcp/tools/get-symbol-impact.ts +0 -64
  157. package/src/mcp/tools/get-symbol.ts +0 -175
  158. package/src/mcp/tools/locate-symbol.ts +0 -196
  159. package/src/mcp/tools/register-domain.ts +0 -75
  160. package/src/mcp/tools/register-feature.ts +0 -110
  161. package/src/mcp/tools/trace-vertical-slice.ts +0 -80
@@ -0,0 +1,43 @@
1
+ /** Accumulate all mount paths at each router before propagating them to descendants. */
2
+ export function composeMountPrefixes<Key>(
3
+ roots: ReadonlyMap<Key, string | undefined>,
4
+ mounts: ReadonlyArray<{ parent: Key; child: Key; prefix: string | undefined }>,
5
+ signal?: AbortSignal,
6
+ ): Map<Key, Set<string>> {
7
+ const children = new Map<Key, typeof mounts[number][]>();
8
+ const incoming = new Map<Key, number>();
9
+ for (const mount of mounts) {
10
+ const edges = children.get(mount.parent) ?? [];
11
+ edges.push(mount);
12
+ children.set(mount.parent, edges);
13
+ incoming.set(mount.child, (incoming.get(mount.child) ?? 0) + 1);
14
+ }
15
+
16
+ const prefixes = new Map<Key, Set<string>>();
17
+ const queue: Key[] = [];
18
+ for (const [key, prefix] of roots) {
19
+ if (incoming.has(key)) continue;
20
+ queue.push(key);
21
+ prefixes.set(key, new Set(prefix === undefined ? [] : [prefix]));
22
+ }
23
+ for (let index = 0; index < queue.length; index++) {
24
+ signal?.throwIfAborted();
25
+ const parent = queue[index]!;
26
+ for (const edge of children.get(parent) ?? []) {
27
+ const paths = prefixes.get(edge.child) ?? new Set<string>();
28
+ if (edge.prefix !== undefined) {
29
+ for (const path of prefixes.get(parent) ?? []) {
30
+ signal?.throwIfAborted();
31
+ paths.add(path + edge.prefix);
32
+ }
33
+ }
34
+ prefixes.set(edge.child, paths);
35
+ const remaining = incoming.get(edge.child)! - 1;
36
+ incoming.set(edge.child, remaining);
37
+ if (!remaining) queue.push(edge.child);
38
+ }
39
+ }
40
+ // Cycles (and routes depending on them) have no complete registration path.
41
+ for (const [key, remaining] of incoming) if (remaining) prefixes.delete(key);
42
+ return prefixes;
43
+ }
@@ -79,19 +79,22 @@ export class RubyExtractor implements CodeExtractor {
79
79
  continue;
80
80
  }
81
81
  }
82
- if (methodName === "require" || methodName === "require_relative") {
82
+ if ((methodName === "require" || methodName === "require_relative") && !child.childForFieldName("receiver")) {
83
83
  const argsNode = child.childForFieldName("arguments") ?? child.namedChildren[1];
84
84
  if (argsNode) {
85
- const rawTarget = argsNode.text.replace(/^["':]|["']$/g, "").trim();
85
+ const arg = argsNode.namedChildren[0];
86
+ const literal = arg?.type === "string" && !arg.namedChildren.some(c => c.type === "interpolation")
87
+ && !arg.text.includes("\\") && argsNode.namedChildren.length === 1;
88
+ const rawTarget = literal ? arg.text.slice(1, -1) : `dynamic:${child.text}`;
86
89
  const isRel = methodName === "require_relative";
87
90
  const leaf = rawTarget.split("/").pop() || rawTarget;
88
91
 
89
92
  dependencies.push({
90
93
  target: rawTarget,
91
- statement: (lines[child.startPosition.row] ?? child.text).trim(),
94
+ statement: child.text.trim(),
92
95
  line_number: child.startPosition.row + 1,
93
- is_external: this.isExternalRequire(rawTarget, isRel),
94
- imported_symbols: [leaf],
96
+ is_external: literal ? this.isExternalRequire(rawTarget, isRel) : false,
97
+ ...(literal ? { imported_symbols: [leaf] } : {}),
95
98
  });
96
99
  }
97
100
  }
@@ -107,7 +110,7 @@ export class RubyExtractor implements CodeExtractor {
107
110
  const fullName = scopeName ? `${scopeName}::${baseName}` : baseName;
108
111
  const lineStart = child.startPosition.row + 1;
109
112
  const lineEnd = Math.max(lineStart, child.endPosition.row + 1);
110
- const headerLine = getNodeHeader(child);
113
+ const headerLine = getNodeHeader(child, content);
111
114
  const kind = child.type === "class" ? "class" : "interface";
112
115
 
113
116
  symbols.push({
@@ -142,7 +145,7 @@ export class RubyExtractor implements CodeExtractor {
142
145
  : methodName;
143
146
  const lineStart = child.startPosition.row + 1;
144
147
  const lineEnd = Math.max(lineStart, child.endPosition.row + 1);
145
- const headerLine = getNodeHeader(child);
148
+ const headerLine = getNodeHeader(child, content);
146
149
  const nestingDepth = calculateAstControlFlowNesting(
147
150
  child,
148
151
  RUBY_CONTROL_FLOW_NODES,
@@ -68,23 +68,41 @@ export class RustExtractor implements CodeExtractor {
68
68
  const body = node.childForFieldName("body");
69
69
  if (name && body) {
70
70
  for (const child of body.namedChildren) processItem(child, qualify(name.text));
71
+ } else if (name) {
72
+ dependencies.push({ target: `mod:${name.text}`, statement: node.text.trim(),
73
+ line_number: node.startPosition.row + 1, is_external: false, imported_symbols: [name.text] });
71
74
  }
72
75
  return;
73
76
  }
74
77
  if (node.type === "use_declaration") {
75
- const text = (lines[node.startPosition.row] ?? node.text).trim().replace(/;$/, "");
76
- const argumentNode = node.namedChildren.find((c) => c.type !== "visibility_modifier");
77
- const fullUsePath = argumentNode ? argumentNode.text : text.replace(/^pub\s+use\s+|^use\s+/, "");
78
- const rawImport = fullUsePath.trim();
79
- const leafSymbol = rawImport.split("::").pop()?.replace(/[{}\s]/g, "") || rawImport;
80
-
81
- dependencies.push({
82
- target: rawImport,
83
- statement: text,
84
- line_number: node.startPosition.row + 1,
85
- is_external: this.isExternalUse(rawImport),
86
- imported_symbols: [leafSymbol],
87
- });
78
+ const argument = node.childForFieldName("argument");
79
+ const addUse = (item: Parser.SyntaxNode, prefix = ""): void => {
80
+ if (item.type === "line_comment" || item.type === "block_comment") return;
81
+ if (item.type === "scoped_use_list") {
82
+ const scope = item.childForFieldName("path")?.text;
83
+ const list = item.childForFieldName("list");
84
+ const nestedPrefix = [prefix, scope].filter(Boolean).join("::");
85
+ if (list) for (const child of list.namedChildren) addUse(child, nestedPrefix);
86
+ return;
87
+ }
88
+ if (item.type === "use_list") {
89
+ for (const child of item.namedChildren) addUse(child, prefix);
90
+ return;
91
+ }
92
+ const alias = item.type === "use_as_clause" ? item.childForFieldName("alias")?.text : undefined;
93
+ const importPath = item.type === "use_as_clause" ? item.childForFieldName("path")?.text : item.text;
94
+ if (!importPath) return;
95
+ const target = importPath === "self" && prefix ? prefix : [prefix, importPath].filter(Boolean).join("::");
96
+ const leaf = target.split("::").pop()!;
97
+ dependencies.push({
98
+ target,
99
+ statement: node.text.trim().replace(/;$/, ""),
100
+ line_number: node.startPosition.row + 1,
101
+ is_external: this.isExternalUse(target),
102
+ imported_symbols: [...new Set([leaf, ...(alias ? [alias] : [])])],
103
+ });
104
+ };
105
+ if (argument) addUse(argument);
88
106
  return;
89
107
  }
90
108
 
@@ -97,7 +115,7 @@ export class RustExtractor implements CodeExtractor {
97
115
  const fnName = nameNode.text;
98
116
  const lineStart = node.startPosition.row + 1;
99
117
  const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
100
- const headerLine = getNodeHeader(node);
118
+ const headerLine = getNodeHeader(node, content);
101
119
  const nestingDepth = calculateAstControlFlowNesting(
102
120
  node,
103
121
  RUST_CONTROL_FLOW_NODES,
@@ -126,7 +144,7 @@ export class RustExtractor implements CodeExtractor {
126
144
  const structName = nameNode.text;
127
145
  const lineStart = node.startPosition.row + 1;
128
146
  const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
129
- const headerLine = getNodeHeader(node);
147
+ const headerLine = getNodeHeader(node, content);
130
148
 
131
149
  symbols.push({
132
150
  name: qualify(structName),
@@ -150,7 +168,7 @@ export class RustExtractor implements CodeExtractor {
150
168
  const enumName = nameNode.text;
151
169
  const lineStart = node.startPosition.row + 1;
152
170
  const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
153
- const headerLine = getNodeHeader(node);
171
+ const headerLine = getNodeHeader(node, content);
154
172
 
155
173
  symbols.push({
156
174
  name: qualify(enumName),
@@ -174,7 +192,7 @@ export class RustExtractor implements CodeExtractor {
174
192
  const traitName = nameNode.text;
175
193
  const lineStart = node.startPosition.row + 1;
176
194
  const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
177
- const headerLine = getNodeHeader(node);
195
+ const headerLine = getNodeHeader(node, content);
178
196
 
179
197
  symbols.push({
180
198
  name: qualify(traitName),
@@ -1,4 +1,5 @@
1
1
  import type { VerticalSliceRecord } from "../../../types/index.ts";
2
+ import type { SourceInventory } from "../../resources/source-inventory.ts";
2
3
 
3
4
  export type VerticalSliceCandidate = Omit<VerticalSliceRecord, "id" | "created_at">;
4
5
 
@@ -17,6 +18,7 @@ export interface SemanticSliceExtractor {
17
18
  extractSlices(
18
19
  projectRoot: string,
19
20
  domainId?: number,
20
- signal?: AbortSignal
21
+ signal?: AbortSignal,
22
+ inventory?: SourceInventory
21
23
  ): Promise<VerticalSliceCandidate[]> | VerticalSliceCandidate[];
22
24
  }
@@ -0,0 +1,114 @@
1
+ import type Parser from "web-tree-sitter";
2
+ import { children, importsFor, literal, phpSections } from "./php-ast-helpers.ts";
3
+
4
+ type Node = Parser.SyntaxNode;
5
+ type RouteAttribute = { path: string; name?: string; methods: string[] };
6
+ type ResolveClass = (name: string) => string | undefined;
7
+
8
+ const routeClasses = new Set([
9
+ "symfony\\component\\routing\\attribute\\route",
10
+ "symfony\\component\\routing\\annotation\\route",
11
+ ]);
12
+
13
+ function routeAttributes(node: Node, resolveClass: ResolveClass): Node[] {
14
+ return children(node.childForFieldName("attributes")).flatMap(group =>
15
+ children(group).filter(attribute => {
16
+ const name = children(attribute)[0];
17
+ return attribute.type === "attribute" && !!name &&
18
+ routeClasses.has(resolveClass(name.text)?.toLowerCase() ?? "");
19
+ })
20
+ );
21
+ }
22
+
23
+ function readAttribute(node: Node): RouteAttribute | undefined {
24
+ if (node.hasError) return undefined;
25
+ const fields = new Map<string, Node>();
26
+ const positional = ["path", "name", "requirements", "options", "defaults", "host", "methods"];
27
+ let position = 0;
28
+ for (const arg of children(node.childForFieldName("parameters"))) {
29
+ const label = arg.childForFieldName("name");
30
+ const key = label?.text ?? positional[position++];
31
+ const values = children(arg).slice(label ? 1 : 0);
32
+ if (arg.type !== "argument" || values.length !== 1 || values[0]?.type === "variadic_unpacking") return undefined;
33
+ if (key && fields.has(key)) return undefined;
34
+ if (key) fields.set(key, values[0]!);
35
+ }
36
+
37
+ const pathNode = fields.get("path");
38
+ const nameNode = fields.get("name");
39
+ const path = !pathNode || pathNode.type === "null" ? "" : literal(pathNode);
40
+ const name = literal(nameNode);
41
+ if (path === undefined || (nameNode && nameNode.type !== "null" && name === undefined)) return undefined;
42
+
43
+ const methodNode = fields.get("methods");
44
+ const values = methodNode?.type === "array_creation_expression"
45
+ ? children(methodNode).map(item => {
46
+ const parts = children(item);
47
+ return parts.length === 1 ? literal(parts[0]) : undefined;
48
+ })
49
+ : methodNode ? [literal(methodNode)] : [];
50
+ if (!values.every((value): value is string => value !== undefined && /^[a-z][a-z-]*$/i.test(value))) return undefined;
51
+ return { path, name, methods: values.map(value => value.toUpperCase()) };
52
+ }
53
+
54
+ export function visitSymfonyRoutes(
55
+ root: Node,
56
+ visit: (route: {
57
+ uri: string;
58
+ name?: string;
59
+ methods: string[];
60
+ className: string;
61
+ action: Node;
62
+ resolveClass: ResolveClass;
63
+ }) => void,
64
+ signal?: AbortSignal,
65
+ ): void {
66
+ for (const { namespace, statements } of phpSections(root)) {
67
+ const imports = importsFor(statements);
68
+ const resolveClass: ResolveClass = name => {
69
+ if (name.startsWith("\\")) return name.slice(1);
70
+ const [head, ...tail] = name.split("\\");
71
+ const key = head!.toLowerCase();
72
+ if (key === "namespace" && tail.length) return [namespace, ...tail].filter(Boolean).join("\\");
73
+ if (!imports.has(key)) return [namespace, name].filter(Boolean).join("\\");
74
+ const imported = imports.get(key);
75
+ return imported ? [imported, ...tail].join("\\") : undefined;
76
+ };
77
+
78
+ for (const node of statements) {
79
+ signal?.throwIfAborted();
80
+ if (node.type !== "class_declaration" || children(node).some(child => child.type === "abstract_modifier")) continue;
81
+ const name = node.childForFieldName("name")?.text;
82
+ if (!name) continue;
83
+ const className = [namespace, name].filter(Boolean).join("\\");
84
+ const classAttributes = routeAttributes(node, resolveClass);
85
+ const methods = children(node.childForFieldName("body"))
86
+ .filter(member => member.type === "method_declaration" && member.childForFieldName("body"))
87
+ .map(action => ({ action, attributes: routeAttributes(action, resolveClass) }));
88
+
89
+ const emit = (action: Node, attributes: Node[], prefix?: RouteAttribute) => {
90
+ for (const attribute of attributes) {
91
+ signal?.throwIfAborted();
92
+ const route = readAttribute(attribute);
93
+ if (!route) continue;
94
+ const methods = [...new Set([...(prefix?.methods ?? []), ...route.methods])];
95
+ const uri = "/" + [prefix?.path, route.path].filter(Boolean).join("").replace(/^\/+/, "");
96
+ visit({
97
+ uri, name: route.name === undefined ? undefined : (prefix?.name ?? "") + route.name,
98
+ methods: methods.length ? methods : ["ANY"], className, action, resolveClass,
99
+ });
100
+ }
101
+ };
102
+
103
+ if (methods.some(method => method.attributes.length)) {
104
+ const prefixAttribute = classAttributes[0];
105
+ const prefix = prefixAttribute && readAttribute(prefixAttribute);
106
+ if (prefixAttribute && !prefix) continue;
107
+ for (const { action, attributes } of methods) emit(action, attributes, prefix);
108
+ } else {
109
+ const invokable = methods.find(({ action }) => action.childForFieldName("name")?.text.toLowerCase() === "__invoke");
110
+ if (invokable) emit(invokable.action, classAttributes);
111
+ }
112
+ }
113
+ }
114
+ }