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,119 +1,134 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import type { SemanticSliceExtractor, VerticalSliceCandidate } from "./semantic-extractor.interface.ts";
|
|
4
|
-
|
|
5
|
-
export class NestJsSemanticExtractor implements SemanticSliceExtractor {
|
|
6
|
-
public readonly id = "nestjs";
|
|
7
|
-
public readonly name = "NestJS Modular Semantic Extractor";
|
|
8
|
-
|
|
9
|
-
public canHandle(projectRoot: string, framework?: string): boolean {
|
|
10
|
-
if (framework === "nestjs") return true;
|
|
11
|
-
|
|
12
|
-
if (fs.existsSync(path.join(projectRoot, "nest-cli.json"))) return true;
|
|
13
|
-
|
|
14
|
-
const pkgPath = path.join(projectRoot, "package.json");
|
|
15
|
-
if (fs.existsSync(pkgPath)) {
|
|
16
|
-
try {
|
|
17
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
18
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
19
|
-
if (deps["@nestjs/core"]) return true;
|
|
20
|
-
} catch {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public extractSlices(projectRoot: string, domainId?: number): VerticalSliceCandidate[] {
|
|
27
|
-
const slices: VerticalSliceCandidate[] = [];
|
|
28
|
-
const srcDir = path.join(projectRoot, "src");
|
|
29
|
-
if (!fs.existsSync(srcDir)) return slices;
|
|
30
|
-
|
|
31
|
-
const controllerFiles = this.findFilesRecursively(srcDir, /\.controller\.(ts|js)$/);
|
|
32
|
-
|
|
33
|
-
for (const file of controllerFiles) {
|
|
34
|
-
const relPath = path.relative(projectRoot, file);
|
|
35
|
-
const content = fs.readFileSync(file, "utf-8");
|
|
36
|
-
|
|
37
|
-
// Extract @Controller('prefix')
|
|
38
|
-
const controllerMatch =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { SemanticSliceExtractor, VerticalSliceCandidate } from "./semantic-extractor.interface.ts";
|
|
4
|
+
|
|
5
|
+
export class NestJsSemanticExtractor implements SemanticSliceExtractor {
|
|
6
|
+
public readonly id = "nestjs";
|
|
7
|
+
public readonly name = "NestJS Modular Semantic Extractor";
|
|
8
|
+
|
|
9
|
+
public canHandle(projectRoot: string, framework?: string): boolean {
|
|
10
|
+
if (framework === "nestjs") return true;
|
|
11
|
+
|
|
12
|
+
if (fs.existsSync(path.join(projectRoot, "nest-cli.json"))) return true;
|
|
13
|
+
|
|
14
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
15
|
+
if (fs.existsSync(pkgPath)) {
|
|
16
|
+
try {
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
18
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
19
|
+
if (deps["@nestjs/core"]) return true;
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public extractSlices(projectRoot: string, domainId?: number): VerticalSliceCandidate[] {
|
|
27
|
+
const slices: VerticalSliceCandidate[] = [];
|
|
28
|
+
const srcDir = path.join(projectRoot, "src");
|
|
29
|
+
if (!fs.existsSync(srcDir)) return slices;
|
|
30
|
+
|
|
31
|
+
const controllerFiles = this.findFilesRecursively(srcDir, /\.controller\.(ts|js)$/);
|
|
32
|
+
|
|
33
|
+
for (const file of controllerFiles) {
|
|
34
|
+
const relPath = path.relative(projectRoot, file).replace(/\\/g, "/");
|
|
35
|
+
const content = fs.readFileSync(file, "utf-8");
|
|
36
|
+
|
|
37
|
+
// Extract @Controller('prefix')
|
|
38
|
+
const controllerMatch = /@Controller\s*\(\s*['"]?([^'")]*)['"]?\s*\)[\s\S]*?export\s+class\s+([A-Za-z0-9_]+)/.exec(
|
|
39
|
+
content
|
|
40
|
+
);
|
|
41
|
+
if (!controllerMatch) continue;
|
|
42
|
+
|
|
43
|
+
const routePrefix = controllerMatch[1] ? `/${controllerMatch[1].replace(/^\/+|\/+$/g, "")}` : "";
|
|
44
|
+
const controllerClass = controllerMatch[2];
|
|
45
|
+
const controllerClassLine =
|
|
46
|
+
controllerMatch.index !== undefined
|
|
47
|
+
? content
|
|
48
|
+
.slice(0, controllerMatch.index + controllerMatch[0].lastIndexOf(controllerClass))
|
|
49
|
+
.split("\n").length
|
|
50
|
+
: 1;
|
|
51
|
+
|
|
52
|
+
// Extract methods: @Get('path'), @Post('path'), etc.
|
|
53
|
+
const methodRegex =
|
|
54
|
+
/@(Get|Post|Put|Patch|Delete)\s*\(\s*['"]?([^'")]*)['"]?\s*\)\s*(?:@[A-Za-z0-9_]+\s*\([^)]*\)\s*)*\s*(?:(?:public|protected|private)\s+)?(?:async\s+)?([a-zA-Z0-9_]+)\s*\(([^)]*)\)/g;
|
|
55
|
+
let match: RegExpExecArray | null;
|
|
56
|
+
|
|
57
|
+
while ((match = methodRegex.exec(content)) !== null) {
|
|
58
|
+
const httpMethod = match[1].toUpperCase();
|
|
59
|
+
const subPath = match[2] ? `/${match[2].replace(/^\/+|\/+$/g, "")}` : "";
|
|
60
|
+
const fullUri = `${routePrefix}${subPath}` || "/";
|
|
61
|
+
const actionName = match[3];
|
|
62
|
+
const params = match[4];
|
|
63
|
+
|
|
64
|
+
const decoratorLine = content.slice(0, match.index).split("\n").length;
|
|
65
|
+
const actionOffset = match.index + match[0].lastIndexOf(actionName);
|
|
66
|
+
const actionLine = content.slice(0, actionOffset).split("\n").length || controllerClassLine;
|
|
67
|
+
|
|
68
|
+
// Extract DTO from parameters: e.g. @Body() createDto: CreateUserDto
|
|
69
|
+
const dtoMatch = params.match(/@Body\s*\([^)]*\)\s*[a-zA-Z0-9_]+\s*:\s*([A-Za-z0-9_]+Dto)/);
|
|
70
|
+
const formRequestClass = dtoMatch ? dtoMatch[1] : null;
|
|
71
|
+
|
|
72
|
+
const chain: Array<{ stage: string; symbol: string; file?: string; line?: number; description?: string }> = [
|
|
73
|
+
{
|
|
74
|
+
stage: "ingress",
|
|
75
|
+
symbol: `${httpMethod} ${fullUri}`,
|
|
76
|
+
file: relPath,
|
|
77
|
+
line: decoratorLine,
|
|
78
|
+
description: `NestJS Route: ${httpMethod} ${fullUri}`,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
if (formRequestClass) {
|
|
83
|
+
chain.push({
|
|
84
|
+
stage: "validation",
|
|
85
|
+
symbol: formRequestClass,
|
|
86
|
+
description: "DTO Validation",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
chain.push({
|
|
91
|
+
stage: "controller",
|
|
92
|
+
symbol: `${controllerClass}::${actionName}`,
|
|
93
|
+
file: relPath,
|
|
94
|
+
line: actionLine,
|
|
95
|
+
description: `NestJS Controller Action`,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
slices.push({
|
|
99
|
+
domain_id: domainId ?? null,
|
|
100
|
+
feature_key: `nest.${controllerClass.toLowerCase().replace("controller", "")}.${actionName}`,
|
|
101
|
+
http_method: httpMethod,
|
|
102
|
+
route_uri: fullUri,
|
|
103
|
+
route_name: `${controllerClass}.${actionName}`,
|
|
104
|
+
controller_class: controllerClass,
|
|
105
|
+
action_name: actionName,
|
|
106
|
+
controller_file: relPath,
|
|
107
|
+
controller_line: actionLine,
|
|
108
|
+
architecture_style: "mvc",
|
|
109
|
+
entry_kind: "http_route",
|
|
110
|
+
execution_chain_json: JSON.stringify(chain),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
return slices;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private findFilesRecursively(dir: string, pattern: RegExp): string[] {
|
|
120
|
+
const results: string[] = [];
|
|
121
|
+
try {
|
|
122
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
123
|
+
for (const entry of entries) {
|
|
124
|
+
const full = path.join(dir, entry.name);
|
|
125
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
126
|
+
results.push(...this.findFilesRecursively(full, pattern));
|
|
127
|
+
} else if (entry.isFile() && pattern.test(entry.name)) {
|
|
128
|
+
results.push(full);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} catch {}
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
}
|