@dimassetoid/septum-mcp 0.2.1 → 0.5.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.
- package/README.md +46 -45
- package/package.json +8 -6
- package/src/cli/commands/check.ts +41 -26
- package/src/cli/commands/hook.ts +77 -105
- package/src/cli/commands/init.ts +35 -9
- package/src/cli/commands/stats.ts +33 -0
- package/src/cli/commands/sync-progress.ts +71 -0
- package/src/cli/commands/sync.ts +35 -9
- package/src/cli/hook-payload.ts +43 -0
- package/src/cli/index.ts +15 -51
- package/src/cli/scaffold/harness-config.ts +48 -8
- package/src/cli/templates/hooks.ts +51 -27
- package/src/cli/templates/rules.ts +34 -49
- package/src/cli/templates/skill.ts +46 -35
- package/src/core/boundary/audit.ts +383 -0
- package/src/core/boundary/evaluator.ts +299 -178
- package/src/core/boundary/staged-auditor.ts +188 -34
- package/src/core/config/domain-ownership.ts +47 -0
- package/src/core/config/domain-registration.ts +141 -0
- package/src/core/config/loader.ts +82 -54
- package/src/core/config/schema.ts +24 -46
- package/src/core/database/client.ts +2 -0
- package/src/core/database/repositories/dependency.repository.ts +326 -543
- package/src/core/database/repositories/domain.repository.ts +48 -4
- package/src/core/database/repositories/file.repository.ts +10 -0
- package/src/core/database/repositories/symbol.repository.ts +97 -259
- package/src/core/database/repository.ts +138 -24
- package/src/core/database/schema.ts +28 -33
- package/src/core/discovery/declarative-routes.ts +69 -0
- package/src/core/discovery/framework-detector.ts +149 -0
- package/src/core/discovery/navigation.ts +269 -0
- package/src/core/discovery/topology-detector.ts +153 -170
- package/src/core/errors.ts +19 -0
- package/src/core/ingestion/pipeline.ts +378 -212
- package/src/core/parser/behavioral-analyzer.ts +26 -22
- package/src/core/parser/boundary-tracker.ts +15 -0
- package/src/core/parser/extractors/base.ts +16 -4
- package/src/core/parser/extractors/csharp.ts +9 -5
- package/src/core/parser/extractors/django-routing.ts +163 -0
- package/src/core/parser/extractors/django-semantic.ts +400 -516
- package/src/core/parser/extractors/elysia-semantic.ts +172 -496
- package/src/core/parser/extractors/express-semantic.ts +195 -398
- package/src/core/parser/extractors/fastapi-semantic.ts +182 -399
- package/src/core/parser/extractors/fastify-semantic.ts +216 -732
- package/src/core/parser/extractors/flask-semantic.ts +92 -388
- package/src/core/parser/extractors/go-routing.ts +344 -0
- package/src/core/parser/extractors/go-semantic.ts +210 -508
- package/src/core/parser/extractors/go.ts +6 -3
- package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
- package/src/core/parser/extractors/hono-semantic.ts +132 -530
- package/src/core/parser/extractors/java.ts +7 -5
- package/src/core/parser/extractors/laravel-routing.ts +263 -0
- package/src/core/parser/extractors/laravel-semantic.ts +169 -333
- package/src/core/parser/extractors/manifest-helpers.ts +64 -0
- package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
- package/src/core/parser/extractors/mcp-cli-semantic.ts +84 -336
- package/src/core/parser/extractors/nestjs-semantic.ts +238 -510
- package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
- package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
- package/src/core/parser/extractors/php.ts +17 -1
- package/src/core/parser/extractors/python-route-ast.ts +249 -0
- package/src/core/parser/extractors/python.ts +9 -8
- package/src/core/parser/extractors/registry.ts +28 -5
- package/src/core/parser/extractors/route-prefixes.ts +43 -0
- package/src/core/parser/extractors/ruby.ts +10 -7
- package/src/core/parser/extractors/rust.ts +35 -17
- package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
- package/src/core/parser/extractors/symfony-routing.ts +114 -0
- package/src/core/parser/extractors/symfony-semantic.ts +75 -262
- package/src/core/parser/extractors/typescript-bindings.ts +333 -0
- package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
- package/src/core/parser/extractors/typescript-fallback.ts +207 -0
- package/src/core/parser/extractors/typescript-route-context.ts +58 -0
- package/src/core/parser/extractors/typescript.ts +36 -216
- package/src/core/parser/implementation-fingerprint.ts +97 -0
- package/src/core/parser/language-capabilities.ts +23 -7
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +77 -51
- package/src/core/parser/schema/schema-provider-registry.ts +1 -3
- package/src/core/parser/schema/schema-provider.interface.ts +2 -1
- package/src/core/parser/semantic-revision.ts +3 -0
- package/src/core/parser/static-string.ts +51 -0
- package/src/core/parser/wasm-loader.ts +6 -2
- package/src/core/resolver/ast-method-tracer.ts +230 -0
- package/src/core/resolver/call-graph-helpers.ts +72 -0
- package/src/core/resolver/call-graph-tracer.ts +375 -311
- package/src/core/resolver/dependency-analysis.ts +593 -0
- package/src/core/resolver/import-candidates.ts +120 -0
- package/src/core/resolver/import-evidence.ts +88 -0
- package/src/core/resolver/import-resolver.ts +162 -181
- package/src/core/resolver/interpretation-inputs.ts +65 -0
- package/src/core/resolver/languages/go.ts +103 -0
- package/src/core/resolver/languages/managed.ts +200 -0
- package/src/core/resolver/languages/python.ts +133 -0
- package/src/core/resolver/languages/ruby.ts +40 -0
- package/src/core/resolver/languages/rust.ts +127 -0
- package/src/core/resolver/languages/shared.ts +74 -0
- package/src/core/resolver/module-resolver.ts +18 -7
- package/src/core/resolver/path-resolver.ts +6 -3
- package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
- package/src/core/resolver/slice-catalog.ts +94 -0
- package/src/core/resolver/slice-format.ts +22 -0
- package/src/core/resolver/slice-selection.ts +237 -0
- package/src/core/resolver/symbol-impact.ts +477 -0
- package/src/core/resolver/symbol-locator.ts +82 -15
- package/src/core/resolver/vertical-slice-tracer.ts +57 -278
- package/src/core/resources/ignore.ts +21 -1
- package/src/core/resources/limits.ts +2 -1
- package/src/core/resources/source-files.ts +143 -20
- package/src/core/resources/source-inventory.ts +55 -0
- package/src/core/resources/work-queue.ts +167 -4
- package/src/core/retrieval/context-page.ts +116 -0
- package/src/core/retrieval/context.ts +457 -0
- package/src/core/retrieval/resolution-warnings.ts +21 -0
- package/src/core/retrieval/source-context.ts +448 -0
- package/src/core/retrieval/symbol-details.ts +453 -0
- package/src/core/retrieval/symbol-evidence.ts +97 -0
- package/src/core/retrieval/typescript-references.ts +293 -0
- package/src/core/retrieval/universal-context.ts +182 -0
- package/src/core/telemetry/summary.ts +114 -0
- package/src/core/telemetry/telemetry.ts +225 -37
- package/src/index.ts +0 -3
- package/src/mcp/formatters/compact-text.ts +439 -0
- package/src/mcp/resources-and-prompts.ts +253 -0
- package/src/mcp/schemas/boundary.ts +145 -0
- package/src/mcp/schemas/map.ts +250 -0
- package/src/mcp/schemas/shared.ts +52 -0
- package/src/mcp/schemas/slice.ts +60 -0
- package/src/mcp/schemas/symbol.ts +268 -0
- package/src/mcp/schemas.ts +5 -1105
- package/src/mcp/server.ts +263 -597
- package/src/mcp/tool-catalog.ts +331 -0
- package/src/mcp/tools/boundary.ts +69 -4
- package/src/mcp/tools/map.ts +126 -0
- package/src/mcp/tools/slice.ts +101 -3
- package/src/mcp/tools/symbol.ts +480 -26
- package/src/mcp/ui/app-client.ts +899 -0
- package/src/mcp/ui/app.html +478 -0
- package/src/mcp/workflow-playbooks.ts +181 -0
- package/src/mcp/workspace-boundary.ts +50 -0
- package/src/mcp/workspace-manager.ts +102 -18
- package/src/mcp/workspace-watcher.ts +38 -19
- package/src/types/index.ts +47 -53
- package/src/cli/commands/topology.ts +0 -161
- package/src/core/database/repositories/environment.repository.ts +0 -207
- package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
- package/src/core/session/session-manager.ts +0 -107
- package/src/core/topology/environment-detector.ts +0 -973
- package/src/core/topology/types.ts +0 -83
- package/src/mcp/tools/check-boundary.ts +0 -387
- package/src/mcp/tools/domain.ts +0 -40
- package/src/mcp/tools/feature.ts +0 -67
- package/src/mcp/tools/get-domain-catalog.ts +0 -226
- package/src/mcp/tools/get-environment-topology.ts +0 -138
- package/src/mcp/tools/get-feature-context.ts +0 -224
- package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
- package/src/mcp/tools/get-symbol-impact.ts +0 -64
- package/src/mcp/tools/get-symbol.ts +0 -175
- package/src/mcp/tools/locate-symbol.ts +0 -196
- package/src/mcp/tools/register-domain.ts +0 -75
- package/src/mcp/tools/register-feature.ts +0 -110
- package/src/mcp/tools/trace-vertical-slice.ts +0 -80
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import type { SeptumRepository } from "../database/repository.ts";
|
|
2
|
+
import type { NavigationQuery } from "../../types/index.ts";
|
|
3
|
+
|
|
4
|
+
export const NAVIGATION_SCHEMA = "navigation/v1";
|
|
5
|
+
|
|
6
|
+
type NavEdge = { from: string; to: string; relation: "imports"; count: number };
|
|
7
|
+
type NavUnresolved = { file: string; target: string; reason: string };
|
|
8
|
+
|
|
9
|
+
/** Aggregate resolved import edges and collect unresolved/stale import diagnostics. */
|
|
10
|
+
function aggregateImportEdges(
|
|
11
|
+
repo: SeptumRepository,
|
|
12
|
+
root: string,
|
|
13
|
+
files: ReturnType<SeptumRepository["getNavigationFiles"]>,
|
|
14
|
+
paths: Set<string>,
|
|
15
|
+
workspace: boolean
|
|
16
|
+
) {
|
|
17
|
+
const byPath = new Map(files.map(file => [file.path, file]));
|
|
18
|
+
const degree = new Map<string, number>();
|
|
19
|
+
const edges = new Map<string, NavEdge>();
|
|
20
|
+
const unresolved: NavUnresolved[] = [];
|
|
21
|
+
|
|
22
|
+
const relationshipList = workspace
|
|
23
|
+
? repo.getImportRelationships(root)
|
|
24
|
+
: repo.getScopedImportRelationships(root, { sourceOrTargetPaths: paths });
|
|
25
|
+
|
|
26
|
+
for (const edge of relationshipList) {
|
|
27
|
+
const source = edge.source.file;
|
|
28
|
+
const targets = [...new Set(edge.resolution.targets.flatMap(target => target.files))];
|
|
29
|
+
if (!paths.has(source) && !targets.some(target => paths.has(target))) continue;
|
|
30
|
+
|
|
31
|
+
const isIncomplete = edge.freshness !== "current" ||
|
|
32
|
+
!["resolved", "external"].includes(edge.resolution.status) ||
|
|
33
|
+
edge.resolution.coverage === "conditional" ||
|
|
34
|
+
edge.index_coverage === "partial";
|
|
35
|
+
if (isIncomplete) {
|
|
36
|
+
unresolved.push({
|
|
37
|
+
file: source,
|
|
38
|
+
target: edge.resolution.source.target,
|
|
39
|
+
reason: edge.freshness !== "current"
|
|
40
|
+
? `source_${edge.freshness}`
|
|
41
|
+
: edge.index_coverage === "partial"
|
|
42
|
+
? "target_not_fully_indexed"
|
|
43
|
+
: edge.resolution.reason,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (edge.freshness !== "current" || edge.resolution.status !== "resolved") continue;
|
|
47
|
+
|
|
48
|
+
for (const target of targets) {
|
|
49
|
+
degree.set(source, (degree.get(source) ?? 0) + 1);
|
|
50
|
+
degree.set(target, (degree.get(target) ?? 0) + 1);
|
|
51
|
+
const from = workspace ? byPath.get(source)?.domain : source;
|
|
52
|
+
const to = workspace ? byPath.get(target)?.domain : target;
|
|
53
|
+
if (!from || !to || (workspace && from === to)) continue;
|
|
54
|
+
const key = JSON.stringify([from, to]);
|
|
55
|
+
const prior = edges.get(key);
|
|
56
|
+
if (prior) prior.count++;
|
|
57
|
+
else edges.set(key, { from, to, relation: "imports", count: 1 });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { byPath, degree, edges, unresolved };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Summarize index health and coverage diagnostics for the selected navigation scope. */
|
|
65
|
+
function computeNavigationHealth(
|
|
66
|
+
repo: SeptumRepository,
|
|
67
|
+
domainRoot: string | undefined,
|
|
68
|
+
unresolved: NavUnresolved[],
|
|
69
|
+
emptyDomainsCount: number,
|
|
70
|
+
totalIndexedFiles: number,
|
|
71
|
+
uncoveredCount: number
|
|
72
|
+
) {
|
|
73
|
+
const sync = repo.getMeta("sync_state") ?? "unindexed";
|
|
74
|
+
const dirty = repo.getMeta("slices_dirty") === "1";
|
|
75
|
+
const prefix = domainRoot ? domainRoot.replace(/\/$/, "") + "/" : undefined;
|
|
76
|
+
const unsupported = (JSON.parse(repo.getMeta("unsupported_files") || "[]") as string[])
|
|
77
|
+
.filter(path => !prefix || path.startsWith(prefix)).length;
|
|
78
|
+
const skipped = (JSON.parse(repo.getMeta("skipped_files") || "[]") as Array<{ path: string }>)
|
|
79
|
+
.filter(file => !prefix || file.path.startsWith(prefix)).length;
|
|
80
|
+
|
|
81
|
+
const reasons = [...new Set([
|
|
82
|
+
...unresolved.map(item => item.reason),
|
|
83
|
+
...(unsupported > 0 ? ["unsupported_files"] : []),
|
|
84
|
+
...(skipped > 0 ? ["skipped_files"] : []),
|
|
85
|
+
...(emptyDomainsCount > 0 ? ["empty_domains"] : []),
|
|
86
|
+
...(totalIndexedFiles === 0 ? ["no_indexed_files"] : []),
|
|
87
|
+
...(!domainRoot && uncoveredCount > 0 ? ["uncovered_workspace_files"] : []),
|
|
88
|
+
...(dirty ? ["slices_dirty"] : []),
|
|
89
|
+
...(sync !== "complete" ? [`index_${sync}`] : []),
|
|
90
|
+
])].sort().slice(0, 10);
|
|
91
|
+
|
|
92
|
+
const coverage = sync === "complete" &&
|
|
93
|
+
!dirty &&
|
|
94
|
+
unresolved.length === 0 &&
|
|
95
|
+
unsupported === 0 &&
|
|
96
|
+
skipped === 0 &&
|
|
97
|
+
emptyDomainsCount === 0 &&
|
|
98
|
+
totalIndexedFiles > 0 &&
|
|
99
|
+
(domainRoot !== undefined || uncoveredCount === 0)
|
|
100
|
+
? "complete"
|
|
101
|
+
: "partial";
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
sync,
|
|
105
|
+
dirty,
|
|
106
|
+
health: { index: sync, sync_needed: dirty, coverage, unresolved_imports: unresolved.length, unsupported_files: unsupported, skipped_files: skipped, reasons },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Navigation selects indexed structure; declaration inspection belongs to symbol. */
|
|
111
|
+
export function buildNavigation(repo: SeptumRepository, args: NavigationQuery, root: string) {
|
|
112
|
+
const domains = repo.getAllDomains();
|
|
113
|
+
const requested = args.domain ?? args.name;
|
|
114
|
+
const domain = domains.find(d => d.name.toLowerCase() === requested?.toLowerCase());
|
|
115
|
+
if (requested && !domain) return {
|
|
116
|
+
schema: NAVIGATION_SCHEMA, status: "not_found", domain: requested,
|
|
117
|
+
found: false, message: `Domain '${requested}' not found in Septum catalog.`,
|
|
118
|
+
suggestions: domains.map(d => d.name),
|
|
119
|
+
suggested_action: { tool: "septum_map", params: { action: "catalog" } },
|
|
120
|
+
available_domains: domains.map(d => d.name),
|
|
121
|
+
next: [{ tool: "septum_map", args: { action: "catalog" } }],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const files = repo.getNavigationFiles();
|
|
125
|
+
const domainCounts = new Map<string, number>();
|
|
126
|
+
for (const file of files) domainCounts.set(file.domain, (domainCounts.get(file.domain) ?? 0) + 1);
|
|
127
|
+
|
|
128
|
+
const filter = args.file_filter?.replace(/\\/g, "/").toLowerCase();
|
|
129
|
+
const archetype = args.archetype_filter ?? args.archetype;
|
|
130
|
+
const matching = files.filter(file =>
|
|
131
|
+
(!domain || file.domain === domain.name) &&
|
|
132
|
+
(!filter || file.path.toLowerCase().includes(filter)) &&
|
|
133
|
+
(!archetype || file.archetype === archetype)
|
|
134
|
+
);
|
|
135
|
+
const paths = new Set(matching.map(file => file.path));
|
|
136
|
+
const workspace = !domain && !filter && !archetype;
|
|
137
|
+
|
|
138
|
+
const { byPath, degree, edges, unresolved } = aggregateImportEdges(repo, root, files, paths, workspace);
|
|
139
|
+
const entries = repo.getNavigationEntrypoints().filter(entry => entry.file && paths.has(entry.file));
|
|
140
|
+
const entryFiles = new Set(entries.map(entry => entry.file));
|
|
141
|
+
matching.sort((a, b) =>
|
|
142
|
+
Number(entryFiles.has(b.path)) - Number(entryFiles.has(a.path)) ||
|
|
143
|
+
(degree.get(b.path) ?? 0) - (degree.get(a.path) ?? 0) ||
|
|
144
|
+
a.path.localeCompare(b.path)
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const compactDomainOnly = Boolean(domain && !filter && !archetype && args.detail_level !== "full");
|
|
148
|
+
const useSubmoduleZoom = Boolean(
|
|
149
|
+
compactDomainOnly &&
|
|
150
|
+
domain &&
|
|
151
|
+
matching.length > 25 &&
|
|
152
|
+
args.file_offset === undefined &&
|
|
153
|
+
args.file_limit === undefined
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const submodules = useSubmoduleZoom && domain ? (() => {
|
|
157
|
+
const rootPrefix = domain.root_path.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
158
|
+
const groups = new Map<string, { path: string; name: string; file_count: number; top_anchors: string[] }>();
|
|
159
|
+
for (const file of matching) {
|
|
160
|
+
const norm = file.path.replace(/\\/g, "/");
|
|
161
|
+
const rel = norm.startsWith(`${rootPrefix}/`) ? norm.slice(rootPrefix.length + 1) : norm;
|
|
162
|
+
const slash = rel.indexOf("/");
|
|
163
|
+
const subName = slash > 0 ? rel.slice(0, slash) : "(root)";
|
|
164
|
+
const subPath = slash > 0 ? `${rootPrefix}/${subName}` : rootPrefix;
|
|
165
|
+
let group = groups.get(subPath);
|
|
166
|
+
if (!group) {
|
|
167
|
+
group = { path: subPath, name: subName, file_count: 0, top_anchors: [] };
|
|
168
|
+
groups.set(subPath, group);
|
|
169
|
+
}
|
|
170
|
+
group.file_count++;
|
|
171
|
+
if (file.anchor && group.top_anchors.length < 3 && !group.top_anchors.includes(file.anchor)) {
|
|
172
|
+
group.top_anchors.push(file.anchor);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return [...groups.values()].sort((a, b) => b.file_count - a.file_count || a.path.localeCompare(b.path));
|
|
176
|
+
})() : undefined;
|
|
177
|
+
|
|
178
|
+
const offset = args.file_offset ?? 0;
|
|
179
|
+
const limit = args.file_limit ?? (useSubmoduleZoom ? 15 : args.detail_level === "full" ? 100 : 40);
|
|
180
|
+
const selected = workspace ? [] : matching.slice(offset, offset + limit);
|
|
181
|
+
const selectedPaths = new Set(selected.map(file => file.path));
|
|
182
|
+
|
|
183
|
+
const allEdges = [...edges.values()].sort((a, b) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to));
|
|
184
|
+
const relevantEdges = workspace ? allEdges : allEdges.filter(edge => selectedPaths.has(edge.from) || selectedPaths.has(edge.to));
|
|
185
|
+
const filteredEdges = compactDomainOnly
|
|
186
|
+
? relevantEdges.filter(edge => byPath.get(edge.from)?.domain !== byPath.get(edge.to)?.domain)
|
|
187
|
+
: relevantEdges;
|
|
188
|
+
|
|
189
|
+
// When zooming out on a large domain (>25 files with submodules), aggregate cross-domain edges
|
|
190
|
+
// by submodule/domain instead of emitting dozens of raw file-to-file lines.
|
|
191
|
+
const dependencies = (() => {
|
|
192
|
+
if (useSubmoduleZoom && submodules && submodules.length > 1 && domain) {
|
|
193
|
+
const rootPrefix = domain.root_path.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
194
|
+
const groupLabel = (filePath: string): string => {
|
|
195
|
+
const meta = byPath.get(filePath);
|
|
196
|
+
if (!meta || meta.domain !== domain.name) return meta?.domain ?? filePath;
|
|
197
|
+
const norm = filePath.replace(/\\/g, "/");
|
|
198
|
+
const rel = norm.startsWith(`${rootPrefix}/`) ? norm.slice(rootPrefix.length + 1) : norm;
|
|
199
|
+
const slash = rel.indexOf("/");
|
|
200
|
+
return slash > 0 ? `${rootPrefix}/${rel.slice(0, slash)}` : rootPrefix;
|
|
201
|
+
};
|
|
202
|
+
const grouped = new Map<string, NavEdge>();
|
|
203
|
+
for (const edge of allEdges) {
|
|
204
|
+
const fromDomain = byPath.get(edge.from)?.domain;
|
|
205
|
+
const toDomain = byPath.get(edge.to)?.domain;
|
|
206
|
+
if (fromDomain === toDomain) continue;
|
|
207
|
+
const from = groupLabel(edge.from);
|
|
208
|
+
const to = groupLabel(edge.to);
|
|
209
|
+
if (from === to) continue;
|
|
210
|
+
const key = JSON.stringify([from, to]);
|
|
211
|
+
const prior = grouped.get(key);
|
|
212
|
+
if (prior) prior.count += edge.count;
|
|
213
|
+
else grouped.set(key, { from, to, relation: "imports", count: edge.count });
|
|
214
|
+
}
|
|
215
|
+
return [...grouped.values()]
|
|
216
|
+
.sort((a, b) => b.count - a.count || a.from.localeCompare(b.from) || a.to.localeCompare(b.to))
|
|
217
|
+
.slice(0, 30);
|
|
218
|
+
}
|
|
219
|
+
return filteredEdges.slice(0, 100);
|
|
220
|
+
})();
|
|
221
|
+
const entrypoints = entries.filter(entry => workspace || selectedPaths.has(entry.file!)).slice(0, 20);
|
|
222
|
+
const scopedDomains = workspace ? domains : domain ? [domain] : [];
|
|
223
|
+
const emptyDomainsCount = scopedDomains.filter(d => (domainCounts.get(d.name) ?? 0) === 0).length;
|
|
224
|
+
const uncoveredCount = (JSON.parse(repo.getMeta("uncovered_files") || "[]") as string[]).length;
|
|
225
|
+
const { sync, dirty, health } = computeNavigationHealth(repo, domain?.root_path, unresolved, emptyDomainsCount, files.length, uncoveredCount);
|
|
226
|
+
const end = offset + selected.length;
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
schema: NAVIGATION_SCHEMA,
|
|
230
|
+
status: requested || filter ? (matching.length ? "success" : domain && !filter ? "empty_domain" : "not_found") : (domains.length ? "success" : "NOT_INDEXED"),
|
|
231
|
+
scope: { level: workspace ? "workspace" : filter ? "file" : "domain", ...(domain ? { domain: domain.name } : {}), ...(filter ? { file_filter: args.file_filter } : {}) },
|
|
232
|
+
domains: (workspace ? domains : domain ? [domain] : []).map(d => ({
|
|
233
|
+
name: d.name,
|
|
234
|
+
root: d.root_path,
|
|
235
|
+
file_count: domainCounts.get(d.name) ?? 0,
|
|
236
|
+
allowed_dependencies: JSON.parse(d.allowed_deps_json || "[]") as string[],
|
|
237
|
+
forbidden_dependencies: JSON.parse(d.forbidden_deps_json || "[]") as string[],
|
|
238
|
+
})),
|
|
239
|
+
...(submodules && submodules.length > 1 ? { submodules } : {}),
|
|
240
|
+
files: selected,
|
|
241
|
+
dependencies,
|
|
242
|
+
entrypoints: entrypoints.map(entry => ({ ...entry, evidence: "static_catalog", runtime_verified: false })),
|
|
243
|
+
health,
|
|
244
|
+
index_status: { sync_state: sync, sync_needed: dirty },
|
|
245
|
+
accounting: {
|
|
246
|
+
matching_files: matching.length,
|
|
247
|
+
returned_files: selected.length,
|
|
248
|
+
omitted_files: workspace ? 0 : Math.max(0, matching.length - selected.length),
|
|
249
|
+
total_dependencies: allEdges.length,
|
|
250
|
+
returned_dependencies: dependencies.length,
|
|
251
|
+
omitted_dependencies: allEdges.length - dependencies.length,
|
|
252
|
+
total_entrypoints: entries.length,
|
|
253
|
+
omitted_entrypoints: entries.length - entrypoints.length,
|
|
254
|
+
},
|
|
255
|
+
...(!workspace && end < matching.length ? { pagination: { next_file_offset: end, file_offset: offset } } : {}),
|
|
256
|
+
...(args.include_evidence ? { diagnostics: unresolved.slice(0, 5), diagnostics_omitted: Math.max(0, unresolved.length - 5) } : {}),
|
|
257
|
+
next: submodules && submodules.length > 1 && domain
|
|
258
|
+
? [
|
|
259
|
+
{ tool: "septum_map", args: { action: "catalog", domain: domain.name, file_filter: submodules[0]!.path } },
|
|
260
|
+
...(selected[0]?.anchor ? [{ tool: "septum_symbol", args: { action: "locate", query: selected[0].anchor, file_path: selected[0].path } }] : []),
|
|
261
|
+
]
|
|
262
|
+
: entrypoints[0]
|
|
263
|
+
? [{ tool: "septum_slice", args: { query: `${entrypoints[0].method} ${entrypoints[0].target}`, controller_file: entrypoints[0].file } }]
|
|
264
|
+
: selected[0]?.anchor
|
|
265
|
+
? [{ tool: "septum_symbol", args: { action: "locate", query: selected[0].anchor, file_path: selected[0].path } }]
|
|
266
|
+
: [{ tool: "septum_map", args: { action: "catalog", ...(domains[0] ? { domain: domains[0].name } : {}) } }],
|
|
267
|
+
relationship_limits: "Dependencies are static imports; entrypoints are from the static catalog.",
|
|
268
|
+
};
|
|
269
|
+
}
|
|
@@ -3,6 +3,13 @@ import * as path from "node:path";
|
|
|
3
3
|
import type { DomainConfig } from "../../types/index.ts";
|
|
4
4
|
import type { SeptumRepository } from "../database/repository.ts";
|
|
5
5
|
import { DEFAULT_IGNORED_DIRECTORIES, isIgnoredDirectory } from "../resources/ignore.ts";
|
|
6
|
+
import { assertUniqueDomainRoots, domainNameKey, domainRootIdentity } from "../config/domain-ownership.ts";
|
|
7
|
+
import {
|
|
8
|
+
detectProjectFramework,
|
|
9
|
+
detectProjectLanguage,
|
|
10
|
+
readTsConfigPaths as readTsConfigPathMappings,
|
|
11
|
+
type DetectedLanguage,
|
|
12
|
+
} from "./framework-detector.ts";
|
|
6
13
|
|
|
7
14
|
export type ProjectType =
|
|
8
15
|
| "monorepo"
|
|
@@ -31,6 +38,13 @@ export interface DiscoveredProjectTopology {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export class TopologyDetector {
|
|
41
|
+
private static warnIfUnexpectedError(context: string, err: unknown): void {
|
|
42
|
+
const errno = (err as NodeJS.ErrnoException | undefined)?.code;
|
|
43
|
+
if (errno === "ENOENT" || errno === "ENOTDIR") return;
|
|
44
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
45
|
+
console.warn(`[Septum Topology] ${context}: ${msg}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
private static readonly IGNORED_DIRS = new Set([
|
|
35
49
|
...DEFAULT_IGNORED_DIRECTORIES,
|
|
36
50
|
"tests",
|
|
@@ -59,22 +73,7 @@ export class TopologyDetector {
|
|
|
59
73
|
* Reads compilerOptions.paths from tsconfig.json or jsconfig.json.
|
|
60
74
|
*/
|
|
61
75
|
public static readTsConfigPaths(projectRoot: string): Record<string, string[]> {
|
|
62
|
-
|
|
63
|
-
const fullPath = path.join(projectRoot, file);
|
|
64
|
-
if (fs.existsSync(fullPath)) {
|
|
65
|
-
try {
|
|
66
|
-
const raw = fs.readFileSync(fullPath, "utf-8");
|
|
67
|
-
const stripped = raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, "");
|
|
68
|
-
const parsed = JSON.parse(stripped);
|
|
69
|
-
if (parsed.compilerOptions?.paths) {
|
|
70
|
-
return parsed.compilerOptions.paths;
|
|
71
|
-
}
|
|
72
|
-
} catch {
|
|
73
|
-
// Ignore tsconfig parse error
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return {};
|
|
76
|
+
return readTsConfigPathMappings(projectRoot);
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
/**
|
|
@@ -189,6 +188,21 @@ export class TopologyDetector {
|
|
|
189
188
|
archetypes: this.inferDefaultArchetypes(path.join(projectRoot, item.relRoot)),
|
|
190
189
|
};
|
|
191
190
|
}
|
|
191
|
+
|
|
192
|
+
// Also include top-level monorepo workspace apps (e.g. Directus api/, app/, sdk/)
|
|
193
|
+
for (const topApp of ["api", "app", "server", "web", "sdk"]) {
|
|
194
|
+
const fullTop = path.join(projectRoot, topApp);
|
|
195
|
+
if (!domains[topApp] && fs.existsSync(fullTop) && fs.statSync(fullTop).isDirectory() && this.hasSourceFiles(fullTop)) {
|
|
196
|
+
const isSdk = topApp === "sdk";
|
|
197
|
+
domains[topApp] = {
|
|
198
|
+
root: topApp,
|
|
199
|
+
description: `Monorepo top-level workspace: ${topApp}`,
|
|
200
|
+
allowed_dependencies: isSdk ? [] : packageDomains,
|
|
201
|
+
forbidden_dependencies: isSdk ? appDomains : [],
|
|
202
|
+
archetypes: this.inferDefaultArchetypes(fullTop),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
192
206
|
}
|
|
193
207
|
|
|
194
208
|
// 2. Modular DDD (app/Domain, src/modules, src/domains, domains/*, etc.)
|
|
@@ -420,66 +434,75 @@ export class TopologyDetector {
|
|
|
420
434
|
} else if (language === "go" || fs.existsSync(path.join(projectRoot, "go.mod"))) {
|
|
421
435
|
architectureStyle = "clean-architecture";
|
|
422
436
|
const pkgDir = path.join(projectRoot, "pkg");
|
|
423
|
-
|
|
437
|
+
const hasPkg = fs.existsSync(pkgDir) && this.hasSourceFiles(pkgDir);
|
|
438
|
+
|
|
439
|
+
const internalDir = path.join(projectRoot, "internal");
|
|
440
|
+
const internalSubs = fs.existsSync(internalDir)
|
|
441
|
+
? this.getSubdirectories(internalDir).filter((s) => this.hasSourceFiles(path.join(internalDir, s))).sort()
|
|
442
|
+
: [];
|
|
443
|
+
const hasFlatInternal = !internalSubs.length && fs.existsSync(internalDir) && this.hasSourceFiles(internalDir);
|
|
444
|
+
const internalNames = internalSubs.length > 0
|
|
445
|
+
? internalSubs.map((s) => s.toLowerCase())
|
|
446
|
+
: hasFlatInternal ? ["internal"] : [];
|
|
447
|
+
|
|
448
|
+
const cmdDir = path.join(projectRoot, "cmd");
|
|
449
|
+
const cmdSubs = fs.existsSync(cmdDir)
|
|
450
|
+
? this.getSubdirectories(cmdDir).filter((s) => this.hasSourceFiles(path.join(cmdDir, s))).sort()
|
|
451
|
+
: [];
|
|
452
|
+
const hasFlatCmd = !cmdSubs.length && fs.existsSync(cmdDir) && this.hasSourceFiles(cmdDir);
|
|
453
|
+
const cmdNames = cmdSubs.length > 0
|
|
454
|
+
? cmdSubs.map((s) => `cmd-${s.toLowerCase()}`)
|
|
455
|
+
: hasFlatCmd ? ["cmd"] : [];
|
|
456
|
+
|
|
457
|
+
if (hasPkg) {
|
|
424
458
|
domains["pkg"] = {
|
|
425
459
|
root: "pkg",
|
|
426
460
|
description: "Go public library pkg",
|
|
427
461
|
allowed_dependencies: [],
|
|
428
|
-
forbidden_dependencies: [
|
|
462
|
+
forbidden_dependencies: [...internalNames, ...cmdNames],
|
|
429
463
|
archetypes: this.inferDefaultArchetypes(pkgDir),
|
|
430
464
|
};
|
|
431
465
|
}
|
|
432
466
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
root: path.join("internal", sub),
|
|
442
|
-
description: `Internal ${sub} domain`,
|
|
443
|
-
allowed_dependencies: domains["pkg"] ? ["pkg"] : [],
|
|
444
|
-
forbidden_dependencies: ["cmd"],
|
|
445
|
-
archetypes: this.inferDefaultArchetypes(path.join(internalDir, sub)),
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
} else if (this.hasSourceFiles(internalDir)) {
|
|
449
|
-
domains["internal"] = {
|
|
450
|
-
root: "internal",
|
|
451
|
-
description: "Go internal layer",
|
|
452
|
-
allowed_dependencies: domains["pkg"] ? ["pkg"] : [],
|
|
453
|
-
forbidden_dependencies: ["cmd"],
|
|
454
|
-
archetypes: this.inferDefaultArchetypes(internalDir),
|
|
467
|
+
if (internalSubs.length > 0) {
|
|
468
|
+
for (const sub of internalSubs) {
|
|
469
|
+
domains[sub.toLowerCase()] = {
|
|
470
|
+
root: path.join("internal", sub),
|
|
471
|
+
description: `Internal ${sub} domain`,
|
|
472
|
+
allowed_dependencies: hasPkg ? ["pkg"] : [],
|
|
473
|
+
forbidden_dependencies: [...cmdNames],
|
|
474
|
+
archetypes: this.inferDefaultArchetypes(path.join(internalDir, sub)),
|
|
455
475
|
};
|
|
456
476
|
}
|
|
477
|
+
} else if (hasFlatInternal) {
|
|
478
|
+
domains["internal"] = {
|
|
479
|
+
root: "internal",
|
|
480
|
+
description: "Go internal layer",
|
|
481
|
+
allowed_dependencies: hasPkg ? ["pkg"] : [],
|
|
482
|
+
forbidden_dependencies: [...cmdNames],
|
|
483
|
+
archetypes: this.inferDefaultArchetypes(internalDir),
|
|
484
|
+
};
|
|
457
485
|
}
|
|
458
486
|
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
domains[`cmd-${sub.toLowerCase()}`] = {
|
|
467
|
-
root: path.join("cmd", sub),
|
|
468
|
-
description: `Go entrypoint: ${sub}`,
|
|
469
|
-
allowed_dependencies: Object.keys(domains),
|
|
470
|
-
forbidden_dependencies: [],
|
|
471
|
-
archetypes: this.inferDefaultArchetypes(path.join(cmdDir, sub)),
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
} else if (this.hasSourceFiles(cmdDir)) {
|
|
475
|
-
domains["cmd"] = {
|
|
476
|
-
root: "cmd",
|
|
477
|
-
description: "Go entrypoint cmd",
|
|
478
|
-
allowed_dependencies: Object.keys(domains),
|
|
487
|
+
const cmdAllowed = [...(hasPkg ? ["pkg"] : []), ...internalNames];
|
|
488
|
+
if (cmdSubs.length > 0) {
|
|
489
|
+
for (const sub of cmdSubs) {
|
|
490
|
+
domains[`cmd-${sub.toLowerCase()}`] = {
|
|
491
|
+
root: path.join("cmd", sub),
|
|
492
|
+
description: `Go entrypoint: ${sub}`,
|
|
493
|
+
allowed_dependencies: [...cmdAllowed],
|
|
479
494
|
forbidden_dependencies: [],
|
|
480
|
-
archetypes: this.inferDefaultArchetypes(cmdDir),
|
|
495
|
+
archetypes: this.inferDefaultArchetypes(path.join(cmdDir, sub)),
|
|
481
496
|
};
|
|
482
497
|
}
|
|
498
|
+
} else if (hasFlatCmd) {
|
|
499
|
+
domains["cmd"] = {
|
|
500
|
+
root: "cmd",
|
|
501
|
+
description: "Go entrypoint cmd",
|
|
502
|
+
allowed_dependencies: [...cmdAllowed],
|
|
503
|
+
forbidden_dependencies: [],
|
|
504
|
+
archetypes: this.inferDefaultArchetypes(cmdDir),
|
|
505
|
+
};
|
|
483
506
|
}
|
|
484
507
|
}
|
|
485
508
|
}
|
|
@@ -523,7 +546,9 @@ export class TopologyDetector {
|
|
|
523
546
|
}
|
|
524
547
|
}
|
|
525
548
|
}
|
|
526
|
-
} catch {
|
|
549
|
+
} catch (err: unknown) {
|
|
550
|
+
this.warnIfUnexpectedError(`Failed to scan ignored directories in ${projectRoot}`, err);
|
|
551
|
+
}
|
|
527
552
|
ignored_folders.sort();
|
|
528
553
|
|
|
529
554
|
return {
|
|
@@ -547,16 +572,73 @@ export class TopologyDetector {
|
|
|
547
572
|
projectRoot: string = process.cwd(),
|
|
548
573
|
forceResetPolicies: boolean = false
|
|
549
574
|
): Record<string, DomainConfig> {
|
|
575
|
+
assertUniqueDomainRoots(Object.fromEntries(repo.getAllDomains().map(domain => [domain.name, { root: domain.root_path }])), projectRoot);
|
|
550
576
|
const topology = this.detect(projectRoot);
|
|
551
577
|
|
|
552
578
|
for (const [name, config] of Object.entries(topology.domains)) {
|
|
553
579
|
const existing = repo.domains.getDomainByName(name);
|
|
554
580
|
if (!existing || forceResetPolicies) {
|
|
555
|
-
|
|
581
|
+
const identity = domainRootIdentity(config.root, projectRoot);
|
|
582
|
+
const owner = repo.getAllDomains().find(domain => domainRootIdentity(domain.root_path, projectRoot) === identity && domainNameKey(domain.name) !== domainNameKey(name));
|
|
583
|
+
// Inference must not create an alias for an explicitly registered owner.
|
|
584
|
+
if (owner && !existing) continue;
|
|
585
|
+
repo.domains.upsertDomain(name, config, projectRoot);
|
|
556
586
|
}
|
|
557
587
|
}
|
|
558
588
|
|
|
559
|
-
|
|
589
|
+
if (forceResetPolicies) {
|
|
590
|
+
repo.domains.pruneDomainsNotIn(Object.keys(topology.domains));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return this.persistMacroMetadata(repo, topology);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Synchronize explicit domains from septum.config.json as the SSOT without
|
|
598
|
+
* writing auto-discovered domains, while still updating macro metadata and
|
|
599
|
+
* reporting any detected framework sub-domains shadowed by coarse roots.
|
|
600
|
+
*/
|
|
601
|
+
public static syncExplicitConfigDomains(
|
|
602
|
+
repo: SeptumRepository,
|
|
603
|
+
projectRoot: string,
|
|
604
|
+
explicitDomains: Record<string, DomainConfig>
|
|
605
|
+
): {
|
|
606
|
+
domains: Record<string, DomainConfig>;
|
|
607
|
+
shadowedSubdomains: Array<{ explicitDomain: string; explicitRoot: string; detectedNames: string[] }>;
|
|
608
|
+
} {
|
|
609
|
+
assertUniqueDomainRoots(explicitDomains, projectRoot);
|
|
610
|
+
for (const [name, config] of Object.entries(explicitDomains)) {
|
|
611
|
+
repo.domains.upsertDomain(name, config, projectRoot);
|
|
612
|
+
}
|
|
613
|
+
repo.domains.pruneDomainsNotIn(Object.keys(explicitDomains));
|
|
614
|
+
|
|
615
|
+
const topology = this.detect(projectRoot);
|
|
616
|
+
const domains = this.persistMacroMetadata(repo, topology);
|
|
617
|
+
|
|
618
|
+
const shadowedSubdomains: Array<{ explicitDomain: string; explicitRoot: string; detectedNames: string[] }> = [];
|
|
619
|
+
for (const [explicitDomain, explicitCfg] of Object.entries(explicitDomains)) {
|
|
620
|
+
const parentAbs = path.resolve(projectRoot, explicitCfg.root);
|
|
621
|
+
const detectedNames: string[] = [];
|
|
622
|
+
for (const [detectedName, detectedCfg] of Object.entries(topology.domains)) {
|
|
623
|
+
if (domainNameKey(detectedName) === domainNameKey(explicitDomain)) continue;
|
|
624
|
+
const childAbs = path.resolve(projectRoot, detectedCfg.root);
|
|
625
|
+
const rel = path.relative(parentAbs, childAbs);
|
|
626
|
+
if (rel !== "" && rel !== ".." && !rel.startsWith(".." + path.sep) && !path.isAbsolute(rel)) {
|
|
627
|
+
detectedNames.push(detectedName);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (detectedNames.length > 0) {
|
|
631
|
+
shadowedSubdomains.push({ explicitDomain, explicitRoot: explicitCfg.root, detectedNames });
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return { domains, shadowedSubdomains };
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
private static persistMacroMetadata(
|
|
639
|
+
repo: SeptumRepository,
|
|
640
|
+
topology: DiscoveredProjectTopology
|
|
641
|
+
): Record<string, DomainConfig> {
|
|
560
642
|
repo.setMeta("project_type", topology.projectType);
|
|
561
643
|
repo.setMeta("architecture_style", topology.architectureStyle);
|
|
562
644
|
repo.setMeta("framework", topology.framework);
|
|
@@ -675,121 +757,22 @@ export class TopologyDetector {
|
|
|
675
757
|
if (Object.keys(archetypes).length === 0) {
|
|
676
758
|
archetypes["source"] = "**/*.*";
|
|
677
759
|
}
|
|
678
|
-
} catch {
|
|
760
|
+
} catch (err: unknown) {
|
|
761
|
+
this.warnIfUnexpectedError(`Failed to infer archetypes in ${fullDir}`, err);
|
|
762
|
+
}
|
|
679
763
|
|
|
680
764
|
return archetypes;
|
|
681
765
|
}
|
|
682
766
|
|
|
683
|
-
private static detectLanguage(projectRoot: string):
|
|
684
|
-
|
|
685
|
-
fs.existsSync(path.join(projectRoot, "composer.json")) ||
|
|
686
|
-
fs.existsSync(path.join(projectRoot, "artisan"))
|
|
687
|
-
) {
|
|
688
|
-
return "php";
|
|
689
|
-
}
|
|
690
|
-
if (fs.existsSync(path.join(projectRoot, "go.mod"))) return "go";
|
|
691
|
-
if (
|
|
692
|
-
fs.existsSync(path.join(projectRoot, "pyproject.toml")) ||
|
|
693
|
-
fs.existsSync(path.join(projectRoot, "requirements.txt"))
|
|
694
|
-
) {
|
|
695
|
-
return "python";
|
|
696
|
-
}
|
|
697
|
-
if (
|
|
698
|
-
fs.existsSync(path.join(projectRoot, "tsconfig.json")) ||
|
|
699
|
-
fs.existsSync(path.join(projectRoot, "package.json"))
|
|
700
|
-
) {
|
|
701
|
-
return "typescript";
|
|
702
|
-
}
|
|
703
|
-
return "generic";
|
|
767
|
+
private static detectLanguage(projectRoot: string): DetectedLanguage {
|
|
768
|
+
return detectProjectLanguage(projectRoot);
|
|
704
769
|
}
|
|
705
770
|
|
|
706
771
|
private static detectFramework(
|
|
707
772
|
projectRoot: string,
|
|
708
|
-
language:
|
|
773
|
+
language: DetectedLanguage
|
|
709
774
|
): string {
|
|
710
|
-
|
|
711
|
-
if (fs.existsSync(path.join(projectRoot, "artisan"))) return "laravel";
|
|
712
|
-
if (
|
|
713
|
-
fs.existsSync(path.join(projectRoot, "bin/console")) ||
|
|
714
|
-
fs.existsSync(path.join(projectRoot, "symfony.lock"))
|
|
715
|
-
) {
|
|
716
|
-
return "symfony";
|
|
717
|
-
}
|
|
718
|
-
const composerJson = path.join(projectRoot, "composer.json");
|
|
719
|
-
if (fs.existsSync(composerJson)) {
|
|
720
|
-
try {
|
|
721
|
-
const composer = JSON.parse(fs.readFileSync(composerJson, "utf-8"));
|
|
722
|
-
const reqs = { ...(composer.require ?? {}), ...(composer["require-dev"] ?? {}) };
|
|
723
|
-
if (reqs["symfony/framework-bundle"] || reqs["symfony/symfony"]) {
|
|
724
|
-
return "symfony";
|
|
725
|
-
}
|
|
726
|
-
} catch {}
|
|
727
|
-
}
|
|
728
|
-
return "generic-php";
|
|
729
|
-
}
|
|
730
|
-
if (language === "typescript" || language === "javascript") {
|
|
731
|
-
const pkgJson = path.join(projectRoot, "package.json");
|
|
732
|
-
try {
|
|
733
|
-
if (fs.existsSync(pkgJson)) {
|
|
734
|
-
const pkg = JSON.parse(fs.readFileSync(pkgJson, "utf-8"));
|
|
735
|
-
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
736
|
-
if (allDeps.next) return "nextjs";
|
|
737
|
-
if (allDeps.nuxt) return "nuxt";
|
|
738
|
-
if (allDeps.astro) return "astro";
|
|
739
|
-
if (allDeps.vue) return "vue";
|
|
740
|
-
if (allDeps["@nestjs/core"]) return "nestjs";
|
|
741
|
-
if (allDeps.express) return "express";
|
|
742
|
-
if (allDeps.fastify) return "fastify";
|
|
743
|
-
if (allDeps.hono) return "hono";
|
|
744
|
-
if (allDeps.elysia) return "elysia";
|
|
745
|
-
if (allDeps["@modelcontextprotocol/sdk"]) return "mcp-server";
|
|
746
|
-
}
|
|
747
|
-
} catch (err: unknown) {
|
|
748
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
749
|
-
console.warn(`[Septum Topology] Failed to inspect dependencies in ${pkgJson}: ${msg}`);
|
|
750
|
-
}
|
|
751
|
-
return "generic-node";
|
|
752
|
-
}
|
|
753
|
-
if (language === "python") {
|
|
754
|
-
if (
|
|
755
|
-
fs.existsSync(path.join(projectRoot, "manage.py")) ||
|
|
756
|
-
fs.existsSync(path.join(projectRoot, "wsgi.py")) ||
|
|
757
|
-
fs.existsSync(path.join(projectRoot, "asgi.py"))
|
|
758
|
-
) {
|
|
759
|
-
return "django";
|
|
760
|
-
}
|
|
761
|
-
const readSafe = (p: string) => {
|
|
762
|
-
try {
|
|
763
|
-
return fs.existsSync(p) ? fs.readFileSync(p, "utf-8").toLowerCase() : "";
|
|
764
|
-
} catch {
|
|
765
|
-
return "";
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
const deps =
|
|
769
|
-
readSafe(path.join(projectRoot, "requirements.txt")) +
|
|
770
|
-
" " +
|
|
771
|
-
readSafe(path.join(projectRoot, "pyproject.toml")) +
|
|
772
|
-
" " +
|
|
773
|
-
readSafe(path.join(projectRoot, "Pipfile"));
|
|
774
|
-
if (deps.includes("fastapi")) return "fastapi";
|
|
775
|
-
if (deps.includes("django")) return "django";
|
|
776
|
-
if (deps.includes("flask")) return "flask";
|
|
777
|
-
return "generic-python";
|
|
778
|
-
}
|
|
779
|
-
if (language === "go") {
|
|
780
|
-
const goModPath = path.join(projectRoot, "go.mod");
|
|
781
|
-
if (fs.existsSync(goModPath)) {
|
|
782
|
-
try {
|
|
783
|
-
const modContent = fs.readFileSync(goModPath, "utf-8").toLowerCase();
|
|
784
|
-
if (modContent.includes("github.com/gin-gonic/gin")) return "gin";
|
|
785
|
-
if (modContent.includes("github.com/labstack/echo")) return "echo";
|
|
786
|
-
if (modContent.includes("github.com/go-chi/chi")) return "chi";
|
|
787
|
-
if (modContent.includes("github.com/gofiber/fiber")) return "fiber";
|
|
788
|
-
} catch {}
|
|
789
|
-
}
|
|
790
|
-
return "generic-go";
|
|
791
|
-
}
|
|
792
|
-
return "generic";
|
|
775
|
+
return detectProjectFramework(projectRoot, language);
|
|
793
776
|
}
|
|
794
777
|
|
|
795
778
|
private static getSubdirectories(dir: string): string[] {
|