@dimassetoid/septum-mcp 0.3.0 → 0.5.1

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 (129) hide show
  1. package/README.md +38 -55
  2. package/package.json +7 -5
  3. package/src/cli/commands/check.ts +14 -10
  4. package/src/cli/commands/hook.ts +41 -6
  5. package/src/cli/commands/init.ts +10 -1
  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 +32 -4
  9. package/src/cli/index.ts +7 -0
  10. package/src/cli/templates/hooks.ts +3 -14
  11. package/src/cli/templates/skill.ts +17 -10
  12. package/src/core/boundary/audit.ts +383 -0
  13. package/src/core/boundary/evaluator.ts +251 -114
  14. package/src/core/boundary/staged-auditor.ts +147 -55
  15. package/src/core/config/domain-ownership.ts +6 -4
  16. package/src/core/config/domain-registration.ts +141 -0
  17. package/src/core/config/loader.ts +1 -25
  18. package/src/core/config/schema.ts +24 -36
  19. package/src/core/database/client.ts +2 -0
  20. package/src/core/database/repositories/dependency.repository.ts +334 -572
  21. package/src/core/database/repositories/domain.repository.ts +2 -1
  22. package/src/core/database/repositories/file.repository.ts +10 -0
  23. package/src/core/database/repositories/symbol.repository.ts +97 -398
  24. package/src/core/database/repository.ts +68 -9
  25. package/src/core/database/schema.ts +26 -0
  26. package/src/core/discovery/declarative-routes.ts +69 -0
  27. package/src/core/discovery/framework-detector.ts +149 -0
  28. package/src/core/discovery/navigation.ts +222 -58
  29. package/src/core/discovery/topology-detector.ts +93 -168
  30. package/src/core/errors.ts +19 -0
  31. package/src/core/ingestion/pipeline.ts +287 -88
  32. package/src/core/parser/extractors/base.ts +11 -3
  33. package/src/core/parser/extractors/csharp.ts +2 -2
  34. package/src/core/parser/extractors/django-routing.ts +163 -0
  35. package/src/core/parser/extractors/django-semantic.ts +397 -481
  36. package/src/core/parser/extractors/elysia-semantic.ts +172 -475
  37. package/src/core/parser/extractors/express-semantic.ts +195 -383
  38. package/src/core/parser/extractors/fastapi-semantic.ts +178 -361
  39. package/src/core/parser/extractors/fastify-semantic.ts +216 -717
  40. package/src/core/parser/extractors/flask-semantic.ts +89 -352
  41. package/src/core/parser/extractors/go-routing.ts +344 -0
  42. package/src/core/parser/extractors/go-semantic.ts +205 -562
  43. package/src/core/parser/extractors/go.ts +6 -3
  44. package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
  45. package/src/core/parser/extractors/hono-semantic.ts +132 -509
  46. package/src/core/parser/extractors/java.ts +2 -2
  47. package/src/core/parser/extractors/laravel-routing.ts +263 -0
  48. package/src/core/parser/extractors/laravel-semantic.ts +143 -335
  49. package/src/core/parser/extractors/manifest-helpers.ts +64 -0
  50. package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
  51. package/src/core/parser/extractors/mcp-cli-semantic.ts +82 -333
  52. package/src/core/parser/extractors/nestjs-semantic.ts +238 -494
  53. package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
  54. package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
  55. package/src/core/parser/extractors/php.ts +1 -1
  56. package/src/core/parser/extractors/python-route-ast.ts +249 -0
  57. package/src/core/parser/extractors/python.ts +5 -9
  58. package/src/core/parser/extractors/registry.ts +2 -0
  59. package/src/core/parser/extractors/route-prefixes.ts +43 -0
  60. package/src/core/parser/extractors/ruby.ts +2 -2
  61. package/src/core/parser/extractors/rust.ts +4 -4
  62. package/src/core/parser/extractors/symfony-routing.ts +114 -0
  63. package/src/core/parser/extractors/symfony-semantic.ts +72 -226
  64. package/src/core/parser/extractors/typescript-bindings.ts +333 -0
  65. package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
  66. package/src/core/parser/extractors/typescript-fallback.ts +207 -0
  67. package/src/core/parser/extractors/typescript-route-context.ts +58 -0
  68. package/src/core/parser/extractors/typescript.ts +23 -216
  69. package/src/core/parser/language-capabilities.ts +1 -1
  70. package/src/core/parser/schema/providers/laravel-migration-provider.ts +4 -1
  71. package/src/core/parser/wasm-loader.ts +6 -2
  72. package/src/core/resolver/ast-method-tracer.ts +230 -0
  73. package/src/core/resolver/call-graph-helpers.ts +72 -0
  74. package/src/core/resolver/call-graph-tracer.ts +169 -414
  75. package/src/core/resolver/dependency-analysis.ts +593 -0
  76. package/src/core/resolver/import-candidates.ts +120 -0
  77. package/src/core/resolver/import-evidence.ts +88 -0
  78. package/src/core/resolver/import-resolver.ts +60 -7
  79. package/src/core/resolver/interpretation-inputs.ts +60 -2
  80. package/src/core/resolver/languages/python.ts +31 -13
  81. package/src/core/resolver/languages/shared.ts +4 -1
  82. package/src/core/resolver/module-resolver.ts +10 -3
  83. package/src/core/resolver/path-resolver.ts +6 -3
  84. package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
  85. package/src/core/resolver/slice-catalog.ts +21 -6
  86. package/src/core/resolver/slice-format.ts +13 -0
  87. package/src/core/resolver/slice-selection.ts +237 -0
  88. package/src/core/resolver/symbol-impact.ts +104 -8
  89. package/src/core/resolver/symbol-locator.ts +82 -15
  90. package/src/core/resolver/vertical-slice-tracer.ts +31 -230
  91. package/src/core/resources/ignore.ts +0 -1
  92. package/src/core/resources/limits.ts +2 -1
  93. package/src/core/resources/work-queue.ts +167 -4
  94. package/src/core/retrieval/context-page.ts +11 -4
  95. package/src/core/retrieval/context.ts +363 -226
  96. package/src/{mcp/tools/get-symbol.ts → core/retrieval/source-context.ts} +145 -96
  97. package/src/core/retrieval/symbol-details.ts +453 -0
  98. package/src/core/retrieval/symbol-evidence.ts +3 -3
  99. package/src/core/retrieval/typescript-references.ts +38 -7
  100. package/src/core/retrieval/universal-context.ts +182 -0
  101. package/src/core/telemetry/summary.ts +114 -0
  102. package/src/core/telemetry/telemetry.ts +192 -49
  103. package/src/mcp/formatters/compact-text.ts +439 -0
  104. package/src/mcp/resources-and-prompts.ts +255 -0
  105. package/src/mcp/schemas/boundary.ts +145 -0
  106. package/src/mcp/schemas/map.ts +250 -0
  107. package/src/mcp/schemas/shared.ts +52 -0
  108. package/src/mcp/schemas/slice.ts +60 -0
  109. package/src/mcp/schemas/symbol.ts +268 -0
  110. package/src/mcp/schemas.ts +5 -746
  111. package/src/mcp/server.ts +269 -429
  112. package/src/mcp/tool-catalog.ts +331 -0
  113. package/src/mcp/tools/boundary.ts +68 -3
  114. package/src/mcp/tools/map.ts +104 -4
  115. package/src/mcp/tools/slice.ts +101 -3
  116. package/src/mcp/tools/symbol.ts +469 -17
  117. package/src/mcp/ui/app-client.ts +899 -0
  118. package/src/mcp/ui/app.html +478 -0
  119. package/src/mcp/workflow-playbooks.ts +181 -0
  120. package/src/mcp/workspace-boundary.ts +50 -0
  121. package/src/mcp/workspace-manager.ts +88 -15
  122. package/src/mcp/workspace-watcher.ts +30 -11
  123. package/src/types/index.ts +12 -0
  124. package/src/mcp/tools/check-boundary.ts +0 -382
  125. package/src/mcp/tools/get-domain-catalog.ts +0 -39
  126. package/src/mcp/tools/get-symbol-impact.ts +0 -104
  127. package/src/mcp/tools/locate-symbol.ts +0 -236
  128. package/src/mcp/tools/register-domain.ts +0 -113
  129. package/src/mcp/tools/trace-vertical-slice.ts +0 -106
