@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
package/src/types/index.ts
CHANGED
|
@@ -15,6 +15,11 @@ export type ArchetypeKind =
|
|
|
15
15
|
| "route"
|
|
16
16
|
| "util"
|
|
17
17
|
| "view"
|
|
18
|
+
| "config"
|
|
19
|
+
| "parser"
|
|
20
|
+
| "resolver"
|
|
21
|
+
| "pipeline"
|
|
22
|
+
| "server"
|
|
18
23
|
| "unknown";
|
|
19
24
|
|
|
20
25
|
export type SymbolKind =
|
|
@@ -42,7 +47,6 @@ export interface SeptumConfig {
|
|
|
42
47
|
ignore_patterns?: string[];
|
|
43
48
|
};
|
|
44
49
|
domains: Record<string, DomainConfig>;
|
|
45
|
-
features?: Record<string, FeatureConfig>;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
export interface DomainConfig {
|
|
@@ -53,55 +57,13 @@ export interface DomainConfig {
|
|
|
53
57
|
description?: string;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
export interface FeatureConfig {
|
|
57
|
-
domain: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
allowed_touchpoints: string[];
|
|
60
|
-
reuse_symbols?: string[];
|
|
61
|
-
input_contract?: Record<string, unknown>;
|
|
62
|
-
output_contract?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface FeatureContextResponse {
|
|
66
|
-
feature_key: string;
|
|
67
|
-
feature?: string;
|
|
68
|
-
domain: string;
|
|
69
|
-
description?: string;
|
|
70
|
-
allowed_touchpoints: string[];
|
|
71
|
-
reuse_symbols: Array<{
|
|
72
|
-
name: string;
|
|
73
|
-
kind: string;
|
|
74
|
-
signature?: string;
|
|
75
|
-
methods?: string[];
|
|
76
|
-
properties?: string[];
|
|
77
|
-
file_path?: string;
|
|
78
|
-
domain?: string;
|
|
79
|
-
}>;
|
|
80
|
-
input_contract: Record<string, unknown>;
|
|
81
|
-
output_contract: Record<string, unknown>;
|
|
82
|
-
governance_directives?: string[];
|
|
83
|
-
is_inferred?: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface RegisterFeatureArgs {
|
|
87
|
-
feature_key: string;
|
|
88
|
-
feature?: string;
|
|
89
|
-
domain: string;
|
|
90
|
-
description?: string;
|
|
91
|
-
allowed_touchpoints?: string[];
|
|
92
|
-
reuse_symbols?: string[];
|
|
93
|
-
input_contract?: Record<string, unknown>;
|
|
94
|
-
output_contract?: Record<string, unknown>;
|
|
95
|
-
workspace_path?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
60
|
export interface CheckBoundaryArgs {
|
|
99
61
|
file_path?: string;
|
|
100
62
|
file_paths?: string[];
|
|
101
63
|
proposed_imports?: string[];
|
|
102
|
-
feature_key?: string;
|
|
103
64
|
scope?: "file" | "all" | "staged" | "domain";
|
|
104
65
|
domain?: string;
|
|
66
|
+
format?: "json" | "text";
|
|
105
67
|
workspace_path?: string;
|
|
106
68
|
}
|
|
107
69
|
|
|
@@ -128,13 +90,6 @@ export interface FileRecord {
|
|
|
128
90
|
last_scanned_at: string;
|
|
129
91
|
}
|
|
130
92
|
|
|
131
|
-
export interface ActiveFeatureSession {
|
|
132
|
-
owner_id?: string;
|
|
133
|
-
feature_key: string;
|
|
134
|
-
domain: string;
|
|
135
|
-
touchpoints: string[];
|
|
136
|
-
locked_at: string;
|
|
137
|
-
}
|
|
138
93
|
|
|
139
94
|
export interface SymbolReference {
|
|
140
95
|
file_path: string;
|
|
@@ -240,8 +195,6 @@ export interface ParsedFileAST {
|
|
|
240
195
|
export type BoundaryViolationRule =
|
|
241
196
|
| "forbidden_dependency"
|
|
242
197
|
| "disallowed_dependency"
|
|
243
|
-
| "touchpoint_violation"
|
|
244
|
-
| "unknown_feature"
|
|
245
198
|
| "unmapped_domain"
|
|
246
199
|
| "circular_dependency";
|
|
247
200
|
|
|
@@ -253,6 +206,7 @@ export interface BoundaryViolation {
|
|
|
253
206
|
imported_target: string;
|
|
254
207
|
rule: BoundaryViolationRule;
|
|
255
208
|
message: string;
|
|
209
|
+
pre_existing?: boolean;
|
|
256
210
|
}
|
|
257
211
|
|
|
258
212
|
export interface FileConnectionsSummary {
|
|
@@ -289,8 +243,37 @@ export interface DomainCatalogResponse {
|
|
|
289
243
|
agent_hint?: string;
|
|
290
244
|
}
|
|
291
245
|
|
|
246
|
+
/** Navigation facts omit source, signatures and declaration identities. */
|
|
247
|
+
export interface NavigationFile {
|
|
248
|
+
path: string;
|
|
249
|
+
domain: string;
|
|
250
|
+
archetype: ArchetypeKind;
|
|
251
|
+
symbol_count: number;
|
|
252
|
+
anchor: string | null;
|
|
253
|
+
}
|
|
254
|
+
export interface NavigationQuery {
|
|
255
|
+
domain?: string;
|
|
256
|
+
name?: string;
|
|
257
|
+
file_filter?: string;
|
|
258
|
+
archetype_filter?: string;
|
|
259
|
+
archetype?: string;
|
|
260
|
+
detail_level?: "compact" | "full";
|
|
261
|
+
file_offset?: number;
|
|
262
|
+
file_limit?: number;
|
|
263
|
+
include_evidence?: boolean;
|
|
264
|
+
include_capabilities?: boolean;
|
|
265
|
+
}
|
|
266
|
+
export interface NavigationEntrypoint {
|
|
267
|
+
method: string;
|
|
268
|
+
target: string;
|
|
269
|
+
file: string | null;
|
|
270
|
+
handler: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
292
273
|
export interface ExecutionChainNode {
|
|
293
274
|
relationship?: { kind: "imports" | "declares" | "member_of" | "calls" | "route_binding" | "schema_binding"; derivation: "source" | "inferred"; source?: { file: string; line: number; statement?: string }; reason: string };
|
|
275
|
+
parent_symbol?: string;
|
|
276
|
+
depth?: number;
|
|
294
277
|
|
|
295
278
|
stage:
|
|
296
279
|
| "ingress"
|
|
@@ -321,6 +304,7 @@ export interface ExecutionChainNode {
|
|
|
321
304
|
mutations?: string[];
|
|
322
305
|
emits?: string[];
|
|
323
306
|
dispatches?: string[];
|
|
307
|
+
semantic_analysis?: "lexical_heuristic";
|
|
324
308
|
transactions?: boolean;
|
|
325
309
|
payload_props?: string[];
|
|
326
310
|
}
|
|
@@ -345,6 +329,9 @@ export interface VerticalSliceRecord {
|
|
|
345
329
|
export interface VerticalSliceTraceResponse {
|
|
346
330
|
coverage?: "partial";
|
|
347
331
|
diagnostics?: string[];
|
|
332
|
+
next?: string[];
|
|
333
|
+
candidate_count?: number;
|
|
334
|
+
alternatives_omitted?: number;
|
|
348
335
|
query: string;
|
|
349
336
|
found: boolean;
|
|
350
337
|
confidence?: "exact" | "inferred";
|
|
@@ -367,6 +354,8 @@ export interface VerticalSliceTraceResponse {
|
|
|
367
354
|
uri: string;
|
|
368
355
|
controller: string;
|
|
369
356
|
action: string;
|
|
357
|
+
file?: string | null;
|
|
358
|
+
line?: number;
|
|
370
359
|
}>;
|
|
371
360
|
message: string;
|
|
372
361
|
}
|
|
@@ -381,6 +370,9 @@ export interface GetSymbolArgs {
|
|
|
381
370
|
include_source?: boolean;
|
|
382
371
|
source_start_line?: number;
|
|
383
372
|
source_line_limit?: number;
|
|
373
|
+
budget_bytes?: number;
|
|
374
|
+
semantic_depth?: number;
|
|
375
|
+
format?: "json" | "text";
|
|
384
376
|
workspace_path?: string;
|
|
385
377
|
}
|
|
386
378
|
|
|
@@ -431,6 +423,7 @@ export interface GetSymbolImpactArgs {
|
|
|
431
423
|
query?: string;
|
|
432
424
|
file_path?: string;
|
|
433
425
|
symbol_ref?: SymbolReference;
|
|
426
|
+
format?: "json" | "text";
|
|
434
427
|
workspace_path?: string;
|
|
435
428
|
}
|
|
436
429
|
|
|
@@ -439,6 +432,7 @@ export interface InboundCaller {
|
|
|
439
432
|
caller: string;
|
|
440
433
|
line: number;
|
|
441
434
|
kind?: string;
|
|
435
|
+
caller_kind?: string;
|
|
442
436
|
domain?: string;
|
|
443
437
|
}
|
|
444
438
|
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { SeptumDatabase } from "../../core/database/client.ts";
|
|
3
|
-
import { SeptumRepository } from "../../core/database/repository.ts";
|
|
4
|
-
import { EnvironmentDetector } from "../../core/topology/environment-detector.ts";
|
|
5
|
-
import type { EnvironmentLayer, TopologyNode } from "../../core/topology/types.ts";
|
|
6
|
-
|
|
7
|
-
const VALID_LAYERS = new Set<EnvironmentLayer>([
|
|
8
|
-
"edge",
|
|
9
|
-
"gateway",
|
|
10
|
-
"host",
|
|
11
|
-
"runtime",
|
|
12
|
-
"storage",
|
|
13
|
-
"telemetry",
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
export async function handleTopologyCommand(
|
|
17
|
-
subcommand?: string,
|
|
18
|
-
arg1?: string,
|
|
19
|
-
arg2?: string,
|
|
20
|
-
arg3?: string,
|
|
21
|
-
arg4?: string,
|
|
22
|
-
workspaceRoot?: string
|
|
23
|
-
): Promise<void> {
|
|
24
|
-
const normalizedSub = subcommand?.trim().toLowerCase();
|
|
25
|
-
|
|
26
|
-
if (normalizedSub && normalizedSub !== "resolve" && normalizedSub !== "add-node" && normalizedSub !== "remove-node" && normalizedSub !== "clear") {
|
|
27
|
-
throw new Error(`Unknown topology subcommand: '${subcommand}'. Valid subcommands: resolve, add-node, remove-node, clear.`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (normalizedSub === "resolve") {
|
|
31
|
-
if (!arg1 || !arg2) {
|
|
32
|
-
throw new Error("Missing required arguments for 'topology resolve'. Usage: septum topology resolve <layer> <platform>");
|
|
33
|
-
}
|
|
34
|
-
const layerCandidate = arg1.trim().toLowerCase() as EnvironmentLayer;
|
|
35
|
-
if (!VALID_LAYERS.has(layerCandidate)) {
|
|
36
|
-
throw new Error(`Invalid environment layer '${arg1}'. Valid layers: ${Array.from(VALID_LAYERS).join(", ")}`);
|
|
37
|
-
}
|
|
38
|
-
} else if (normalizedSub === "add-node") {
|
|
39
|
-
if (!arg1 || !arg2 || !arg3) {
|
|
40
|
-
throw new Error("Missing required arguments for 'topology add-node'. Usage: septum topology add-node <id> <layer> <platform> [domain_or_ip]");
|
|
41
|
-
}
|
|
42
|
-
const layerCandidate = arg2.trim().toLowerCase() as EnvironmentLayer;
|
|
43
|
-
if (!VALID_LAYERS.has(layerCandidate)) {
|
|
44
|
-
throw new Error(`Invalid environment layer '${arg2}'. Valid layers: ${Array.from(VALID_LAYERS).join(", ")}`);
|
|
45
|
-
}
|
|
46
|
-
} else if (normalizedSub === "remove-node") {
|
|
47
|
-
if (!arg1) {
|
|
48
|
-
throw new Error("Missing required argument for 'topology remove-node'. Usage: septum topology remove-node <id>");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const cwd = workspaceRoot || process.cwd();
|
|
53
|
-
const dbPath = workspaceRoot ? join(workspaceRoot, ".septum/septum.db") : undefined;
|
|
54
|
-
const db = new SeptumDatabase(dbPath);
|
|
55
|
-
const repo = new SeptumRepository(db.raw);
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
if (normalizedSub === "resolve" && arg1 && arg2) {
|
|
59
|
-
const layer = arg1.trim().toLowerCase() as EnvironmentLayer;
|
|
60
|
-
const platform = arg2;
|
|
61
|
-
// Fix: Preserve existing constraints instead of overwriting with empty array
|
|
62
|
-
const existing = repo.environment.getLayer(layer);
|
|
63
|
-
repo.environment.saveLayer({
|
|
64
|
-
layer,
|
|
65
|
-
platform,
|
|
66
|
-
canonical_tag: EnvironmentDetector.matchCanonicalTag(platform),
|
|
67
|
-
status: "VERIFIED",
|
|
68
|
-
detected_from: ["CLI Manual Resolution"],
|
|
69
|
-
constraints: existing?.constraints && existing.constraints.length > 0 ? existing.constraints : [
|
|
70
|
-
`Configured manually as '${platform}'.`
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
console.log(`[Septum Topology] Layer '${layer}' successfully verified as '${platform}' in SQLite SSOT.\n`);
|
|
74
|
-
} else if (normalizedSub === "add-node" && arg1 && arg2 && arg3) {
|
|
75
|
-
const nodeId = arg1;
|
|
76
|
-
const layer = arg2.trim().toLowerCase() as EnvironmentLayer;
|
|
77
|
-
const platform = arg3;
|
|
78
|
-
const domainOrIp = arg4;
|
|
79
|
-
|
|
80
|
-
const node: TopologyNode = {
|
|
81
|
-
id: nodeId,
|
|
82
|
-
layer,
|
|
83
|
-
name: nodeId,
|
|
84
|
-
platform,
|
|
85
|
-
canonical_tag: EnvironmentDetector.matchCanonicalTag(platform),
|
|
86
|
-
domain_or_ip: domainOrIp,
|
|
87
|
-
status: "VERIFIED",
|
|
88
|
-
detected_from: ["CLI Manual Node Resolution"],
|
|
89
|
-
constraints: [`Node added manually with platform '${platform}'.`],
|
|
90
|
-
};
|
|
91
|
-
repo.environment.saveNode(node);
|
|
92
|
-
console.log(`[Septum Topology] Node '${nodeId}' (${layer.toUpperCase()}) added to distributed topology graph.\n`);
|
|
93
|
-
} else if (normalizedSub === "remove-node" && arg1) {
|
|
94
|
-
repo.environment.deleteNode(arg1);
|
|
95
|
-
console.log(`[Septum Topology] Node '${arg1}' removed from distributed topology graph.\n`);
|
|
96
|
-
} else if (normalizedSub === "clear") {
|
|
97
|
-
repo.environment.clearAll();
|
|
98
|
-
console.log("[Septum Topology] Cleared environment topology and nodes in SQLite SSOT.\n");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const topology = EnvironmentDetector.detect(cwd, repo);
|
|
102
|
-
|
|
103
|
-
console.log("================================================================================");
|
|
104
|
-
console.log("🌐 SEPTUM SELF-AWARE ENVIRONMENT TOPOLOGY PLANE");
|
|
105
|
-
console.log("================================================================================");
|
|
106
|
-
console.log(`Overall Status: ${topology.overall_status}`);
|
|
107
|
-
console.log(`Topology Mode: ${topology.is_distributed ? "DISTRIBUTED MULTI-NODE GRAPH" : "MONOLITHIC SINGLE-NODE"}`);
|
|
108
|
-
console.log(`Summary: ${topology.architectural_summary}\n`);
|
|
109
|
-
|
|
110
|
-
if (topology.nodes.length > 0) {
|
|
111
|
-
console.log("--- DISTRIBUTED TOPOLOGY NODES ---");
|
|
112
|
-
for (const node of topology.nodes) {
|
|
113
|
-
const statusIcon = node.status === "VERIFIED" ? "✓ [VERIFIED]" : node.status === "DETECTED" ? "• [DETECTED]" : "? [AMBIGUOUS]";
|
|
114
|
-
const domainStr = node.domain_or_ip ? ` @ ${node.domain_or_ip}` : "";
|
|
115
|
-
const roleStr = node.role ? ` [Role: ${node.role}]` : "";
|
|
116
|
-
console.log(` ${statusIcon} ${node.id.padEnd(20)} (${node.layer.toUpperCase()}): ${node.platform}${domainStr}${roleStr}`);
|
|
117
|
-
if (node.connected_to && node.connected_to.length > 0) {
|
|
118
|
-
console.log(` ➔ Connected to: ${node.connected_to.join(", ")}`);
|
|
119
|
-
}
|
|
120
|
-
if (node.constraints && node.constraints.length > 0) {
|
|
121
|
-
for (const c of node.constraints) {
|
|
122
|
-
console.log(` - ${c}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
console.log("");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
console.log("--- 6-LAYER PRODUCTION SUMMARY PLANE ---");
|
|
130
|
-
for (const [layerKey, info] of Object.entries(topology.layers)) {
|
|
131
|
-
const statusIcon = info.status === "VERIFIED" ? "✓ [VERIFIED]" : info.status === "DETECTED" ? "• [DETECTED]" : "? [AMBIGUOUS]";
|
|
132
|
-
console.log(` ${statusIcon} ${layerKey.toUpperCase().padEnd(10)}: ${info.platform || "Unresolved"}`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (topology.interplays.length > 0) {
|
|
136
|
-
console.log("\n--- CROSS-LAYER & DISTRIBUTED INVARIANTS ---");
|
|
137
|
-
for (const interplay of topology.interplays) {
|
|
138
|
-
console.log(` ⚡ ${interplay.title} (${interplay.involved_layers.join(" ➔ ")})`);
|
|
139
|
-
console.log(` Rule: ${interplay.risk_or_rule}`);
|
|
140
|
-
console.log(` Action: ${interplay.required_action}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (topology.pending_inquiries.length > 0) {
|
|
145
|
-
console.log("\n--- PENDING ARCHITECTURAL INQUIRIES ---");
|
|
146
|
-
console.log("Action Required: Please clarify these ambiguous layers/nodes for your AI Agent:\n");
|
|
147
|
-
for (const inquiry of topology.pending_inquiries) {
|
|
148
|
-
console.log(` ❓ ${inquiry}`);
|
|
149
|
-
}
|
|
150
|
-
console.log("\nTip: To resolve an inquiry or add distributed nodes, run:");
|
|
151
|
-
console.log(" septum topology resolve <layer> \"<Platform Name>\"");
|
|
152
|
-
console.log(" septum topology add-node <id> <layer> \"<Platform Name>\" [domain_or_ip]");
|
|
153
|
-
console.log("Example:");
|
|
154
|
-
console.log(" septum topology add-node host:vps-worker host \"Ubuntu 24.04 (Dedicated Worker)\" 10.0.0.6");
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
console.log("================================================================================\n");
|
|
158
|
-
} finally {
|
|
159
|
-
db.close();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import type { Database } from "bun:sqlite";
|
|
2
|
-
import type { CanonicalPlatformTag, EnvironmentLayer, EnvironmentLayerInfo, TopologyNode } from "../../topology/types.ts";
|
|
3
|
-
|
|
4
|
-
export class EnvironmentRepository {
|
|
5
|
-
constructor(private db: Database) {}
|
|
6
|
-
|
|
7
|
-
public getLayer(layer: EnvironmentLayer): EnvironmentLayerInfo | null {
|
|
8
|
-
const row = this.db
|
|
9
|
-
.query<{
|
|
10
|
-
layer: string;
|
|
11
|
-
platform: string | null;
|
|
12
|
-
status: string;
|
|
13
|
-
detected_from_json: string;
|
|
14
|
-
constraints_json: string;
|
|
15
|
-
unresolved_inquiry: string | null;
|
|
16
|
-
}, [string]>("SELECT * FROM environment_topology WHERE layer = ?")
|
|
17
|
-
.get(layer);
|
|
18
|
-
|
|
19
|
-
if (!row) return null;
|
|
20
|
-
return {
|
|
21
|
-
layer: row.layer as EnvironmentLayer,
|
|
22
|
-
platform: row.platform ?? undefined,
|
|
23
|
-
status: row.status as any,
|
|
24
|
-
detected_from: JSON.parse(row.detected_from_json || "[]"),
|
|
25
|
-
constraints: JSON.parse(row.constraints_json || "[]"),
|
|
26
|
-
unresolved_inquiry: row.unresolved_inquiry ?? undefined,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public getAllLayers(): Record<EnvironmentLayer, EnvironmentLayerInfo> {
|
|
31
|
-
const rows = this.db
|
|
32
|
-
.query<{
|
|
33
|
-
layer: string;
|
|
34
|
-
platform: string | null;
|
|
35
|
-
status: string;
|
|
36
|
-
detected_from_json: string;
|
|
37
|
-
constraints_json: string;
|
|
38
|
-
unresolved_inquiry: string | null;
|
|
39
|
-
}, []>("SELECT * FROM environment_topology")
|
|
40
|
-
.all();
|
|
41
|
-
|
|
42
|
-
const result: Partial<Record<EnvironmentLayer, EnvironmentLayerInfo>> = {};
|
|
43
|
-
for (const row of rows) {
|
|
44
|
-
result[row.layer as EnvironmentLayer] = {
|
|
45
|
-
layer: row.layer as EnvironmentLayer,
|
|
46
|
-
platform: row.platform ?? undefined,
|
|
47
|
-
status: row.status as any,
|
|
48
|
-
detected_from: JSON.parse(row.detected_from_json || "[]"),
|
|
49
|
-
constraints: JSON.parse(row.constraints_json || "[]"),
|
|
50
|
-
unresolved_inquiry: row.unresolved_inquiry ?? undefined,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return result as Record<EnvironmentLayer, EnvironmentLayerInfo>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public saveLayer(info: EnvironmentLayerInfo): void {
|
|
57
|
-
this.db
|
|
58
|
-
.query(
|
|
59
|
-
`INSERT INTO environment_topology (
|
|
60
|
-
layer, platform, status, detected_from_json, constraints_json, unresolved_inquiry, updated_at
|
|
61
|
-
) VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
|
62
|
-
ON CONFLICT(layer) DO UPDATE SET
|
|
63
|
-
platform = excluded.platform,
|
|
64
|
-
status = excluded.status,
|
|
65
|
-
detected_from_json = excluded.detected_from_json,
|
|
66
|
-
constraints_json = excluded.constraints_json,
|
|
67
|
-
unresolved_inquiry = excluded.unresolved_inquiry,
|
|
68
|
-
updated_at = CURRENT_TIMESTAMP`
|
|
69
|
-
)
|
|
70
|
-
.run(
|
|
71
|
-
info.layer,
|
|
72
|
-
info.platform ?? null,
|
|
73
|
-
info.status,
|
|
74
|
-
JSON.stringify(info.detected_from ?? []),
|
|
75
|
-
JSON.stringify(info.constraints ?? []),
|
|
76
|
-
info.unresolved_inquiry ?? null
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public clearAll(): void {
|
|
81
|
-
this.db.run("DELETE FROM environment_topology");
|
|
82
|
-
this.db.run("DELETE FROM environment_nodes");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Node CRUD operations for Multi-Node Topology
|
|
86
|
-
public getNode(id: string): TopologyNode | null {
|
|
87
|
-
const row = this.db
|
|
88
|
-
.query<{
|
|
89
|
-
id: string;
|
|
90
|
-
layer: string;
|
|
91
|
-
name: string;
|
|
92
|
-
platform: string;
|
|
93
|
-
canonical_tag: string;
|
|
94
|
-
domain_or_ip: string | null;
|
|
95
|
-
role: string | null;
|
|
96
|
-
status: string;
|
|
97
|
-
detected_from_json: string;
|
|
98
|
-
constraints_json: string;
|
|
99
|
-
connected_to_json: string;
|
|
100
|
-
unresolved_inquiry: string | null;
|
|
101
|
-
}, [string]>("SELECT * FROM environment_nodes WHERE id = ?")
|
|
102
|
-
.get(id);
|
|
103
|
-
|
|
104
|
-
if (!row) return null;
|
|
105
|
-
return this.mapNodeRow(row);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public getAllNodes(): TopologyNode[] {
|
|
109
|
-
const rows = this.db
|
|
110
|
-
.query<{
|
|
111
|
-
id: string;
|
|
112
|
-
layer: string;
|
|
113
|
-
name: string;
|
|
114
|
-
platform: string;
|
|
115
|
-
canonical_tag: string;
|
|
116
|
-
domain_or_ip: string | null;
|
|
117
|
-
role: string | null;
|
|
118
|
-
status: string;
|
|
119
|
-
detected_from_json: string;
|
|
120
|
-
constraints_json: string;
|
|
121
|
-
connected_to_json: string;
|
|
122
|
-
unresolved_inquiry: string | null;
|
|
123
|
-
}, []>("SELECT * FROM environment_nodes ORDER BY layer, id")
|
|
124
|
-
.all();
|
|
125
|
-
|
|
126
|
-
return rows.map((r) => this.mapNodeRow(r));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public getNodesByLayer(layer: EnvironmentLayer): TopologyNode[] {
|
|
130
|
-
const rows = this.db
|
|
131
|
-
.query<{
|
|
132
|
-
id: string;
|
|
133
|
-
layer: string;
|
|
134
|
-
name: string;
|
|
135
|
-
platform: string;
|
|
136
|
-
canonical_tag: string;
|
|
137
|
-
domain_or_ip: string | null;
|
|
138
|
-
role: string | null;
|
|
139
|
-
status: string;
|
|
140
|
-
detected_from_json: string;
|
|
141
|
-
constraints_json: string;
|
|
142
|
-
connected_to_json: string;
|
|
143
|
-
unresolved_inquiry: string | null;
|
|
144
|
-
}, [string]>("SELECT * FROM environment_nodes WHERE layer = ? ORDER BY id")
|
|
145
|
-
.all(layer);
|
|
146
|
-
|
|
147
|
-
return rows.map((r) => this.mapNodeRow(r));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public saveNode(node: TopologyNode): void {
|
|
151
|
-
this.db
|
|
152
|
-
.query(
|
|
153
|
-
`INSERT INTO environment_nodes (
|
|
154
|
-
id, layer, name, platform, canonical_tag, domain_or_ip, role, status,
|
|
155
|
-
detected_from_json, constraints_json, connected_to_json, unresolved_inquiry, updated_at
|
|
156
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
|
157
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
158
|
-
layer = excluded.layer,
|
|
159
|
-
name = excluded.name,
|
|
160
|
-
platform = excluded.platform,
|
|
161
|
-
canonical_tag = excluded.canonical_tag,
|
|
162
|
-
domain_or_ip = excluded.domain_or_ip,
|
|
163
|
-
role = excluded.role,
|
|
164
|
-
status = excluded.status,
|
|
165
|
-
detected_from_json = excluded.detected_from_json,
|
|
166
|
-
constraints_json = excluded.constraints_json,
|
|
167
|
-
connected_to_json = excluded.connected_to_json,
|
|
168
|
-
unresolved_inquiry = excluded.unresolved_inquiry,
|
|
169
|
-
updated_at = CURRENT_TIMESTAMP`
|
|
170
|
-
)
|
|
171
|
-
.run(
|
|
172
|
-
node.id,
|
|
173
|
-
node.layer,
|
|
174
|
-
node.name,
|
|
175
|
-
node.platform,
|
|
176
|
-
node.canonical_tag || "unspecified",
|
|
177
|
-
node.domain_or_ip ?? null,
|
|
178
|
-
node.role ?? null,
|
|
179
|
-
node.status,
|
|
180
|
-
JSON.stringify(node.detected_from ?? []),
|
|
181
|
-
JSON.stringify(node.constraints ?? []),
|
|
182
|
-
JSON.stringify(node.connected_to ?? []),
|
|
183
|
-
node.unresolved_inquiry ?? null
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public deleteNode(id: string): void {
|
|
188
|
-
this.db.query("DELETE FROM environment_nodes WHERE id = ?").run(id);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private mapNodeRow(row: any): TopologyNode {
|
|
192
|
-
return {
|
|
193
|
-
id: row.id,
|
|
194
|
-
layer: row.layer as EnvironmentLayer,
|
|
195
|
-
name: row.name,
|
|
196
|
-
platform: row.platform,
|
|
197
|
-
canonical_tag: (row.canonical_tag as CanonicalPlatformTag) || "unspecified",
|
|
198
|
-
domain_or_ip: row.domain_or_ip ?? undefined,
|
|
199
|
-
role: row.role ?? undefined,
|
|
200
|
-
status: row.status as any,
|
|
201
|
-
detected_from: JSON.parse(row.detected_from_json || "[]"),
|
|
202
|
-
constraints: JSON.parse(row.constraints_json || "[]"),
|
|
203
|
-
connected_to: JSON.parse(row.connected_to_json || "[]"),
|
|
204
|
-
unresolved_inquiry: row.unresolved_inquiry ?? undefined,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { readOptionalSourceFile } from "../../../resources/source-files.ts";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import type {
|
|
5
|
-
SchemaFieldSummary,
|
|
6
|
-
SchemaMetadata,
|
|
7
|
-
StackSchemaProvider,
|
|
8
|
-
} from "../schema-provider.interface.ts";
|
|
9
|
-
|
|
10
|
-
export class PrismaSchemaProvider implements StackSchemaProvider {
|
|
11
|
-
public readonly id = "prisma";
|
|
12
|
-
public readonly name = "Prisma Schema Provider";
|
|
13
|
-
|
|
14
|
-
public canHandle(projectRoot: string): boolean {
|
|
15
|
-
return (
|
|
16
|
-
fs.existsSync(path.join(projectRoot, "prisma", "schema.prisma")) ||
|
|
17
|
-
fs.existsSync(path.join(projectRoot, "schema.prisma"))
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public resolveEntitySchema(
|
|
22
|
-
projectRoot: string,
|
|
23
|
-
entitySymbol: string,
|
|
24
|
-
_entityFilePath?: string
|
|
25
|
-
): SchemaMetadata | null {
|
|
26
|
-
const candidatePaths = [
|
|
27
|
-
path.join(projectRoot, "prisma", "schema.prisma"),
|
|
28
|
-
path.join(projectRoot, "schema.prisma"),
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
let schemaPath: string | null = null;
|
|
32
|
-
for (const p of candidatePaths) {
|
|
33
|
-
if (fs.existsSync(p)) {
|
|
34
|
-
schemaPath = p;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!schemaPath) return null;
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const content = readOptionalSourceFile(schemaPath, "utf-8");
|
|
43
|
-
const modelRegex = new RegExp(`model\\s+${entitySymbol}\\s*\\{([^}]+)\\}`, "m");
|
|
44
|
-
const match = modelRegex.exec(content);
|
|
45
|
-
if (!match) return null;
|
|
46
|
-
|
|
47
|
-
const body = match[1];
|
|
48
|
-
const lines = body.split("\n");
|
|
49
|
-
const fields: SchemaFieldSummary[] = [];
|
|
50
|
-
|
|
51
|
-
for (const rawLine of lines) {
|
|
52
|
-
const line = rawLine.trim();
|
|
53
|
-
if (!line || line.startsWith("//") || line.startsWith("@@")) continue;
|
|
54
|
-
|
|
55
|
-
// Pattern: fieldName FieldType attributes...
|
|
56
|
-
const parts = line.split(/\s+/);
|
|
57
|
-
if (parts.length >= 2) {
|
|
58
|
-
const name = parts[0];
|
|
59
|
-
let type = parts[1];
|
|
60
|
-
const nullable = type.endsWith("?");
|
|
61
|
-
if (nullable) {
|
|
62
|
-
type = type.slice(0, -1);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const isPrimary = line.includes("@id");
|
|
66
|
-
const isForeign = line.includes("@relation");
|
|
67
|
-
|
|
68
|
-
fields.push({
|
|
69
|
-
name,
|
|
70
|
-
type,
|
|
71
|
-
nullable: nullable || undefined,
|
|
72
|
-
isPrimary: isPrimary || undefined,
|
|
73
|
-
isForeign: isForeign || undefined,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (fields.length === 0) return null;
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
entityName: entitySymbol,
|
|
82
|
-
tableName: entitySymbol.toLowerCase(),
|
|
83
|
-
schemaSourceFile: path.relative(projectRoot, schemaPath),
|
|
84
|
-
fields,
|
|
85
|
-
};
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|