septum 0.1.4 → 0.1.5
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/LICENSE +21 -21
- package/README.md +105 -105
- package/bin/septum.ts +4 -4
- package/package.json +63 -63
- package/src/cli/commands/check.ts +161 -161
- package/src/cli/commands/hook.ts +188 -188
- package/src/cli/commands/ingest.ts +29 -29
- package/src/cli/commands/init.ts +211 -211
- package/src/cli/commands/locate.ts +61 -61
- package/src/cli/commands/query.ts +64 -64
- package/src/cli/commands/serve.ts +5 -5
- package/src/cli/commands/slice.ts +48 -48
- package/src/cli/commands/sync.ts +31 -31
- package/src/cli/index.ts +210 -210
- package/src/cli/templates/hooks.ts +75 -75
- package/src/cli/templates/rules.ts +38 -38
- package/src/cli/templates/skill.ts +69 -69
- package/src/core/boundary/evaluator.ts +232 -210
- package/src/core/config/loader.ts +97 -97
- package/src/core/config/schema.ts +39 -39
- package/src/core/database/client.ts +44 -44
- package/src/core/database/repositories/dependency.repository.ts +366 -349
- package/src/core/database/repositories/domain.repository.ts +218 -198
- package/src/core/database/repositories/file.repository.ts +116 -106
- package/src/core/database/repositories/meta.repository.ts +33 -33
- package/src/core/database/repositories/symbol.repository.ts +443 -443
- package/src/core/database/repository.ts +264 -260
- package/src/core/database/schema.ts +153 -153
- package/src/core/discovery/topology-detector.ts +486 -486
- package/src/core/ingestion/hasher.ts +5 -5
- package/src/core/ingestion/pipeline.ts +584 -535
- package/src/core/parser/boundary-tracker.ts +288 -288
- package/src/core/parser/extractors/base.ts +62 -62
- package/src/core/parser/extractors/blade.ts +158 -158
- package/src/core/parser/extractors/frontend.ts +194 -194
- package/src/core/parser/extractors/go.ts +229 -180
- package/src/core/parser/extractors/laravel-semantic.ts +1039 -901
- package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
- package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
- package/src/core/parser/extractors/php.ts +153 -153
- package/src/core/parser/extractors/python.ts +228 -228
- package/src/core/parser/extractors/registry.ts +70 -70
- package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
- package/src/core/parser/extractors/typescript.ts +181 -181
- package/src/core/parser/tree-sitter.ts +41 -41
- package/src/core/resolver/call-graph-tracer.ts +666 -668
- package/src/core/resolver/module-resolver.ts +408 -342
- package/src/core/resolver/path-resolver.ts +147 -147
- package/src/core/resolver/symbol-locator.ts +543 -543
- package/src/core/resolver/vertical-slice-tracer.ts +301 -285
- package/src/core/session/session-manager.ts +56 -56
- package/src/core/telemetry/telemetry.ts +86 -86
- package/src/index.ts +21 -21
- package/src/mcp/schemas.ts +578 -286
- package/src/mcp/server.ts +875 -716
- package/src/mcp/tools/check-boundary.ts +171 -152
- package/src/mcp/tools/get-domain-catalog.ts +145 -121
- package/src/mcp/tools/get-feature-context.ts +212 -116
- package/src/mcp/tools/get-symbol-hotspots.ts +60 -59
- package/src/mcp/tools/get-symbol-impact.ts +28 -26
- package/src/mcp/tools/get-symbol.ts +65 -63
- package/src/mcp/tools/locate-symbol.ts +171 -190
- package/src/mcp/tools/register-domain.ts +68 -64
- package/src/mcp/tools/register-feature.ts +100 -0
- package/src/mcp/tools/trace-vertical-slice.ts +74 -48
- package/src/types/index.ts +335 -315
- package/src/version.ts +3 -3
|
@@ -1,116 +1,212 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
4
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
5
|
-
import { SessionManager } from "../../core/session/session-manager.ts";
|
|
6
|
-
import type { FeatureContextResponse } from "../../types/index.ts";
|
|
7
|
-
|
|
8
|
-
export interface GetFeatureContextArgs {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const features = config.features ?? {};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!
|
|
29
|
-
const available = Object.keys(features)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
4
|
+
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
5
|
+
import { SessionManager } from "../../core/session/session-manager.ts";
|
|
6
|
+
import type { FeatureContextResponse } from "../../types/index.ts";
|
|
7
|
+
|
|
8
|
+
export interface GetFeatureContextArgs {
|
|
9
|
+
feature_key?: string;
|
|
10
|
+
feature?: string;
|
|
11
|
+
workspace_path?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function handleClearFeatureContext(workspaceRoot: string = process.cwd()): boolean {
|
|
15
|
+
return SessionManager.clearActiveSession(workspaceRoot);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function handleGetFeatureContext(
|
|
19
|
+
repo: SeptumRepository,
|
|
20
|
+
config: ValidatedSeptumConfig,
|
|
21
|
+
args: GetFeatureContextArgs,
|
|
22
|
+
workspaceRoot: string = process.cwd()
|
|
23
|
+
) {
|
|
24
|
+
const featureKey = (args.feature_key || args.feature || "").trim();
|
|
25
|
+
const features = config.features ?? {};
|
|
26
|
+
|
|
27
|
+
// ZERO-ARGUMENT GRACEFUL FALLBACK: Guide the agent instead of throwing validation errors
|
|
28
|
+
if (!featureKey) {
|
|
29
|
+
const available = Object.keys(features);
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text" as const,
|
|
34
|
+
text: JSON.stringify(
|
|
35
|
+
{
|
|
36
|
+
status: "prompt",
|
|
37
|
+
message: "No feature specified. Please specify 'feature_key' from the registered features below or trace routes.",
|
|
38
|
+
available_features: available.length > 0 ? available : [],
|
|
39
|
+
instructions: "Call 'septum_get_feature_context({ feature_key: \"<name>\" })' or register a new feature with 'septum_register_feature'.",
|
|
40
|
+
},
|
|
41
|
+
null,
|
|
42
|
+
2
|
|
43
|
+
),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let featureConfig = features[featureKey];
|
|
50
|
+
let isInferred = false;
|
|
51
|
+
|
|
52
|
+
if (!featureConfig) {
|
|
53
|
+
// Attempt auto-derive from vertical slices or domain symbols
|
|
54
|
+
const searchTerm = featureKey.toLowerCase();
|
|
55
|
+
const allSlices = typeof repo.getAllVerticalSlices === "function" ? repo.getAllVerticalSlices() : [];
|
|
56
|
+
const fromRepoSearch = typeof repo.findVerticalSlices === "function" ? repo.findVerticalSlices(searchTerm) : [];
|
|
57
|
+
const matchingSlices = [
|
|
58
|
+
...fromRepoSearch,
|
|
59
|
+
...allSlices.filter(
|
|
60
|
+
(s) =>
|
|
61
|
+
s.route_uri.toLowerCase().includes(searchTerm) ||
|
|
62
|
+
(s.route_name && s.route_name.toLowerCase().includes(searchTerm)) ||
|
|
63
|
+
s.controller_class.toLowerCase().includes(searchTerm) ||
|
|
64
|
+
(s.feature_key && s.feature_key.toLowerCase().includes(searchTerm))
|
|
65
|
+
),
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const uniqueSlices = Array.from(
|
|
69
|
+
new Map(matchingSlices.map((s) => [`${s.http_method}:${s.route_uri}`, s])).values()
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (uniqueSlices.length > 0) {
|
|
73
|
+
isInferred = true;
|
|
74
|
+
const candidateTouchpoints = new Set<string>();
|
|
75
|
+
const candidateSymbols = new Set<string>();
|
|
76
|
+
let detectedDomain = "app";
|
|
77
|
+
|
|
78
|
+
if (config.domains && config.domains[featureKey]) {
|
|
79
|
+
detectedDomain = featureKey;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const slice of uniqueSlices) {
|
|
83
|
+
if (slice.controller_file) {
|
|
84
|
+
candidateTouchpoints.add(slice.controller_file);
|
|
85
|
+
}
|
|
86
|
+
candidateSymbols.add(slice.controller_class);
|
|
87
|
+
if (slice.action_name) {
|
|
88
|
+
candidateSymbols.add(`${slice.controller_class}@${slice.action_name}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (slice.execution_chain_json) {
|
|
92
|
+
try {
|
|
93
|
+
const chain = JSON.parse(slice.execution_chain_json);
|
|
94
|
+
if (Array.isArray(chain)) {
|
|
95
|
+
for (const node of chain) {
|
|
96
|
+
if (node.file) candidateTouchpoints.add(node.file);
|
|
97
|
+
if (node.symbol) candidateSymbols.add(node.symbol);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch {}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
featureConfig = {
|
|
105
|
+
domain: detectedDomain,
|
|
106
|
+
description: `[Auto-Derived] Feature context inferred from ${uniqueSlices.length} vertical slices matching '${featureKey}'`,
|
|
107
|
+
allowed_touchpoints: Array.from(candidateTouchpoints),
|
|
108
|
+
reuse_symbols: Array.from(candidateSymbols).slice(0, 10),
|
|
109
|
+
input_contract: {},
|
|
110
|
+
output_contract: {},
|
|
111
|
+
};
|
|
112
|
+
} else {
|
|
113
|
+
const available = Object.keys(features);
|
|
114
|
+
const availableStr = available.length > 0 ? available.join(", ") : "none";
|
|
115
|
+
const recoveryMessage = [
|
|
116
|
+
`Feature '${featureKey}' not found in configuration. Available features: [${availableStr}].`,
|
|
117
|
+
`No matching vertical slices found for auto-derivation.`,
|
|
118
|
+
``,
|
|
119
|
+
`▶ RECOVERY OPTIONS:`,
|
|
120
|
+
`1. Register this feature on-the-fly:`,
|
|
121
|
+
` septum_register_feature({ feature_key: "${featureKey}", domain: "<domain_name>", allowed_touchpoints: ["path/to/file"] })`,
|
|
122
|
+
`2. Or discover available routes / vertical slices first:`,
|
|
123
|
+
` septum_trace_vertical_slice({ entry_file: "routes/web.php" })`,
|
|
124
|
+
].join("\n");
|
|
125
|
+
throw new Error(recoveryMessage);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Record Active Feature Session Lease (.septum/session.json)
|
|
130
|
+
SessionManager.saveActiveSession(workspaceRoot, {
|
|
131
|
+
feature_key: featureKey,
|
|
132
|
+
domain: featureConfig.domain,
|
|
133
|
+
touchpoints: featureConfig.allowed_touchpoints ?? [],
|
|
134
|
+
locked_at: new Date().toISOString(),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Deterministically fetch signatures, methods, and properties for reuse_symbols from SQLite
|
|
138
|
+
const reuseSymbolsWithMeta: FeatureContextResponse["reuse_symbols"] = [];
|
|
139
|
+
const requestedSymbols = featureConfig.reuse_symbols ?? [];
|
|
140
|
+
|
|
141
|
+
for (const symName of requestedSymbols) {
|
|
142
|
+
const record = repo.findSymbolWithMembers(symName);
|
|
143
|
+
if (record) {
|
|
144
|
+
reuseSymbolsWithMeta.push({
|
|
145
|
+
name: record.symbol_name,
|
|
146
|
+
kind: record.kind,
|
|
147
|
+
signature: record.signature,
|
|
148
|
+
methods: record.methods.length > 0 ? record.methods : undefined,
|
|
149
|
+
properties: record.properties.length > 0 ? record.properties : undefined,
|
|
150
|
+
file_path: record.file_path,
|
|
151
|
+
domain: record.domain_name,
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
reuseSymbolsWithMeta.push({
|
|
155
|
+
name: symName,
|
|
156
|
+
kind: "unknown",
|
|
157
|
+
domain: featureConfig.domain,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const response: FeatureContextResponse = {
|
|
163
|
+
feature_key: featureKey,
|
|
164
|
+
feature: featureKey,
|
|
165
|
+
domain: featureConfig.domain,
|
|
166
|
+
description: featureConfig.description,
|
|
167
|
+
allowed_touchpoints: featureConfig.allowed_touchpoints,
|
|
168
|
+
reuse_symbols: reuseSymbolsWithMeta,
|
|
169
|
+
input_contract: (featureConfig.input_contract as Record<string, unknown>) ?? {},
|
|
170
|
+
output_contract: (featureConfig.output_contract as Record<string, unknown>) ?? {},
|
|
171
|
+
governance_directives: [
|
|
172
|
+
"DO NOT modify or edit any files outside allowed_touchpoints.",
|
|
173
|
+
"DO NOT create duplicate helpers/services; reuse the existing symbols and methods declared in reuse_symbols.",
|
|
174
|
+
"DO NOT emit or expect phantom payload fields outside input_contract and output_contract.",
|
|
175
|
+
"DO NOT import cross-domain modules without declared allowed_dependencies in Septum domain boundaries.",
|
|
176
|
+
],
|
|
177
|
+
...(isInferred ? { is_inferred: true } : {}),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
recordFeatureAccess(featureConfig.domain, featureKey);
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
content: [
|
|
184
|
+
{
|
|
185
|
+
type: "text" as const,
|
|
186
|
+
text: JSON.stringify(response, null, 2),
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function recordFeatureAccess(domain: string, feature: string): void {
|
|
193
|
+
try {
|
|
194
|
+
const septumDir = path.resolve(process.cwd(), ".septum");
|
|
195
|
+
if (!fs.existsSync(septumDir)) {
|
|
196
|
+
fs.mkdirSync(septumDir, { recursive: true });
|
|
197
|
+
}
|
|
198
|
+
const logPath = path.join(septumDir, "catalog_access.json");
|
|
199
|
+
let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
|
|
200
|
+
if (fs.existsSync(logPath)) {
|
|
201
|
+
try {
|
|
202
|
+
log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
|
|
203
|
+
} catch {}
|
|
204
|
+
}
|
|
205
|
+
log.domains = log.domains || {};
|
|
206
|
+
log.features = log.features || {};
|
|
207
|
+
const now = new Date().toISOString();
|
|
208
|
+
log.domains[domain] = now;
|
|
209
|
+
log.features[feature] = now;
|
|
210
|
+
fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
|
|
211
|
+
} catch {}
|
|
212
|
+
}
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
-
import type { DatabaseRepository } from "../../core/database/repository.ts";
|
|
3
|
-
import type { SymbolKind } from "../../types/index.ts";
|
|
4
|
-
|
|
5
|
-
export interface GetSymbolHotspotsArgs {
|
|
6
|
-
min_lines?: number;
|
|
7
|
-
min_nesting?: number;
|
|
8
|
-
kind?: SymbolKind | string;
|
|
9
|
-
domain?: string;
|
|
10
|
-
limit?: number;
|
|
11
|
-
sort_by?: "lines" | "nesting" | "risk_score";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function handleGetSymbolHotspots(
|
|
15
|
-
repo: DatabaseRepository,
|
|
16
|
-
_config: ValidatedSeptumConfig,
|
|
17
|
-
args: GetSymbolHotspotsArgs
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
1
|
+
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
+
import type { DatabaseRepository } from "../../core/database/repository.ts";
|
|
3
|
+
import type { SymbolKind } from "../../types/index.ts";
|
|
4
|
+
|
|
5
|
+
export interface GetSymbolHotspotsArgs {
|
|
6
|
+
min_lines?: number;
|
|
7
|
+
min_nesting?: number;
|
|
8
|
+
kind?: SymbolKind | string;
|
|
9
|
+
domain?: string;
|
|
10
|
+
limit?: number;
|
|
11
|
+
sort_by?: "lines" | "nesting" | "risk_score";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function handleGetSymbolHotspots(
|
|
15
|
+
repo: DatabaseRepository,
|
|
16
|
+
_config: ValidatedSeptumConfig,
|
|
17
|
+
args: GetSymbolHotspotsArgs,
|
|
18
|
+
_workspaceRoot?: string
|
|
19
|
+
) {
|
|
20
|
+
const minLines = args.min_lines ?? (args.min_nesting ? 0 : 30);
|
|
21
|
+
const minNesting = args.min_nesting ?? 1;
|
|
22
|
+
const limit = args.limit ?? 30;
|
|
23
|
+
const sortBy = args.sort_by ?? "risk_score";
|
|
24
|
+
|
|
25
|
+
const hotspots = repo.getHotspotSymbols({
|
|
26
|
+
minLines,
|
|
27
|
+
minNesting,
|
|
28
|
+
kind: args.kind as SymbolKind | undefined,
|
|
29
|
+
domain: args.domain,
|
|
30
|
+
limit,
|
|
31
|
+
sortBy,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const payload = {
|
|
35
|
+
total_found: hotspots.length,
|
|
36
|
+
threshold_min_lines: minLines,
|
|
37
|
+
threshold_min_nesting: minNesting,
|
|
38
|
+
sort_by: sortBy,
|
|
39
|
+
hotspots: hotspots.map((h) => ({
|
|
40
|
+
name: h.name,
|
|
41
|
+
kind: h.kind,
|
|
42
|
+
line_count: h.line_count,
|
|
43
|
+
nesting_depth: (h as any).nesting_depth ?? 1,
|
|
44
|
+
risk_score: (h as any).risk_score ?? h.line_count,
|
|
45
|
+
line_span: `${h.line_start}-${h.line_end}`,
|
|
46
|
+
file_path: h.file_path,
|
|
47
|
+
domain: h.domain_name,
|
|
48
|
+
signature: h.signature,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text" as const,
|
|
56
|
+
text: JSON.stringify(payload, null, 2),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
-
import type { GetSymbolImpactArgs } from "../../types/index.ts";
|
|
4
|
-
|
|
5
|
-
export function handleGetSymbolImpact(
|
|
6
|
-
repo: SeptumRepository,
|
|
7
|
-
_config: ValidatedSeptumConfig,
|
|
8
|
-
args: GetSymbolImpactArgs
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
+
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
+
import type { GetSymbolImpactArgs } from "../../types/index.ts";
|
|
4
|
+
|
|
5
|
+
export function handleGetSymbolImpact(
|
|
6
|
+
repo: SeptumRepository,
|
|
7
|
+
_config: ValidatedSeptumConfig,
|
|
8
|
+
args: GetSymbolImpactArgs,
|
|
9
|
+
_workspaceRoot?: string
|
|
10
|
+
) {
|
|
11
|
+
const symbol = (args.symbol || (args as unknown as Record<string, unknown>).query || "").toString().trim();
|
|
12
|
+
if (!symbol) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"Missing required argument: 'symbol' (e.g. 'OrderService::cancelOrder', 'OrderService', or 'cancelOrder')"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const impact = repo.getSymbolImpact(symbol);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: "text" as const,
|
|
24
|
+
text: JSON.stringify(impact, null, 2),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,63 +1,65 @@
|
|
|
1
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
-
import { SymbolLocator } from "../../core/resolver/symbol-locator.ts";
|
|
4
|
-
import type { GetSymbolArgs } from "../../types/index.ts";
|
|
5
|
-
|
|
6
|
-
export function handleGetSymbol(
|
|
7
|
-
repo: SeptumRepository,
|
|
8
|
-
_config: ValidatedSeptumConfig,
|
|
9
|
-
args: GetSymbolArgs
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
+
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
+
import { SymbolLocator } from "../../core/resolver/symbol-locator.ts";
|
|
4
|
+
import type { GetSymbolArgs } from "../../types/index.ts";
|
|
5
|
+
|
|
6
|
+
export function handleGetSymbol(
|
|
7
|
+
repo: SeptumRepository,
|
|
8
|
+
_config: ValidatedSeptumConfig,
|
|
9
|
+
args: GetSymbolArgs,
|
|
10
|
+
_workspaceRoot?: string
|
|
11
|
+
) {
|
|
12
|
+
const symbol = (args.symbol || (args as unknown as Record<string, unknown>).query || "").toString().trim();
|
|
13
|
+
if (!symbol) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Missing required argument: 'symbol' (e.g. 'OrderController::cancelOrder', 'OrderService', or 'cancelOrder')"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const details = repo.getSymbolDetails(symbol, {
|
|
20
|
+
domain: args.domain,
|
|
21
|
+
includeDependencies: args.include_dependencies,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (details) {
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text" as const,
|
|
29
|
+
text: JSON.stringify(details, null, 2),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Fallback to fuzzy SymbolLocator to provide actionable hints
|
|
36
|
+
const locator = new SymbolLocator(repo);
|
|
37
|
+
const fallback = locator.locate(symbol, args.domain);
|
|
38
|
+
|
|
39
|
+
const payload = {
|
|
40
|
+
symbol,
|
|
41
|
+
found: false,
|
|
42
|
+
message: `Symbol '${symbol}' was not found in the deterministic catalog.`,
|
|
43
|
+
suggestions: fallback.suggestions.map((s) => ({
|
|
44
|
+
name: s.name,
|
|
45
|
+
similarity_score: Math.round(s.similarity_score * 100) / 100,
|
|
46
|
+
exact_range: {
|
|
47
|
+
start_line: s.line_start,
|
|
48
|
+
end_line: s.line_end,
|
|
49
|
+
total_lines: s.line_end - s.line_start + 1,
|
|
50
|
+
},
|
|
51
|
+
signature: s.signature,
|
|
52
|
+
file_path: s.file_path,
|
|
53
|
+
})),
|
|
54
|
+
sibling_methods: fallback.sibling_methods,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: "text" as const,
|
|
61
|
+
text: JSON.stringify(payload, null, 2),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
}
|