septum 0.1.3 → 0.1.5
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.
- package/LICENSE +21 -21
- package/README.md +105 -102
- package/bin/septum.ts +4 -4
- package/package.json +63 -63
- package/src/cli/commands/check.ts +161 -161
- package/src/cli/commands/hook.ts +188 -188
- package/src/cli/commands/ingest.ts +29 -29
- package/src/cli/commands/init.ts +211 -211
- package/src/cli/commands/locate.ts +61 -61
- package/src/cli/commands/query.ts +64 -64
- package/src/cli/commands/serve.ts +5 -5
- package/src/cli/commands/slice.ts +48 -90
- package/src/cli/commands/sync.ts +31 -31
- package/src/cli/commands/topology.ts +119 -0
- package/src/cli/index.ts +210 -199
- package/src/cli/templates/hooks.ts +75 -75
- package/src/cli/templates/rules.ts +38 -38
- package/src/cli/templates/skill.ts +69 -69
- package/src/core/boundary/evaluator.ts +232 -210
- package/src/core/config/loader.ts +97 -97
- package/src/core/config/schema.ts +39 -39
- package/src/core/database/client.ts +44 -44
- package/src/core/database/repositories/dependency.repository.ts +366 -349
- package/src/core/database/repositories/domain.repository.ts +218 -198
- package/src/core/database/repositories/environment.repository.ts +207 -0
- package/src/core/database/repositories/file.repository.ts +116 -106
- package/src/core/database/repositories/meta.repository.ts +33 -33
- package/src/core/database/repositories/symbol.repository.ts +443 -424
- package/src/core/database/repository.ts +264 -255
- package/src/core/database/schema.ts +34 -1
- package/src/core/discovery/topology-detector.ts +486 -486
- package/src/core/ingestion/hasher.ts +5 -5
- package/src/core/ingestion/pipeline.ts +584 -535
- package/src/core/parser/behavioral-analyzer.ts +119 -0
- package/src/core/parser/boundary-tracker.ts +288 -128
- package/src/core/parser/extractors/base.ts +62 -61
- package/src/core/parser/extractors/frontend.ts +194 -194
- package/src/core/parser/extractors/go.ts +229 -176
- package/src/core/parser/extractors/laravel-semantic.ts +1039 -585
- package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
- package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
- package/src/core/parser/extractors/php.ts +153 -149
- package/src/core/parser/extractors/python.ts +228 -226
- package/src/core/parser/extractors/registry.ts +70 -70
- package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
- package/src/core/parser/extractors/typescript.ts +181 -177
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +215 -0
- package/src/core/parser/schema/providers/prisma-schema-provider.ts +89 -0
- package/src/core/parser/schema/schema-provider-registry.ts +43 -0
- package/src/core/parser/schema/schema-provider.interface.ts +33 -0
- package/src/core/parser/tree-sitter.ts +41 -41
- package/src/core/resolver/call-graph-tracer.ts +666 -668
- package/src/core/resolver/module-resolver.ts +408 -342
- package/src/core/resolver/symbol-locator.ts +543 -543
- package/src/core/resolver/vertical-slice-tracer.ts +301 -252
- package/src/core/session/session-manager.ts +56 -56
- package/src/core/telemetry/telemetry.ts +86 -86
- package/src/core/topology/environment-detector.ts +860 -0
- package/src/core/topology/types.ts +83 -0
- package/src/index.ts +21 -18
- package/src/mcp/schemas.ts +578 -238
- package/src/mcp/server.ts +875 -656
- package/src/mcp/tools/check-boundary.ts +171 -152
- package/src/mcp/tools/get-domain-catalog.ts +145 -121
- package/src/mcp/tools/get-environment-topology.ts +141 -0
- package/src/mcp/tools/get-feature-context.ts +212 -116
- package/src/mcp/tools/get-symbol-hotspots.ts +60 -49
- package/src/mcp/tools/get-symbol-impact.ts +28 -26
- package/src/mcp/tools/get-symbol.ts +65 -63
- package/src/mcp/tools/locate-symbol.ts +171 -190
- package/src/mcp/tools/register-domain.ts +68 -64
- package/src/mcp/tools/register-feature.ts +100 -0
- package/src/mcp/tools/trace-vertical-slice.ts +74 -103
- package/src/types/index.ts +335 -299
|
@@ -1,176 +1,229 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (trimmed
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { ExtractedDependency, ExtractedSymbol, ParsedFileAST, Visibility } from "../../../types/index.ts";
|
|
4
|
+
import { findBraceBlockEnd, calculateControlFlowNesting } from "../boundary-tracker.ts";
|
|
5
|
+
import type { CodeExtractor } from "./base.ts";
|
|
6
|
+
|
|
7
|
+
const GO_STDLIB_PREFIXES = new Set([
|
|
8
|
+
"bufio",
|
|
9
|
+
"bytes",
|
|
10
|
+
"context",
|
|
11
|
+
"crypto",
|
|
12
|
+
"database",
|
|
13
|
+
"encoding",
|
|
14
|
+
"errors",
|
|
15
|
+
"flag",
|
|
16
|
+
"fmt",
|
|
17
|
+
"html",
|
|
18
|
+
"image",
|
|
19
|
+
"io",
|
|
20
|
+
"log",
|
|
21
|
+
"math",
|
|
22
|
+
"mime",
|
|
23
|
+
"net",
|
|
24
|
+
"os",
|
|
25
|
+
"path",
|
|
26
|
+
"plugin",
|
|
27
|
+
"reflect",
|
|
28
|
+
"regexp",
|
|
29
|
+
"runtime",
|
|
30
|
+
"sort",
|
|
31
|
+
"strconv",
|
|
32
|
+
"strings",
|
|
33
|
+
"sync",
|
|
34
|
+
"syscall",
|
|
35
|
+
"testing",
|
|
36
|
+
"text",
|
|
37
|
+
"time",
|
|
38
|
+
"unicode",
|
|
39
|
+
"unsafe",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export class GoExtractor implements CodeExtractor {
|
|
43
|
+
public canHandle(filePath: string): boolean {
|
|
44
|
+
return /\.go$/i.test(filePath);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
|
|
48
|
+
const symbols: ExtractedSymbol[] = [];
|
|
49
|
+
const dependencies: ExtractedDependency[] = [];
|
|
50
|
+
|
|
51
|
+
const lines = content.split("\n");
|
|
52
|
+
|
|
53
|
+
// 1. Extract Go Imports
|
|
54
|
+
let inImportBlock = false;
|
|
55
|
+
|
|
56
|
+
for (let i = 0; i < lines.length; i++) {
|
|
57
|
+
const line = lines[i];
|
|
58
|
+
const trimmed = line.trim();
|
|
59
|
+
const lineNum = i + 1;
|
|
60
|
+
|
|
61
|
+
if (trimmed.startsWith("//")) continue;
|
|
62
|
+
|
|
63
|
+
if (trimmed === "import (") {
|
|
64
|
+
inImportBlock = true;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (inImportBlock) {
|
|
69
|
+
if (trimmed === ")") {
|
|
70
|
+
inImportBlock = false;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const blockMatch = /^(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
75
|
+
if (blockMatch) {
|
|
76
|
+
const importPath = blockMatch[1];
|
|
77
|
+
const isExternal = this.isExternalImport(importPath, filePath);
|
|
78
|
+
dependencies.push({
|
|
79
|
+
target: importPath,
|
|
80
|
+
statement: trimmed,
|
|
81
|
+
line_number: lineNum,
|
|
82
|
+
is_external: isExternal,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Single line import: import "fmt" or import alias "pkg"
|
|
89
|
+
const singleMatch = /^import\s+(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
90
|
+
if (singleMatch) {
|
|
91
|
+
const importPath = singleMatch[1];
|
|
92
|
+
const isExternal = this.isExternalImport(importPath, filePath);
|
|
93
|
+
dependencies.push({
|
|
94
|
+
target: importPath,
|
|
95
|
+
statement: trimmed,
|
|
96
|
+
line_number: lineNum,
|
|
97
|
+
is_external: isExternal,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 2. Extract Go Types, Structs, Interfaces, and Functions
|
|
103
|
+
for (let i = 0; i < lines.length; i++) {
|
|
104
|
+
const line = lines[i];
|
|
105
|
+
const trimmed = line.trim();
|
|
106
|
+
const lineNum = i + 1;
|
|
107
|
+
|
|
108
|
+
if (trimmed.startsWith("//")) continue;
|
|
109
|
+
|
|
110
|
+
// Struct or Interface: type User struct / type Reader interface
|
|
111
|
+
const typeMatch = /^type\s+([A-Za-z0-9_]+)\s+(struct|interface)\b/.exec(trimmed);
|
|
112
|
+
if (typeMatch) {
|
|
113
|
+
const typeName = typeMatch[1];
|
|
114
|
+
const kind = typeMatch[2] === "interface" ? "interface" : "class";
|
|
115
|
+
const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
|
|
116
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
117
|
+
|
|
118
|
+
symbols.push({
|
|
119
|
+
name: typeName,
|
|
120
|
+
kind,
|
|
121
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
122
|
+
visibility,
|
|
123
|
+
line_start: lineNum,
|
|
124
|
+
line_end: endLine,
|
|
125
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
126
|
+
});
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Method with receiver: func (r *Repo) FindUser(...) (...)
|
|
131
|
+
const methodMatch = /^func\s*\([^)]+\)\s*([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
132
|
+
if (methodMatch) {
|
|
133
|
+
const methodName = methodMatch[1];
|
|
134
|
+
const visibility: Visibility = /^[A-Z]/.test(methodName) ? "public" : "private";
|
|
135
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
136
|
+
const nestingDepth = calculateControlFlowNesting(lines, i, endLine - 1);
|
|
137
|
+
|
|
138
|
+
symbols.push({
|
|
139
|
+
name: methodName,
|
|
140
|
+
kind: "method",
|
|
141
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
142
|
+
visibility,
|
|
143
|
+
line_start: lineNum,
|
|
144
|
+
line_end: endLine,
|
|
145
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
146
|
+
nesting_depth: nestingDepth,
|
|
147
|
+
});
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Function: func ProcessPayment(...) (...)
|
|
152
|
+
const funcMatch = /^func\s+([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
153
|
+
if (funcMatch) {
|
|
154
|
+
const funcName = funcMatch[1];
|
|
155
|
+
const visibility: Visibility = /^[A-Z]/.test(funcName) ? "public" : "private";
|
|
156
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
157
|
+
const nestingDepth = calculateControlFlowNesting(lines, i, endLine - 1);
|
|
158
|
+
|
|
159
|
+
symbols.push({
|
|
160
|
+
name: funcName,
|
|
161
|
+
kind: "function",
|
|
162
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
163
|
+
visibility,
|
|
164
|
+
line_start: lineNum,
|
|
165
|
+
line_end: endLine,
|
|
166
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
167
|
+
nesting_depth: nestingDepth,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
symbols,
|
|
174
|
+
dependencies,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private isExternalImport(importPath: string, filePath?: string): boolean {
|
|
179
|
+
if (this.isGoStdlib(importPath)) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (importPath.startsWith(".") || importPath.startsWith("/")) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const modName = this.findGoModuleName(filePath);
|
|
186
|
+
if (modName) {
|
|
187
|
+
if (importPath === modName || importPath.startsWith(`${modName}/`)) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (
|
|
194
|
+
importPath.includes("/domains/") ||
|
|
195
|
+
importPath.includes("/internal/") ||
|
|
196
|
+
importPath.includes("/pkg/")
|
|
197
|
+
) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (importPath.includes(".")) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private findGoModuleName(filePath?: string): string | null {
|
|
209
|
+
if (!filePath) return null;
|
|
210
|
+
try {
|
|
211
|
+
let currentDir = path.dirname(path.resolve(filePath));
|
|
212
|
+
while (currentDir && currentDir !== path.dirname(currentDir)) {
|
|
213
|
+
const goModPath = path.join(currentDir, "go.mod");
|
|
214
|
+
if (fs.existsSync(goModPath)) {
|
|
215
|
+
const content = fs.readFileSync(goModPath, "utf-8");
|
|
216
|
+
const match = /^module\s+([^\s\r\n]+)/m.exec(content);
|
|
217
|
+
if (match) return match[1];
|
|
218
|
+
}
|
|
219
|
+
currentDir = path.dirname(currentDir);
|
|
220
|
+
}
|
|
221
|
+
} catch {}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private isGoStdlib(importPath: string): boolean {
|
|
226
|
+
const rootSegment = importPath.split("/")[0];
|
|
227
|
+
return GO_STDLIB_PREFIXES.has(rootSegment) || !importPath.includes(".");
|
|
228
|
+
}
|
|
229
|
+
}
|