septum 0.1.0

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/bin/septum.ts +4 -0
  4. package/package.json +62 -0
  5. package/src/cli/commands/check.ts +161 -0
  6. package/src/cli/commands/hook.ts +188 -0
  7. package/src/cli/commands/ingest.ts +29 -0
  8. package/src/cli/commands/init.ts +211 -0
  9. package/src/cli/commands/locate.ts +61 -0
  10. package/src/cli/commands/query.ts +64 -0
  11. package/src/cli/commands/serve.ts +5 -0
  12. package/src/cli/commands/slice.ts +90 -0
  13. package/src/cli/commands/sync.ts +31 -0
  14. package/src/cli/index.ts +178 -0
  15. package/src/cli/templates/hooks.ts +75 -0
  16. package/src/cli/templates/rules.ts +38 -0
  17. package/src/cli/templates/skill.ts +66 -0
  18. package/src/core/boundary/evaluator.ts +210 -0
  19. package/src/core/config/loader.ts +84 -0
  20. package/src/core/config/schema.ts +39 -0
  21. package/src/core/database/client.ts +132 -0
  22. package/src/core/database/repositories/dependency.repository.ts +279 -0
  23. package/src/core/database/repositories/domain.repository.ts +198 -0
  24. package/src/core/database/repositories/file.repository.ts +99 -0
  25. package/src/core/database/repositories/meta.repository.ts +33 -0
  26. package/src/core/database/repositories/symbol.repository.ts +424 -0
  27. package/src/core/database/repository.ts +242 -0
  28. package/src/core/database/schema.sql +92 -0
  29. package/src/core/discovery/topology-detector.ts +418 -0
  30. package/src/core/ingestion/hasher.ts +5 -0
  31. package/src/core/ingestion/pipeline.ts +438 -0
  32. package/src/core/parser/boundary-tracker.ts +128 -0
  33. package/src/core/parser/extractors/base.ts +60 -0
  34. package/src/core/parser/extractors/frontend.ts +194 -0
  35. package/src/core/parser/extractors/go.ts +176 -0
  36. package/src/core/parser/extractors/laravel-semantic.ts +426 -0
  37. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -0
  38. package/src/core/parser/extractors/nestjs-semantic.ts +119 -0
  39. package/src/core/parser/extractors/php.ts +149 -0
  40. package/src/core/parser/extractors/python.ts +226 -0
  41. package/src/core/parser/extractors/registry.ts +49 -0
  42. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -0
  43. package/src/core/parser/extractors/typescript.ts +177 -0
  44. package/src/core/parser/tree-sitter.ts +39 -0
  45. package/src/core/resolver/call-graph-tracer.ts +668 -0
  46. package/src/core/resolver/module-resolver.ts +323 -0
  47. package/src/core/resolver/symbol-locator.ts +405 -0
  48. package/src/core/resolver/vertical-slice-tracer.ts +236 -0
  49. package/src/core/session/session-manager.ts +56 -0
  50. package/src/core/telemetry/telemetry.ts +86 -0
  51. package/src/index.ts +18 -0
  52. package/src/mcp/schemas.ts +68 -0
  53. package/src/mcp/server.ts +602 -0
  54. package/src/mcp/tools/check-boundary.ts +102 -0
  55. package/src/mcp/tools/get-domain-catalog.ts +91 -0
  56. package/src/mcp/tools/get-feature-context.ts +116 -0
  57. package/src/mcp/tools/get-symbol-hotspots.ts +49 -0
  58. package/src/mcp/tools/get-symbol-impact.ts +26 -0
  59. package/src/mcp/tools/get-symbol.ts +63 -0
  60. package/src/mcp/tools/locate-symbol.ts +74 -0
  61. package/src/mcp/tools/register-domain.ts +64 -0
  62. package/src/mcp/tools/trace-vertical-slice.ts +102 -0
  63. package/src/types/index.ts +296 -0
