septum 0.1.4 → 0.1.6
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 -105
- 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 +216 -188
- package/src/cli/commands/ingest.ts +29 -29
- package/src/cli/commands/init.ts +213 -211
- package/src/cli/commands/locate.ts +61 -61
- package/src/cli/commands/query.ts +104 -64
- package/src/cli/commands/serve.ts +5 -5
- package/src/cli/commands/slice.ts +50 -48
- package/src/cli/commands/sync.ts +31 -31
- package/src/cli/index.ts +220 -210
- package/src/cli/templates/hooks.ts +75 -75
- package/src/cli/templates/rules.ts +50 -38
- package/src/cli/templates/skill.ts +65 -69
- package/src/core/boundary/evaluator.ts +429 -210
- package/src/core/config/loader.ts +117 -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 +552 -349
- package/src/core/database/repositories/domain.repository.ts +275 -198
- package/src/core/database/repositories/file.repository.ts +117 -106
- package/src/core/database/repositories/meta.repository.ts +33 -33
- package/src/core/database/repositories/symbol.repository.ts +482 -443
- package/src/core/database/repository.ts +281 -260
- package/src/core/database/schema.ts +154 -153
- package/src/core/discovery/topology-detector.ts +486 -486
- package/src/core/ingestion/hasher.ts +5 -5
- package/src/core/ingestion/pipeline.ts +606 -535
- package/src/core/parser/boundary-tracker.ts +433 -288
- package/src/core/parser/extractors/base.ts +62 -62
- package/src/core/parser/extractors/blade.ts +158 -158
- package/src/core/parser/extractors/frontend.ts +147 -194
- package/src/core/parser/extractors/go.ts +408 -180
- package/src/core/parser/extractors/laravel-semantic.ts +1045 -901
- package/src/core/parser/extractors/mcp-cli-semantic.ts +328 -199
- package/src/core/parser/extractors/nestjs-semantic.ts +134 -119
- package/src/core/parser/extractors/php.ts +415 -153
- package/src/core/parser/extractors/python.ts +460 -228
- 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 +668 -181
- package/src/core/parser/tree-sitter.ts +41 -41
- package/src/core/parser/wasm-loader.ts +271 -0
- package/src/core/resolver/call-graph-tracer.ts +698 -668
- package/src/core/resolver/module-resolver.ts +479 -342
- package/src/core/resolver/path-resolver.ts +147 -147
- package/src/core/resolver/symbol-locator.ts +543 -543
- package/src/core/resolver/vertical-slice-tracer.ts +323 -285
- package/src/core/session/session-manager.ts +56 -56
- package/src/core/telemetry/telemetry.ts +86 -86
- package/src/core/topology/environment-detector.ts +109 -6
- package/src/index.ts +21 -21
- package/src/mcp/schemas.ts +695 -286
- package/src/mcp/server.ts +927 -716
- package/src/mcp/tools/check-boundary.ts +307 -152
- package/src/mcp/tools/get-domain-catalog.ts +155 -121
- package/src/mcp/tools/get-environment-topology.ts +3 -6
- package/src/mcp/tools/get-feature-context.ts +227 -116
- package/src/mcp/tools/get-symbol-hotspots.ts +54 -59
- 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 +169 -190
- package/src/mcp/tools/register-domain.ts +59 -64
- package/src/mcp/tools/register-feature.ts +91 -0
- package/src/mcp/tools/trace-vertical-slice.ts +74 -48
- package/src/types/index.ts +366 -315
- package/src/version.ts +3 -3
|
@@ -1,194 +1,147 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExtractedDependency,
|
|
3
|
-
ExtractedSymbol,
|
|
4
|
-
ParsedFileAST,
|
|
5
|
-
} from "../../../types/index.ts";
|
|
6
|
-
import type { CodeExtractor } from "./base.ts";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
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
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const tagOpenMatch = fullMatch.match(/<script(\s+[^>]*?)?>/i);
|
|
50
|
-
const tagOpenLen = tagOpenMatch ? tagOpenMatch[0].length : 0;
|
|
51
|
-
const scriptStartOffset = match.index + tagOpenLen;
|
|
52
|
-
const startLine = content.slice(0, scriptStartOffset).split("\n").length;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
symbols.push({
|
|
59
|
-
name: "<script setup>",
|
|
60
|
-
kind: "method",
|
|
61
|
-
signature: "script setup",
|
|
62
|
-
visibility: "public",
|
|
63
|
-
line_start: startLine,
|
|
64
|
-
line_end: startLine +
|
|
65
|
-
line_count:
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
symbols.push({
|
|
75
|
-
name: "Props",
|
|
76
|
-
kind: "interface",
|
|
77
|
-
signature: `defineProps<${definePropsMatch[1]}>`,
|
|
78
|
-
visibility: "public",
|
|
79
|
-
line_start: line,
|
|
80
|
-
line_end: line,
|
|
81
|
-
line_count: 1,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private extractAstro(
|
|
87
|
-
content: string,
|
|
88
|
-
symbols: ExtractedSymbol[],
|
|
89
|
-
dependencies: ExtractedDependency[]
|
|
90
|
-
): void {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const funcRegex = /(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)/g;
|
|
149
|
-
const constFuncRegex = /(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[a-zA-Z0-9_]+)\s*=>/g;
|
|
150
|
-
const classRegex = /(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g;
|
|
151
|
-
|
|
152
|
-
for (let i = 0; i < lines.length; i++) {
|
|
153
|
-
const line = lines[i];
|
|
154
|
-
const currentLineNum = lineOffset + i;
|
|
155
|
-
|
|
156
|
-
let m: RegExpExecArray | null;
|
|
157
|
-
while ((m = funcRegex.exec(line)) !== null) {
|
|
158
|
-
symbols.push({
|
|
159
|
-
name: m[1],
|
|
160
|
-
kind: "function",
|
|
161
|
-
signature: line.trim(),
|
|
162
|
-
visibility: line.includes("export") ? "public" : "private",
|
|
163
|
-
line_start: currentLineNum,
|
|
164
|
-
line_end: currentLineNum,
|
|
165
|
-
line_count: 1,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
while ((m = constFuncRegex.exec(line)) !== null) {
|
|
170
|
-
symbols.push({
|
|
171
|
-
name: m[1],
|
|
172
|
-
kind: "function",
|
|
173
|
-
signature: line.trim(),
|
|
174
|
-
visibility: line.includes("export") ? "public" : "private",
|
|
175
|
-
line_start: currentLineNum,
|
|
176
|
-
line_end: currentLineNum,
|
|
177
|
-
line_count: 1,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
while ((m = classRegex.exec(line)) !== null) {
|
|
182
|
-
symbols.push({
|
|
183
|
-
name: m[1],
|
|
184
|
-
kind: "class",
|
|
185
|
-
signature: line.trim(),
|
|
186
|
-
visibility: line.includes("export") ? "public" : "private",
|
|
187
|
-
line_start: currentLineNum,
|
|
188
|
-
line_end: currentLineNum,
|
|
189
|
-
line_count: 1,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
ExtractedDependency,
|
|
3
|
+
ExtractedSymbol,
|
|
4
|
+
ParsedFileAST,
|
|
5
|
+
} from "../../../types/index.ts";
|
|
6
|
+
import type { CodeExtractor } from "./base.ts";
|
|
7
|
+
import { TypeScriptExtractor } from "./typescript.ts";
|
|
8
|
+
|
|
9
|
+
export class FrontendExtractor implements CodeExtractor {
|
|
10
|
+
private readonly tsExtractor = new TypeScriptExtractor();
|
|
11
|
+
|
|
12
|
+
public canHandle(filePath: string): boolean {
|
|
13
|
+
return /\.(vue|astro|svelte)$/i.test(filePath);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
|
|
17
|
+
const symbols: ExtractedSymbol[] = [];
|
|
18
|
+
const dependencies: ExtractedDependency[] = [];
|
|
19
|
+
|
|
20
|
+
const isVue = /\.vue$/i.test(filePath);
|
|
21
|
+
const isAstro = /\.astro$/i.test(filePath);
|
|
22
|
+
const isSvelte = /\.svelte$/i.test(filePath);
|
|
23
|
+
|
|
24
|
+
if (isVue) {
|
|
25
|
+
await this.extractVue(content, symbols, dependencies);
|
|
26
|
+
} else if (isAstro) {
|
|
27
|
+
await this.extractAstro(content, symbols, dependencies);
|
|
28
|
+
} else if (isSvelte) {
|
|
29
|
+
await this.extractSvelte(content, symbols, dependencies);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { symbols, dependencies };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private async extractVue(
|
|
36
|
+
content: string,
|
|
37
|
+
symbols: ExtractedSymbol[],
|
|
38
|
+
dependencies: ExtractedDependency[]
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
|
|
41
|
+
let match: RegExpExecArray | null;
|
|
42
|
+
|
|
43
|
+
while ((match = scriptRegex.exec(content)) !== null) {
|
|
44
|
+
const fullMatch = match[0];
|
|
45
|
+
const attributes = match[1] || "";
|
|
46
|
+
const scriptBody = match[2];
|
|
47
|
+
const isSetup = /\bsetup\b/i.test(attributes);
|
|
48
|
+
|
|
49
|
+
const tagOpenMatch = fullMatch.match(/<script(\s+[^>]*?)?>/i);
|
|
50
|
+
const tagOpenLen = tagOpenMatch ? tagOpenMatch[0].length : 0;
|
|
51
|
+
const scriptStartOffset = match.index + tagOpenLen;
|
|
52
|
+
const startLine = content.slice(0, scriptStartOffset).split("\n").length;
|
|
53
|
+
|
|
54
|
+
await this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
|
|
55
|
+
|
|
56
|
+
if (isSetup) {
|
|
57
|
+
const scriptLines = scriptBody.split("\n").length;
|
|
58
|
+
symbols.push({
|
|
59
|
+
name: "<script setup>",
|
|
60
|
+
kind: "method",
|
|
61
|
+
signature: "script setup",
|
|
62
|
+
visibility: "public",
|
|
63
|
+
line_start: startLine,
|
|
64
|
+
line_end: startLine + scriptLines - 1,
|
|
65
|
+
line_count: Math.max(1, scriptLines),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const definePropsMatch = content.match(/defineProps\s*<([^>]+)>/);
|
|
71
|
+
if (definePropsMatch) {
|
|
72
|
+
const line = content.slice(0, content.indexOf(definePropsMatch[0])).split("\n").length;
|
|
73
|
+
const propLines = definePropsMatch[0].split("\n").length;
|
|
74
|
+
symbols.push({
|
|
75
|
+
name: "Props",
|
|
76
|
+
kind: "interface",
|
|
77
|
+
signature: `defineProps<${definePropsMatch[1]}>`,
|
|
78
|
+
visibility: "public",
|
|
79
|
+
line_start: line,
|
|
80
|
+
line_end: line + propLines - 1,
|
|
81
|
+
line_count: Math.max(1, propLines),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private async extractAstro(
|
|
87
|
+
content: string,
|
|
88
|
+
symbols: ExtractedSymbol[],
|
|
89
|
+
dependencies: ExtractedDependency[]
|
|
90
|
+
): Promise<void> {
|
|
91
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
92
|
+
if (frontmatterMatch) {
|
|
93
|
+
const scriptBody = frontmatterMatch[1];
|
|
94
|
+
const startLine = 2;
|
|
95
|
+
await this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private async extractSvelte(
|
|
100
|
+
content: string,
|
|
101
|
+
symbols: ExtractedSymbol[],
|
|
102
|
+
dependencies: ExtractedDependency[]
|
|
103
|
+
): Promise<void> {
|
|
104
|
+
const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
|
|
105
|
+
let match: RegExpExecArray | null;
|
|
106
|
+
|
|
107
|
+
while ((match = scriptRegex.exec(content)) !== null) {
|
|
108
|
+
const fullMatch = match[0];
|
|
109
|
+
const scriptBody = match[2];
|
|
110
|
+
const tagOpenMatch = fullMatch.match(/<script(\s+[^>]*?)?>/i);
|
|
111
|
+
const tagOpenLen = tagOpenMatch ? tagOpenMatch[0].length : 0;
|
|
112
|
+
const scriptStartOffset = match.index + tagOpenLen;
|
|
113
|
+
const startLine = content.slice(0, scriptStartOffset).split("\n").length;
|
|
114
|
+
|
|
115
|
+
await this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async extractScriptContent(
|
|
120
|
+
scriptContent: string,
|
|
121
|
+
startLine: number,
|
|
122
|
+
symbols: ExtractedSymbol[],
|
|
123
|
+
dependencies: ExtractedDependency[]
|
|
124
|
+
): Promise<void> {
|
|
125
|
+
const parsed = await this.tsExtractor.extract("component-script.ts", scriptContent);
|
|
126
|
+
const delta = Math.max(0, startLine - 1);
|
|
127
|
+
|
|
128
|
+
for (const dep of parsed.dependencies) {
|
|
129
|
+
dependencies.push({
|
|
130
|
+
...dep,
|
|
131
|
+
line_number: dep.line_number + delta,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for (const sym of parsed.symbols) {
|
|
136
|
+
const shiftedStart = sym.line_start + delta;
|
|
137
|
+
const shiftedEnd = Math.max(shiftedStart, sym.line_end + delta);
|
|
138
|
+
symbols.push({
|
|
139
|
+
...sym,
|
|
140
|
+
line_start: shiftedStart,
|
|
141
|
+
line_end: shiftedEnd,
|
|
142
|
+
line_count: Math.max(1, shiftedEnd - shiftedStart + 1),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|