septum 0.1.0 → 0.1.2

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 (65) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +100 -100
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -62
  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 +90 -90
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +199 -178
  15. package/src/cli/templates/hooks.ts +75 -75
  16. package/src/cli/templates/rules.ts +38 -38
  17. package/src/cli/templates/skill.ts +66 -66
  18. package/src/core/boundary/evaluator.ts +210 -210
  19. package/src/core/config/loader.ts +84 -84
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -132
  22. package/src/core/database/repositories/dependency.repository.ts +279 -279
  23. package/src/core/database/repositories/domain.repository.ts +198 -198
  24. package/src/core/database/repositories/file.repository.ts +99 -99
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +424 -424
  27. package/src/core/database/repository.ts +242 -242
  28. package/src/core/database/schema.ts +120 -0
  29. package/src/core/discovery/topology-detector.ts +418 -418
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +438 -438
  32. package/src/core/parser/boundary-tracker.ts +128 -128
  33. package/src/core/parser/extractors/base.ts +60 -60
  34. package/src/core/parser/extractors/frontend.ts +194 -194
  35. package/src/core/parser/extractors/go.ts +176 -176
  36. package/src/core/parser/extractors/laravel-semantic.ts +426 -426
  37. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  38. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  39. package/src/core/parser/extractors/php.ts +149 -149
  40. package/src/core/parser/extractors/python.ts +226 -226
  41. package/src/core/parser/extractors/registry.ts +49 -49
  42. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  43. package/src/core/parser/extractors/typescript.ts +177 -177
  44. package/src/core/parser/tree-sitter.ts +39 -39
  45. package/src/core/resolver/call-graph-tracer.ts +668 -668
  46. package/src/core/resolver/module-resolver.ts +342 -323
  47. package/src/core/resolver/symbol-locator.ts +543 -405
  48. package/src/core/resolver/vertical-slice-tracer.ts +237 -236
  49. package/src/core/session/session-manager.ts +56 -56
  50. package/src/core/telemetry/telemetry.ts +86 -86
  51. package/src/index.ts +18 -18
  52. package/src/mcp/schemas.ts +68 -68
  53. package/src/mcp/server.ts +612 -602
  54. package/src/mcp/tools/check-boundary.ts +102 -102
  55. package/src/mcp/tools/get-domain-catalog.ts +91 -91
  56. package/src/mcp/tools/get-feature-context.ts +116 -116
  57. package/src/mcp/tools/get-symbol-hotspots.ts +49 -49
  58. package/src/mcp/tools/get-symbol-impact.ts +26 -26
  59. package/src/mcp/tools/get-symbol.ts +63 -63
  60. package/src/mcp/tools/locate-symbol.ts +74 -74
  61. package/src/mcp/tools/register-domain.ts +64 -64
  62. package/src/mcp/tools/trace-vertical-slice.ts +102 -102
  63. package/src/types/index.ts +296 -296
  64. package/src/version.ts +3 -0
  65. package/src/core/database/schema.sql +0 -92
@@ -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
+ }