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.
Files changed (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +105 -105
  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 +216 -188
  7. package/src/cli/commands/ingest.ts +29 -29
  8. package/src/cli/commands/init.ts +213 -211
  9. package/src/cli/commands/locate.ts +61 -61
  10. package/src/cli/commands/query.ts +104 -64
  11. package/src/cli/commands/serve.ts +5 -5
  12. package/src/cli/commands/slice.ts +50 -48
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +220 -210
  15. package/src/cli/templates/hooks.ts +75 -75
  16. package/src/cli/templates/rules.ts +50 -38
  17. package/src/cli/templates/skill.ts +65 -69
  18. package/src/core/boundary/evaluator.ts +429 -210
  19. package/src/core/config/loader.ts +117 -97
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -44
  22. package/src/core/database/repositories/dependency.repository.ts +552 -349
  23. package/src/core/database/repositories/domain.repository.ts +275 -198
  24. package/src/core/database/repositories/file.repository.ts +117 -106
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +482 -443
  27. package/src/core/database/repository.ts +281 -260
  28. package/src/core/database/schema.ts +154 -153
  29. package/src/core/discovery/topology-detector.ts +486 -486
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +606 -535
  32. package/src/core/parser/boundary-tracker.ts +433 -288
  33. package/src/core/parser/extractors/base.ts +62 -62
  34. package/src/core/parser/extractors/blade.ts +158 -158
  35. package/src/core/parser/extractors/frontend.ts +147 -194
  36. package/src/core/parser/extractors/go.ts +408 -180
  37. package/src/core/parser/extractors/laravel-semantic.ts +1045 -901
  38. package/src/core/parser/extractors/mcp-cli-semantic.ts +328 -199
  39. package/src/core/parser/extractors/nestjs-semantic.ts +134 -119
  40. package/src/core/parser/extractors/php.ts +415 -153
  41. package/src/core/parser/extractors/python.ts +460 -228
  42. package/src/core/parser/extractors/registry.ts +70 -70
  43. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  44. package/src/core/parser/extractors/typescript.ts +668 -181
  45. package/src/core/parser/tree-sitter.ts +41 -41
  46. package/src/core/parser/wasm-loader.ts +271 -0
  47. package/src/core/resolver/call-graph-tracer.ts +698 -668
  48. package/src/core/resolver/module-resolver.ts +479 -342
  49. package/src/core/resolver/path-resolver.ts +147 -147
  50. package/src/core/resolver/symbol-locator.ts +543 -543
  51. package/src/core/resolver/vertical-slice-tracer.ts +323 -285
  52. package/src/core/session/session-manager.ts +56 -56
  53. package/src/core/telemetry/telemetry.ts +86 -86
  54. package/src/core/topology/environment-detector.ts +109 -6
  55. package/src/index.ts +21 -21
  56. package/src/mcp/schemas.ts +695 -286
  57. package/src/mcp/server.ts +927 -716
  58. package/src/mcp/tools/check-boundary.ts +307 -152
  59. package/src/mcp/tools/get-domain-catalog.ts +155 -121
  60. package/src/mcp/tools/get-environment-topology.ts +3 -6
  61. package/src/mcp/tools/get-feature-context.ts +227 -116
  62. package/src/mcp/tools/get-symbol-hotspots.ts +54 -59
  63. package/src/mcp/tools/get-symbol-impact.ts +28 -26
  64. package/src/mcp/tools/get-symbol.ts +65 -63
  65. package/src/mcp/tools/locate-symbol.ts +169 -190
  66. package/src/mcp/tools/register-domain.ts +59 -64
  67. package/src/mcp/tools/register-feature.ts +91 -0
  68. package/src/mcp/tools/trace-vertical-slice.ts +74 -48
  69. package/src/types/index.ts +366 -315
  70. 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 = content.match(/@Controller\s*\(\s*['"]?([^'")]*)['"]?\s*\)\s*export\s+class\s+([A-Za-z0-9_]+)/);
39
- if (!controllerMatch) continue;
40
-
41
- const routePrefix = controllerMatch[1] ? `/${controllerMatch[1].replace(/^\/+|\/+$/g, "")}` : "";
42
- const controllerClass = controllerMatch[2];
43
-
44
- // Extract methods: @Get('path'), @Post('path'), etc.
45
- const methodRegex = /@(Get|Post|Put|Patch|Delete)\s*\(\s*['"]?([^'")]*)['"]?\s*\)\s*(?:@[A-Za-z0-9_]+\s*\([^)]*\)\s*)*\s*(?:async\s+)?([a-zA-Z0-9_]+)\s*\(([^)]*)\)/g;
46
- let match: RegExpExecArray | null;
47
-
48
- while ((match = methodRegex.exec(content)) !== null) {
49
- const httpMethod = match[1].toUpperCase();
50
- const subPath = match[2] ? `/${match[2].replace(/^\/+|\/+$/g, "")}` : "";
51
- const fullUri = `${routePrefix}${subPath}` || "/";
52
- const actionName = match[3];
53
- const params = match[4];
54
-
55
- // Extract DTO from parameters: e.g. @Body() createDto: CreateUserDto
56
- const dtoMatch = params.match(/@Body\s*\([^)]*\)\s*[a-zA-Z0-9_]+\s*:\s*([A-Za-z0-9_]+Dto)/);
57
- const formRequestClass = dtoMatch ? dtoMatch[1] : null;
58
-
59
- const chain: Array<{ stage: string; symbol: string; file?: string; line?: number; description?: string }> = [
60
- {
61
- stage: "ingress",
62
- symbol: `${httpMethod} ${fullUri}`,
63
- file: relPath,
64
- description: `NestJS Route: ${httpMethod} ${fullUri}`,
65
- },
66
- ];
67
-
68
- if (formRequestClass) {
69
- chain.push({
70
- stage: "validation",
71
- symbol: formRequestClass,
72
- description: "DTO Validation",
73
- });
74
- }
75
-
76
- chain.push({
77
- stage: "controller",
78
- symbol: `${controllerClass}::${actionName}`,
79
- file: relPath,
80
- line: 1,
81
- description: `NestJS Controller Action`,
82
- });
83
-
84
- slices.push({
85
- domain_id: domainId ?? null,
86
- feature_key: `nest.${controllerClass.toLowerCase().replace("controller", "")}.${actionName}`,
87
- http_method: httpMethod,
88
- route_uri: fullUri,
89
- route_name: `${controllerClass}.${actionName}`,
90
- controller_class: controllerClass,
91
- action_name: actionName,
92
- controller_file: relPath,
93
- controller_line: 1,
94
- architecture_style: "mvc",
95
- entry_kind: "http_route",
96
- execution_chain_json: JSON.stringify(chain),
97
- });
98
- }
99
- }
100
-
101
- return slices;
102
- }
103
-
104
- private findFilesRecursively(dir: string, pattern: RegExp): string[] {
105
- const results: string[] = [];
106
- try {
107
- const entries = fs.readdirSync(dir, { withFileTypes: true });
108
- for (const entry of entries) {
109
- const full = path.join(dir, entry.name);
110
- if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
111
- results.push(...this.findFilesRecursively(full, pattern));
112
- } else if (entry.isFile() && pattern.test(entry.name)) {
113
- results.push(full);
114
- }
115
- }
116
- } catch {}
117
- return results;
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
+ }