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.
Files changed (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +105 -102
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -63
  5. package/src/cli/commands/check.ts +161 -161
  6. package/src/cli/commands/hook.ts +188 -188
  7. package/src/cli/commands/ingest.ts +29 -29
  8. package/src/cli/commands/init.ts +211 -211
  9. package/src/cli/commands/locate.ts +61 -61
  10. package/src/cli/commands/query.ts +64 -64
  11. package/src/cli/commands/serve.ts +5 -5
  12. package/src/cli/commands/slice.ts +48 -90
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/commands/topology.ts +119 -0
  15. package/src/cli/index.ts +210 -199
  16. package/src/cli/templates/hooks.ts +75 -75
  17. package/src/cli/templates/rules.ts +38 -38
  18. package/src/cli/templates/skill.ts +69 -69
  19. package/src/core/boundary/evaluator.ts +232 -210
  20. package/src/core/config/loader.ts +97 -97
  21. package/src/core/config/schema.ts +39 -39
  22. package/src/core/database/client.ts +44 -44
  23. package/src/core/database/repositories/dependency.repository.ts +366 -349
  24. package/src/core/database/repositories/domain.repository.ts +218 -198
  25. package/src/core/database/repositories/environment.repository.ts +207 -0
  26. package/src/core/database/repositories/file.repository.ts +116 -106
  27. package/src/core/database/repositories/meta.repository.ts +33 -33
  28. package/src/core/database/repositories/symbol.repository.ts +443 -424
  29. package/src/core/database/repository.ts +264 -255
  30. package/src/core/database/schema.ts +34 -1
  31. package/src/core/discovery/topology-detector.ts +486 -486
  32. package/src/core/ingestion/hasher.ts +5 -5
  33. package/src/core/ingestion/pipeline.ts +584 -535
  34. package/src/core/parser/behavioral-analyzer.ts +119 -0
  35. package/src/core/parser/boundary-tracker.ts +288 -128
  36. package/src/core/parser/extractors/base.ts +62 -61
  37. package/src/core/parser/extractors/frontend.ts +194 -194
  38. package/src/core/parser/extractors/go.ts +229 -176
  39. package/src/core/parser/extractors/laravel-semantic.ts +1039 -585
  40. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  41. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  42. package/src/core/parser/extractors/php.ts +153 -149
  43. package/src/core/parser/extractors/python.ts +228 -226
  44. package/src/core/parser/extractors/registry.ts +70 -70
  45. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  46. package/src/core/parser/extractors/typescript.ts +181 -177
  47. package/src/core/parser/schema/providers/laravel-migration-provider.ts +215 -0
  48. package/src/core/parser/schema/providers/prisma-schema-provider.ts +89 -0
  49. package/src/core/parser/schema/schema-provider-registry.ts +43 -0
  50. package/src/core/parser/schema/schema-provider.interface.ts +33 -0
  51. package/src/core/parser/tree-sitter.ts +41 -41
  52. package/src/core/resolver/call-graph-tracer.ts +666 -668
  53. package/src/core/resolver/module-resolver.ts +408 -342
  54. package/src/core/resolver/symbol-locator.ts +543 -543
  55. package/src/core/resolver/vertical-slice-tracer.ts +301 -252
  56. package/src/core/session/session-manager.ts +56 -56
  57. package/src/core/telemetry/telemetry.ts +86 -86
  58. package/src/core/topology/environment-detector.ts +860 -0
  59. package/src/core/topology/types.ts +83 -0
  60. package/src/index.ts +21 -18
  61. package/src/mcp/schemas.ts +578 -238
  62. package/src/mcp/server.ts +875 -656
  63. package/src/mcp/tools/check-boundary.ts +171 -152
  64. package/src/mcp/tools/get-domain-catalog.ts +145 -121
  65. package/src/mcp/tools/get-environment-topology.ts +141 -0
  66. package/src/mcp/tools/get-feature-context.ts +212 -116
  67. package/src/mcp/tools/get-symbol-hotspots.ts +60 -49
  68. package/src/mcp/tools/get-symbol-impact.ts +28 -26
  69. package/src/mcp/tools/get-symbol.ts +65 -63
  70. package/src/mcp/tools/locate-symbol.ts +171 -190
  71. package/src/mcp/tools/register-domain.ts +68 -64
  72. package/src/mcp/tools/register-feature.ts +100 -0
  73. package/src/mcp/tools/trace-vertical-slice.ts +74 -103
  74. package/src/types/index.ts +335 -299
@@ -1,194 +1,194 @@
1
- import type {
2
- ExtractedDependency,
3
- ExtractedSymbol,
4
- ParsedFileAST,
5
- } from "../../../types/index.ts";
6
- import type { CodeExtractor } from "./base.ts";
7
-
8
- export class FrontendExtractor implements CodeExtractor {
9
- public canHandle(filePath: string): boolean {
10
- return /\.(vue|astro|svelte)$/i.test(filePath);
11
- }
12
-
13
- public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
14
- const symbols: ExtractedSymbol[] = [];
15
- const dependencies: ExtractedDependency[] = [];
16
-
17
- const isVue = /\.vue$/i.test(filePath);
18
- const isAstro = /\.astro$/i.test(filePath);
19
- const isSvelte = /\.svelte$/i.test(filePath);
20
-
21
- if (isVue) {
22
- this.extractVue(content, symbols, dependencies);
23
- } else if (isAstro) {
24
- this.extractAstro(content, symbols, dependencies);
25
- } else if (isSvelte) {
26
- this.extractSvelte(content, symbols, dependencies);
27
- }
28
-
29
- return { symbols, dependencies };
30
- }
31
-
32
- private extractVue(
33
- content: string,
34
- symbols: ExtractedSymbol[],
35
- dependencies: ExtractedDependency[]
36
- ): void {
37
- // Match <script> and <script setup> blocks
38
- const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
39
- let match: RegExpExecArray | null;
40
-
41
- while ((match = scriptRegex.exec(content)) !== null) {
42
- const fullMatch = match[0];
43
- const attributes = match[1] || "";
44
- const scriptBody = match[2];
45
- const isSetup = /\bsetup\b/i.test(attributes);
46
-
47
- // Calculate start line of the script body
48
- const beforeMatch = content.slice(0, match.index);
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
- // Extract symbols and dependencies from this script block
55
- this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
56
-
57
- if (isSetup) {
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 + scriptBody.split("\n").length,
65
- line_count: scriptBody.split("\n").length,
66
- });
67
- }
68
- }
69
-
70
- // Vue defineProps / defineEmits detection
71
- const definePropsMatch = content.match(/defineProps\s*<([^>]+)>/);
72
- if (definePropsMatch) {
73
- const line = content.slice(0, content.indexOf(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,
81
- line_count: 1,
82
- });
83
- }
84
- }
85
-
86
- private extractAstro(
87
- content: string,
88
- symbols: ExtractedSymbol[],
89
- dependencies: ExtractedDependency[]
90
- ): void {
91
- // Astro frontmatter is between the first --- and the second ---
92
- const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
93
- if (frontmatterMatch) {
94
- const scriptBody = frontmatterMatch[1];
95
- const startLine = 2; // Line 1 is '---'
96
- this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
97
- }
98
- }
99
-
100
- private extractSvelte(
101
- content: string,
102
- symbols: ExtractedSymbol[],
103
- dependencies: ExtractedDependency[]
104
- ): void {
105
- const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
106
- let match: RegExpExecArray | null;
107
-
108
- while ((match = scriptRegex.exec(content)) !== null) {
109
- const fullMatch = match[0];
110
- const scriptBody = match[2];
111
- const tagOpenMatch = fullMatch.match(/<script(\s+[^>]*?)?>/i);
112
- const tagOpenLen = tagOpenMatch ? tagOpenMatch[0].length : 0;
113
- const scriptStartOffset = match.index + tagOpenLen;
114
- const startLine = content.slice(0, scriptStartOffset).split("\n").length;
115
-
116
- this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
117
- }
118
- }
119
-
120
- private extractScriptContent(
121
- scriptContent: string,
122
- lineOffset: number,
123
- symbols: ExtractedSymbol[],
124
- dependencies: ExtractedDependency[]
125
- ): void {
126
- const lines = scriptContent.split("\n");
127
-
128
- // 1. Extract Imports
129
- const importRegex = /(?:import\s+(?:(?:[\w*\s{},]+)\s+from\s+)?['"]([^'"]+)['"]|require\s*\(\s*['"]([^'"]+)['"]\s*\))/g;
130
- for (let i = 0; i < lines.length; i++) {
131
- const line = lines[i];
132
- let match: RegExpExecArray | null;
133
- while ((match = importRegex.exec(line)) !== null) {
134
- const target = match[1] || match[2];
135
- if (target) {
136
- const isExternal = !target.startsWith(".") && !target.startsWith("/");
137
- dependencies.push({
138
- target,
139
- statement: line.trim(),
140
- line_number: lineOffset + i,
141
- is_external: isExternal,
142
- });
143
- }
144
- }
145
- }
146
-
147
- // 2. Extract Functions / Methods / Classes / Components
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
+
8
+ export class FrontendExtractor implements CodeExtractor {
9
+ public canHandle(filePath: string): boolean {
10
+ return /\.(vue|astro|svelte)$/i.test(filePath);
11
+ }
12
+
13
+ public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
14
+ const symbols: ExtractedSymbol[] = [];
15
+ const dependencies: ExtractedDependency[] = [];
16
+
17
+ const isVue = /\.vue$/i.test(filePath);
18
+ const isAstro = /\.astro$/i.test(filePath);
19
+ const isSvelte = /\.svelte$/i.test(filePath);
20
+
21
+ if (isVue) {
22
+ this.extractVue(content, symbols, dependencies);
23
+ } else if (isAstro) {
24
+ this.extractAstro(content, symbols, dependencies);
25
+ } else if (isSvelte) {
26
+ this.extractSvelte(content, symbols, dependencies);
27
+ }
28
+
29
+ return { symbols, dependencies };
30
+ }
31
+
32
+ private extractVue(
33
+ content: string,
34
+ symbols: ExtractedSymbol[],
35
+ dependencies: ExtractedDependency[]
36
+ ): void {
37
+ // Match <script> and <script setup> blocks
38
+ const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
39
+ let match: RegExpExecArray | null;
40
+
41
+ while ((match = scriptRegex.exec(content)) !== null) {
42
+ const fullMatch = match[0];
43
+ const attributes = match[1] || "";
44
+ const scriptBody = match[2];
45
+ const isSetup = /\bsetup\b/i.test(attributes);
46
+
47
+ // Calculate start line of the script body
48
+ const beforeMatch = content.slice(0, match.index);
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
+ // Extract symbols and dependencies from this script block
55
+ this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
56
+
57
+ if (isSetup) {
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 + scriptBody.split("\n").length,
65
+ line_count: scriptBody.split("\n").length,
66
+ });
67
+ }
68
+ }
69
+
70
+ // Vue defineProps / defineEmits detection
71
+ const definePropsMatch = content.match(/defineProps\s*<([^>]+)>/);
72
+ if (definePropsMatch) {
73
+ const line = content.slice(0, content.indexOf(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,
81
+ line_count: 1,
82
+ });
83
+ }
84
+ }
85
+
86
+ private extractAstro(
87
+ content: string,
88
+ symbols: ExtractedSymbol[],
89
+ dependencies: ExtractedDependency[]
90
+ ): void {
91
+ // Astro frontmatter is between the first --- and the second ---
92
+ const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
93
+ if (frontmatterMatch) {
94
+ const scriptBody = frontmatterMatch[1];
95
+ const startLine = 2; // Line 1 is '---'
96
+ this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
97
+ }
98
+ }
99
+
100
+ private extractSvelte(
101
+ content: string,
102
+ symbols: ExtractedSymbol[],
103
+ dependencies: ExtractedDependency[]
104
+ ): void {
105
+ const scriptRegex = /<script(\s+[^>]*?)?>([\s\S]*?)<\/script>/gi;
106
+ let match: RegExpExecArray | null;
107
+
108
+ while ((match = scriptRegex.exec(content)) !== null) {
109
+ const fullMatch = match[0];
110
+ const scriptBody = match[2];
111
+ const tagOpenMatch = fullMatch.match(/<script(\s+[^>]*?)?>/i);
112
+ const tagOpenLen = tagOpenMatch ? tagOpenMatch[0].length : 0;
113
+ const scriptStartOffset = match.index + tagOpenLen;
114
+ const startLine = content.slice(0, scriptStartOffset).split("\n").length;
115
+
116
+ this.extractScriptContent(scriptBody, startLine, symbols, dependencies);
117
+ }
118
+ }
119
+
120
+ private extractScriptContent(
121
+ scriptContent: string,
122
+ lineOffset: number,
123
+ symbols: ExtractedSymbol[],
124
+ dependencies: ExtractedDependency[]
125
+ ): void {
126
+ const lines = scriptContent.split("\n");
127
+
128
+ // 1. Extract Imports
129
+ const importRegex = /(?:import\s+(?:(?:[\w*\s{},]+)\s+from\s+)?['"]([^'"]+)['"]|require\s*\(\s*['"]([^'"]+)['"]\s*\))/g;
130
+ for (let i = 0; i < lines.length; i++) {
131
+ const line = lines[i];
132
+ let match: RegExpExecArray | null;
133
+ while ((match = importRegex.exec(line)) !== null) {
134
+ const target = match[1] || match[2];
135
+ if (target) {
136
+ const isExternal = !target.startsWith(".") && !target.startsWith("/");
137
+ dependencies.push({
138
+ target,
139
+ statement: line.trim(),
140
+ line_number: lineOffset + i,
141
+ is_external: isExternal,
142
+ });
143
+ }
144
+ }
145
+ }
146
+
147
+ // 2. Extract Functions / Methods / Classes / Components
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
+ }