@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,227 @@
1
+ import { getLanguageCapability } from "../language-capabilities.ts";
2
+ import type { ExtractedDependency, ExtractedSymbol, ParsedFileAST, Visibility } from "../../../types/index.ts";
3
+ import { findBraceBlockEnd } from "../boundary-tracker.ts";
4
+ import { calculateAstControlFlowNesting, getNodeHeader, parseSourceWithTreeSitter } from "../wasm-loader.ts";
5
+ import type { CodeExtractor } from "./base.ts";
6
+ import type Parser from "web-tree-sitter";
7
+
8
+ const JAVA_CONTROL_FLOW_NODES = new Set([
9
+ "if_statement",
10
+ "for_statement",
11
+ "enhanced_for_statement",
12
+ "while_statement",
13
+ "do_statement",
14
+ "switch_expression",
15
+ "switch_statement",
16
+ ]);
17
+
18
+ const JAVA_FUNCTION_BOUNDARY_NODES = new Set([
19
+ "method_declaration",
20
+ "constructor_declaration",
21
+ "lambda_expression",
22
+ ]);
23
+
24
+ export class JavaExtractor implements CodeExtractor {
25
+ public canHandle(filePath: string): boolean {
26
+ return getLanguageCapability(filePath)?.extractor === "java";
27
+ }
28
+
29
+ public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
30
+ const astResult = await parseSourceWithTreeSitter("java", content, (rootNode) =>
31
+ this.extractFromAst(rootNode, filePath, content),
32
+ () => this.extractFallback(filePath, content)
33
+ );
34
+ if (astResult) {
35
+ return astResult;
36
+ }
37
+
38
+ return { ...this.extractFallback(filePath, content), status: "degraded" };
39
+ }
40
+
41
+ private isExternalImport(importTarget: string): boolean {
42
+ const trimmed = importTarget.trim();
43
+ if (trimmed.startsWith("java.") || trimmed.startsWith("javax.")) {
44
+ return true;
45
+ }
46
+ return true; // Unless configured otherwise, Java imports are typically external or package-scoped
47
+ }
48
+
49
+ private extractFromAst(
50
+ rootNode: Parser.SyntaxNode,
51
+ filePath: string,
52
+ content: string
53
+ ): ParsedFileAST {
54
+ const symbols: ExtractedSymbol[] = [];
55
+ const dependencies: ExtractedDependency[] = [];
56
+ const lines = content.split("\n");
57
+
58
+ const getVisibility = (node: Parser.SyntaxNode): Visibility => {
59
+ const modifiers = node.namedChildren.find((c) => c.type === "modifiers");
60
+ if (modifiers) {
61
+ const text = modifiers.text;
62
+ if (/\bpublic\b/.test(text)) return "public";
63
+ if (/\bprotected\b/.test(text)) return "protected";
64
+ if (/\bprivate\b/.test(text)) return "private";
65
+ }
66
+ return "private";
67
+ };
68
+
69
+ const processClassBody = (bodyNode: Parser.SyntaxNode, className: string): void => {
70
+ for (const member of bodyNode.namedChildren) {
71
+ if (member.type === "method_declaration" || member.type === "constructor_declaration") {
72
+ const nameNode =
73
+ member.childForFieldName("name") ??
74
+ member.namedChildren.find((c) => c.type === "identifier");
75
+ if (!nameNode) continue;
76
+
77
+ const methodName = nameNode.text;
78
+ const lineStart = member.startPosition.row + 1;
79
+ const lineEnd = Math.max(lineStart, member.endPosition.row + 1);
80
+ const headerLine = getNodeHeader(member);
81
+ const nestingDepth = calculateAstControlFlowNesting(
82
+ member,
83
+ JAVA_CONTROL_FLOW_NODES,
84
+ JAVA_FUNCTION_BOUNDARY_NODES
85
+ );
86
+
87
+ symbols.push({
88
+ name: `${className}.${methodName}`,
89
+ kind: "method",
90
+ signature: headerLine || `${methodName}()`,
91
+ visibility: getVisibility(member),
92
+ line_start: lineStart,
93
+ line_end: lineEnd,
94
+ line_count: Math.max(1, lineEnd - lineStart + 1),
95
+ nesting_depth: nestingDepth,
96
+ });
97
+ } else if (
98
+ member.type === "class_declaration" ||
99
+ member.type === "interface_declaration" ||
100
+ member.type === "enum_declaration" ||
101
+ member.type === "record_declaration"
102
+ ) {
103
+ processTopLevel(member, className);
104
+ }
105
+ }
106
+ };
107
+
108
+ const processTopLevel = (node: Parser.SyntaxNode, parentName?: string): void => {
109
+ if (node.type === "import_declaration") {
110
+ const pathNode = node.namedChildren.find((c) => c.type === "scoped_identifier" || c.type === "identifier");
111
+ const rawImport = pathNode ? pathNode.text + (node.namedChildren.some(c => c.type === "asterisk") ? ".*" : "")
112
+ : node.text.replace(/^import\s+(?:static\s+)?|;$/g, "").trim();
113
+ const leafSymbol = rawImport.split(".").pop() || rawImport;
114
+
115
+ dependencies.push({
116
+ target: rawImport,
117
+ statement: node.text.trim().replace(/;$/, ""),
118
+ line_number: node.startPosition.row + 1,
119
+ is_external: this.isExternalImport(rawImport),
120
+ imported_symbols: [leafSymbol],
121
+ });
122
+ return;
123
+ }
124
+
125
+ if (
126
+ node.type === "class_declaration" ||
127
+ node.type === "interface_declaration" ||
128
+ node.type === "enum_declaration" ||
129
+ node.type === "record_declaration"
130
+ ) {
131
+ const nameNode =
132
+ node.childForFieldName("name") ??
133
+ node.namedChildren.find((c) => c.type === "identifier");
134
+ if (!nameNode) return;
135
+
136
+ const baseName = nameNode.text;
137
+ const fullName = parentName ? `${parentName}.${baseName}` : baseName;
138
+ const lineStart = node.startPosition.row + 1;
139
+ const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
140
+ const headerLine = getNodeHeader(node);
141
+ const kind =
142
+ node.type === "interface_declaration"
143
+ ? "interface"
144
+ : node.type === "enum_declaration"
145
+ ? "enum"
146
+ : "class";
147
+
148
+ symbols.push({
149
+ name: fullName,
150
+ kind,
151
+ signature: headerLine || `${kind} ${fullName}`,
152
+ visibility: getVisibility(node),
153
+ line_start: lineStart,
154
+ line_end: lineEnd,
155
+ line_count: Math.max(1, lineEnd - lineStart + 1),
156
+ nesting_depth: 1,
157
+ });
158
+
159
+ const bodyNode =
160
+ node.childForFieldName("body") ??
161
+ node.namedChildren.find(
162
+ (c) =>
163
+ c.type === "class_body" ||
164
+ c.type === "interface_body" ||
165
+ c.type === "enum_body" ||
166
+ c.type === "record_body"
167
+ );
168
+ if (bodyNode) {
169
+ processClassBody(bodyNode, fullName);
170
+ }
171
+ }
172
+ };
173
+
174
+ for (const node of rootNode.namedChildren) {
175
+ processTopLevel(node);
176
+ }
177
+
178
+ return { symbols, dependencies };
179
+ }
180
+
181
+ private extractFallback(filePath: string, content: string): ParsedFileAST {
182
+ const symbols: ExtractedSymbol[] = [];
183
+ const dependencies: ExtractedDependency[] = [];
184
+ const lines = content.split("\n");
185
+
186
+ for (let i = 0; i < lines.length; i++) {
187
+ const line = lines[i];
188
+ const trimmed = line.trim();
189
+ const lineNum = i + 1;
190
+
191
+ if (!trimmed || trimmed.startsWith("//")) continue;
192
+
193
+ const importMatch = /^import\s+(?:static\s+)?([^;]+);/.exec(trimmed);
194
+ if (importMatch) {
195
+ const target = importMatch[1].trim();
196
+ const leaf = target.split(".").pop() || target;
197
+ dependencies.push({
198
+ target,
199
+ statement: trimmed,
200
+ line_number: lineNum,
201
+ is_external: this.isExternalImport(target),
202
+ imported_symbols: [leaf],
203
+ });
204
+ continue;
205
+ }
206
+
207
+ const classMatch = /^(?:(?:public|protected|private|static|final|abstract)\s+)*(?:class|interface|enum|record)\s+([a-zA-Z0-9_]+)/.exec(trimmed);
208
+ if (classMatch) {
209
+ const name = classMatch[1];
210
+ const lineEnd = findBraceBlockEnd(lines, i);
211
+ symbols.push({
212
+ name,
213
+ kind: trimmed.includes("interface") ? "interface" : trimmed.includes("enum") ? "enum" : "class",
214
+ signature: trimmed.replace(/\{$/, "").trim(),
215
+ visibility: trimmed.startsWith("public") ? "public" : trimmed.startsWith("protected") ? "protected" : "private",
216
+ line_start: lineNum,
217
+ line_end: lineEnd,
218
+ line_count: Math.max(1, lineEnd - lineNum + 1),
219
+ nesting_depth: 1,
220
+ });
221
+ continue;
222
+ }
223
+ }
224
+
225
+ return { symbols, dependencies };
226
+ }
227
+ }