@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,164 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import type { ExecutionChainNode } from "../../../types/index.ts";
|
|
5
|
+
import { probeSourcePath, readOptionalSourceFile } from "../../resources/source-files.ts";
|
|
6
|
+
import { listSourceFiles, type SourceInventory } from "../../resources/source-inventory.ts";
|
|
7
|
+
import type { SemanticSliceExtractor, VerticalSliceCandidate } from "./semantic-extractor.interface.ts";
|
|
8
|
+
import { lineOf, TypeScriptBindings } from "./typescript-bindings.ts";
|
|
9
|
+
|
|
10
|
+
const NEXTJS_HTTP_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]);
|
|
11
|
+
|
|
12
|
+
/** Converts an App Router `.../app/.../route.ts` relative path into a normalized URI. */
|
|
13
|
+
export function nextAppRouteFileToUri(relPath: string): string | null {
|
|
14
|
+
const norm = relPath.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
15
|
+
const match = norm.match(/(?:^|.*\/)app\/(?:(.+)\/)?route\.[cm]?[jt]sx?$/i);
|
|
16
|
+
if (!match) return null;
|
|
17
|
+
const rawSegments = (match[1] ?? "").split("/").filter(Boolean);
|
|
18
|
+
const uriSegments: string[] = [];
|
|
19
|
+
for (const seg of rawSegments) {
|
|
20
|
+
// Next.js route groups `(group)` do not appear in URL paths.
|
|
21
|
+
if (/^\([^)]+\)$/.test(seg)) continue;
|
|
22
|
+
const catchAll = seg.match(/^\[\.\.\.([^\]]+)\]$/);
|
|
23
|
+
if (catchAll) {
|
|
24
|
+
uriSegments.push(`*${catchAll[1]}`);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const optCatchAll = seg.match(/^\[\[\.\.\.([^\]]+)\]\]$/);
|
|
28
|
+
if (optCatchAll) {
|
|
29
|
+
uriSegments.push(`*${optCatchAll[1]}`);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const dynamicSeg = seg.match(/^\[([^\]]+)\]$/);
|
|
33
|
+
if (dynamicSeg) {
|
|
34
|
+
uriSegments.push(`:${dynamicSeg[1]}`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
uriSegments.push(seg);
|
|
38
|
+
}
|
|
39
|
+
return "/" + uriSegments.join("/");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class NextJsSemanticExtractor implements SemanticSliceExtractor {
|
|
43
|
+
public readonly id = "nextjs";
|
|
44
|
+
public readonly name = "Next.js App Router Semantic Extractor";
|
|
45
|
+
|
|
46
|
+
public canHandle(projectRoot: string, framework?: string): boolean {
|
|
47
|
+
if (framework === "nextjs") return true;
|
|
48
|
+
const hasNextInPkg = (manifestFile: string): boolean => {
|
|
49
|
+
if (probeSourcePath(manifestFile) !== "file") return false;
|
|
50
|
+
const manifest = readOptionalSourceFile(manifestFile, "utf-8");
|
|
51
|
+
if (!manifest) return false;
|
|
52
|
+
try {
|
|
53
|
+
const pkg = JSON.parse(manifest);
|
|
54
|
+
return !!(pkg.dependencies?.next || pkg.devDependencies?.next);
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (hasNextInPkg(path.join(projectRoot, "package.json"))) return true;
|
|
60
|
+
for (const group of ["apps", "packages"]) {
|
|
61
|
+
const groupDir = path.join(projectRoot, group);
|
|
62
|
+
if (probeSourcePath(groupDir) === "directory") {
|
|
63
|
+
try {
|
|
64
|
+
for (const entry of fs.readdirSync(groupDir, { withFileTypes: true })) {
|
|
65
|
+
if (entry.isDirectory() && hasNextInPkg(path.join(groupDir, entry.name, "package.json"))) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
// Ignore unreadable directories
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public async extractSlices(
|
|
78
|
+
projectRoot: string,
|
|
79
|
+
domainId?: number,
|
|
80
|
+
signal?: AbortSignal,
|
|
81
|
+
inventory?: SourceInventory
|
|
82
|
+
): Promise<VerticalSliceCandidate[]> {
|
|
83
|
+
const root = path.resolve(projectRoot);
|
|
84
|
+
const allTsFiles = listSourceFiles(root, /\.[cm]?[jt]sx?$/, inventory).filter((f) => !/\.d\.[cm]?ts$/.test(f));
|
|
85
|
+
const routeFiles = allTsFiles.filter((f) => /(?:^|\/)app\/(?:.+\/)?route\.[cm]?[jt]sx?$/i.test(f));
|
|
86
|
+
if (routeFiles.length === 0) return [];
|
|
87
|
+
|
|
88
|
+
const bindings = new TypeScriptBindings(root, new Set(allTsFiles), signal);
|
|
89
|
+
const slices: VerticalSliceCandidate[] = [];
|
|
90
|
+
|
|
91
|
+
for (const file of routeFiles) {
|
|
92
|
+
signal?.throwIfAborted();
|
|
93
|
+
const relFile = path.relative(root, file).replace(/\\/g, "/");
|
|
94
|
+
const uri = nextAppRouteFileToUri(relFile);
|
|
95
|
+
if (!uri) continue;
|
|
96
|
+
|
|
97
|
+
const unit = bindings.load(file);
|
|
98
|
+
if (!unit) continue;
|
|
99
|
+
|
|
100
|
+
const exportedHandlers: Array<{ method: string; node: ts.Node; line: number }> = [];
|
|
101
|
+
for (const stmt of unit.source.statements) {
|
|
102
|
+
const mods = ts.canHaveModifiers(stmt) ? ts.getModifiers(stmt) : undefined;
|
|
103
|
+
const isExported = Boolean(mods?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword));
|
|
104
|
+
if (!isExported) continue;
|
|
105
|
+
|
|
106
|
+
if (ts.isFunctionDeclaration(stmt) && stmt.name && NEXTJS_HTTP_METHODS.has(stmt.name.text)) {
|
|
107
|
+
exportedHandlers.push({ method: stmt.name.text, node: stmt, line: lineOf(stmt) });
|
|
108
|
+
} else if (ts.isVariableStatement(stmt)) {
|
|
109
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
110
|
+
if (ts.isIdentifier(decl.name) && NEXTJS_HTTP_METHODS.has(decl.name.text) && decl.initializer) {
|
|
111
|
+
const handler = bindings.handler(decl.initializer);
|
|
112
|
+
exportedHandlers.push({
|
|
113
|
+
method: decl.name.text,
|
|
114
|
+
node: handler?.node ?? decl.initializer,
|
|
115
|
+
line: handler ? lineOf(handler.node) : lineOf(decl),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (exportedHandlers.length === 0) continue;
|
|
123
|
+
|
|
124
|
+
const controllerClass = path.basename(path.dirname(relFile)) || "Route";
|
|
125
|
+
for (const entry of exportedHandlers) {
|
|
126
|
+
const chain: ExecutionChainNode[] = [
|
|
127
|
+
{
|
|
128
|
+
stage: "ingress",
|
|
129
|
+
symbol: `${entry.method} ${uri}`,
|
|
130
|
+
file: relFile,
|
|
131
|
+
line: entry.line,
|
|
132
|
+
description: "Next.js App Router Route Handler",
|
|
133
|
+
relationship: { kind: "declares", derivation: "source", reason: "Next.js App Router export" },
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
stage: "controller",
|
|
137
|
+
symbol: `${controllerClass}::${entry.method}`,
|
|
138
|
+
file: relFile,
|
|
139
|
+
line: entry.line,
|
|
140
|
+
description: `Next.js ${entry.method} Handler`,
|
|
141
|
+
relationship: { kind: "route_binding", derivation: "source", reason: "Next.js App Router handler" },
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
slices.push({
|
|
146
|
+
domain_id: domainId ?? null,
|
|
147
|
+
feature_key: `nextjs.${controllerClass.toLowerCase()}.${entry.method.toLowerCase()}`,
|
|
148
|
+
http_method: entry.method,
|
|
149
|
+
route_uri: uri,
|
|
150
|
+
route_name: `${controllerClass}.${entry.method}`,
|
|
151
|
+
controller_class: controllerClass,
|
|
152
|
+
action_name: entry.method,
|
|
153
|
+
controller_file: relFile,
|
|
154
|
+
controller_line: entry.line,
|
|
155
|
+
architecture_style: "mvc",
|
|
156
|
+
entry_kind: "http_route",
|
|
157
|
+
execution_chain_json: JSON.stringify(chain),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return slices;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type Parser from "web-tree-sitter";
|
|
2
|
+
|
|
3
|
+
type Node = Parser.SyntaxNode;
|
|
4
|
+
|
|
5
|
+
export function children(node?: Node | null): Node[] {
|
|
6
|
+
return node?.namedChildren.filter(child => child.type !== "comment") ?? [];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function literal(node?: Node): string | undefined {
|
|
10
|
+
if (node?.type === "string") return node.text.slice(1, -1).replace(/\\([\\'])/g, "$1");
|
|
11
|
+
if (node?.type === "encapsed_string" && children(node).every(child => child.type === "string_content")) {
|
|
12
|
+
const value = node.text.slice(1, -1);
|
|
13
|
+
if (!value.includes("\\")) return value;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function phpSections(root: Node): Array<{ namespace: string; statements: Node[] }> {
|
|
19
|
+
const sections = [{ namespace: "", statements: [] as Node[] }];
|
|
20
|
+
for (const node of children(root)) {
|
|
21
|
+
if (node.type !== "namespace_definition") {
|
|
22
|
+
sections.at(-1)!.statements.push(node);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const namespace = node.childForFieldName("name")?.text ?? "";
|
|
26
|
+
const body = node.childForFieldName("body");
|
|
27
|
+
sections.push({ namespace, statements: children(body) });
|
|
28
|
+
if (body) sections.push({ namespace: "", statements: [] });
|
|
29
|
+
}
|
|
30
|
+
return sections;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function importsFor(statements: Node[]): Map<string, string | null> {
|
|
34
|
+
const imports = new Map<string, string | null>();
|
|
35
|
+
for (const node of statements) {
|
|
36
|
+
if (node.type !== "namespace_use_declaration" || /^use\s+(?:function|const)\b/i.test(node.text)) continue;
|
|
37
|
+
const group = children(node).find(child => child.type === "namespace_use_group");
|
|
38
|
+
const prefix = group ? children(node).find(child => child.type === "namespace_name")?.text : undefined;
|
|
39
|
+
for (const clause of group ? children(group) : children(node)) {
|
|
40
|
+
if (!["namespace_use_clause", "namespace_use_group_clause"].includes(clause.type) ||
|
|
41
|
+
/^(?:function|const)\s/i.test(clause.text)) continue;
|
|
42
|
+
const targetNode = children(clause).find(child => ["name", "qualified_name", "namespace_name"].includes(child.type));
|
|
43
|
+
if (!targetNode) continue;
|
|
44
|
+
const target = [prefix, targetNode.text].filter(Boolean).join("\\").replace(/^\\/, "");
|
|
45
|
+
const alias = children(clause).find(child => child.type === "namespace_aliasing_clause");
|
|
46
|
+
const key = (alias?.namedChild(0)?.text ?? target.split("\\").at(-1)!).toLowerCase();
|
|
47
|
+
imports.set(key, imports.has(key) ? null : target);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return imports;
|
|
51
|
+
}
|
|
@@ -369,7 +369,7 @@ export class PHPExtractor implements CodeExtractor {
|
|
|
369
369
|
};
|
|
370
370
|
const lineStart = node.startPosition.row + 1;
|
|
371
371
|
const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
|
|
372
|
-
const headerLine = getNodeHeader(node);
|
|
372
|
+
const headerLine = getNodeHeader(node, content);
|
|
373
373
|
|
|
374
374
|
symbols.push({
|
|
375
375
|
name: containerName,
|
|
@@ -485,6 +485,22 @@ export class PHPExtractor implements CodeExtractor {
|
|
|
485
485
|
line_count: mCount,
|
|
486
486
|
nesting_depth: nestingDepth,
|
|
487
487
|
});
|
|
488
|
+
if (methodName.toLowerCase() === "__construct" && paramsNode) {
|
|
489
|
+
for (const param of paramsNode.namedChildren) {
|
|
490
|
+
if (param.type !== "property_promotion_parameter") continue;
|
|
491
|
+
const propName = param.childForFieldName("name");
|
|
492
|
+
if (!propName) continue;
|
|
493
|
+
symbols.push({
|
|
494
|
+
name: `${containerName}::${propName.text}`,
|
|
495
|
+
kind: "property",
|
|
496
|
+
signature: param.text,
|
|
497
|
+
visibility: this.extractPhpVisibility(param),
|
|
498
|
+
line_start: param.startPosition.row + 1,
|
|
499
|
+
line_end: param.endPosition.row + 1,
|
|
500
|
+
line_count: param.endPosition.row - param.startPosition.row + 1,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
488
504
|
continue;
|
|
489
505
|
}
|
|
490
506
|
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import type Parser from "web-tree-sitter";
|
|
2
|
+
import type { ImportResolver } from "../../resolver/import-resolver.ts";
|
|
3
|
+
import { readPythonStaticString } from "../static-string.ts";
|
|
4
|
+
|
|
5
|
+
type Node = Parser.SyntaxNode;
|
|
6
|
+
export type PythonImport = { module: string; symbol?: string; qualifiedRoot?: string };
|
|
7
|
+
|
|
8
|
+
export function pythonImports(statement: Node): Array<[string, PythonImport]> {
|
|
9
|
+
const from = statement.type === "import_from_statement";
|
|
10
|
+
if (!from && statement.type !== "import_statement") return [];
|
|
11
|
+
const source = statement.childForFieldName("module_name");
|
|
12
|
+
return statement.namedChildren.flatMap((child): Array<[string, PythonImport]> => {
|
|
13
|
+
if (child.id === source?.id) return [];
|
|
14
|
+
const name = child.type === "aliased_import" ? child.childForFieldName("name") : child;
|
|
15
|
+
if (name?.type !== "dotted_name") return [];
|
|
16
|
+
const alias = child.childForFieldName("alias")?.text;
|
|
17
|
+
if (from && source) return [[alias ?? name.text, { module: source.text, symbol: name.text }]];
|
|
18
|
+
const head = name.text.split(".")[0]!;
|
|
19
|
+
return [[alias ?? head, { module: name.text, qualifiedRoot: alias ? undefined : name.text }]];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function pythonImportMember(module: string, symbol: string): string {
|
|
24
|
+
return module.endsWith(".") ? module + symbol : module + "." + symbol;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function pythonCallArgument(call: Node, name: string, position?: number): Node | undefined {
|
|
28
|
+
const args = call.childForFieldName("arguments")?.namedChildren.filter(child => child.type !== "comment") ?? [];
|
|
29
|
+
const keyword = args.find(child => child.type === "keyword_argument" && child.childForFieldName("name")?.text === name);
|
|
30
|
+
if (keyword) return keyword.childForFieldName("value") ?? undefined;
|
|
31
|
+
const argument = position === undefined ? undefined : args[position];
|
|
32
|
+
if (!argument || ["keyword_argument", "list_splat", "dictionary_splat"].includes(argument.type)) return undefined;
|
|
33
|
+
return argument;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Resolve the imported spelling of a dotted identifier. Calls provide no binding evidence. */
|
|
37
|
+
export function pythonImportedName(name: string, imports: ReadonlyMap<string, PythonImport>): string | undefined {
|
|
38
|
+
const [head, ...tail] = name.split(".");
|
|
39
|
+
const binding = imports.get(head!);
|
|
40
|
+
if (!binding) return undefined;
|
|
41
|
+
if (binding.qualifiedRoot) {
|
|
42
|
+
return name === binding.qualifiedRoot || name.startsWith(binding.qualifiedRoot + ".") ? name : undefined;
|
|
43
|
+
}
|
|
44
|
+
const module = binding.symbol ? pythonImportMember(binding.module, binding.symbol) : binding.module;
|
|
45
|
+
return [module, ...tail].join(".");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function pythonCallUsesUnpacking(call: Node): boolean {
|
|
49
|
+
return call.childForFieldName("arguments")?.namedChildren.some(
|
|
50
|
+
child => child.type === "list_splat" || child.type === "dictionary_splat",
|
|
51
|
+
) ?? false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function pythonLiteralMethods(methods: Node): string[] | undefined {
|
|
55
|
+
if (!["list", "tuple", "set"].includes(methods.type)) return undefined;
|
|
56
|
+
const values = methods.namedChildren.filter(child => child.type !== "comment").map(readPythonStaticString);
|
|
57
|
+
if (!values.every((value): value is string => value !== undefined && /^[a-z]+$/i.test(value))) return undefined;
|
|
58
|
+
return [...new Set(values.map(value => value.toUpperCase()))];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type PythonRouterTarget = { key: string } | { module: string; symbol: string };
|
|
62
|
+
type RouterNames = Map<string, string>;
|
|
63
|
+
|
|
64
|
+
export function pythonImportedMember(
|
|
65
|
+
expression: string,
|
|
66
|
+
imports: ReadonlyMap<string, PythonImport>,
|
|
67
|
+
): { module: string; symbol: string } | undefined {
|
|
68
|
+
const binding = imports.get(expression);
|
|
69
|
+
if (binding?.symbol) return { module: binding.module, symbol: binding.symbol };
|
|
70
|
+
const imported = pythonImportedName(expression, imports);
|
|
71
|
+
const split = imported?.lastIndexOf(".") ?? -1;
|
|
72
|
+
if (imported && split > 0) return { module: imported.slice(0, split), symbol: imported.slice(split + 1) };
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function resolvePythonRouterTarget(
|
|
77
|
+
target: PythonRouterTarget,
|
|
78
|
+
source: string,
|
|
79
|
+
resolver: ImportResolver,
|
|
80
|
+
exportedRouters: ReadonlyMap<string, RouterNames>,
|
|
81
|
+
): string | undefined {
|
|
82
|
+
if ("key" in target) return target.key;
|
|
83
|
+
const module = resolver.resolve(target.module, source);
|
|
84
|
+
if (module.status !== "resolved") return undefined;
|
|
85
|
+
const candidates = module.targets.flatMap(item => item.files)
|
|
86
|
+
.map(file => exportedRouters.get(file)?.get(target.symbol)).filter((key): key is string => !!key);
|
|
87
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type RouterCall = {
|
|
91
|
+
key: string;
|
|
92
|
+
receiver: string;
|
|
93
|
+
method: string;
|
|
94
|
+
call: Node;
|
|
95
|
+
line: number;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
interface PythonRouteVisitor {
|
|
99
|
+
constructorCall: (key: string, name: string, constructor: string, call: Node) => boolean;
|
|
100
|
+
routerCall: (call: RouterCall, targets: {
|
|
101
|
+
router: (expression: string) => PythonRouterTarget | undefined;
|
|
102
|
+
function: (expression: string) => Node | undefined;
|
|
103
|
+
}) => void;
|
|
104
|
+
decorator: (call: RouterCall, handler: Node) => void;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function visitPythonRouterModule(root: Node, file: string, visitor: PythonRouteVisitor, signal?: AbortSignal) {
|
|
108
|
+
const imports = new Map<string, PythonImport>();
|
|
109
|
+
const routers: RouterNames = new Map();
|
|
110
|
+
const functions = new Map<string, Node>();
|
|
111
|
+
const bound = new Set<string>();
|
|
112
|
+
const unbind = (name: string) => {
|
|
113
|
+
bound.add(name);
|
|
114
|
+
routers.delete(name);
|
|
115
|
+
functions.delete(name);
|
|
116
|
+
imports.delete(name);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const routerTarget = (expression: string): PythonRouterTarget | undefined => {
|
|
120
|
+
const local = routers.get(expression);
|
|
121
|
+
if (local) return { key: local };
|
|
122
|
+
return pythonImportedMember(expression, imports);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const callOnRouter = (call: Node | null, line: number): RouterCall | undefined => {
|
|
126
|
+
if (call?.type !== "call" || call.hasError) return undefined;
|
|
127
|
+
const attr = call.childForFieldName("function");
|
|
128
|
+
if (attr?.type !== "attribute") return undefined;
|
|
129
|
+
const receiver = attr.childForFieldName("object")?.text ?? "";
|
|
130
|
+
const key = routers.get(receiver);
|
|
131
|
+
const method = attr.childForFieldName("attribute")?.text;
|
|
132
|
+
if (key && method) return { key, receiver, method, call, line };
|
|
133
|
+
return undefined;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
for (const statement of root.namedChildren) {
|
|
137
|
+
signal?.throwIfAborted();
|
|
138
|
+
for (const [name, binding] of pythonImports(statement)) {
|
|
139
|
+
unbind(name);
|
|
140
|
+
imports.set(name, binding);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const expression = statement.type === "expression_statement" ? statement.namedChild(0) : null;
|
|
144
|
+
if (expression?.type === "assignment") {
|
|
145
|
+
const left = expression.childForFieldName("left");
|
|
146
|
+
const right = expression.childForFieldName("right");
|
|
147
|
+
if (left?.type !== "identifier" || !right) continue;
|
|
148
|
+
const router = routers.get(right.text);
|
|
149
|
+
const handler = functions.get(right.text);
|
|
150
|
+
const importAlias = imports.get(right.text);
|
|
151
|
+
const callee = right.childForFieldName("function")?.text ?? "";
|
|
152
|
+
const constructor = pythonImportedName(callee, imports) ?? (!callee.includes(".") && !bound.has(callee) ? callee : "");
|
|
153
|
+
unbind(left.text);
|
|
154
|
+
if (router) routers.set(left.text, router);
|
|
155
|
+
if (handler) functions.set(left.text, handler);
|
|
156
|
+
if (importAlias) imports.set(left.text, importAlias);
|
|
157
|
+
if (right.type !== "call" || right.hasError || !constructor) continue;
|
|
158
|
+
const key = file + "#" + left.text + "@" + left.startIndex;
|
|
159
|
+
if (visitor.constructorCall(key, left.text, constructor, right)) routers.set(left.text, key);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (expression?.type === "call") {
|
|
163
|
+
const registration = callOnRouter(expression, expression.startPosition.row + 1);
|
|
164
|
+
if (registration) visitor.routerCall(registration, { router: routerTarget, function: name => functions.get(name) });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const definition = statement.type === "decorated_definition" ? statement.childForFieldName("definition") : statement;
|
|
168
|
+
if (definition?.type !== "function_definition" && definition?.type !== "class_definition") continue;
|
|
169
|
+
const name = definition.childForFieldName("name")?.text;
|
|
170
|
+
if (!name) continue;
|
|
171
|
+
if (definition.type === "function_definition" && !definition.hasError) {
|
|
172
|
+
for (const decorator of statement.namedChildren.filter(child => child.type === "decorator")) {
|
|
173
|
+
const registration = callOnRouter(decorator.namedChild(0), decorator.startPosition.row + 1);
|
|
174
|
+
if (registration) visitor.decorator(registration, definition);
|
|
175
|
+
}
|
|
176
|
+
unbind(name);
|
|
177
|
+
functions.set(name, definition);
|
|
178
|
+
} else unbind(name);
|
|
179
|
+
}
|
|
180
|
+
return { imports, routers };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface UnwrappedPythonView {
|
|
184
|
+
node: Node;
|
|
185
|
+
methods?: string[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function isAsViewCall(node: Node): boolean {
|
|
189
|
+
if (node.type !== "call") return false;
|
|
190
|
+
const fn = node.childForFieldName("function");
|
|
191
|
+
return fn?.type === "attribute" && fn.childForFieldName("attribute")?.text === "as_view";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function decoratorMethodConstraint(
|
|
195
|
+
fnNode: Node | null,
|
|
196
|
+
callee: (name: string) => string,
|
|
197
|
+
): string[] | undefined {
|
|
198
|
+
if (!fnNode) return undefined;
|
|
199
|
+
if (fnNode.type === "call") {
|
|
200
|
+
const innerName = callee(fnNode.childForFieldName("function")?.text ?? "");
|
|
201
|
+
if (/^(?:django\.views\.decorators\.http\.)?require_http_methods$/.test(innerName)) {
|
|
202
|
+
const arg = pythonCallArgument(fnNode, "request_method_list", 0);
|
|
203
|
+
return arg ? pythonLiteralMethods(arg) : undefined;
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
const qualified = callee(fnNode.text);
|
|
208
|
+
if (/^(?:django\.views\.decorators\.http\.)?require_GET$/.test(qualified)) return ["GET"];
|
|
209
|
+
if (/^(?:django\.views\.decorators\.http\.)?require_POST$/.test(qualified)) return ["POST"];
|
|
210
|
+
if (/^(?:django\.views\.decorators\.http\.)?require_safe$/.test(qualified)) return ["GET", "HEAD"];
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Unwraps decorator/middleware wrapper calls (e.g. `csrf_exempt(View.as_view(...))`,
|
|
216
|
+
* `login_required(fn)`, `cache_page(60)(View.as_view(...))`) to the underlying view expression.
|
|
217
|
+
*/
|
|
218
|
+
export function unwrapPythonCallWrapper(
|
|
219
|
+
viewNode: Node,
|
|
220
|
+
callee: (name: string) => string = (name) => name,
|
|
221
|
+
): UnwrappedPythonView {
|
|
222
|
+
let current = viewNode;
|
|
223
|
+
let methods: string[] | undefined;
|
|
224
|
+
|
|
225
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
226
|
+
if (current.type === "parenthesized_expression") {
|
|
227
|
+
const inner = current.namedChildren.find((c) => c.type !== "comment");
|
|
228
|
+
if (!inner) break;
|
|
229
|
+
current = inner;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (current.type !== "call" || isAsViewCall(current) || pythonCallUsesUnpacking(current)) {
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
const args = current.childForFieldName("arguments")?.namedChildren.filter((c) => c.type !== "comment") ?? [];
|
|
236
|
+
if (args.length !== 1) break;
|
|
237
|
+
const innerArg = args[0]!;
|
|
238
|
+
if (!["identifier", "attribute", "call", "parenthesized_expression"].includes(innerArg.type)) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
const constraint = decoratorMethodConstraint(current.childForFieldName("function"), callee);
|
|
242
|
+
if (constraint) {
|
|
243
|
+
methods = methods ? methods.filter((m) => constraint.includes(m)) : constraint;
|
|
244
|
+
}
|
|
245
|
+
current = innerArg;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return { node: current, methods };
|
|
249
|
+
}
|
|
@@ -290,7 +290,7 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
290
290
|
? "protected"
|
|
291
291
|
: "public";
|
|
292
292
|
|
|
293
|
-
const
|
|
293
|
+
for (const node of rootNode.descendantsOfType(["import_statement", "import_from_statement"])) {
|
|
294
294
|
if (node.type === "import_from_statement") {
|
|
295
295
|
const modNode =
|
|
296
296
|
node.childForFieldName("module_name") ??
|
|
@@ -316,13 +316,13 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
316
316
|
|
|
317
317
|
dependencies.push({
|
|
318
318
|
target: modulePath,
|
|
319
|
-
statement:
|
|
319
|
+
statement: node.text.trim(),
|
|
320
320
|
line_number: node.startPosition.row + 1,
|
|
321
321
|
is_external: isExternal,
|
|
322
322
|
...(importedSymbols.length > 0 ? { imported_symbols: Array.from(new Set(importedSymbols)) } : {}),
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
continue;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
if (node.type === "import_statement") {
|
|
@@ -333,7 +333,7 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
333
333
|
const shortName = modulePath.split(".").pop() || modulePath;
|
|
334
334
|
dependencies.push({
|
|
335
335
|
target: modulePath,
|
|
336
|
-
statement:
|
|
336
|
+
statement: node.text.trim(),
|
|
337
337
|
line_number: node.startPosition.row + 1,
|
|
338
338
|
is_external: PYTHON_STDLIB_AND_EXTERNALS.has(topPackage),
|
|
339
339
|
imported_symbols: [shortName],
|
|
@@ -347,7 +347,7 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
347
347
|
const shortName = alias?.text?.trim() || modulePath.split(".").pop() || modulePath;
|
|
348
348
|
dependencies.push({
|
|
349
349
|
target: modulePath,
|
|
350
|
-
statement:
|
|
350
|
+
statement: node.text.trim(),
|
|
351
351
|
line_number: node.startPosition.row + 1,
|
|
352
352
|
is_external: PYTHON_STDLIB_AND_EXTERNALS.has(topPackage),
|
|
353
353
|
imported_symbols: [shortName],
|
|
@@ -355,9 +355,10 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
return;
|
|
359
358
|
}
|
|
359
|
+
}
|
|
360
360
|
|
|
361
|
+
const processNode = (node: Parser.SyntaxNode, currentClass: string | null, pendingDecorators?: string[]): void => {
|
|
361
362
|
if (node.type === "decorated_definition") {
|
|
362
363
|
const decorators: string[] = [];
|
|
363
364
|
for (const child of node.namedChildren) {
|
|
@@ -382,7 +383,7 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
382
383
|
const qualifiedName = currentClass ? `${currentClass}::${className}` : className;
|
|
383
384
|
const lineStart = node.startPosition.row + 1;
|
|
384
385
|
const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
|
|
385
|
-
const headerLine = getNodeHeader(node).replace(/:$/, "").trim();
|
|
386
|
+
const headerLine = getNodeHeader(node, content).replace(/:$/, "").trim();
|
|
386
387
|
const baseSignature = headerLine || `class ${className}`;
|
|
387
388
|
const signature = pendingDecorators?.length ? `${pendingDecorators.join("\n")}\n${baseSignature}` : baseSignature;
|
|
388
389
|
|
|
@@ -418,7 +419,7 @@ export class PythonExtractor implements CodeExtractor {
|
|
|
418
419
|
const isProperty = pendingDecorators?.some((d) => d === "@property");
|
|
419
420
|
const lineStart = node.startPosition.row + 1;
|
|
420
421
|
const lineEnd = Math.max(lineStart, node.endPosition.row + 1);
|
|
421
|
-
const headerLine = getNodeHeader(node).replace(/:$/, "").trim();
|
|
422
|
+
const headerLine = getNodeHeader(node, content).replace(/:$/, "").trim();
|
|
422
423
|
const baseSignature = headerLine || `def ${funcName}()`;
|
|
423
424
|
const signature = pendingDecorators?.length ? `${pendingDecorators.join("\n")}\n${baseSignature}` : baseSignature;
|
|
424
425
|
const nestingDepth = calculateAstControlFlowNesting(
|
|
@@ -14,6 +14,16 @@ import { ExpressSemanticExtractor } from "./express-semantic.ts";
|
|
|
14
14
|
import { FastifySemanticExtractor } from "./fastify-semantic.ts";
|
|
15
15
|
import { HonoSemanticExtractor } from "./hono-semantic.ts";
|
|
16
16
|
import { ElysiaSemanticExtractor } from "./elysia-semantic.ts";
|
|
17
|
+
import { NextJsSemanticExtractor } from "./nextjs-semantic.ts";
|
|
18
|
+
import { scanSourceFiles, type SourceInventory } from "../../resources/source-inventory.ts";
|
|
19
|
+
import { shouldIgnoreSourcePath } from "../../resources/ignore.ts";
|
|
20
|
+
|
|
21
|
+
export interface AdapterExtractionResult { id: string; slices: number }
|
|
22
|
+
interface ExtractionOptions {
|
|
23
|
+
ignorePatterns?: string[];
|
|
24
|
+
inventory?: SourceInventory;
|
|
25
|
+
onResult?: (result: AdapterExtractionResult) => void;
|
|
26
|
+
}
|
|
17
27
|
|
|
18
28
|
export class SemanticSliceExtractorRegistry {
|
|
19
29
|
private static extractors: SemanticSliceExtractor[] = [
|
|
@@ -25,14 +35,23 @@ export class SemanticSliceExtractorRegistry {
|
|
|
25
35
|
new FastifySemanticExtractor(),
|
|
26
36
|
new HonoSemanticExtractor(),
|
|
27
37
|
new ElysiaSemanticExtractor(),
|
|
38
|
+
new NextJsSemanticExtractor(),
|
|
28
39
|
new FastApiSemanticExtractor(),
|
|
29
40
|
new DjangoSemanticExtractor(),
|
|
30
41
|
new FlaskSemanticExtractor(),
|
|
31
42
|
new GoSemanticExtractor(),
|
|
32
43
|
];
|
|
33
44
|
|
|
34
|
-
public static getCapabilities() {
|
|
35
|
-
return this.extractors.map(
|
|
45
|
+
public static getCapabilities(projectRoot?: string, framework?: string) {
|
|
46
|
+
return this.extractors.map(extractor => {
|
|
47
|
+
let applicable: boolean | null = null;
|
|
48
|
+
let diagnostic: string | undefined;
|
|
49
|
+
try { if (projectRoot) applicable = extractor.canHandle(projectRoot, framework); }
|
|
50
|
+
catch (error) { diagnostic = error instanceof Error ? error.message : String(error); }
|
|
51
|
+
return { id: extractor.id, name: extractor.name, coverage: "partial", registered: true, applicable,
|
|
52
|
+
extraction: "not_established_by_registration", ...(diagnostic ? { diagnostic } : {}),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
/**
|
|
@@ -58,18 +77,22 @@ export class SemanticSliceExtractorRegistry {
|
|
|
58
77
|
projectRoot: string,
|
|
59
78
|
framework?: string,
|
|
60
79
|
domainId?: number,
|
|
61
|
-
signal?: AbortSignal
|
|
80
|
+
signal?: AbortSignal,
|
|
81
|
+
options: ExtractionOptions = {}
|
|
62
82
|
): Promise<VerticalSliceCandidate[]> {
|
|
63
83
|
const matched = this.getExtractors(projectRoot, framework);
|
|
84
|
+
const sources = options.inventory ?? scanSourceFiles(projectRoot, { ignorePatterns: options.ignorePatterns, signal });
|
|
64
85
|
const combinedSlices: VerticalSliceCandidate[] = [];
|
|
65
86
|
|
|
66
87
|
for (const extractor of matched) {
|
|
67
88
|
signal?.throwIfAborted();
|
|
68
89
|
let slices: VerticalSliceCandidate[];
|
|
69
|
-
try { slices = await extractor.extractSlices(projectRoot, domainId, signal); }
|
|
90
|
+
try { slices = await extractor.extractSlices(projectRoot, domainId, signal, sources); }
|
|
70
91
|
catch (error) { signal?.throwIfAborted(); throw new Error(`Semantic adapter '${extractor.id}' failed: ${error instanceof Error ? error.message : String(error)}`); }
|
|
71
92
|
signal?.throwIfAborted();
|
|
72
|
-
|
|
93
|
+
const selected = slices.filter(slice => !slice.controller_file || !shouldIgnoreSourcePath(slice.controller_file, options.ignorePatterns));
|
|
94
|
+
options.onResult?.({ id: extractor.id, slices: selected.length });
|
|
95
|
+
combinedSlices.push(...selected);
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
return combinedSlices;
|