@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,226 +0,0 @@
|
|
|
1
|
-
import { RESOLVER_REVISION } from "../../core/resolver/import-resolver.ts";
|
|
2
|
-
import { getParserCapabilities } from "../../core/parser/language-capabilities.ts";
|
|
3
|
-
import { SemanticSliceExtractorRegistry } from "../../core/parser/extractors/registry.ts";
|
|
4
|
-
import * as fs from "node:fs";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
7
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
8
|
-
import type { DomainCatalogResponse } from "../../types/index.ts";
|
|
9
|
-
import type { GetDomainCatalogArgs } from "../schemas.ts";
|
|
10
|
-
import { checkRuntimeVersion, getCachedRuntimeVersion } from "../../utils/version-check.ts";
|
|
11
|
-
|
|
12
|
-
export type { GetDomainCatalogArgs } from "../schemas.ts";
|
|
13
|
-
|
|
14
|
-
export function handleGetDomainCatalog(
|
|
15
|
-
repo: SeptumRepository,
|
|
16
|
-
config: ValidatedSeptumConfig,
|
|
17
|
-
args: GetDomainCatalogArgs,
|
|
18
|
-
workspaceRoot?: string
|
|
19
|
-
) {
|
|
20
|
-
const targetRoot = args.workspace_path || workspaceRoot || (repo as any)?.projectRoot || process.cwd();
|
|
21
|
-
const domainName = args.domain ?? args.name;
|
|
22
|
-
const runtimeVersion = getCachedRuntimeVersion();
|
|
23
|
-
// Non-blocking background version refresh if needed
|
|
24
|
-
void checkRuntimeVersion().catch(() => {});
|
|
25
|
-
const parserCapabilities = {
|
|
26
|
-
...getParserCapabilities(args.detail_level === "full"),
|
|
27
|
-
analysis_contracts: { foundation_revision: "1", resolver_revision: RESOLVER_REVISION, relationships: "imports-v1", semantic_lifecycle: "async-v1" },
|
|
28
|
-
semantic_adapters: args.detail_level === "full"
|
|
29
|
-
? SemanticSliceExtractorRegistry.getCapabilities()
|
|
30
|
-
: SemanticSliceExtractorRegistry.getCapabilities().map(adapter => adapter.id),
|
|
31
|
-
semantic_limits: "Registered adapters cover selected static patterns; registration does not prove applicability, AST backing, complete routes or runtime calls.",
|
|
32
|
-
};
|
|
33
|
-
const isDirty = repo.getMeta("slices_dirty") === "1";
|
|
34
|
-
const indexStatus = {
|
|
35
|
-
runtime_version: runtimeVersion,
|
|
36
|
-
unsupported_files: JSON.parse(repo.getMeta("unsupported_files") || "[]"),
|
|
37
|
-
watcher_mode: repo.getMeta("watcher_mode") || "manual",
|
|
38
|
-
sync_state: repo.getMeta("sync_state") || "unknown",
|
|
39
|
-
sync_needed: isDirty,
|
|
40
|
-
skipped_files: JSON.parse(repo.getMeta("skipped_files") || "[]"),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (!domainName) {
|
|
44
|
-
const allDomains = repo.getAllDomains();
|
|
45
|
-
if (allDomains.length === 0) {
|
|
46
|
-
const root = targetRoot;
|
|
47
|
-
let agentGuidance =
|
|
48
|
-
"Panggil tool 'septum_domain(action: \"register\", name: \"core\", root: \"src\", ingest_now: true)' untuk mendaftarkan dan mengindeks domain utama secara otomatis, atau jalankan 'septum init' di terminal workspace.";
|
|
49
|
-
if (runtimeVersion.update_available) {
|
|
50
|
-
agentGuidance += ` Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`;
|
|
51
|
-
}
|
|
52
|
-
const diagnostic = {
|
|
53
|
-
status: "NOT_INDEXED",
|
|
54
|
-
parser_capabilities: parserCapabilities,
|
|
55
|
-
total_domains: 0,
|
|
56
|
-
runtime_version: runtimeVersion,
|
|
57
|
-
message: `Workspace '${root}' belum memiliki domain terdaftar dalam Septum catalog.`,
|
|
58
|
-
suggested_action: {
|
|
59
|
-
tool: "septum_domain",
|
|
60
|
-
params: {
|
|
61
|
-
action: "register",
|
|
62
|
-
name: "core",
|
|
63
|
-
root: "src",
|
|
64
|
-
ingest_now: true,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
agent_guidance: agentGuidance,
|
|
68
|
-
...(runtimeVersion.update_available
|
|
69
|
-
? {
|
|
70
|
-
agent_instruction: `Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`,
|
|
71
|
-
}
|
|
72
|
-
: {}),
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
content: [
|
|
76
|
-
{
|
|
77
|
-
type: "text" as const,
|
|
78
|
-
text: JSON.stringify(diagnostic, null, 2),
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
metadata: diagnostic,
|
|
82
|
-
runtime_version: runtimeVersion,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const projectType = repo.getMeta("project_type") || "generic";
|
|
87
|
-
const framework = repo.getMeta("framework") || "unknown";
|
|
88
|
-
const archStyle = repo.getMeta("architecture_style") || "modular";
|
|
89
|
-
const totalSlices =
|
|
90
|
-
typeof (repo as any).countVerticalSlices === "function"
|
|
91
|
-
? (repo as any).countVerticalSlices()
|
|
92
|
-
: repo.getAllVerticalSlices().length;
|
|
93
|
-
|
|
94
|
-
let agentInstruction =
|
|
95
|
-
"Macro semantic map loaded from SQLite SSOT. Use 'septum_domain' with domain='<name>' for granular file/symbol catalogs, or 'septum_slice' with query='<route|command|intent>' for end-to-end execution flow.";
|
|
96
|
-
if (isDirty) {
|
|
97
|
-
agentInstruction += " Notice: Index has pending or unsynchronized file changes. Run 'septum sync' to ensure all symbol coordinates and call graphs are fully refreshed.";
|
|
98
|
-
}
|
|
99
|
-
if (runtimeVersion.update_available) {
|
|
100
|
-
agentInstruction += ` Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const macroMap = {
|
|
104
|
-
parser_capabilities: parserCapabilities,
|
|
105
|
-
runtime_version: runtimeVersion,
|
|
106
|
-
index_status: indexStatus,
|
|
107
|
-
telescope_view: {
|
|
108
|
-
project_type: projectType,
|
|
109
|
-
framework,
|
|
110
|
-
architecture_style: archStyle,
|
|
111
|
-
total_domains: allDomains.length,
|
|
112
|
-
total_vertical_slices: totalSlices,
|
|
113
|
-
scanned_folders: JSON.parse(repo.getMeta("scanned_folders") || "[]"),
|
|
114
|
-
ignored_folders: JSON.parse(repo.getMeta("ignored_folders") || "[]"),
|
|
115
|
-
},
|
|
116
|
-
domains: allDomains.map((d) => ({
|
|
117
|
-
name: d.name,
|
|
118
|
-
root: d.root_path,
|
|
119
|
-
archetypes: Object.keys(JSON.parse(d.archetypes_json || "{}")),
|
|
120
|
-
allowed_dependencies: JSON.parse(d.allowed_deps_json || "[]"),
|
|
121
|
-
forbidden_dependencies: JSON.parse(d.forbidden_deps_json || "[]"),
|
|
122
|
-
})),
|
|
123
|
-
agent_instruction: agentInstruction,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
content: [
|
|
128
|
-
{
|
|
129
|
-
type: "text" as const,
|
|
130
|
-
text: JSON.stringify(macroMap, null, 2),
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
metadata: { runtime_version: runtimeVersion },
|
|
134
|
-
runtime_version: runtimeVersion,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const archetypeFilter = args.archetype_filter ?? args.archetype;
|
|
139
|
-
const detailLevel = args.detail_level ?? "compact";
|
|
140
|
-
const fileFilter = args.file_filter;
|
|
141
|
-
|
|
142
|
-
const catalog: DomainCatalogResponse | null = (repo.getDomainCatalog as any)(
|
|
143
|
-
domainName,
|
|
144
|
-
archetypeFilter,
|
|
145
|
-
{ detailLevel, fileFilter, workspaceRoot: targetRoot }
|
|
146
|
-
);
|
|
147
|
-
if (!catalog) {
|
|
148
|
-
const available = Object.keys(config.domains || {});
|
|
149
|
-
const suggestions = available.filter((d) =>
|
|
150
|
-
d.toLowerCase().includes(domainName.toLowerCase()) ||
|
|
151
|
-
domainName.toLowerCase().includes(d.toLowerCase())
|
|
152
|
-
);
|
|
153
|
-
const notFoundPayload: Record<string, any> = {
|
|
154
|
-
status: "not_found",
|
|
155
|
-
parser_capabilities: parserCapabilities,
|
|
156
|
-
found: false,
|
|
157
|
-
domain: domainName,
|
|
158
|
-
runtime_version: runtimeVersion,
|
|
159
|
-
message: `Domain '${domainName}' not found in Septum catalog.`,
|
|
160
|
-
available_domains: available,
|
|
161
|
-
suggestions: suggestions.length > 0 ? suggestions : available,
|
|
162
|
-
suggested_action: {
|
|
163
|
-
tool: "septum_domain",
|
|
164
|
-
params: { action: "register", domain: domainName, root: `src/domains/${domainName}` },
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
if (runtimeVersion.update_available) {
|
|
168
|
-
notFoundPayload.agent_instruction = `Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`;
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
content: [
|
|
172
|
-
{
|
|
173
|
-
type: "text" as const,
|
|
174
|
-
text: JSON.stringify(notFoundPayload, null, 2),
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
metadata: notFoundPayload,
|
|
178
|
-
runtime_version: runtimeVersion,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Record access log for Gate 3 (Mandatory Catalog Consultation)
|
|
183
|
-
recordCatalogAccess(domainName, targetRoot);
|
|
184
|
-
|
|
185
|
-
const catalogPayload: Record<string, any> = {
|
|
186
|
-
...catalog,
|
|
187
|
-
...(args.detail_level === "full" ? { relationships: repo.getImportRelationships(targetRoot).filter(edge => catalog.files.some(file => file.path === edge.source.file)) } : {}),
|
|
188
|
-
parser_capabilities: parserCapabilities,
|
|
189
|
-
runtime_version: runtimeVersion,
|
|
190
|
-
index_status: indexStatus,
|
|
191
|
-
};
|
|
192
|
-
if (runtimeVersion.update_available) {
|
|
193
|
-
catalogPayload.agent_instruction = `Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Compact catalogs omit per-language capability details.
|
|
197
|
-
return {
|
|
198
|
-
content: [
|
|
199
|
-
{
|
|
200
|
-
type: "text" as const,
|
|
201
|
-
text: JSON.stringify(catalogPayload, null, 2),
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
metadata: { runtime_version: runtimeVersion },
|
|
205
|
-
runtime_version: runtimeVersion,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function recordCatalogAccess(domain: string, projectRoot: string = process.cwd()): void {
|
|
210
|
-
try {
|
|
211
|
-
const septumDir = path.resolve(projectRoot, ".septum");
|
|
212
|
-
if (!fs.existsSync(septumDir)) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const logPath = path.join(septumDir, "catalog_access.json");
|
|
216
|
-
let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
|
|
217
|
-
if (fs.existsSync(logPath)) {
|
|
218
|
-
try {
|
|
219
|
-
log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
|
|
220
|
-
} catch {}
|
|
221
|
-
}
|
|
222
|
-
log.domains = log.domains || {};
|
|
223
|
-
log.domains[domain] = new Date().toISOString();
|
|
224
|
-
fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
|
|
225
|
-
} catch {}
|
|
226
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
-
import { EnvironmentDetector } from "../../core/topology/environment-detector.ts";
|
|
4
|
-
import type { EnvironmentLayer } from "../../core/topology/types.ts";
|
|
5
|
-
import type { GetEnvironmentTopologyArgs } from "../schemas.ts";
|
|
6
|
-
|
|
7
|
-
export type { GetEnvironmentTopologyArgs } from "../schemas.ts";
|
|
8
|
-
|
|
9
|
-
export function handleGetEnvironmentTopology(
|
|
10
|
-
repo: SeptumRepository,
|
|
11
|
-
_config: ValidatedSeptumConfig,
|
|
12
|
-
args: GetEnvironmentTopologyArgs,
|
|
13
|
-
workspaceRoot: string
|
|
14
|
-
) {
|
|
15
|
-
// If layer resolution input is provided, persist into SQLite SSOT
|
|
16
|
-
if (args.resolve) {
|
|
17
|
-
const existing = repo.environment.getLayer(args.resolve.layer);
|
|
18
|
-
repo.environment.saveLayer({
|
|
19
|
-
layer: args.resolve.layer,
|
|
20
|
-
platform: args.resolve.platform,
|
|
21
|
-
canonical_tag: EnvironmentDetector.matchCanonicalTag(args.resolve.platform),
|
|
22
|
-
status: "VERIFIED",
|
|
23
|
-
constraints: args.resolve.constraints && args.resolve.constraints.length > 0 ? args.resolve.constraints : (existing?.constraints ?? []),
|
|
24
|
-
detected_from: ["Manual Developer Resolution via Septum"],
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// If node resolution input is provided, persist node into SQLite SSOT
|
|
29
|
-
if (args.resolveNode) {
|
|
30
|
-
repo.environment.saveNode({
|
|
31
|
-
id: args.resolveNode.id,
|
|
32
|
-
layer: args.resolveNode.layer,
|
|
33
|
-
name: args.resolveNode.name,
|
|
34
|
-
platform: args.resolveNode.platform,
|
|
35
|
-
canonical_tag: args.resolveNode.canonical_tag || EnvironmentDetector.matchCanonicalTag(args.resolveNode.platform),
|
|
36
|
-
domain_or_ip: args.resolveNode.domain_or_ip,
|
|
37
|
-
role: args.resolveNode.role,
|
|
38
|
-
status: "VERIFIED",
|
|
39
|
-
detected_from: ["Manual Developer Resolution via Septum MCP"],
|
|
40
|
-
constraints: args.resolveNode.constraints ?? [],
|
|
41
|
-
connected_to: args.resolveNode.connected_to ?? [],
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Detect current topology merging heuristics with SQLite SSOT
|
|
46
|
-
const topology = EnvironmentDetector.detect(workspaceRoot, repo, args.refresh);
|
|
47
|
-
|
|
48
|
-
// Format into high-density Markdown output
|
|
49
|
-
let output = `### 🌐 Septum Environment & Topology Plane\n\n`;
|
|
50
|
-
output += `> **Overall Status:** \`${topology.overall_status}\`\n`;
|
|
51
|
-
output += `> **Topology Mode:** \`${topology.is_distributed ? "DISTRIBUTED MULTI-NODE GRAPH" : "MONOLITHIC SINGLE-NODE"}\`\n`;
|
|
52
|
-
output += `> **Architecture:** ${topology.architectural_summary}\n\n`;
|
|
53
|
-
|
|
54
|
-
// Section 1: Distributed Nodes Graph
|
|
55
|
-
if (topology.nodes.length > 0) {
|
|
56
|
-
output += `#### 📦 Distributed Topology Nodes (${topology.nodes.length} entities):\n`;
|
|
57
|
-
output += `| Node ID | Layer | Platform / Specs | Role | Domain / Host | Connected To | Status |\n`;
|
|
58
|
-
output += `| :--- | :--- | :--- | :--- | :--- | :--- | :--- |\n`;
|
|
59
|
-
for (const node of topology.nodes) {
|
|
60
|
-
const statusBadge = node.status === "VERIFIED" ? "✅ VERIFIED" : node.status === "DETECTED" ? "🔍 DETECTED" : "⚠️ " + node.status;
|
|
61
|
-
const domain = node.domain_or_ip ? `\`${node.domain_or_ip}\`` : "-";
|
|
62
|
-
const role = node.role ? `\`${node.role}\`` : "-";
|
|
63
|
-
const connected = node.connected_to && node.connected_to.length > 0 ? node.connected_to.join(", ") : "-";
|
|
64
|
-
output += `| **\`${node.id}\`** | ${node.layer.toUpperCase()} | ${node.platform} | ${role} | ${domain} | ${connected} | ${statusBadge} |\n`;
|
|
65
|
-
}
|
|
66
|
-
output += `\n`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Section 2: 6-Layer Summary
|
|
70
|
-
output += `#### 🗺️ 6-Layer Plane Summary:\n`;
|
|
71
|
-
output += `| Layer | Plane Domain | Platform / Setup | Status | Evidence / Files |\n`;
|
|
72
|
-
output += `| :--- | :--- | :--- | :--- | :--- |\n`;
|
|
73
|
-
|
|
74
|
-
const layerLabels: Record<EnvironmentLayer, string> = {
|
|
75
|
-
edge: "Perimeter & WAF",
|
|
76
|
-
gateway: "Ingress & Web Server",
|
|
77
|
-
host: "Deployment Platform",
|
|
78
|
-
runtime: "Application Engine",
|
|
79
|
-
storage: "Data & Cache",
|
|
80
|
-
telemetry: "Observability & Logs",
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
for (const layerKey of Object.keys(topology.layers) as EnvironmentLayer[]) {
|
|
84
|
-
const info = topology.layers[layerKey];
|
|
85
|
-
const evidence = info.detected_from && info.detected_from.length > 0 ? info.detected_from.join(", ") : "-";
|
|
86
|
-
const statusBadge = info.status === "VERIFIED" ? "✅ VERIFIED" : info.status === "DETECTED" ? "🔍 DETECTED" : "⚠️ " + info.status;
|
|
87
|
-
output += `| **${layerKey.toUpperCase()}** | ${layerLabels[layerKey]} | ${info.platform || "Not Defined"} | ${statusBadge} | ${evidence} |\n`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Section 3: Active Constraints
|
|
91
|
-
output += `\n#### 📌 Active Architectural Constraints:\n`;
|
|
92
|
-
let hasConstraints = false;
|
|
93
|
-
for (const node of topology.nodes) {
|
|
94
|
-
if (node.constraints && node.constraints.length > 0) {
|
|
95
|
-
hasConstraints = true;
|
|
96
|
-
output += `- **\`${node.id}\` (${node.platform}):**\n`;
|
|
97
|
-
for (const c of node.constraints) {
|
|
98
|
-
output += ` • ${c}\n`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (!hasConstraints) {
|
|
103
|
-
output += `*No specific node constraints recorded.*\n`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Section 4: Cross-Layer & Distributed Interplays
|
|
107
|
-
if (topology.interplays.length > 0) {
|
|
108
|
-
output += `\n#### ⚡ Cross-Layer & Distributed Invariants:\n`;
|
|
109
|
-
for (const interplay of topology.interplays) {
|
|
110
|
-
const nodeTrace = interplay.involved_node_ids && interplay.involved_node_ids.length > 0 ? ` (Nodes: \`${interplay.involved_node_ids.join(", ")}\`)` : "";
|
|
111
|
-
output += `- **${interplay.title}** (Layers: \`${interplay.involved_layers.join(" ➔ ")}\`)${nodeTrace}:\n`;
|
|
112
|
-
output += ` • *Invarian:* ${interplay.risk_or_rule}\n`;
|
|
113
|
-
output += ` • *Tindakan Wajib:* ${interplay.required_action}\n`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Section 5: Pending Inquiries
|
|
118
|
-
if (topology.pending_inquiries.length > 0) {
|
|
119
|
-
output += `\n#### ❓ Pending Architectural Inquiries (Self-Aware Inquiry Required):\n`;
|
|
120
|
-
output += `Terdapat layer atau node arsitektural yang belum terkonfirmasi. Sebelum mengeksekusi kode terkait deployment/throttling/cron/cookies, klarifikasikan hal berikut ke pengguna:\n`;
|
|
121
|
-
for (const q of topology.pending_inquiries) {
|
|
122
|
-
output += `- ${q}\n`;
|
|
123
|
-
}
|
|
124
|
-
output += `\n*Untuk mengunci jawaban pengguna ke SQLite SSOT, panggil kembali tool ini dengan argumen:*\n`;
|
|
125
|
-
output += `\`septum_domain(action: "topology", resolve: { layer: "<layer_name>", platform: "<platform_name>" })\`\n`;
|
|
126
|
-
output += `*atau untuk entitas terdistribusi:*\n`;
|
|
127
|
-
output += `\`septum_domain(action: "topology", resolve_node: { id: "<node_id>", layer: "<layer>", name: "<name>", platform: "<platform>", domain_or_ip: "<domain_or_ip>", role: "<role>" })\`\n`;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
content: [
|
|
132
|
-
{
|
|
133
|
-
type: "text" as const,
|
|
134
|
-
text: output,
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
};
|
|
138
|
-
}
|
|
@@ -1,224 +0,0 @@
|
|
|
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
|
-
import type { GetFeatureContextArgs } from "../schemas.ts";
|
|
8
|
-
|
|
9
|
-
export type { GetFeatureContextArgs } from "../schemas.ts";
|
|
10
|
-
|
|
11
|
-
export function handleClearFeatureContext(
|
|
12
|
-
workspaceRoot: string = process.cwd(),
|
|
13
|
-
force: boolean = false
|
|
14
|
-
): boolean {
|
|
15
|
-
return SessionManager.clearActiveSession(workspaceRoot, undefined, force);
|
|
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
|
-
if (typeof repo?.getMeta === "function") {
|
|
27
|
-
try {
|
|
28
|
-
const metaFeaturesRaw = repo.getMeta("features_json");
|
|
29
|
-
if (metaFeaturesRaw) {
|
|
30
|
-
Object.assign(features, JSON.parse(metaFeaturesRaw));
|
|
31
|
-
}
|
|
32
|
-
} catch {}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ZERO-ARGUMENT GRACEFUL FALLBACK: Guide the agent instead of throwing validation errors
|
|
36
|
-
if (!featureKey) {
|
|
37
|
-
const available = Object.keys(features);
|
|
38
|
-
return {
|
|
39
|
-
content: [
|
|
40
|
-
{
|
|
41
|
-
type: "text" as const,
|
|
42
|
-
text: JSON.stringify(
|
|
43
|
-
{
|
|
44
|
-
status: "prompt",
|
|
45
|
-
message: "No feature specified. Please specify 'feature_key' from the registered features below or trace routes.",
|
|
46
|
-
available_features: available.length > 0 ? available : [],
|
|
47
|
-
instructions: "Call 'septum_feature({ action: \"get\", feature_key: \"<name>\" })' or lock a feature with 'septum_feature({ action: \"lock\", feature_key: \"<name>\", domain: \"<domain>\" })'.",
|
|
48
|
-
},
|
|
49
|
-
null,
|
|
50
|
-
2
|
|
51
|
-
),
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let featureConfig = features[featureKey];
|
|
58
|
-
let isInferred = false;
|
|
59
|
-
|
|
60
|
-
if (!featureConfig) {
|
|
61
|
-
// Attempt auto-derive from vertical slices or domain symbols
|
|
62
|
-
const searchTerm = featureKey.toLowerCase();
|
|
63
|
-
const allSlices = typeof repo.getAllVerticalSlices === "function" ? repo.getAllVerticalSlices() : [];
|
|
64
|
-
const fromRepoSearch = typeof repo.findVerticalSlices === "function" ? repo.findVerticalSlices(searchTerm) : [];
|
|
65
|
-
const matchingSlices = [
|
|
66
|
-
...fromRepoSearch,
|
|
67
|
-
...allSlices.filter(
|
|
68
|
-
(s) =>
|
|
69
|
-
s.route_uri.toLowerCase().includes(searchTerm) ||
|
|
70
|
-
(s.route_name && s.route_name.toLowerCase().includes(searchTerm)) ||
|
|
71
|
-
s.controller_class.toLowerCase().includes(searchTerm) ||
|
|
72
|
-
(s.feature_key && s.feature_key.toLowerCase().includes(searchTerm))
|
|
73
|
-
),
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
const uniqueSlices = Array.from(
|
|
77
|
-
new Map(matchingSlices.map((s) => [`${s.http_method}:${s.route_uri}`, s])).values()
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
if (uniqueSlices.length > 0) {
|
|
81
|
-
isInferred = true;
|
|
82
|
-
const candidateTouchpoints = new Set<string>();
|
|
83
|
-
const candidateSymbols = new Set<string>();
|
|
84
|
-
let detectedDomain = "app";
|
|
85
|
-
|
|
86
|
-
if (config.domains && config.domains[featureKey]) {
|
|
87
|
-
detectedDomain = featureKey;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for (const slice of uniqueSlices) {
|
|
91
|
-
if (slice.controller_file) {
|
|
92
|
-
candidateTouchpoints.add(slice.controller_file);
|
|
93
|
-
}
|
|
94
|
-
candidateSymbols.add(slice.controller_class);
|
|
95
|
-
if (slice.action_name) {
|
|
96
|
-
candidateSymbols.add(`${slice.controller_class}@${slice.action_name}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (slice.execution_chain_json) {
|
|
100
|
-
try {
|
|
101
|
-
const chain = JSON.parse(slice.execution_chain_json);
|
|
102
|
-
if (Array.isArray(chain)) {
|
|
103
|
-
for (const node of chain) {
|
|
104
|
-
if (node.file) candidateTouchpoints.add(node.file);
|
|
105
|
-
if (node.symbol) candidateSymbols.add(node.symbol);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} catch {}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
featureConfig = {
|
|
113
|
-
domain: detectedDomain,
|
|
114
|
-
description: `[Auto-Derived] Feature context inferred from ${uniqueSlices.length} vertical slices matching '${featureKey}'`,
|
|
115
|
-
allowed_touchpoints: Array.from(candidateTouchpoints),
|
|
116
|
-
reuse_symbols: Array.from(candidateSymbols).slice(0, 10),
|
|
117
|
-
input_contract: {},
|
|
118
|
-
output_contract: {},
|
|
119
|
-
};
|
|
120
|
-
} else {
|
|
121
|
-
const available = Object.keys(features);
|
|
122
|
-
const availableStr = available.length > 0 ? available.join(", ") : "none";
|
|
123
|
-
return {
|
|
124
|
-
content: [
|
|
125
|
-
{
|
|
126
|
-
type: "text" as const,
|
|
127
|
-
text: JSON.stringify(
|
|
128
|
-
{
|
|
129
|
-
status: "not_found",
|
|
130
|
-
feature_key: featureKey,
|
|
131
|
-
message: `Feature '${featureKey}' not found in configuration or vertical slices. Available features: [${availableStr}].`,
|
|
132
|
-
recovery_options: [
|
|
133
|
-
`septum_feature({ action: "lock", feature_key: "${featureKey}", domain: "<domain_name>", allowed_touchpoints: ["path/to/file"] })`,
|
|
134
|
-
`septum_slice({ query: "routes/web.php" })`,
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
null,
|
|
138
|
-
2
|
|
139
|
-
),
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// MCP-14: handleGetFeatureContext is strictly read-only and does not mutate session leases
|
|
147
|
-
|
|
148
|
-
// Deterministically fetch signatures, methods, and properties for reuse_symbols from SQLite
|
|
149
|
-
const reuseSymbolsWithMeta: FeatureContextResponse["reuse_symbols"] = [];
|
|
150
|
-
const requestedSymbols = featureConfig.reuse_symbols ?? [];
|
|
151
|
-
|
|
152
|
-
for (const symName of requestedSymbols) {
|
|
153
|
-
const record = repo.findSymbolWithMembers(symName);
|
|
154
|
-
if (record) {
|
|
155
|
-
reuseSymbolsWithMeta.push({
|
|
156
|
-
name: record.symbol_name,
|
|
157
|
-
kind: record.kind,
|
|
158
|
-
signature: record.signature,
|
|
159
|
-
methods: record.methods.length > 0 ? record.methods : undefined,
|
|
160
|
-
properties: record.properties.length > 0 ? record.properties : undefined,
|
|
161
|
-
file_path: record.file_path,
|
|
162
|
-
domain: record.domain_name,
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
reuseSymbolsWithMeta.push({
|
|
166
|
-
name: symName,
|
|
167
|
-
kind: "unknown",
|
|
168
|
-
domain: featureConfig.domain,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const response: FeatureContextResponse = {
|
|
174
|
-
feature_key: featureKey,
|
|
175
|
-
feature: featureKey,
|
|
176
|
-
domain: featureConfig.domain,
|
|
177
|
-
description: featureConfig.description,
|
|
178
|
-
allowed_touchpoints: featureConfig.allowed_touchpoints,
|
|
179
|
-
reuse_symbols: reuseSymbolsWithMeta,
|
|
180
|
-
input_contract: (featureConfig.input_contract as Record<string, unknown>) ?? {},
|
|
181
|
-
output_contract: (featureConfig.output_contract as Record<string, unknown>) ?? {},
|
|
182
|
-
governance_directives: [
|
|
183
|
-
"DO NOT modify or edit any files outside allowed_touchpoints.",
|
|
184
|
-
"DO NOT create duplicate helpers/services; reuse the existing symbols and methods declared in reuse_symbols.",
|
|
185
|
-
"DO NOT emit or expect phantom payload fields outside input_contract and output_contract.",
|
|
186
|
-
"DO NOT import cross-domain modules without declared allowed_dependencies in Septum domain boundaries.",
|
|
187
|
-
],
|
|
188
|
-
...(isInferred ? { is_inferred: true } : {}),
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
recordFeatureAccess(featureConfig.domain, featureKey, workspaceRoot);
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
content: [
|
|
195
|
-
{
|
|
196
|
-
type: "text" as const,
|
|
197
|
-
text: JSON.stringify(response, null, 2),
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function recordFeatureAccess(domain: string, feature: string, workspaceRoot: string = process.cwd()): void {
|
|
204
|
-
try {
|
|
205
|
-
const septumDir = path.resolve(workspaceRoot, ".septum");
|
|
206
|
-
if (!fs.existsSync(septumDir)) {
|
|
207
|
-
fs.mkdirSync(septumDir, { recursive: true });
|
|
208
|
-
}
|
|
209
|
-
const logPath = path.join(septumDir, "catalog_access.json");
|
|
210
|
-
let log: { domains?: Record<string, string>; features?: Record<string, string> } = {};
|
|
211
|
-
if (fs.existsSync(logPath)) {
|
|
212
|
-
try {
|
|
213
|
-
log = JSON.parse(fs.readFileSync(logPath, "utf-8"));
|
|
214
|
-
} catch {}
|
|
215
|
-
}
|
|
216
|
-
log.domains = log.domains || {};
|
|
217
|
-
log.features = log.features || {};
|
|
218
|
-
const now = new Date().toISOString();
|
|
219
|
-
log.domains[domain] = now;
|
|
220
|
-
log.features[feature] = now;
|
|
221
|
-
fs.writeFileSync(logPath, JSON.stringify(log, null, 2), "utf-8");
|
|
222
|
-
} catch {}
|
|
223
|
-
}
|
|
224
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { ValidatedSeptumConfig } from "../../core/config/schema.ts";
|
|
2
|
-
import type { SeptumRepository } from "../../core/database/repository.ts";
|
|
3
|
-
import type { SymbolKind } from "../../types/index.ts";
|
|
4
|
-
import type { GetSymbolHotspotsArgs } from "../schemas.ts";
|
|
5
|
-
|
|
6
|
-
export type { GetSymbolHotspotsArgs } from "../schemas.ts";
|
|
7
|
-
|
|
8
|
-
export function handleGetSymbolHotspots(
|
|
9
|
-
repo: SeptumRepository,
|
|
10
|
-
_config: ValidatedSeptumConfig,
|
|
11
|
-
args: GetSymbolHotspotsArgs,
|
|
12
|
-
_workspaceRoot?: string
|
|
13
|
-
) {
|
|
14
|
-
const minLines = args.min_lines ?? (args.min_nesting ? 0 : 30);
|
|
15
|
-
const minNesting = args.min_nesting ?? 1;
|
|
16
|
-
const limit = args.limit ?? 30;
|
|
17
|
-
const sortBy = args.sort_by ?? "risk_score";
|
|
18
|
-
|
|
19
|
-
const hotspots = repo.getHotspotSymbols({
|
|
20
|
-
minLines,
|
|
21
|
-
minNesting,
|
|
22
|
-
kind: args.kind as SymbolKind | undefined,
|
|
23
|
-
domain: args.domain,
|
|
24
|
-
limit,
|
|
25
|
-
sortBy,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const payload = {
|
|
29
|
-
total_found: hotspots.length,
|
|
30
|
-
threshold_min_lines: minLines,
|
|
31
|
-
threshold_min_nesting: minNesting,
|
|
32
|
-
sort_by: sortBy,
|
|
33
|
-
hotspots: hotspots.map((h) => ({
|
|
34
|
-
name: h.name,
|
|
35
|
-
kind: h.kind,
|
|
36
|
-
line_count: h.line_count,
|
|
37
|
-
nesting_depth: (h as any).nesting_depth ?? 1,
|
|
38
|
-
risk_score: (h as any).risk_score ?? h.line_count,
|
|
39
|
-
line_span: `${h.line_start}-${h.line_end}`,
|
|
40
|
-
file_path: h.file_path,
|
|
41
|
-
domain: h.domain_name,
|
|
42
|
-
signature: h.signature,
|
|
43
|
-
})),
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
content: [
|
|
48
|
-
{
|
|
49
|
-
type: "text" as const,
|
|
50
|
-
text: JSON.stringify(payload, null, 2),
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
}
|