@@ -0,0 +1,92 @@
1
+ -- Septum Embedded SQLite Database Schema
2
+ -- Version 1.0
3
+
4
+ PRAGMA foreign_keys = ON;
5
+
6
+ CREATE TABLE IF NOT EXISTS domains (
7
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
8
+ name TEXT NOT NULL UNIQUE,
9
+ root_path TEXT NOT NULL,
10
+ allowed_deps_json TEXT NOT NULL DEFAULT '[]',
11
+ forbidden_deps_json TEXT NOT NULL DEFAULT '[]',
12
+ archetypes_json TEXT NOT NULL DEFAULT '{}',
13
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
14
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
15
+ );
16
+
17
+ CREATE TABLE IF NOT EXISTS files (
18
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
19
+ domain_id INTEGER NOT NULL,
20
+ path TEXT NOT NULL UNIQUE,
21
+ archetype TEXT NOT NULL DEFAULT 'unknown',
22
+ content_hash TEXT NOT NULL,
23
+ line_count INTEGER NOT NULL DEFAULT 0,
24
+ mtime_ms INTEGER NOT NULL DEFAULT 0,
25
+ size_bytes INTEGER NOT NULL DEFAULT 0,
26
+ last_scanned_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
27
+ FOREIGN KEY (domain_id) REFERENCES domains(id) ON DELETE CASCADE
28
+ );
29
+
30
+ CREATE TABLE IF NOT EXISTS symbols (
31
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
32
+ file_id INTEGER NOT NULL,
33
+ name TEXT NOT NULL,
34
+ kind TEXT NOT NULL, -- 'class' | 'interface' | 'trait' | 'method' | 'function' | 'property'
35
+ signature TEXT NOT NULL,
36
+ visibility TEXT NOT NULL DEFAULT 'public', -- 'public' | 'protected' | 'private'
37
+ line_start INTEGER NOT NULL DEFAULT 0,
38
+ line_end INTEGER NOT NULL DEFAULT 0,
39
+ line_count INTEGER NOT NULL DEFAULT 1,
40
+ FOREIGN KEY (file_id) REFERENCES files(id) ON DELETE CASCADE
41
+ );
42
+
43
+ CREATE TABLE IF NOT EXISTS dependencies (
44
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
45
+ source_file_id INTEGER NOT NULL,
46
+ target_symbol_or_path TEXT NOT NULL,
47
+ import_statement TEXT NOT NULL,
48
+ line_number INTEGER NOT NULL DEFAULT 0,
49
+ is_external BOOLEAN NOT NULL DEFAULT 0,
50
+ FOREIGN KEY (source_file_id) REFERENCES files(id) ON DELETE CASCADE
51
+ );
52
+
53
+ -- Fast Lookup Indexes
54
+ CREATE INDEX IF NOT EXISTS idx_domains_name ON domains(name);
55
+ CREATE INDEX IF NOT EXISTS idx_files_domain_id ON files(domain_id);
56
+ CREATE INDEX IF NOT EXISTS idx_files_path ON files(path);
57
+ CREATE INDEX IF NOT EXISTS idx_symbols_file_id ON symbols(file_id);
58
+ CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
59
+ CREATE INDEX IF NOT EXISTS idx_symbols_kind ON symbols(kind);
60
+ CREATE INDEX IF NOT EXISTS idx_symbols_line_count ON symbols(kind, line_count DESC);
61
+ CREATE INDEX IF NOT EXISTS idx_dependencies_source ON dependencies(source_file_id);
62
+ CREATE INDEX IF NOT EXISTS idx_dependencies_target ON dependencies(target_symbol_or_path);
63
+
64
+ CREATE TABLE IF NOT EXISTS vertical_slices (
65
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
66
+ domain_id INTEGER,
67
+ feature_key TEXT,
68
+ http_method TEXT NOT NULL,
69
+ route_uri TEXT NOT NULL,
70
+ route_name TEXT,
71
+ controller_class TEXT NOT NULL,
72
+ action_name TEXT NOT NULL,
73
+ controller_file TEXT,
74
+ controller_line INTEGER DEFAULT 0,
75
+ architecture_style TEXT NOT NULL DEFAULT 'clean',
76
+ entry_kind TEXT NOT NULL DEFAULT 'http_route',
77
+ execution_chain_json TEXT NOT NULL,
78
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
79
+ FOREIGN KEY (domain_id) REFERENCES domains(id) ON DELETE CASCADE
80
+ );
81
+
82
+ CREATE INDEX IF NOT EXISTS idx_slices_route_uri ON vertical_slices(route_uri);
83
+ CREATE INDEX IF NOT EXISTS idx_slices_route_name ON vertical_slices(route_name);
84
+ CREATE INDEX IF NOT EXISTS idx_slices_controller ON vertical_slices(controller_class, action_name);
85
+
86
+ -- Synchronization & Watermark SSOT Tracking
87
+ CREATE TABLE IF NOT EXISTS repo_meta (
88
+ key TEXT PRIMARY KEY,
89
+ value TEXT NOT NULL,
90
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
91
+ );
92
+
@@ -0,0 +1,418 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import type { DomainConfig } from "../../types/index.ts";
4
+ import type { SeptumRepository } from "../database/repository.ts";
5
+
6
+ export type ProjectType =
7
+ | "monorepo"
8
+ | "fullstack"
9
+ | "backend"
10
+ | "frontend"
11
+ | "cli-mcp"
12
+ | "generic";
13
+
14
+ export type ArchitectureStyle =
15
+ | "modular-ddd"
16
+ | "layered-monolith"
17
+ | "clean-architecture"
18
+ | "monorepo-workspaces"
19
+ | "cli-adapter"
20
+ | "generic";
21
+
22
+ export interface DiscoveredProjectTopology {
23
+ framework: string;
24
+ language: "typescript" | "javascript" | "php" | "python" | "go" | "generic";
25
+ projectType: ProjectType;
26
+ architectureStyle: ArchitectureStyle;
27
+ domains: Record<string, DomainConfig>;
28
+ }
29
+
30
+ export class TopologyDetector {
31
+ private static readonly IGNORED_DIRS = new Set([
32
+ "node_modules",
33
+ "vendor",
34
+ "dist",
35
+ "build",
36
+ ".git",
37
+ ".septum",
38
+ ".system_generated",
39
+ "tests",
40
+ "test",
41
+ "coverage",
42
+ ".vscode",
43
+ ".idea",
44
+ ".agents",
45
+ "bin",
46
+ ]);
47
+
48
+ /**
49
+ * Detects project topology, classifies project type & architecture style, and maps domains.
50
+ */
51
+ public static detect(projectRoot: string = process.cwd()): DiscoveredProjectTopology {
52
+ const language = this.detectLanguage(projectRoot);
53
+ const framework = this.detectFramework(projectRoot, language);
54
+ const isMonorepo = this.detectMonorepo(projectRoot);
55
+
56
+ const domains: Record<string, DomainConfig> = {};
57
+ let architectureStyle: ArchitectureStyle = "generic";
58
+
59
+ // 1. Monorepo Workspaces (apps/*, packages/*)
60
+ if (isMonorepo) {
61
+ architectureStyle = "monorepo-workspaces";
62
+ const workspaceDirs = ["apps", "packages", "modules"];
63
+ const appDomains: string[] = [];
64
+ const packageDomains: string[] = [];
65
+
66
+ for (const parent of workspaceDirs) {
67
+ const fullParent = path.join(projectRoot, parent);
68
+ if (fs.existsSync(fullParent) && fs.statSync(fullParent).isDirectory()) {
69
+ const subs = this.getSubdirectories(fullParent);
70
+ for (const sub of subs) {
71
+ const relRoot = path.join(parent, sub);
72
+ const domainName = sub.toLowerCase();
73
+ if (parent === "apps") appDomains.push(domainName);
74
+ else packageDomains.push(domainName);
75
+
76
+ domains[domainName] = {
77
+ root: relRoot,
78
+ description: `Monorepo ${parent} package: ${sub}`,
79
+ allowed_dependencies: parent === "apps" ? packageDomains : [],
80
+ forbidden_dependencies: parent !== "apps" ? appDomains : [],
81
+ archetypes: this.inferDefaultArchetypes(path.join(projectRoot, relRoot)),
82
+ };
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ // 2. Modular DDD (app/Domain, src/modules, src/domains, etc.)
89
+ if (Object.keys(domains).length === 0) {
90
+ const modularCandidates = [
91
+ { prefix: "domain", dir: path.join(projectRoot, "app", "Domain") },
92
+ { prefix: "domain", dir: path.join(projectRoot, "app", "Domains") },
93
+ { prefix: "domain", dir: path.join(projectRoot, "src", "domains") },
94
+ { prefix: "feature", dir: path.join(projectRoot, "src", "features") },
95
+ { prefix: "module", dir: path.join(projectRoot, "src", "modules") },
96
+ ];
97
+
98
+ for (const cand of modularCandidates) {
99
+ if (fs.existsSync(cand.dir) && fs.statSync(cand.dir).isDirectory()) {
100
+ const subdirs = this.getSubdirectories(cand.dir);
101
+ if (subdirs.length > 0) {
102
+ architectureStyle = "modular-ddd";
103
+ for (const sub of subdirs) {
104
+ const relRoot = path.relative(projectRoot, path.join(cand.dir, sub));
105
+ domains[sub.toLowerCase()] = {
106
+ root: relRoot,
107
+ description: `Modular ${cand.prefix} domain: ${sub}`,
108
+ allowed_dependencies: ["shared", "common"],
109
+ forbidden_dependencies: [],
110
+ archetypes: this.inferDefaultArchetypes(path.join(projectRoot, relRoot)),
111
+ };
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ // 3. Layered Monolith / Clean Architecture in src/
119
+ const srcDir = path.join(projectRoot, "src");
120
+ if (Object.keys(domains).length === 0 && fs.existsSync(srcDir) && fs.statSync(srcDir).isDirectory()) {
121
+ const subdirs = this.getSubdirectories(srcDir);
122
+ if (subdirs.length > 0) {
123
+ architectureStyle =
124
+ framework === "mcp-server" || framework === "cli"
125
+ ? "cli-adapter"
126
+ : "layered-monolith";
127
+
128
+ const sharedKernelNames = new Set(["types", "shared", "common", "contracts"]);
129
+ const coreNames = new Set(["core", "domain", "services", "usecase", "internal"]);
130
+ const adapterNames = new Set([
131
+ "cli",
132
+ "mcp",
133
+ "api",
134
+ "controllers",
135
+ "routes",
136
+ "handlers",
137
+ "delivery",
138
+ ]);
139
+
140
+ for (const sub of subdirs) {
141
+ const relRoot = path.join("src", sub);
142
+ const name = sub.toLowerCase();
143
+ let allowed: string[] = [];
144
+ let forbidden: string[] = [];
145
+
146
+ if (sharedKernelNames.has(name)) {
147
+ allowed = [];
148
+ forbidden = Array.from(adapterNames)
149
+ .concat(Array.from(coreNames))
150
+ .filter((n) => subdirs.map((s) => s.toLowerCase()).includes(n));
151
+ } else if (coreNames.has(name)) {
152
+ allowed = subdirs
153
+ .map((s) => s.toLowerCase())
154
+ .filter((s) => sharedKernelNames.has(s));
155
+ forbidden = subdirs
156
+ .map((s) => s.toLowerCase())
157
+ .filter((s) => adapterNames.has(s));
158
+ } else {
159
+ // Adapters
160
+ allowed = subdirs
161
+ .map((s) => s.toLowerCase())
162
+ .filter((s) => sharedKernelNames.has(s) || coreNames.has(s));
163
+ forbidden = [];
164
+ }
165
+
166
+ domains[name] = {
167
+ root: relRoot,
168
+ description: `${sub} layer`,
169
+ allowed_dependencies: allowed,
170
+ forbidden_dependencies: forbidden,
171
+ archetypes: this.inferDefaultArchetypes(path.join(projectRoot, relRoot)),
172
+ };
173
+ }
174
+ }
175
+ }
176
+
177
+ // 4. Framework-specific structural patterns (Laravel, Go)
178
+ if (Object.keys(domains).length === 0) {
179
+ if (language === "php" || framework.includes("laravel")) {
180
+ const appDir = path.join(projectRoot, "app");
181
+ if (fs.existsSync(appDir)) {
182
+ architectureStyle = "layered-monolith";
183
+ const subdirs = this.getSubdirectories(appDir);
184
+ for (const sub of subdirs) {
185
+ domains[sub.toLowerCase()] = {
186
+ root: path.join("app", sub),
187
+ description: `Laravel layer: ${sub}`,
188
+ allowed_dependencies: [],
189
+ forbidden_dependencies: [],
190
+ archetypes: this.inferDefaultArchetypes(path.join(projectRoot, "app", sub)),
191
+ };
192
+ }
193
+ }
194
+ } else if (language === "go") {
195
+ architectureStyle = "clean-architecture";
196
+ for (const goDir of ["cmd", "internal", "pkg"]) {
197
+ const full = path.join(projectRoot, goDir);
198
+ if (fs.existsSync(full)) {
199
+ domains[goDir] = {
200
+ root: goDir,
201
+ description: `Go layer: ${goDir}`,
202
+ allowed_dependencies:
203
+ goDir === "cmd"
204
+ ? ["internal", "pkg"]
205
+ : goDir === "internal"
206
+ ? ["pkg"]
207
+ : [],
208
+ forbidden_dependencies: goDir === "pkg" ? ["internal", "cmd"] : [],
209
+ archetypes: this.inferDefaultArchetypes(full),
210
+ };
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ // 5. Fallback: Top-level directories
217
+ if (Object.keys(domains).length === 0) {
218
+ const topDirs = this.getSubdirectories(projectRoot);
219
+ for (const d of topDirs) {
220
+ domains[d.toLowerCase()] = {
221
+ root: d,
222
+ description: `Top-level domain: ${d}`,
223
+ allowed_dependencies: [],
224
+ forbidden_dependencies: [],
225
+ archetypes: this.inferDefaultArchetypes(path.join(projectRoot, d)),
226
+ };
227
+ }
228
+ }
229
+
230
+ const projectType = this.detectProjectType(projectRoot, framework, language, isMonorepo);
231
+
232
+ return {
233
+ framework,
234
+ language,
235
+ projectType,
236
+ architectureStyle,
237
+ domains,
238
+ };
239
+ }
240
+
241
+ /**
242
+ * Discovers project topology and persists domains and macro metadata directly into SQLite SSOT.
243
+ */
244
+ public static discoverAndPersist(
245
+ repo: SeptumRepository,
246
+ projectRoot: string = process.cwd()
247
+ ): Record<string, DomainConfig> {
248
+ const topology = this.detect(projectRoot);
249
+
250
+ for (const [name, config] of Object.entries(topology.domains)) {
251
+ repo.upsertDomain(name, config);
252
+ }
253
+
254
+ // Persist Macro Metadata SSOT
255
+ repo.setMeta("project_type", topology.projectType);
256
+ repo.setMeta("architecture_style", topology.architectureStyle);
257
+ repo.setMeta("framework", topology.framework);
258
+ repo.setMeta("language", topology.language);
259
+ repo.setMeta(
260
+ "macro_summary",
261
+ JSON.stringify({
262
+ projectType: topology.projectType,
263
+ framework: topology.framework,
264
+ architectureStyle: topology.architectureStyle,
265
+ domainsCount: Object.keys(topology.domains).length,
266
+ domains: Object.keys(topology.domains),
267
+ })
268
+ );
269
+
270
+ return topology.domains;
271
+ }
272
+
273
+ private static detectMonorepo(projectRoot: string): boolean {
274
+ if (
275
+ fs.existsSync(path.join(projectRoot, "pnpm-workspace.yaml")) ||
276
+ fs.existsSync(path.join(projectRoot, "lerna.json")) ||
277
+ fs.existsSync(path.join(projectRoot, "turbo.json"))
278
+ ) {
279
+ return true;
280
+ }
281
+
282
+ const hasApps = fs.existsSync(path.join(projectRoot, "apps"));
283
+ const hasPackages = fs.existsSync(path.join(projectRoot, "packages"));
284
+ if (hasApps && hasPackages) return true;
285
+
286
+ const pkgPath = path.join(projectRoot, "package.json");
287
+ if (fs.existsSync(pkgPath)) {
288
+ try {
289
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
290
+ if (pkg.workspaces && Array.isArray(pkg.workspaces) && pkg.workspaces.length > 0) {
291
+ return true;
292
+ }
293
+ } catch (err: unknown) {
294
+ const msg = err instanceof Error ? err.message : String(err);
295
+ console.warn(`[Septum Topology] Could not parse ${pkgPath}: ${msg}`);
296
+ }
297
+ }
298
+
299
+ return false;
300
+ }
301
+
302
+ private static detectProjectType(
303
+ projectRoot: string,
304
+ framework: string,
305
+ language: string,
306
+ isMonorepo: boolean
307
+ ): ProjectType {
308
+ if (isMonorepo) return "monorepo";
309
+
310
+ if (framework === "mcp-server" || framework === "cli") return "cli-mcp";
311
+
312
+ if (framework === "nextjs" || framework === "nuxt" || framework === "astro") {
313
+ return "fullstack";
314
+ }
315
+
316
+ if (framework.includes("laravel")) {
317
+ const hasJs = fs.existsSync(path.join(projectRoot, "resources/js"));
318
+ const hasViews = fs.existsSync(path.join(projectRoot, "resources/views"));
319
+ return hasJs || hasViews ? "fullstack" : "backend";
320
+ }
321
+
322
+ if (framework === "vue" || framework === "react") {
323
+ return "frontend";
324
+ }
325
+
326
+ if (
327
+ framework === "nestjs" ||
328
+ framework === "express" ||
329
+ framework === "fastify" ||
330
+ language === "go" ||
331
+ language === "python" ||
332
+ language === "php"
333
+ ) {
334
+ return "backend";
335
+ }
336
+
337
+ return "generic";
338
+ }
339
+
340
+ private static inferDefaultArchetypes(fullDir: string): Record<string, string> {
341
+ const archetypes: Record<string, string> = {};
342
+ if (!fs.existsSync(fullDir)) return archetypes;
343
+
344
+ try {
345
+ const items = fs.readdirSync(fullDir, { withFileTypes: true });
346
+ for (const it of items) {
347
+ if (it.isDirectory() && !it.name.startsWith(".")) {
348
+ const name = it.name.toLowerCase();
349
+ archetypes[name] = `${it.name}/**`;
350
+ }
351
+ }
352
+ if (Object.keys(archetypes).length === 0) {
353
+ archetypes["source"] = "**/*.*";
354
+ }
355
+ } catch {}
356
+
357
+ return archetypes;
358
+ }
359
+
360
+ private static detectLanguage(projectRoot: string): DiscoveredProjectTopology["language"] {
361
+ if (fs.existsSync(path.join(projectRoot, "composer.json"))) return "php";
362
+ if (fs.existsSync(path.join(projectRoot, "go.mod"))) return "go";
363
+ if (
364
+ fs.existsSync(path.join(projectRoot, "pyproject.toml")) ||
365
+ fs.existsSync(path.join(projectRoot, "requirements.txt"))
366
+ ) {
367
+ return "python";
368
+ }
369
+ if (
370
+ fs.existsSync(path.join(projectRoot, "tsconfig.json")) ||
371
+ fs.existsSync(path.join(projectRoot, "package.json"))
372
+ ) {
373
+ return "typescript";
374
+ }
375
+ return "generic";
376
+ }
377
+
378
+ private static detectFramework(
379
+ projectRoot: string,
380
+ language: DiscoveredProjectTopology["language"]
381
+ ): string {
382
+ if (language === "php") {
383
+ if (fs.existsSync(path.join(projectRoot, "artisan"))) return "laravel";
384
+ return "generic-php";
385
+ }
386
+ if (language === "typescript" || language === "javascript") {
387
+ try {
388
+ const pkgJson = path.join(projectRoot, "package.json");
389
+ if (fs.existsSync(pkgJson)) {
390
+ const pkg = JSON.parse(fs.readFileSync(pkgJson, "utf-8"));
391
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
392
+ if (allDeps.next) return "nextjs";
393
+ if (allDeps.nuxt) return "nuxt";
394
+ if (allDeps.astro) return "astro";
395
+ if (allDeps.vue) return "vue";
396
+ if (allDeps["@nestjs/core"]) return "nestjs";
397
+ if (allDeps["@modelcontextprotocol/sdk"]) return "mcp-server";
398
+ }
399
+ } catch (err: unknown) {
400
+ const msg = err instanceof Error ? err.message : String(err);
401
+ console.warn(`[Septum Topology] Failed to inspect dependencies in ${pkgJson}: ${msg}`);
402
+ }
403
+ return "generic-node";
404
+ }
405
+ return "generic";
406
+ }
407
+
408
+ private static getSubdirectories(dir: string): string[] {
409
+ try {
410
+ return fs
411
+ .readdirSync(dir, { withFileTypes: true })
412
+ .filter((e) => e.isDirectory() && !this.IGNORED_DIRS.has(e.name) && !e.name.startsWith("."))
413
+ .map((e) => e.name);
414
+ } catch {
415
+ return [];
416
+ }
417
+ }
418
+ }
@@ -0,0 +1,5 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ export function computeContentHash(content: string): string {
4
+ return createHash("sha256").update(content, "utf8").digest("hex");
5
+ }