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.
- package/LICENSE +21 -21
- package/README.md +100 -100
- package/bin/septum.ts +4 -4
- package/package.json +63 -62
- 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 +90 -90
- package/src/cli/commands/sync.ts +31 -31
- package/src/cli/index.ts +199 -178
- package/src/cli/templates/hooks.ts +75 -75
- package/src/cli/templates/rules.ts +38 -38
- package/src/cli/templates/skill.ts +66 -66
- package/src/core/boundary/evaluator.ts +210 -210
- package/src/core/config/loader.ts +84 -84
- package/src/core/config/schema.ts +39 -39
- package/src/core/database/client.ts +44 -132
- package/src/core/database/repositories/dependency.repository.ts +279 -279
- package/src/core/database/repositories/domain.repository.ts +198 -198
- package/src/core/database/repositories/file.repository.ts +99 -99
- package/src/core/database/repositories/meta.repository.ts +33 -33
- package/src/core/database/repositories/symbol.repository.ts +424 -424
- package/src/core/database/repository.ts +242 -242
- package/src/core/database/schema.ts +120 -0
- package/src/core/discovery/topology-detector.ts +418 -418
- package/src/core/ingestion/hasher.ts +5 -5
- package/src/core/ingestion/pipeline.ts +438 -438
- package/src/core/parser/boundary-tracker.ts +128 -128
- package/src/core/parser/extractors/base.ts +60 -60
- package/src/core/parser/extractors/frontend.ts +194 -194
- package/src/core/parser/extractors/go.ts +176 -176
- package/src/core/parser/extractors/laravel-semantic.ts +426 -426
- 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 +149 -149
- package/src/core/parser/extractors/python.ts +226 -226
- package/src/core/parser/extractors/registry.ts +49 -49
- package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
- package/src/core/parser/extractors/typescript.ts +177 -177
- package/src/core/parser/tree-sitter.ts +39 -39
- package/src/core/resolver/call-graph-tracer.ts +668 -668
- package/src/core/resolver/module-resolver.ts +342 -323
- package/src/core/resolver/symbol-locator.ts +543 -405
- package/src/core/resolver/vertical-slice-tracer.ts +237 -236
- package/src/core/session/session-manager.ts +56 -56
- package/src/core/telemetry/telemetry.ts +86 -86
- package/src/index.ts +18 -18
- package/src/mcp/schemas.ts +68 -68
- package/src/mcp/server.ts +612 -602
- package/src/mcp/tools/check-boundary.ts +102 -102
- package/src/mcp/tools/get-domain-catalog.ts +91 -91
- package/src/mcp/tools/get-feature-context.ts +116 -116
- package/src/mcp/tools/get-symbol-hotspots.ts +49 -49
- package/src/mcp/tools/get-symbol-impact.ts +26 -26
- package/src/mcp/tools/get-symbol.ts +63 -63
- package/src/mcp/tools/locate-symbol.ts +74 -74
- package/src/mcp/tools/register-domain.ts +64 -64
- package/src/mcp/tools/trace-vertical-slice.ts +102 -102
- package/src/types/index.ts +296 -296
- package/src/version.ts +3 -0
- package/src/core/database/schema.sql +0 -92
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
import type { ExtractedDependency, ExtractedSymbol, ParsedFileAST, Visibility } from "../../../types/index.ts";
|
|
2
|
-
import { findBraceBlockEnd } from "../boundary-tracker.ts";
|
|
3
|
-
import type { CodeExtractor } from "./base.ts";
|
|
4
|
-
|
|
5
|
-
const GO_STDLIB_PREFIXES = new Set([
|
|
6
|
-
"bufio",
|
|
7
|
-
"bytes",
|
|
8
|
-
"context",
|
|
9
|
-
"crypto",
|
|
10
|
-
"database",
|
|
11
|
-
"encoding",
|
|
12
|
-
"errors",
|
|
13
|
-
"flag",
|
|
14
|
-
"fmt",
|
|
15
|
-
"html",
|
|
16
|
-
"image",
|
|
17
|
-
"io",
|
|
18
|
-
"log",
|
|
19
|
-
"math",
|
|
20
|
-
"mime",
|
|
21
|
-
"net",
|
|
22
|
-
"os",
|
|
23
|
-
"path",
|
|
24
|
-
"plugin",
|
|
25
|
-
"reflect",
|
|
26
|
-
"regexp",
|
|
27
|
-
"runtime",
|
|
28
|
-
"sort",
|
|
29
|
-
"strconv",
|
|
30
|
-
"strings",
|
|
31
|
-
"sync",
|
|
32
|
-
"syscall",
|
|
33
|
-
"testing",
|
|
34
|
-
"text",
|
|
35
|
-
"time",
|
|
36
|
-
"unicode",
|
|
37
|
-
"unsafe",
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
export class GoExtractor implements CodeExtractor {
|
|
41
|
-
public canHandle(filePath: string): boolean {
|
|
42
|
-
return /\.go$/i.test(filePath);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
|
|
46
|
-
const symbols: ExtractedSymbol[] = [];
|
|
47
|
-
const dependencies: ExtractedDependency[] = [];
|
|
48
|
-
|
|
49
|
-
const lines = content.split("\n");
|
|
50
|
-
|
|
51
|
-
// 1. Extract Go Imports
|
|
52
|
-
let inImportBlock = false;
|
|
53
|
-
|
|
54
|
-
for (let i = 0; i < lines.length; i++) {
|
|
55
|
-
const line = lines[i];
|
|
56
|
-
const trimmed = line.trim();
|
|
57
|
-
const lineNum = i + 1;
|
|
58
|
-
|
|
59
|
-
if (trimmed.startsWith("//")) continue;
|
|
60
|
-
|
|
61
|
-
if (trimmed === "import (") {
|
|
62
|
-
inImportBlock = true;
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (inImportBlock) {
|
|
67
|
-
if (trimmed === ")") {
|
|
68
|
-
inImportBlock = false;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const blockMatch = /^(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
73
|
-
if (blockMatch) {
|
|
74
|
-
const importPath = blockMatch[1];
|
|
75
|
-
const isExternal = this.isGoStdlib(importPath);
|
|
76
|
-
dependencies.push({
|
|
77
|
-
target: importPath,
|
|
78
|
-
statement: trimmed,
|
|
79
|
-
line_number: lineNum,
|
|
80
|
-
is_external: isExternal,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Single line import: import "fmt" or import alias "pkg"
|
|
87
|
-
const singleMatch = /^import\s+(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
88
|
-
if (singleMatch) {
|
|
89
|
-
const importPath = singleMatch[1];
|
|
90
|
-
const isExternal = this.isGoStdlib(importPath);
|
|
91
|
-
dependencies.push({
|
|
92
|
-
target: importPath,
|
|
93
|
-
statement: trimmed,
|
|
94
|
-
line_number: lineNum,
|
|
95
|
-
is_external: isExternal,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// 2. Extract Go Types, Structs, Interfaces, and Functions
|
|
101
|
-
for (let i = 0; i < lines.length; i++) {
|
|
102
|
-
const line = lines[i];
|
|
103
|
-
const trimmed = line.trim();
|
|
104
|
-
const lineNum = i + 1;
|
|
105
|
-
|
|
106
|
-
if (trimmed.startsWith("//")) continue;
|
|
107
|
-
|
|
108
|
-
// Struct or Interface: type User struct / type Reader interface
|
|
109
|
-
const typeMatch = /^type\s+([A-Za-z0-9_]+)\s+(struct|interface)\b/.exec(trimmed);
|
|
110
|
-
if (typeMatch) {
|
|
111
|
-
const typeName = typeMatch[1];
|
|
112
|
-
const kind = typeMatch[2] === "interface" ? "interface" : "class";
|
|
113
|
-
const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
|
|
114
|
-
const endLine = findBraceBlockEnd(lines, i);
|
|
115
|
-
|
|
116
|
-
symbols.push({
|
|
117
|
-
name: typeName,
|
|
118
|
-
kind,
|
|
119
|
-
signature: trimmed.replace(/\{$/, "").trim(),
|
|
120
|
-
visibility,
|
|
121
|
-
line_start: lineNum,
|
|
122
|
-
line_end: endLine,
|
|
123
|
-
line_count: Math.max(1, endLine - lineNum + 1),
|
|
124
|
-
});
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Method with receiver: func (r *Repo) FindUser(...) (...)
|
|
129
|
-
const methodMatch = /^func\s*\([^)]+\)\s*([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
130
|
-
if (methodMatch) {
|
|
131
|
-
const methodName = methodMatch[1];
|
|
132
|
-
const visibility: Visibility = /^[A-Z]/.test(methodName) ? "public" : "private";
|
|
133
|
-
const endLine = findBraceBlockEnd(lines, i);
|
|
134
|
-
|
|
135
|
-
symbols.push({
|
|
136
|
-
name: methodName,
|
|
137
|
-
kind: "method",
|
|
138
|
-
signature: trimmed.replace(/\{$/, "").trim(),
|
|
139
|
-
visibility,
|
|
140
|
-
line_start: lineNum,
|
|
141
|
-
line_end: endLine,
|
|
142
|
-
line_count: Math.max(1, endLine - lineNum + 1),
|
|
143
|
-
});
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Function: func ProcessPayment(...) (...)
|
|
148
|
-
const funcMatch = /^func\s+([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
149
|
-
if (funcMatch) {
|
|
150
|
-
const funcName = funcMatch[1];
|
|
151
|
-
const visibility: Visibility = /^[A-Z]/.test(funcName) ? "public" : "private";
|
|
152
|
-
const endLine = findBraceBlockEnd(lines, i);
|
|
153
|
-
|
|
154
|
-
symbols.push({
|
|
155
|
-
name: funcName,
|
|
156
|
-
kind: "function",
|
|
157
|
-
signature: trimmed.replace(/\{$/, "").trim(),
|
|
158
|
-
visibility,
|
|
159
|
-
line_start: lineNum,
|
|
160
|
-
line_end: endLine,
|
|
161
|
-
line_count: Math.max(1, endLine - lineNum + 1),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
symbols,
|
|
168
|
-
dependencies,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private isGoStdlib(importPath: string): boolean {
|
|
173
|
-
const rootSegment = importPath.split("/")[0];
|
|
174
|
-
return GO_STDLIB_PREFIXES.has(rootSegment) || !importPath.includes(".");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
1
|
+
import type { ExtractedDependency, ExtractedSymbol, ParsedFileAST, Visibility } from "../../../types/index.ts";
|
|
2
|
+
import { findBraceBlockEnd } from "../boundary-tracker.ts";
|
|
3
|
+
import type { CodeExtractor } from "./base.ts";
|
|
4
|
+
|
|
5
|
+
const GO_STDLIB_PREFIXES = new Set([
|
|
6
|
+
"bufio",
|
|
7
|
+
"bytes",
|
|
8
|
+
"context",
|
|
9
|
+
"crypto",
|
|
10
|
+
"database",
|
|
11
|
+
"encoding",
|
|
12
|
+
"errors",
|
|
13
|
+
"flag",
|
|
14
|
+
"fmt",
|
|
15
|
+
"html",
|
|
16
|
+
"image",
|
|
17
|
+
"io",
|
|
18
|
+
"log",
|
|
19
|
+
"math",
|
|
20
|
+
"mime",
|
|
21
|
+
"net",
|
|
22
|
+
"os",
|
|
23
|
+
"path",
|
|
24
|
+
"plugin",
|
|
25
|
+
"reflect",
|
|
26
|
+
"regexp",
|
|
27
|
+
"runtime",
|
|
28
|
+
"sort",
|
|
29
|
+
"strconv",
|
|
30
|
+
"strings",
|
|
31
|
+
"sync",
|
|
32
|
+
"syscall",
|
|
33
|
+
"testing",
|
|
34
|
+
"text",
|
|
35
|
+
"time",
|
|
36
|
+
"unicode",
|
|
37
|
+
"unsafe",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export class GoExtractor implements CodeExtractor {
|
|
41
|
+
public canHandle(filePath: string): boolean {
|
|
42
|
+
return /\.go$/i.test(filePath);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async extract(filePath: string, content: string): Promise<ParsedFileAST> {
|
|
46
|
+
const symbols: ExtractedSymbol[] = [];
|
|
47
|
+
const dependencies: ExtractedDependency[] = [];
|
|
48
|
+
|
|
49
|
+
const lines = content.split("\n");
|
|
50
|
+
|
|
51
|
+
// 1. Extract Go Imports
|
|
52
|
+
let inImportBlock = false;
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < lines.length; i++) {
|
|
55
|
+
const line = lines[i];
|
|
56
|
+
const trimmed = line.trim();
|
|
57
|
+
const lineNum = i + 1;
|
|
58
|
+
|
|
59
|
+
if (trimmed.startsWith("//")) continue;
|
|
60
|
+
|
|
61
|
+
if (trimmed === "import (") {
|
|
62
|
+
inImportBlock = true;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (inImportBlock) {
|
|
67
|
+
if (trimmed === ")") {
|
|
68
|
+
inImportBlock = false;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const blockMatch = /^(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
73
|
+
if (blockMatch) {
|
|
74
|
+
const importPath = blockMatch[1];
|
|
75
|
+
const isExternal = this.isGoStdlib(importPath);
|
|
76
|
+
dependencies.push({
|
|
77
|
+
target: importPath,
|
|
78
|
+
statement: trimmed,
|
|
79
|
+
line_number: lineNum,
|
|
80
|
+
is_external: isExternal,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Single line import: import "fmt" or import alias "pkg"
|
|
87
|
+
const singleMatch = /^import\s+(?:[\w.]+\s+)?["']([^"']+)["']/.exec(trimmed);
|
|
88
|
+
if (singleMatch) {
|
|
89
|
+
const importPath = singleMatch[1];
|
|
90
|
+
const isExternal = this.isGoStdlib(importPath);
|
|
91
|
+
dependencies.push({
|
|
92
|
+
target: importPath,
|
|
93
|
+
statement: trimmed,
|
|
94
|
+
line_number: lineNum,
|
|
95
|
+
is_external: isExternal,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 2. Extract Go Types, Structs, Interfaces, and Functions
|
|
101
|
+
for (let i = 0; i < lines.length; i++) {
|
|
102
|
+
const line = lines[i];
|
|
103
|
+
const trimmed = line.trim();
|
|
104
|
+
const lineNum = i + 1;
|
|
105
|
+
|
|
106
|
+
if (trimmed.startsWith("//")) continue;
|
|
107
|
+
|
|
108
|
+
// Struct or Interface: type User struct / type Reader interface
|
|
109
|
+
const typeMatch = /^type\s+([A-Za-z0-9_]+)\s+(struct|interface)\b/.exec(trimmed);
|
|
110
|
+
if (typeMatch) {
|
|
111
|
+
const typeName = typeMatch[1];
|
|
112
|
+
const kind = typeMatch[2] === "interface" ? "interface" : "class";
|
|
113
|
+
const visibility: Visibility = /^[A-Z]/.test(typeName) ? "public" : "private";
|
|
114
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
115
|
+
|
|
116
|
+
symbols.push({
|
|
117
|
+
name: typeName,
|
|
118
|
+
kind,
|
|
119
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
120
|
+
visibility,
|
|
121
|
+
line_start: lineNum,
|
|
122
|
+
line_end: endLine,
|
|
123
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Method with receiver: func (r *Repo) FindUser(...) (...)
|
|
129
|
+
const methodMatch = /^func\s*\([^)]+\)\s*([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
130
|
+
if (methodMatch) {
|
|
131
|
+
const methodName = methodMatch[1];
|
|
132
|
+
const visibility: Visibility = /^[A-Z]/.test(methodName) ? "public" : "private";
|
|
133
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
134
|
+
|
|
135
|
+
symbols.push({
|
|
136
|
+
name: methodName,
|
|
137
|
+
kind: "method",
|
|
138
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
139
|
+
visibility,
|
|
140
|
+
line_start: lineNum,
|
|
141
|
+
line_end: endLine,
|
|
142
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
143
|
+
});
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Function: func ProcessPayment(...) (...)
|
|
148
|
+
const funcMatch = /^func\s+([A-Za-z0-9_]+)\s*\([^)]*\)/.exec(trimmed);
|
|
149
|
+
if (funcMatch) {
|
|
150
|
+
const funcName = funcMatch[1];
|
|
151
|
+
const visibility: Visibility = /^[A-Z]/.test(funcName) ? "public" : "private";
|
|
152
|
+
const endLine = findBraceBlockEnd(lines, i);
|
|
153
|
+
|
|
154
|
+
symbols.push({
|
|
155
|
+
name: funcName,
|
|
156
|
+
kind: "function",
|
|
157
|
+
signature: trimmed.replace(/\{$/, "").trim(),
|
|
158
|
+
visibility,
|
|
159
|
+
line_start: lineNum,
|
|
160
|
+
line_end: endLine,
|
|
161
|
+
line_count: Math.max(1, endLine - lineNum + 1),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
symbols,
|
|
168
|
+
dependencies,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private isGoStdlib(importPath: string): boolean {
|
|
173
|
+
const rootSegment = importPath.split("/")[0];
|
|
174
|
+
return GO_STDLIB_PREFIXES.has(rootSegment) || !importPath.includes(".");
|
|
175
|
+
}
|
|
176
|
+
}
|