@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
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertPathContained } from "./path-resolver.ts";
|
|
4
|
-
import { join, relative, resolve } from "node:path";
|
|
5
|
-
import { collectSourceSkips } from "../resources/source-files.ts";
|
|
1
|
+
import { refreshSliceCatalog } from "./slice-catalog.ts";
|
|
2
|
+
import { selectSliceTarget } from "./slice-selection.ts";
|
|
6
3
|
import type {
|
|
7
4
|
ExecutionChainNode,
|
|
8
5
|
VerticalSliceRecord,
|
|
@@ -10,74 +7,29 @@ import type {
|
|
|
10
7
|
} from "../../types/index.ts";
|
|
11
8
|
import type { SeptumRepository } from "../database/repository.ts";
|
|
12
9
|
import { CallGraphTracer } from "./call-graph-tracer.ts";
|
|
13
|
-
import {
|
|
14
|
-
import { TopologyDetector } from "../discovery/topology-detector.ts";
|
|
15
|
-
import { readdirSync } from "node:fs";
|
|
16
|
-
import { ASTParserEngine } from "../parser/tree-sitter.ts";
|
|
17
|
-
import { shouldIgnoreSourcePath } from "../resources/ignore.ts";
|
|
10
|
+
import { formatSliceNode, parseSliceChain, SLICE_RELATIONSHIP_LIMITS } from "./slice-format.ts";
|
|
18
11
|
|
|
19
12
|
export class VerticalSliceTracer {
|
|
20
13
|
constructor(private repo: SeptumRepository, private projectRoot: string = process.cwd(), private ignorePatterns: string[] = [], private verifyMembership = true) {}
|
|
21
14
|
|
|
22
|
-
public async traceAsync(rawQuery: string, maxDepth = 5, signal?: AbortSignal): Promise<VerticalSliceTraceResponse> {
|
|
15
|
+
public async traceAsync(rawQuery: string, maxDepth = 5, signal?: AbortSignal, controllerFile?: string): Promise<VerticalSliceTraceResponse> {
|
|
23
16
|
signal?.throwIfAborted();
|
|
24
17
|
if (this.repo.getMeta("sync_state") === "error" || this.repo.getMeta("sync_state") === "running") {
|
|
25
18
|
return { query: rawQuery, found: false, coverage: "partial", diagnostics: ["index_incomplete"], message: "Workspace synchronization is incomplete." };
|
|
26
19
|
}
|
|
27
|
-
let inputsChanged = false;
|
|
28
|
-
let membershipChanged = false;
|
|
29
20
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
signal
|
|
33
|
-
|
|
34
|
-
return computeContentHash(readSourceFile(resolve(this.projectRoot,input.path))) !== input.hash;
|
|
21
|
+
await refreshSliceCatalog(this.repo, this.projectRoot, {
|
|
22
|
+
ignorePatterns: this.ignorePatterns,
|
|
23
|
+
signal,
|
|
24
|
+
verifyMembership: this.verifyMembership,
|
|
35
25
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
} catch { signal?.throwIfAborted(); inputsChanged = true; }
|
|
41
|
-
if (inputsChanged || membershipChanged || this.repo.getAllVerticalSlices().length === 0 || this.repo.getMeta("slices_dirty") === "1") {
|
|
42
|
-
try {
|
|
43
|
-
const topology = TopologyDetector.detect(this.projectRoot);
|
|
44
|
-
const extracted = await collectSourceSkips(this.projectRoot, async () => {
|
|
45
|
-
const slices = await SemanticSliceExtractorRegistry.extractAllSlices(this.projectRoot,topology.framework,undefined,signal);
|
|
46
|
-
return slices.length ? slices : new CallGraphTracer(this.repo,this.projectRoot).traceAllSlices(maxDepth);
|
|
47
|
-
});
|
|
48
|
-
signal?.throwIfAborted();
|
|
49
|
-
if (extracted.skipped.length) throw new Error("Semantic source exceeds read limits; catalog is incomplete.");
|
|
50
|
-
this.repo.runInTransaction(() => {
|
|
51
|
-
signal?.throwIfAborted();
|
|
52
|
-
this.repo.clearVerticalSlices();
|
|
53
|
-
for (const slice of extracted.value) this.repo.upsertVerticalSlice(slice);
|
|
54
|
-
this.repo.setMeta("slices_dirty", "");
|
|
55
|
-
this.repo.setMeta("semantic_inputs", JSON.stringify(extracted.inputs));
|
|
56
|
-
if (this.verifyMembership) this.repo.setMeta("semantic_catalog_files", JSON.stringify(this.listSourceFiles(this.projectRoot)));
|
|
57
|
-
});
|
|
58
|
-
} catch (error) {
|
|
59
|
-
signal?.throwIfAborted();
|
|
60
|
-
this.repo.setMeta("slices_dirty", "1");
|
|
61
|
-
return { query: rawQuery, found: false, coverage: "partial", diagnostics: [error instanceof Error ? error.message : String(error)], message: "Semantic extraction failed; no complete catalog was published." };
|
|
62
|
-
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
signal?.throwIfAborted();
|
|
28
|
+
return { query: rawQuery, found: false, coverage: "partial", diagnostics: [error instanceof Error ? error.message : String(error)], message: "Semantic extraction failed; no complete catalog was published." };
|
|
63
29
|
}
|
|
64
|
-
return this.trace(rawQuery,maxDepth);
|
|
30
|
+
return this.trace(rawQuery, maxDepth, controllerFile);
|
|
65
31
|
}
|
|
66
32
|
|
|
67
|
-
private listSourceFiles(root: string): string[] {
|
|
68
|
-
const files: string[] = [];
|
|
69
|
-
const walk = (dir: string) => {
|
|
70
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
71
|
-
const fullPath = join(dir, entry.name);
|
|
72
|
-
const relPath = relative(root, fullPath).replace(/\\/g, "/");
|
|
73
|
-
if (shouldIgnoreSourcePath(relPath, this.ignorePatterns)) continue;
|
|
74
|
-
if (entry.isDirectory()) walk(fullPath);
|
|
75
|
-
else if (entry.isFile() && ASTParserEngine.isSourceFile(fullPath)) files.push(relPath);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
walk(root);
|
|
79
|
-
return files.sort();
|
|
80
|
-
}
|
|
81
33
|
|
|
82
34
|
/**
|
|
83
35
|
* Trace an end-to-end vertical slice from route/action/intent query.
|
|
@@ -91,188 +43,25 @@ export class VerticalSliceTracer {
|
|
|
91
43
|
* - "Ubah status order di dashboard"
|
|
92
44
|
*/
|
|
93
45
|
// Synchronous compatibility API reads persisted slices only; use traceAsync for on-demand extraction.
|
|
94
|
-
public trace(rawQuery: string, maxDepth: number = 5): VerticalSliceTraceResponse {
|
|
46
|
+
public trace(rawQuery: string, maxDepth: number = 5, controllerFile?: string): VerticalSliceTraceResponse {
|
|
95
47
|
const effectiveMaxDepth = Math.min(Math.max(Math.trunc(maxDepth || 5), 1), 8);
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (methodUriMatch) {
|
|
112
|
-
const httpMethod = methodUriMatch[1].toUpperCase();
|
|
113
|
-
const uri = methodUriMatch[2];
|
|
114
|
-
const candidates = allSlices.filter((s) => s.http_method.toUpperCase() === httpMethod && this.urisMatch(s.route_uri, uri));
|
|
115
|
-
const literal = candidates.filter(s => s.route_uri === uri);
|
|
116
|
-
if (literal.length === 1) {
|
|
117
|
-
return this.formatSuccessResponse(trimmed, literal[0], "exact", undefined, effectiveMaxDepth);
|
|
118
|
-
}
|
|
119
|
-
if (literal.length > 1 || candidates.length > 1) {
|
|
120
|
-
return this.formatSuccessResponse(trimmed, literal[0] ?? candidates[0], "inferred", (literal.length ? literal : candidates).slice(1), effectiveMaxDepth);
|
|
121
|
-
}
|
|
122
|
-
if (candidates.length === 1) {
|
|
123
|
-
return this.formatSuccessResponse(trimmed, candidates[0], "inferred", undefined, effectiveMaxDepth);
|
|
124
|
-
}
|
|
125
|
-
return { query: trimmed, found: false, max_depth_applied: effectiveMaxDepth, message: `No vertical slice found matching query '${trimmed}'.` };
|
|
48
|
+
const exactCandidates = typeof this.repo.findExactVerticalSlices === "function"
|
|
49
|
+
? this.repo.findExactVerticalSlices(rawQuery, controllerFile)
|
|
50
|
+
: [];
|
|
51
|
+
const indexedCandidates = exactCandidates.length > 0
|
|
52
|
+
? exactCandidates
|
|
53
|
+
: typeof this.repo.findVerticalSlices === "function"
|
|
54
|
+
? this.repo.findVerticalSlices(rawQuery)
|
|
55
|
+
: [];
|
|
56
|
+
const filteredIndexed = controllerFile
|
|
57
|
+
? indexedCandidates.filter(s => s.controller_file === controllerFile)
|
|
58
|
+
: indexedCandidates;
|
|
59
|
+
const slices = filteredIndexed.length > 0 ? filteredIndexed : this.repo.getAllVerticalSlices();
|
|
60
|
+
const selection = selectSliceTarget(slices, rawQuery, effectiveMaxDepth, controllerFile);
|
|
61
|
+
if ("record" in selection) {
|
|
62
|
+
return this.formatSuccessResponse(selection.query, selection.record, selection.confidence, selection.alternatives, effectiveMaxDepth);
|
|
126
63
|
}
|
|
127
|
-
|
|
128
|
-
// 2. URI-only match: "/orders" or "orders/{id}"
|
|
129
|
-
const literalUriMatches = allSlices.filter((s) => s.route_uri === trimmed);
|
|
130
|
-
const uriMatches = literalUriMatches.length ? literalUriMatches : allSlices.filter((s) => this.urisMatch(s.route_uri, trimmed));
|
|
131
|
-
if (uriMatches.length > 0) {
|
|
132
|
-
const confidence = literalUriMatches.length ? "exact" : "inferred";
|
|
133
|
-
if (uriMatches.length === 1) {
|
|
134
|
-
return this.formatSuccessResponse(trimmed, uriMatches[0], confidence, undefined, effectiveMaxDepth);
|
|
135
|
-
}
|
|
136
|
-
// Multiple matches (e.g. GET /orders and POST /orders) -> return primary with alternatives
|
|
137
|
-
return this.formatSuccessResponse(trimmed, uriMatches[0], confidence, uriMatches.slice(1), effectiveMaxDepth);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 3. Named Route match: "orders.status.update" or "admin.users.index"
|
|
141
|
-
const nameMatch = allSlices.find(
|
|
142
|
-
(s) => s.route_name && s.route_name.toLowerCase() === lowerTrimmed
|
|
143
|
-
);
|
|
144
|
-
if (nameMatch) {
|
|
145
|
-
return this.formatSuccessResponse(trimmed, nameMatch, "exact", undefined, effectiveMaxDepth);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 3b. Omni-Trigger Match: "JOB ProcessOrderJob", "job:ProcessOrderJob", "CLI order:cleanup", "EVENT OrderPlacedListener"
|
|
149
|
-
const omniTriggerMatch = trimmed.match(/^(JOB|CLI|EVENT)\s+([A-Za-z0-9_:\-]+)$/i);
|
|
150
|
-
if (omniTriggerMatch) {
|
|
151
|
-
const triggerKind = omniTriggerMatch[1].toUpperCase();
|
|
152
|
-
const targetName = omniTriggerMatch[2].toLowerCase();
|
|
153
|
-
const exact = allSlices.find(
|
|
154
|
-
(s) =>
|
|
155
|
-
s.http_method.toUpperCase() === triggerKind &&
|
|
156
|
-
(s.controller_class.toLowerCase() === targetName ||
|
|
157
|
-
s.route_uri.toLowerCase() === targetName ||
|
|
158
|
-
s.route_uri.toLowerCase() === `${triggerKind.toLowerCase()}:${targetName}`)
|
|
159
|
-
);
|
|
160
|
-
if (exact) {
|
|
161
|
-
return this.formatSuccessResponse(trimmed, exact, "exact", undefined, effectiveMaxDepth);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// 4. Controller@Action match: "OrderController@updateStatus" or "OrderController"
|
|
166
|
-
const controllerActionMatch = trimmed.match(/^([A-Za-z0-9_\\/.]+?)(?:(?:@|::)([A-Za-z0-9_]+))?$/);
|
|
167
|
-
if (controllerActionMatch) {
|
|
168
|
-
const [, rawCtrl, act] = controllerActionMatch;
|
|
169
|
-
const ctrl = rawCtrl.split(/[\\/]/).pop()?.replace(/\.(php|ts|js)$/i, "") || rawCtrl;
|
|
170
|
-
const lowerCtrl = ctrl.toLowerCase();
|
|
171
|
-
const lowerAct = act ? act.toLowerCase() : undefined;
|
|
172
|
-
|
|
173
|
-
const exact = allSlices.find((s) => {
|
|
174
|
-
const sCtrlLower = s.controller_class.toLowerCase();
|
|
175
|
-
const ctrlMatch =
|
|
176
|
-
sCtrlLower === lowerCtrl ||
|
|
177
|
-
sCtrlLower.endsWith(`\\${lowerCtrl}`) ||
|
|
178
|
-
sCtrlLower.endsWith(`/${lowerCtrl}`);
|
|
179
|
-
if (!ctrlMatch) return false;
|
|
180
|
-
if (lowerAct) return s.action_name.toLowerCase() === lowerAct;
|
|
181
|
-
if (!act && !lowerCtrl.endsWith("controller") && sCtrlLower !== lowerCtrl) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
return true;
|
|
185
|
-
});
|
|
186
|
-
if (exact) {
|
|
187
|
-
return this.formatSuccessResponse(trimmed, exact, "exact", undefined, effectiveMaxDepth);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// 5. Symbol Match in Execution Chain or Action Name (e.g. "createOrder", "CreateOrderUseCase", "OrderController")
|
|
192
|
-
const symbolMatch = allSlices.find((s) => {
|
|
193
|
-
if (s.action_name.toLowerCase() === lowerTrimmed) return true;
|
|
194
|
-
if (s.controller_class.toLowerCase() === lowerTrimmed) return true;
|
|
195
|
-
if (s.execution_chain_json) {
|
|
196
|
-
try {
|
|
197
|
-
const chain: ExecutionChainNode[] = JSON.parse(s.execution_chain_json);
|
|
198
|
-
return chain.some(
|
|
199
|
-
(node) =>
|
|
200
|
-
node.symbol.toLowerCase() === lowerTrimmed ||
|
|
201
|
-
node.symbol.toLowerCase().includes(lowerTrimmed) ||
|
|
202
|
-
(node.file && node.file.toLowerCase().includes(lowerTrimmed))
|
|
203
|
-
);
|
|
204
|
-
} catch {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return false;
|
|
209
|
-
});
|
|
210
|
-
if (symbolMatch) {
|
|
211
|
-
return this.formatSuccessResponse(trimmed, symbolMatch, "inferred", undefined, effectiveMaxDepth);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// 6. Semantic / Token Scoring for Natural Language (e.g. "Ubah status order di dashboard")
|
|
215
|
-
const tokens = this.tokenize(trimmed);
|
|
216
|
-
const scoredSlices = allSlices
|
|
217
|
-
.map((slice) => {
|
|
218
|
-
let score = 0;
|
|
219
|
-
const textCorpus = [
|
|
220
|
-
slice.route_uri,
|
|
221
|
-
slice.route_name || "",
|
|
222
|
-
slice.controller_class,
|
|
223
|
-
slice.action_name,
|
|
224
|
-
slice.execution_chain_json || "",
|
|
225
|
-
].join(" ").toLowerCase();
|
|
226
|
-
|
|
227
|
-
for (const token of tokens) {
|
|
228
|
-
if (textCorpus.includes(token)) {
|
|
229
|
-
score += 1;
|
|
230
|
-
if (slice.route_uri.toLowerCase().includes(token)) score += 2;
|
|
231
|
-
if (slice.action_name.toLowerCase().includes(token)) score += 2;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return { slice, score };
|
|
235
|
-
})
|
|
236
|
-
.filter((item) => item.score > 0)
|
|
237
|
-
.sort((a, b) => b.score - a.score);
|
|
238
|
-
|
|
239
|
-
if (scoredSlices.length > 0) {
|
|
240
|
-
const primary = scoredSlices[0].slice;
|
|
241
|
-
const alternatives = scoredSlices.slice(1, 4).map((item) => item.slice);
|
|
242
|
-
return this.formatSuccessResponse(trimmed, primary, "inferred", alternatives, effectiveMaxDepth);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
query: trimmed,
|
|
247
|
-
found: false,
|
|
248
|
-
max_depth_applied: effectiveMaxDepth,
|
|
249
|
-
alternatives: allSlices.slice(0, 5).map((s) => ({
|
|
250
|
-
method: s.http_method,
|
|
251
|
-
uri: s.route_uri,
|
|
252
|
-
controller: s.controller_class,
|
|
253
|
-
action: s.action_name,
|
|
254
|
-
})),
|
|
255
|
-
message: `No vertical slice found matching query '${trimmed}'.`,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
private urisMatch(uriA: string, uriB: string): boolean {
|
|
260
|
-
const normA = uriA
|
|
261
|
-
.replace(/\{[^}]+\}/g, ":param")
|
|
262
|
-
.replace(/:[a-zA-Z0-9_]+/g, ":param");
|
|
263
|
-
const normB = uriB
|
|
264
|
-
.replace(/\{[^}]+\}/g, ":param")
|
|
265
|
-
.replace(/:[a-zA-Z0-9_]+/g, ":param");
|
|
266
|
-
return normA === normB;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private tokenize(str: string): string[] {
|
|
270
|
-
return str
|
|
271
|
-
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
272
|
-
.toLowerCase()
|
|
273
|
-
.replace(/[^a-z0-9_]+/g, " ")
|
|
274
|
-
.split(/\s+/)
|
|
275
|
-
.filter((t) => t.length > 2 && !["ubah", "di", "dan", "yang", "the", "for", "and"].includes(t));
|
|
64
|
+
return selection;
|
|
276
65
|
}
|
|
277
66
|
|
|
278
67
|
private formatSuccessResponse(
|
|
@@ -283,62 +72,52 @@ export class VerticalSliceTracer {
|
|
|
283
72
|
effectiveMaxDepth: number = 5
|
|
284
73
|
): VerticalSliceTraceResponse {
|
|
285
74
|
let chain: ExecutionChainNode[] = [];
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
console.error(`[Septum Slice Error] Corrupted execution chain JSON for slice ${record.id}: ${msg}`);
|
|
292
|
-
}
|
|
75
|
+
const diagnostics: string[] = [];
|
|
76
|
+
try {
|
|
77
|
+
chain = parseSliceChain(record.execution_chain_json);
|
|
78
|
+
} catch {
|
|
79
|
+
diagnostics.push("invalid_execution_chain");
|
|
293
80
|
}
|
|
294
81
|
|
|
295
82
|
// Import expansion is derived per request, so cached depth cannot override the requested hop limit.
|
|
296
83
|
chain = chain.filter(node => node.relationship?.kind !== "imports" && !node.description?.includes("(dependency)"));
|
|
84
|
+
// Go imports resolve whole packages; expanding them injects unrelated handlers/services.
|
|
297
85
|
if (
|
|
298
|
-
record.controller_file &&
|
|
86
|
+
record.architecture_style !== "go-http" && !diagnostics.length && record.controller_file &&
|
|
299
87
|
typeof (this.repo as any).getAllFiles === "function"
|
|
300
88
|
) {
|
|
301
89
|
try {
|
|
302
90
|
const callGraphTracer = new CallGraphTracer(this.repo, this.projectRoot);
|
|
303
|
-
chain =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
91
|
+
chain = record.action_name
|
|
92
|
+
? callGraphTracer.expandChainFromMethod(
|
|
93
|
+
record.controller_file,
|
|
94
|
+
record.action_name,
|
|
95
|
+
chain,
|
|
96
|
+
effectiveMaxDepth
|
|
97
|
+
)
|
|
98
|
+
: callGraphTracer.expandChainFromFile(
|
|
99
|
+
record.controller_file,
|
|
100
|
+
chain,
|
|
101
|
+
effectiveMaxDepth
|
|
102
|
+
);
|
|
308
103
|
} catch {
|
|
309
|
-
|
|
104
|
+
diagnostics.push("dependency_expansion_failed");
|
|
310
105
|
}
|
|
311
106
|
}
|
|
312
107
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const loc = node.file ? ` (${node.file}${node.line ? `:${node.line}` : ""})` : "";
|
|
318
|
-
let extra = "";
|
|
319
|
-
if (node.table) {
|
|
320
|
-
extra += ` [table: ${node.table}]`;
|
|
321
|
-
}
|
|
322
|
-
if (node.columns_summary) {
|
|
323
|
-
extra += ` {${node.columns_summary}}`;
|
|
324
|
-
}
|
|
325
|
-
if (node.guards && node.guards.length > 0 && node.stage !== "guard") {
|
|
326
|
-
extra += ` [guards: ${node.guards.join(", ")}]`;
|
|
327
|
-
}
|
|
328
|
-
if (node.mutations && node.mutations.length > 0 && node.stage !== "side_effect") {
|
|
329
|
-
extra += ` [mutates: ${node.mutations.join(", ")}]`;
|
|
330
|
-
}
|
|
331
|
-
if (node.transactions && node.stage !== "transaction") {
|
|
332
|
-
extra += ` [tx: active]`;
|
|
333
|
-
}
|
|
334
|
-
return `${stageLabel} ${node.symbol}${loc}${extra}`;
|
|
335
|
-
});
|
|
336
|
-
message = `=== VERTICAL SLICE TRACE (${confidence.toUpperCase()}) ===\n` + stageLines.join("\n");
|
|
108
|
+
if (chain.some(node => node.stage === "ingress" && node.relationship?.derivation === "inferred")) confidence = "inferred";
|
|
109
|
+
let message = `Vertical slice target match (${confidence}): ${record.http_method} ${record.route_uri} -> ${record.controller_class}@${record.action_name} (${chain.length} node(s)).`;
|
|
110
|
+
if (record.architecture_style === "go-http") {
|
|
111
|
+
message += " Go package import expansion is omitted; extracted handler/service relationships remain lexical and partial.";
|
|
337
112
|
}
|
|
113
|
+
if (diagnostics.length) message += ` Analysis incomplete: ${diagnostics.join(", ")}. Run septum sync and retry; inspect source if it persists.`;
|
|
338
114
|
|
|
339
115
|
return {
|
|
340
116
|
query,
|
|
341
117
|
found: true,
|
|
118
|
+
coverage: "partial",
|
|
119
|
+
diagnostics: diagnostics.length ? diagnostics : undefined,
|
|
120
|
+
next: diagnostics.length ? ["Run septum sync to rebuild analysis; retry the query. Inspect source directly if the diagnostic persists."] : undefined,
|
|
342
121
|
confidence,
|
|
343
122
|
is_exact_match: confidence === "exact",
|
|
344
123
|
architecture_style: record.architecture_style,
|
|
@@ -4,10 +4,21 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
|
4
4
|
"vendor",
|
|
5
5
|
"bower_components",
|
|
6
6
|
"jspm_packages",
|
|
7
|
+
"deps",
|
|
8
|
+
".bundle",
|
|
9
|
+
".cargo",
|
|
10
|
+
".gradle",
|
|
11
|
+
".m2",
|
|
12
|
+
".mvn",
|
|
13
|
+
".nuget",
|
|
14
|
+
".dart_tool",
|
|
15
|
+
".pub-cache",
|
|
16
|
+
".pub",
|
|
7
17
|
|
|
8
18
|
// Build, bundle & compilation outputs (visible & hidden)
|
|
9
19
|
"dist",
|
|
10
20
|
"build",
|
|
21
|
+
"_build",
|
|
11
22
|
"out",
|
|
12
23
|
"output",
|
|
13
24
|
".output",
|
|
@@ -15,6 +26,8 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
|
15
26
|
"obj",
|
|
16
27
|
"bin",
|
|
17
28
|
"scripts",
|
|
29
|
+
"zig-out",
|
|
30
|
+
".zig-cache",
|
|
18
31
|
".next",
|
|
19
32
|
".nuxt",
|
|
20
33
|
".turbo",
|
|
@@ -23,7 +36,7 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
|
23
36
|
".astro",
|
|
24
37
|
".docusaurus",
|
|
25
38
|
|
|
26
|
-
// Python virtual environments and bytecode caches
|
|
39
|
+
// Python virtual environments, packaging and bytecode caches
|
|
27
40
|
".venv",
|
|
28
41
|
"venv",
|
|
29
42
|
"env",
|
|
@@ -34,6 +47,8 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
|
34
47
|
".mypy_cache",
|
|
35
48
|
".ruff_cache",
|
|
36
49
|
".tox",
|
|
50
|
+
".nox",
|
|
51
|
+
".eggs",
|
|
37
52
|
|
|
38
53
|
// Test coverage
|
|
39
54
|
"coverage",
|
|
@@ -64,11 +79,16 @@ export const DEFAULT_IGNORED_DIRECTORIES: ReadonlySet<string> = new Set([
|
|
|
64
79
|
".antigravity",
|
|
65
80
|
".cline",
|
|
66
81
|
".roo",
|
|
82
|
+
".toolbench",
|
|
67
83
|
".windsurf",
|
|
68
84
|
".continue",
|
|
69
85
|
".copilot",
|
|
70
86
|
".chat",
|
|
71
87
|
|
|
88
|
+
// Framework storage & uploads
|
|
89
|
+
"storage",
|
|
90
|
+
"public/storage",
|
|
91
|
+
|
|
72
92
|
// Cache & Temp
|
|
73
93
|
".cache",
|
|
74
94
|
"tmp",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const RESOURCE_LIMITS = Object.freeze({
|
|
2
2
|
workspaces: 4,
|
|
3
3
|
workspaceIdleMs: 10 * 60_000,
|
|
4
|
-
watches:
|
|
4
|
+
watches: 8192,
|
|
5
5
|
pendingPaths: 1000,
|
|
6
6
|
debounceMs: 300,
|
|
7
7
|
pollMs: 5000,
|
|
@@ -10,5 +10,6 @@ export const RESOURCE_LIMITS = Object.freeze({
|
|
|
10
10
|
batchFiles: 50,
|
|
11
11
|
batchBytes: 1024 * 1024,
|
|
12
12
|
maxQueuePending: 50,
|
|
13
|
+
requestTimeoutMs: 120_000,
|
|
13
14
|
shutdownMs: 5000,
|
|
14
15
|
});
|