@@ -77,7 +77,7 @@ export class JavaExtractor implements CodeExtractor {
77
77
  const methodName = nameNode.text;
78
78
  const lineStart = member.startPosition.row + 1;
79
79
  const lineEnd = Math.max(lineStart, member.endPosition.row + 1);
80
- const headerLine = getNodeHeader(member);
80
+ const headerLine = getNodeHeader(member, content);
81
81
  const nestingDepth = calculateAstControlFlowNesting(
82
82
  member,
83
83
  JAVA_CONTROL_FLOW_NODES,
@@ -137,7 +137,7 @@ export class JavaExtractor implements CodeExtractor {
137
137
  const fullName = parentName ? `${parentName}.${baseName}` : baseName;
138
138
  const lineStart = node.startPosition.row + 1;
139
139
  const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
140
- const headerLine = getNodeHeader(node);
140
+ const headerLine = getNodeHeader(node, content);
141
141
  const kind =
142
142
  node.type === "interface_declaration"
143
143
  ? "interface"
@@ -0,0 +1,263 @@
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 Controller = { controllerClass: string; controllerTarget?: string };
6
+ export type ParsedRoute = Controller & {
7
+ httpMethod: string;
8
+ uri: string;
9
+ routeName?: string;
10
+ actionName: string;
11
+ line: number;
12
+ handlerLine?: number;
13
+ file?: string;
14
+ };
15
+
16
+ const facade = "illuminate\\support\\facades\\route";
17
+ const methods = new Set(["get", "post", "put", "patch", "delete", "any", "options", "head"]);
18
+ const groupModifiers = new Set(["prefix", "name", "as", "controller", "middleware", "domain", "where", "scopebindings", "withoutscopedbindings"]);
19
+ const resources = [
20
+ ["GET", "", "index"], ["GET", "/create", "create"], ["POST", "", "store"],
21
+ ["GET", "/{id}", "show"], ["GET", "/{id}/edit", "edit"],
22
+ ["PUT", "/{id}", "update"], ["DELETE", "/{id}", "destroy"],
23
+ ] as const;
24
+
25
+ type Call = { name: string; args: Array<Node | undefined>; line: number };
26
+
27
+ function routeCalls(expression: Node, isFacade: (name: string) => boolean): Call[] {
28
+ const chain: Call[] = [];
29
+ let node: Node | null = expression;
30
+ while (node && !node.hasError && ["scoped_call_expression", "member_call_expression"].includes(node.type)) {
31
+ const name: Node | null = node.childForFieldName("name");
32
+ if (name?.type !== "name") break;
33
+ const args = children(node.childForFieldName("arguments")).map(arg => {
34
+ const values = children(arg);
35
+ return arg.type === "argument" && values.length === 1 && values[0]?.type !== "variadic_unpacking" ? values[0] : undefined;
36
+ });
37
+ chain.push({ name: name.text.toLowerCase(), args, line: node.startPosition.row + 1 });
38
+ if (node.type === "scoped_call_expression") {
39
+ return isFacade(node.childForFieldName("scope")?.text ?? "") ? chain.reverse() : [];
40
+ }
41
+ node = node.childForFieldName("object");
42
+ }
43
+ return [];
44
+ }
45
+
46
+ function uriJoin(base: string, uri: string): string {
47
+ return "/" + [base, uri].map(value => value.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
48
+ }
49
+
50
+ function arrayOptions(node?: Node): Map<string, Node> | undefined {
51
+ if (node?.type !== "array_creation_expression") return undefined;
52
+ const options = new Map<string, Node>();
53
+ for (const item of children(node)) {
54
+ const [key, value] = children(item);
55
+ const name = literal(key);
56
+ if (item.type !== "array_element_initializer" || name === undefined || !value) return undefined;
57
+ options.set(name.toLowerCase(), value);
58
+ }
59
+ return options;
60
+ }
61
+
62
+ function actionList(args: Array<Node | undefined>): string[] | undefined {
63
+ const names = args.flatMap(arg => arg?.type === "array_creation_expression"
64
+ ? children(arg).map(element => {
65
+ const values = children(element);
66
+ return values.length === 1 ? literal(values[0]) : undefined;
67
+ })
68
+ : [literal(arg)]);
69
+ return names.every(name => name !== undefined) ? names : undefined;
70
+ }
71
+
72
+ type Group = { prefix: string; name: string; controller?: Controller };
73
+
74
+ export function readLaravelRoutes(
75
+ root: Node,
76
+ signal?: AbortSignal,
77
+ resolveInclude?: (spec: string, group: Group) => ParsedRoute[] | undefined
78
+ ): ParsedRoute[] {
79
+ const routes: ParsedRoute[] = [];
80
+ for (const { namespace, statements } of phpSections(root)) {
81
+ const imports = importsFor(statements);
82
+ const localClasses = new Set(statements.filter(node => node.type === "class_declaration")
83
+ .map(node => node.childForFieldName("name")?.text.toLowerCase()));
84
+ const resolve = (name: string): string | undefined => {
85
+ if (name.startsWith("\\")) return name.slice(1);
86
+ const [head, ...tail] = name.split("\\");
87
+ const key = head!.toLowerCase();
88
+ if (imports.has(key)) {
89
+ const imported = imports.get(key);
90
+ return imported ? [imported, ...tail].join("\\") : undefined;
91
+ }
92
+ if (key === "namespace" && tail.length) return [namespace, ...tail].filter(Boolean).join("\\");
93
+ return [namespace, name].filter(Boolean).join("\\");
94
+ };
95
+ const isFacade = (name: string) => {
96
+ const target = resolve(name)?.toLowerCase();
97
+ return target === facade || (target === "route" && !localClasses.has("route"));
98
+ };
99
+ const classTarget = (name: string): Controller | undefined => {
100
+ if (!/^\\?(?:[a-z_]\w*\\)*[a-z_]\w*$/i.test(name)) return undefined;
101
+ const target = resolve(name);
102
+ // A global short name without an import still supports Laravel's conventional path.
103
+ return { controllerClass: name, controllerTarget: target === name && !namespace && !name.includes("\\")
104
+ && !imports.has(name.toLowerCase()) ? undefined : target ?? "" };
105
+ };
106
+ const controller = (node?: Node): Controller | undefined => {
107
+ if (node?.type !== "class_constant_access_expression") return undefined;
108
+ const [name, constant] = children(node);
109
+ return constant?.text.toLowerCase() === "class" && name ? classTarget(name.text) : undefined;
110
+ };
111
+ const emit = (
112
+ call: Call, group: Group, uri: string, httpMethod: string, target: Controller,
113
+ actionName: string, routeName?: string, handlerLine?: number,
114
+ ) => routes.push({ ...target, httpMethod, uri: uriJoin(group.prefix, uri), actionName,
115
+ routeName: routeName === undefined ? undefined : group.name + routeName, line: call.line, handlerLine });
116
+
117
+ const visit = (node: Node, group: Group, depth = 0): void => {
118
+ signal?.throwIfAborted();
119
+ if (depth > 128 || node.type === "ERROR") return;
120
+ if (["if_statement", "else_clause", "else_if_clause", "compound_statement"].includes(node.type)) {
121
+ for (const child of children(node)) visit(child, group, depth + 1);
122
+ return;
123
+ }
124
+ const expression = node.type === "expression_statement" ? children(node)[0] : node.type === "arrow_function" ? node.childForFieldName("body") : null;
125
+ if (!expression) return;
126
+ if (
127
+ resolveInclude &&
128
+ ["require_expression", "require_once_expression", "include_expression", "include_once_expression"].includes(expression.type)
129
+ ) {
130
+ const specNode = expression.namedChildren.find((c) => c.type === "string" || c.type === "encapsed_string");
131
+ const spec = literal(specNode);
132
+ if (spec) {
133
+ const included = resolveInclude(spec, group);
134
+ if (included) routes.push(...included);
135
+ }
136
+ return;
137
+ }
138
+ const calls = routeCalls(expression, isFacade);
139
+ const first = calls[0];
140
+ if (!first) return;
141
+ const groupCall = calls.at(-1)!;
142
+ if (groupCall.name === "group") {
143
+ const [options, callback] = groupCall.args;
144
+ const closure = groupCall.args.length === 1 ? options : callback;
145
+ const next = { ...group };
146
+ const apply = (name: string, arg?: Node): boolean => {
147
+ if (name === "namespace") return false;
148
+ if (name === "prefix" || name === "name" || name === "as") {
149
+ const text = literal(arg);
150
+ if (text === undefined) return false;
151
+ if (name === "prefix") next.prefix = uriJoin(next.prefix, text);
152
+ else next.name += text;
153
+ } else if (name === "controller") {
154
+ next.controller = controller(arg) ?? (literal(arg) ? classTarget(literal(arg)!) : undefined);
155
+ if (!next.controller) return false;
156
+ }
157
+ return true;
158
+ };
159
+ if (groupCall.args.length === 2) {
160
+ const values = arrayOptions(options);
161
+ if (!values || ![...values].every(([name, value]) => apply(name, value))) return;
162
+ }
163
+ if (!calls.slice(0, -1).every(call => groupModifiers.has(call.name) && apply(call.name, call.args[0]))) return;
164
+ if (closure?.type === "anonymous_function_creation_expression") {
165
+ const body = closure.childForFieldName("body");
166
+ if (body) visit(body, next, depth + 1);
167
+ } else if (closure?.type === "arrow_function") {
168
+ visit(closure, next, depth + 1);
169
+ }
170
+ return;
171
+ }
172
+
173
+ const [uriNode, targetNode] = first.args;
174
+ const uri = literal(uriNode);
175
+ if (uri === undefined) return;
176
+ if (first.name === "resource" || first.name === "apiresource") {
177
+ const target = controller(targetNode) ?? (literal(targetNode) ? classTarget(literal(targetNode)!) : undefined);
178
+ if (!target) return;
179
+ const options = first.args.length > 2 ? arrayOptions(first.args[2]) : new Map<string, Node>();
180
+ const modifiers = calls.slice(1);
181
+ const unsupported = ["parameter", "parameters", "name", "names", "shallow", "scoped", "singleton"];
182
+ if (!options || unsupported.some(key => options.has(key)) || modifiers.some(call => unsupported.includes(call.name))) return;
183
+ const readFilter = (key: string) => {
184
+ const modifier = modifiers.findLast(call => call.name === key);
185
+ const option = options.get(key);
186
+ if (modifier) return actionList(modifier.args) ?? null;
187
+ if (option) return actionList([option]) ?? null;
188
+ return undefined;
189
+ };
190
+ const only = readFilter("only");
191
+ const except = readFilter("except");
192
+ if (only === null || except === null) return;
193
+ const actions = resources.filter(([, , action]) =>
194
+ (first.name === "resource" || !["create", "edit"].includes(action)) &&
195
+ (!only || only.includes(action)) && !except?.includes(action));
196
+ for (const [method, suffix, action] of actions) {
197
+ const base = uri.replace(/^\/+|\/+$/g, "");
198
+ emit(first, group, base + suffix, method, target, action, base + "." + action);
199
+ }
200
+ return;
201
+ }
202
+
203
+ const name = literal(calls.findLast(call => call.name === "name")?.args[0]);
204
+ const text = literal(targetNode);
205
+ if (first.name === "view" && text !== undefined) {
206
+ emit(first, group, uri, "GET", { controllerClass: "View" }, text, name);
207
+ return;
208
+ }
209
+ if (!methods.has(first.name) || !targetNode) return;
210
+ const array = targetNode.type === "array_creation_expression" ? children(targetNode) : [];
211
+ const pair = array.map(item => children(item)).filter(items => items.length === 1);
212
+ const legacy = text?.split("@");
213
+ let target: Controller | undefined;
214
+ let action: string | undefined;
215
+ let handlerLine: number | undefined;
216
+ if (array.length === 2 && pair.length === 2) {
217
+ target = controller(pair[0]?.[0]);
218
+ action = literal(pair[1]?.[0]);
219
+ } else if (legacy?.length === 2) {
220
+ target = classTarget(legacy[0]!);
221
+ action = legacy[1];
222
+ } else if (text !== undefined && group.controller) {
223
+ target = group.controller;
224
+ action = text;
225
+ } else if (["anonymous_function_creation_expression", "arrow_function"].includes(targetNode.type)) {
226
+ target = { controllerClass: "Closure" };
227
+ action = "handle";
228
+ handlerLine = targetNode.startPosition.row + 1;
229
+ } else {
230
+ target = controller(targetNode);
231
+ action = "__invoke";
232
+ }
233
+ if (target && action && /^[a-z_]\w*$/i.test(action)) {
234
+ emit(first, group, uri, first.name.toUpperCase(), target, action, name, handlerLine);
235
+ }
236
+ };
237
+ for (const statement of statements) visit(statement, { prefix: "", name: "" });
238
+ }
239
+ return routes;
240
+ }
241
+
242
+ export type LaravelAction = { line: number; source: string; body: string };
243
+ export function readLaravelActions(root: Node): Map<string, Map<string, LaravelAction>> {
244
+ const classes = new Map<string, Map<string, LaravelAction>>();
245
+ for (const { namespace, statements } of phpSections(root)) {
246
+ for (const node of statements) {
247
+ if (node.type !== "class_declaration") continue;
248
+ const className = node.childForFieldName("name")?.text;
249
+ if (!className) continue;
250
+ const methods = new Map<string, LaravelAction>();
251
+ for (const member of children(node.childForFieldName("body"))) {
252
+ if (member.type !== "method_declaration" || member.hasError) continue;
253
+ const name = member.childForFieldName("name");
254
+ const body = member.childForFieldName("body");
255
+ if (name && body) methods.set(name.text.toLowerCase(), {
256
+ line: member.startPosition.row + 1, source: member.text, body: body.text.slice(1, -1),
257
+ });
258
+ }
259
+ classes.set([namespace, className].filter(Boolean).join("\\").toLowerCase(), methods);
260
+ }
261
+ }
262
+ return classes;
263
+ }