@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,107 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import type { SeptumRepository } from "../database/repository.ts";
|
|
5
|
-
import type { ActiveFeatureSession } from "../../types/index.ts";
|
|
6
|
-
import { SeptumDatabase } from "../database/client.ts";
|
|
7
|
-
|
|
8
|
-
export class SessionManager {
|
|
9
|
-
private static readonly SESSION_FILE = ".septum/session.json";
|
|
10
|
-
|
|
11
|
-
public static getOwnerId(): string {
|
|
12
|
-
return process.env.SEPTUM_SESSION_ID || `process:${process.pid}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public static isOwnerAlive(ownerId?: string): boolean {
|
|
16
|
-
if (!ownerId) return false;
|
|
17
|
-
const match = ownerId.match(/^process:(\d+)$/);
|
|
18
|
-
if (!match) {
|
|
19
|
-
// If it's a custom SEPTUM_SESSION_ID or UUID, we cannot inspect OS PID; treat as active.
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
const pid = parseInt(match[1], 10);
|
|
23
|
-
try {
|
|
24
|
-
process.kill(pid, 0);
|
|
25
|
-
return true;
|
|
26
|
-
} catch (error: any) {
|
|
27
|
-
return error?.code === "EPERM";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private static mutate<T>(workspaceRoot: string, fn: () => T, repo?: SeptumRepository): T {
|
|
32
|
-
if (repo) return repo.runInTransaction(fn, true);
|
|
33
|
-
const db = new SeptumDatabase(join(workspaceRoot, ".septum/septum.db"));
|
|
34
|
-
try {
|
|
35
|
-
// Serialize ownership checks with writes across CLI and MCP processes.
|
|
36
|
-
return db.raw.transaction(fn).immediate();
|
|
37
|
-
} finally {
|
|
38
|
-
db.close();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public static saveActiveSession(
|
|
43
|
-
workspaceRoot: string,
|
|
44
|
-
session: ActiveFeatureSession,
|
|
45
|
-
ownerId: string = SessionManager.getOwnerId(),
|
|
46
|
-
persistence?: { repo: SeptumRepository; save: () => void }
|
|
47
|
-
): void {
|
|
48
|
-
SessionManager.mutate(workspaceRoot, () => {
|
|
49
|
-
const current = SessionManager.getActiveSession(workspaceRoot);
|
|
50
|
-
if (current && current.owner_id !== ownerId) {
|
|
51
|
-
if (SessionManager.isOwnerAlive(current.owner_id)) {
|
|
52
|
-
throw new Error(`Workspace already has an active feature session owned by '${current.owner_id || "legacy-session"}'. Release it with its owner, or explicitly run 'septum feature clear --force'.`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const septumDir = join(workspaceRoot, ".septum");
|
|
56
|
-
mkdirSync(septumDir, { recursive: true });
|
|
57
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
58
|
-
const temporaryPath = `${sessionPath}.${randomUUID()}.tmp`;
|
|
59
|
-
try {
|
|
60
|
-
writeFileSync(temporaryPath, JSON.stringify({ ...session, owner_id: ownerId }, null, 2), "utf-8");
|
|
61
|
-
// Metadata and ownership use one write lock; a failed rename rolls back SQLite.
|
|
62
|
-
persistence?.save();
|
|
63
|
-
renameSync(temporaryPath, sessionPath);
|
|
64
|
-
} finally {
|
|
65
|
-
rmSync(temporaryPath, { force: true });
|
|
66
|
-
}
|
|
67
|
-
}, persistence?.repo);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public static getActiveSession(workspaceRoot: string): ActiveFeatureSession | null {
|
|
71
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
72
|
-
if (!existsSync(sessionPath)) return null;
|
|
73
|
-
let parsed: any;
|
|
74
|
-
try {
|
|
75
|
-
parsed = JSON.parse(readFileSync(sessionPath, "utf-8")) as ActiveFeatureSession;
|
|
76
|
-
} catch (e: any) {
|
|
77
|
-
throw new Error(`Corrupted active feature session JSON in '${sessionPath}': ${e.message}. Release it explicitly with 'septum feature clear --force' or 'septum_feature({action: "release", force: true})'.`);
|
|
78
|
-
}
|
|
79
|
-
if (parsed && typeof parsed.feature_key === "string" && parsed.feature_key.trim() &&
|
|
80
|
-
typeof parsed.domain === "string" && parsed.domain.trim() &&
|
|
81
|
-
Array.isArray(parsed.touchpoints) && parsed.touchpoints.every((tp: unknown) => typeof tp === "string") &&
|
|
82
|
-
(parsed.owner_id === undefined || typeof parsed.owner_id === "string")) return parsed;
|
|
83
|
-
throw new Error(`Invalid active feature session in '${sessionPath}'. Release it explicitly with 'septum feature clear --force'.`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public static clearActiveSession(
|
|
87
|
-
workspaceRoot: string,
|
|
88
|
-
ownerId: string = SessionManager.getOwnerId(),
|
|
89
|
-
force: boolean = false
|
|
90
|
-
): boolean {
|
|
91
|
-
if (!existsSync(join(workspaceRoot, SessionManager.SESSION_FILE))) return false;
|
|
92
|
-
return SessionManager.mutate(workspaceRoot, () => {
|
|
93
|
-
const sessionPath = join(workspaceRoot, SessionManager.SESSION_FILE);
|
|
94
|
-
if (!existsSync(sessionPath)) return false;
|
|
95
|
-
if (!force) {
|
|
96
|
-
const current = SessionManager.getActiveSession(workspaceRoot);
|
|
97
|
-
if (current?.owner_id && current.owner_id !== ownerId) {
|
|
98
|
-
if (SessionManager.isOwnerAlive(current.owner_id)) {
|
|
99
|
-
throw new Error("Only the active session owner can release it. Use 'septum feature clear --force' for explicit recovery.");
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
rmSync(sessionPath, { force: true });
|
|
104
|
-
return true;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|