@dimassetoid/septum-mcp 0.3.0 → 0.5.1
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 +38 -55
- package/package.json +7 -5
- package/src/cli/commands/check.ts +14 -10
- package/src/cli/commands/hook.ts +41 -6
- package/src/cli/commands/init.ts +10 -1
- package/src/cli/commands/stats.ts +33 -0
- package/src/cli/commands/sync-progress.ts +71 -0
- package/src/cli/commands/sync.ts +32 -4
- package/src/cli/index.ts +7 -0
- package/src/cli/templates/hooks.ts +3 -14
- package/src/cli/templates/skill.ts +17 -10
- package/src/core/boundary/audit.ts +383 -0
- package/src/core/boundary/evaluator.ts +251 -114
- package/src/core/boundary/staged-auditor.ts +147 -55
- package/src/core/config/domain-ownership.ts +6 -4
- package/src/core/config/domain-registration.ts +141 -0
- package/src/core/config/loader.ts +1 -25
- package/src/core/config/schema.ts +24 -36
- package/src/core/database/client.ts +2 -0
- package/src/core/database/repositories/dependency.repository.ts +334 -572
- package/src/core/database/repositories/domain.repository.ts +2 -1
- package/src/core/database/repositories/file.repository.ts +10 -0
- package/src/core/database/repositories/symbol.repository.ts +97 -398
- package/src/core/database/repository.ts +68 -9
- package/src/core/database/schema.ts +26 -0
- package/src/core/discovery/declarative-routes.ts +69 -0
- package/src/core/discovery/framework-detector.ts +149 -0
- package/src/core/discovery/navigation.ts +222 -58
- package/src/core/discovery/topology-detector.ts +93 -168
- package/src/core/errors.ts +19 -0
- package/src/core/ingestion/pipeline.ts +287 -88
- package/src/core/parser/extractors/base.ts +11 -3
- package/src/core/parser/extractors/csharp.ts +2 -2
- package/src/core/parser/extractors/django-routing.ts +163 -0
- package/src/core/parser/extractors/django-semantic.ts +397 -481
- package/src/core/parser/extractors/elysia-semantic.ts +172 -475
- package/src/core/parser/extractors/express-semantic.ts +195 -383
- package/src/core/parser/extractors/fastapi-semantic.ts +178 -361
- package/src/core/parser/extractors/fastify-semantic.ts +216 -717
- package/src/core/parser/extractors/flask-semantic.ts +89 -352
- package/src/core/parser/extractors/go-routing.ts +344 -0
- package/src/core/parser/extractors/go-semantic.ts +205 -562
- 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 -509
- package/src/core/parser/extractors/java.ts +2 -2
- package/src/core/parser/extractors/laravel-routing.ts +263 -0
- package/src/core/parser/extractors/laravel-semantic.ts +143 -335
- 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 +82 -333
- package/src/core/parser/extractors/nestjs-semantic.ts +238 -494
- 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 +1 -1
- package/src/core/parser/extractors/python-route-ast.ts +249 -0
- package/src/core/parser/extractors/python.ts +5 -9
- package/src/core/parser/extractors/registry.ts +2 -0
- package/src/core/parser/extractors/route-prefixes.ts +43 -0
- package/src/core/parser/extractors/ruby.ts +2 -2
- package/src/core/parser/extractors/rust.ts +4 -4
- package/src/core/parser/extractors/symfony-routing.ts +114 -0
- package/src/core/parser/extractors/symfony-semantic.ts +72 -226
- 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 +23 -216
- package/src/core/parser/language-capabilities.ts +1 -1
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +4 -1
- 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 +169 -414
- 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 +60 -7
- package/src/core/resolver/interpretation-inputs.ts +60 -2
- package/src/core/resolver/languages/python.ts +31 -13
- package/src/core/resolver/languages/shared.ts +4 -1
- package/src/core/resolver/module-resolver.ts +10 -3
- 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 +21 -6
- package/src/core/resolver/slice-format.ts +13 -0
- package/src/core/resolver/slice-selection.ts +237 -0
- package/src/core/resolver/symbol-impact.ts +104 -8
- package/src/core/resolver/symbol-locator.ts +82 -15
- package/src/core/resolver/vertical-slice-tracer.ts +31 -230
- package/src/core/resources/ignore.ts +0 -1
- package/src/core/resources/limits.ts +2 -1
- package/src/core/resources/work-queue.ts +167 -4
- package/src/core/retrieval/context-page.ts +11 -4
- package/src/core/retrieval/context.ts +363 -226
- package/src/{mcp/tools/get-symbol.ts → core/retrieval/source-context.ts} +145 -96
- package/src/core/retrieval/symbol-details.ts +453 -0
- package/src/core/retrieval/symbol-evidence.ts +3 -3
- package/src/core/retrieval/typescript-references.ts +38 -7
- package/src/core/retrieval/universal-context.ts +182 -0
- package/src/core/telemetry/summary.ts +114 -0
- package/src/core/telemetry/telemetry.ts +192 -49
- package/src/mcp/formatters/compact-text.ts +439 -0
- package/src/mcp/resources-and-prompts.ts +255 -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 -746
- package/src/mcp/server.ts +269 -429
- package/src/mcp/tool-catalog.ts +331 -0
- package/src/mcp/tools/boundary.ts +68 -3
- package/src/mcp/tools/map.ts +104 -4
- package/src/mcp/tools/slice.ts +101 -3
- package/src/mcp/tools/symbol.ts +469 -17
- 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 +88 -15
- package/src/mcp/workspace-watcher.ts +30 -11
- package/src/types/index.ts +12 -0
- package/src/mcp/tools/check-boundary.ts +0 -382
- package/src/mcp/tools/get-domain-catalog.ts +0 -39
- package/src/mcp/tools/get-symbol-impact.ts +0 -104
- package/src/mcp/tools/locate-symbol.ts +0 -236
- package/src/mcp/tools/register-domain.ts +0 -113
- package/src/mcp/tools/trace-vertical-slice.ts +0 -106
package/README.md
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
# Septum
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Local codebase intelligence and architecture boundary guard for AI coding agents.**
|
|
4
4
|
|
|
5
|
-
[](package.json)
|
|
6
6
|
[](https://bun.sh)
|
|
7
7
|
[](https://modelcontextprotocol.io/)
|
|
8
8
|
[-003B57?logo=sqlite)](https://sqlite.org/)
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
|
|
11
|
-
Septum
|
|
11
|
+
Septum is a local static-analysis MCP server and CLI that keeps AI coding agents oriented and within architectural boundaries. Instead of reading entire files or guessing module rules, agents query a local SQLite AST index (`.septum/septum.db`) for compact domain maps, budget-bounded symbol context, static flow slices, and deterministic import/boundary checks before and after edits.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What It Does
|
|
16
|
+
|
|
17
|
+
- **Domain Map & Discovery (`septum_map`):** Provides a compact navigation catalog of domains, file import relationships, static entrypoints, and index health—and lets you register or update allowed/forbidden domain dependencies.
|
|
18
|
+
- **Bounded Symbol Context & Impact (`septum_symbol`):** Locates declarations across the codebase, retrieves bounded implementation context (deep TypeScript reference context within `budget_bytes`, or bounded polyglot source inspection), and reports static dependents and caller hints.
|
|
19
|
+
- **Static Flow Tracing (`septum_slice`):** Traces static relationship chains from supported application entrypoints (`query`, `controller_file`, `max_depth`) across layers, showing relationship evidence or `unknown` for each node.
|
|
20
|
+
- **Architecture Boundary Guard (`septum_boundary`):** Validates proposed file imports against domain rules before writing (`scope: "file"`), checks staged Git changes before commit (`scope: "staged"`), and audits circular or cross-domain violations (`scope: "domain"`, `scope: "all"`).
|
|
21
|
+
|
|
22
|
+
### Language Support & Analysis Scope
|
|
23
|
+
|
|
24
|
+
- **AST & Declarations (`web-tree-sitter` + TypeScript compiler fallback):** Partial declaration extraction for TypeScript, JavaScript, PHP, Python, Go, Rust, Java, C#, Ruby, Blade, and embedded scripts in Vue, Astro, and Svelte. TypeScript and TSX files automatically fall back to the TypeScript compiler parser when `tree-sitter-wasms` hits syntax recovery on newer syntax. Deep context (`context_mode: "deep"`) targets `.ts`, `.tsx`, `.mts`, and `.cts` files.
|
|
25
|
+
- **Entrypoint Adapters:** Selected patterns in Laravel, Symfony, MCP/CLI, NestJS, Express, Fastify, Hono, Elysia, Next.js App Router, FastAPI, Django, Flask, and Go.
|
|
26
|
+
- **Import Resolution:** Supported patterns across JS/TS, PHP, Python manifests/lockfiles, Go workspaces/replacements, Rust Cargo/modules, Ruby literal requires/gems, Java source projects, and C# namespaces/project references.
|
|
27
|
+
|
|
28
|
+
> **Static Analysis Scope:** Septum evaluates source files and dependency policies statically—it does not execute the target application or establish complete runtime call graphs. Application behavior still requires application tests. See [implemented features](docs/feature/README.md) and [import resolution](docs/feature/import-resolution.md) for full tool contracts and known limits.
|
|
14
29
|
|
|
15
30
|
---
|
|
16
31
|
|
|
@@ -18,7 +33,7 @@ Start with the [implemented feature documentation](docs/feature/README.md), whic
|
|
|
18
33
|
|
|
19
34
|
### Option 1: Standalone Binary
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
Precompiled executables bundle the runtime:
|
|
22
37
|
|
|
23
38
|
**Linux & macOS:**
|
|
24
39
|
```bash
|
|
@@ -30,7 +45,7 @@ curl -fsSL https://raw.githubusercontent.com/Shironim/septum-mcp/master/install.
|
|
|
30
45
|
irm https://raw.githubusercontent.com/Shironim/septum-mcp/master/install.ps1 | iex
|
|
31
46
|
```
|
|
32
47
|
|
|
33
|
-
> **Manual Downloads:**
|
|
48
|
+
> **Manual Downloads:** Binaries are also available on [GitHub Releases](https://github.com/Shironim/septum-mcp/releases) for `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`, and `windows-x64.exe`.
|
|
34
49
|
|
|
35
50
|
### Option 2: Via Bun
|
|
36
51
|
|
|
@@ -40,7 +55,7 @@ If you already use [Bun](https://bun.sh):
|
|
|
40
55
|
bun add -g @dimassetoid/septum-mcp
|
|
41
56
|
```
|
|
42
57
|
|
|
43
|
-
You can invoke
|
|
58
|
+
You can also invoke it directly with `bunx @dimassetoid/septum-mcp <command>`.
|
|
44
59
|
|
|
45
60
|
---
|
|
46
61
|
|
|
@@ -48,7 +63,7 @@ You can invoke the package with `bunx @dimassetoid/septum-mcp <command>`.
|
|
|
48
63
|
|
|
49
64
|
### 1. Initialize a Workspace
|
|
50
65
|
|
|
51
|
-
Run `septum init`
|
|
66
|
+
Run `septum init` in your project root:
|
|
52
67
|
|
|
53
68
|
```bash
|
|
54
69
|
septum init
|
|
@@ -56,26 +71,20 @@ septum init
|
|
|
56
71
|
bunx @dimassetoid/septum-mcp init
|
|
57
72
|
```
|
|
58
73
|
|
|
59
|
-
Initialization:
|
|
74
|
+
Initialization performs three steps:
|
|
60
75
|
|
|
61
|
-
1. **Infers Project Structure:** Uses supported manifests and directory layouts to propose
|
|
62
|
-
2. **Indexes Supported Source:**
|
|
63
|
-
3. **Scaffolds
|
|
76
|
+
1. **Infers Project Structure:** Uses supported manifests and directory layouts to propose domain boundaries and dependency policies.
|
|
77
|
+
2. **Indexes Supported Source:** Extracts declarations, imports, and static entrypoints into `.septum/septum.db`.
|
|
78
|
+
3. **Scaffolds Agent Integrations:** Writes MCP configs, skills, and hook artifacts for supported clients:
|
|
64
79
|
- **Antigravity** (`.gemini/`)
|
|
65
80
|
- **Claude Code** (`.claude/`, `.mcp.json`, `CLAUDE.md`)
|
|
66
81
|
- **Codex** (`.codex/`)
|
|
67
82
|
- **Opencode** (`opencode/`, `opencode.json`)
|
|
68
83
|
- **.agents Standard** (`.agents/`, `AGENTS.md`)
|
|
69
84
|
|
|
70
|
-
Semantic adapters cover selected patterns in Laravel, Symfony, MCP/CLI, NestJS, Express, Fastify, Hono, Elysia, FastAPI, Django, Flask and Go. Their applicability and extraction results depend on repository syntax and configuration.
|
|
71
|
-
|
|
72
|
-
Import resolution includes supported Python manifests/lockfiles, Go workspaces/replacements, Rust Cargo/modules, Ruby literal requires/gems, Java source projects and C# namespaces/project references. See [import resolution](docs/feature/import-resolution.md) for supported cases and unresolved boundaries.
|
|
73
|
-
|
|
74
|
-
Detection and scaffolding do not certify every framework pattern or active client hook. See the [feature specifications and architecture contracts](docs/feature/README.md) for full scope and technical details.
|
|
75
|
-
|
|
76
85
|
### 2. Manual MCP Client Configuration (Optional)
|
|
77
86
|
|
|
78
|
-
If your MCP client is not configured via `septum init`, add Septum to
|
|
87
|
+
If your MCP client is not configured via `septum init`, add Septum to `.mcp.json` or `claude_desktop_config.json`:
|
|
79
88
|
|
|
80
89
|
```json
|
|
81
90
|
{
|
|
@@ -87,7 +96,7 @@ If your MCP client is not configured via `septum init`, add Septum to your MCP c
|
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
```
|
|
90
|
-
*(Or use `"command": "bunx", "args": ["@dimassetoid/septum-mcp", "serve"]` when invoking
|
|
99
|
+
*(Or use `"command": "bunx", "args": ["@dimassetoid/septum-mcp", "serve"]` when invoking through Bun.)*
|
|
91
100
|
|
|
92
101
|
---
|
|
93
102
|
|
|
@@ -95,49 +104,23 @@ If your MCP client is not configured via `septum init`, add Septum to your MCP c
|
|
|
95
104
|
|
|
96
105
|
| Command | Description |
|
|
97
106
|
|---|---|
|
|
98
|
-
| `septum init [--force]` | Scaffold agent integrations and build initial symbol catalog. `--force` regenerates Septum-managed configs while preserving existing database and user git hooks |
|
|
99
|
-
| `septum sync [--json]` | Synchronize AST and update symbol catalog
|
|
107
|
+
| `septum init [--force]` | Scaffold agent integrations and build the initial symbol catalog. `--force` regenerates Septum-managed configs while preserving the existing database and user git hooks |
|
|
108
|
+
| `septum sync [--json]` | Synchronize AST and update the symbol catalog in `.septum/septum.db` (full or incremental) |
|
|
100
109
|
| `septum check [--strict] [--staged] [--json]` | Verify boundary rules and detect cross-domain or circular dependency violations |
|
|
101
|
-
| `septum
|
|
102
|
-
| `septum
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## MCP Tools
|
|
107
|
-
|
|
108
|
-
All tools provide structured schemas via the Model Context Protocol:
|
|
109
|
-
|
|
110
|
-
- **Domain Map & Discovery (`septum_map`):**
|
|
111
|
-
- `action: "catalog"`: Navigation map (`navigation/v1`): domain/file import paths, static entrypoints, health and targeted next steps. `full` expands navigation; inspect signatures and source with `septum_symbol`.
|
|
112
|
-
- `action: "register"`: Register or update domain boundaries with allowed and forbidden dependencies.
|
|
113
|
-
- **Symbol Inspection & Impact Analysis (`septum_symbol`):**
|
|
114
|
-
- `action: "locate"`: Search and find symbols across the codebase.
|
|
115
|
-
- `action: "context"` (accepts `action: "inspect"` as alias): Retrieve declaration implementation and supporting declarations (deep TypeScript context retrieval within `budget_bytes`, or bounded polyglot source inspection).
|
|
116
|
-
- `action: "impact"`: Inspect static dependent/caller hints. Imports are reported separately and do not prove executed calls or a complete runtime blast radius.
|
|
117
|
-
- **Execution Flow Tracer (`septum_slice`):**
|
|
118
|
-
- Navigate static context across application layers from supported entrypoints (`query`, `controller_file`, `max_depth`). Each node shows its relationship evidence or `unknown`.
|
|
119
|
-
- **Dependency & Boundary Validator (`septum_boundary`):**
|
|
120
|
-
- Validate proposed file imports against defined architectural rules (`scope: "file"`).
|
|
121
|
-
- Check staged files in the Git index before commit (`scope: "staged"`).
|
|
122
|
-
- Audit circular dependencies and boundary violations for a specific domain (`scope: "domain"`) or the entire codebase (`scope: "all"`).
|
|
110
|
+
| `septum stats [workspace] [--json]` | Summarize recent MCP tool calls, error rates, and latency/size percentiles from `.septum/septum.log` |
|
|
111
|
+
| `septum hook pre-write` | Reconstruct supported candidate edits from stdin and evaluate their imports (interception depends on client hook configuration) |
|
|
112
|
+
| `septum serve` | Start the stdio Model Context Protocol (MCP) server |
|
|
123
113
|
|
|
124
114
|
---
|
|
125
115
|
|
|
126
|
-
##
|
|
127
|
-
|
|
128
|
-
Locate a declaration, select its returned `symbol_ref` when names are ambiguous, then request context:
|
|
116
|
+
## Documentation
|
|
129
117
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Send these arguments to `septum_symbol` with an explicit `workspace_path` when needed. Context v4 supports `.ts/.mts/.cts` and selects supporting declarations through bounded local/import bindings. Set `context_mode: "deep"` explicitly for this policy, or `context_mode: "source"` for bounded source inspection. Omission preserves legacy automatic selection; responses identify the selected mode. TSX and complete business dependency closure are outside the deep-context policy.
|
|
135
|
-
|
|
136
|
-
Read evidence scope, freshness and omissions before editing. Context inspection returns source/contracts; lookup and server freshness guards can synchronize the local index. Use impact for potential consumers and application checks for behavior. Budget, paging, source identity and recovery semantics have one owner: the [symbol context contract](docs/feature/symbol-context-contract.md). Per-action requirements are in [septum_symbol](docs/feature/septum-symbol.md).
|
|
118
|
+
- [Implemented Features & Limits](docs/feature/README.md) — Tool behaviors, language coverage, and verification scope
|
|
119
|
+
- [Symbol Context Contract](docs/feature/symbol-context-contract.md) — Deep context selection, byte budgets, and pagination
|
|
120
|
+
- [Import Resolution](docs/feature/import-resolution.md) — Supported static targets and unresolved boundaries
|
|
137
121
|
|
|
138
122
|
---
|
|
139
123
|
|
|
140
124
|
## License
|
|
141
125
|
|
|
142
126
|
[MIT](LICENSE) © shironim
|
|
143
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimassetoid/septum-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Deterministic Bounded-Context, Structural File Catalog & Anti-Poisoning Partition for AI Agents",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,19 +21,21 @@
|
|
|
21
21
|
"sync": "bun run bin/septum.ts sync",
|
|
22
22
|
"check": "bun run bin/septum.ts check",
|
|
23
23
|
"test": "bun test",
|
|
24
|
-
"build": "bun
|
|
24
|
+
"build:ui": "bun run scripts/build-mcp-app.ts",
|
|
25
|
+
"build": "bun run build:ui && bun build ./bin/septum.ts --compile --outfile dist/septum",
|
|
25
26
|
"compile:all": "bun run scripts/compile.ts",
|
|
26
27
|
"typecheck": "tsc --noEmit",
|
|
27
28
|
"test:integration": "python3 tests/integration/mcp-reliability.py",
|
|
28
29
|
"postinstall": "bun run scripts/postinstall.ts || true"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/ext-apps": "^2.0.4",
|
|
31
33
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
34
|
+
"tree-sitter-wasms": "^0.1.13",
|
|
35
|
+
"typescript": "^5.7.3",
|
|
32
36
|
"web-tree-sitter": "^0.24.0",
|
|
33
37
|
"yaml": "^2.7.0",
|
|
34
|
-
"zod": "^3.24.2"
|
|
35
|
-
"tree-sitter-wasms": "^0.1.13",
|
|
36
|
-
"typescript": "^5.7.3"
|
|
38
|
+
"zod": "^3.24.2"
|
|
37
39
|
},
|
|
38
40
|
"license": "MIT",
|
|
39
41
|
"repository": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { evaluateBoundary } from "../../core/boundary/audit.ts";
|
|
1
2
|
import { BoundaryEvaluator } from "../../core/boundary/evaluator.ts";
|
|
2
3
|
import { ConfigLoader, resolveDatabasePath } from "../../core/config/loader.ts";
|
|
3
4
|
import { SeptumDatabase } from "../../core/database/client.ts";
|
|
@@ -66,18 +67,21 @@ export async function handleCheckCommand(
|
|
|
66
67
|
}
|
|
67
68
|
} else {
|
|
68
69
|
await new IngestionPipeline(repo, workspaceRoot).run(config, { verifyContent: true });
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
throw new Error(`Cannot complete boundary audit: unsupported source files: ${
|
|
70
|
+
const { payload } = await evaluateBoundary(evaluator, config, { scope: "all" }, repo, workspaceRoot);
|
|
71
|
+
if ("unsupported_files" in payload) {
|
|
72
|
+
throw new Error(`Cannot complete boundary audit: unsupported source files: ${payload.unsupported_files.join(", ")}`);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
74
|
+
if ("skipped_files" in payload) {
|
|
75
|
+
throw new Error(`Cannot complete boundary audit: files exceed resource limits: ${payload.skipped_files.map(file => file.path).join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
violations = "violations" in payload ? payload.violations : [];
|
|
78
|
+
if (payload.status === "unknown") {
|
|
78
79
|
const strict = options.strict || config.settings.enforcement === "strict";
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
console.warn(options.json ? JSON.stringify({
|
|
81
|
+
status: payload.status,
|
|
82
|
+
...("relationships" in payload && { relationships: payload.relationships }),
|
|
83
|
+
message: payload.message,
|
|
84
|
+
}) : payload.message);
|
|
81
85
|
if (strict) process.exitCode = 1;
|
|
82
86
|
return;
|
|
83
87
|
}
|
package/src/cli/commands/hook.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { SeptumDatabase } from "../../core/database/client.ts";
|
|
|
9
9
|
import { SeptumRepository } from "../../core/database/repository.ts";
|
|
10
10
|
import { ASTParserEngine } from "../../core/parser/tree-sitter.ts";
|
|
11
11
|
import { ModuleResolver } from "../../core/resolver/module-resolver.ts";
|
|
12
|
+
import { SeptumTelemetry } from "../../core/telemetry/telemetry.ts";
|
|
12
13
|
|
|
13
14
|
interface ToolCallInfo {
|
|
14
15
|
name?: string;
|
|
@@ -92,9 +93,13 @@ function blockHook(db: SeptumDatabase | null, reason: string): never {
|
|
|
92
93
|
async function runPreWriteHook(): Promise<void> {
|
|
93
94
|
const callerRoot = process.cwd();
|
|
94
95
|
const workspaceRoot = path.resolve(process.env.SEPTUM_HOOK_ROOT || callerRoot);
|
|
95
|
-
const
|
|
96
|
+
const configFilePath = path.join(workspaceRoot, "septum.config.json");
|
|
97
|
+
const hasDiskConfig = fs.existsSync(configFilePath);
|
|
98
|
+
const config = hasDiskConfig
|
|
99
|
+
? ConfigLoader.loadFromDisk(configFilePath)
|
|
100
|
+
: ConfigLoader.load(undefined, workspaceRoot);
|
|
96
101
|
const dbPath = resolveDatabasePath(workspaceRoot, config.settings.db_path);
|
|
97
|
-
if (!fs.existsSync(dbPath)) {
|
|
102
|
+
if (!hasDiskConfig && !fs.existsSync(dbPath)) {
|
|
98
103
|
process.exit(0);
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -128,8 +133,10 @@ async function runPreWriteHook(): Promise<void> {
|
|
|
128
133
|
const targetFile = path.relative(workspaceRoot, path.resolve(callerRoot, edit.target)).replace(/\\/g, "/");
|
|
129
134
|
const content = edit.content;
|
|
130
135
|
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
// Zero-SQLite fast path: when septum.config.json owns policy, evaluate proposed imports
|
|
137
|
+
// in-memory without opening SQLite on every edit.
|
|
138
|
+
const db = hasDiskConfig ? null : new SeptumDatabase(dbPath);
|
|
139
|
+
const repo = db ? new SeptumRepository(db.raw) : undefined;
|
|
133
140
|
const evaluator = new BoundaryEvaluator(repo, new ModuleResolver(workspaceRoot, repo));
|
|
134
141
|
|
|
135
142
|
try {
|
|
@@ -154,6 +161,20 @@ async function runPreWriteHook(): Promise<void> {
|
|
|
154
161
|
|
|
155
162
|
if (boundaryViolations.length > 0) {
|
|
156
163
|
const v = boundaryViolations[0];
|
|
164
|
+
SeptumTelemetry.recordSystemEvent({
|
|
165
|
+
level: "WARN",
|
|
166
|
+
component: "hook",
|
|
167
|
+
event: "hook_decision",
|
|
168
|
+
fields: {
|
|
169
|
+
decision: "deny",
|
|
170
|
+
rule: v.rule,
|
|
171
|
+
source_domain: v.source_domain,
|
|
172
|
+
target_domain: v.target_domain,
|
|
173
|
+
zero_sqlite: hasDiskConfig,
|
|
174
|
+
},
|
|
175
|
+
workspaceRoot,
|
|
176
|
+
emitStderr: false,
|
|
177
|
+
});
|
|
157
178
|
blockHook(
|
|
158
179
|
db,
|
|
159
180
|
`\n[SEPTUM BOUNDARY VIOLATION - Forbidden Cross-Domain Import]\n` +
|
|
@@ -166,7 +187,21 @@ async function runPreWriteHook(): Promise<void> {
|
|
|
166
187
|
}
|
|
167
188
|
}
|
|
168
189
|
|
|
169
|
-
db
|
|
190
|
+
db?.close();
|
|
191
|
+
|
|
192
|
+
SeptumTelemetry.recordSystemEvent({
|
|
193
|
+
level: "INFO",
|
|
194
|
+
component: "hook",
|
|
195
|
+
event: "hook_decision",
|
|
196
|
+
fields: {
|
|
197
|
+
decision: "allow",
|
|
198
|
+
coverage: edit.coverage,
|
|
199
|
+
evaluated: sourceDomain ? "proposed_imports" : "unmapped_domain",
|
|
200
|
+
zero_sqlite: hasDiskConfig,
|
|
201
|
+
},
|
|
202
|
+
workspaceRoot,
|
|
203
|
+
emitStderr: false,
|
|
204
|
+
});
|
|
170
205
|
|
|
171
206
|
// If running in Antigravity or standard JSON IPC mode, emit allow decision
|
|
172
207
|
try {
|
|
@@ -176,7 +211,7 @@ async function runPreWriteHook(): Promise<void> {
|
|
|
176
211
|
}
|
|
177
212
|
process.exit(0);
|
|
178
213
|
} catch (err) {
|
|
179
|
-
db
|
|
214
|
+
db?.close();
|
|
180
215
|
const message = err instanceof Error ? err.message : String(err);
|
|
181
216
|
console.error(`\x1b[31m[Septum Hook Error]\x1b[0m ${message}`);
|
|
182
217
|
process.exit(configuredExitCode);
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
4
|
import { handleSyncCommand } from "./sync.ts";
|
|
5
|
+
import { createSyncProgressReporter } from "./sync-progress.ts";
|
|
5
6
|
import { TopologyDetector } from "../../core/discovery/topology-detector.ts";
|
|
6
7
|
import { SeptumDatabase } from "../../core/database/client.ts";
|
|
7
8
|
import { SeptumRepository } from "../../core/database/repository.ts";
|
|
@@ -91,8 +92,16 @@ export async function handleInitCommand(force: boolean = false): Promise<void> {
|
|
|
91
92
|
|
|
92
93
|
// 4. Run initial codebase ingestion
|
|
93
94
|
console.log("\x1b[36m◇\x1b[0m Indexing codebase AST (Tree-Sitter) to build symbol table & dependency graph...");
|
|
95
|
+
const progressReporter = createSyncProgressReporter({ prefix: "\x1b[36m│\x1b[0m " });
|
|
94
96
|
try {
|
|
95
|
-
await handleSyncCommand({
|
|
97
|
+
await handleSyncCommand({
|
|
98
|
+
workspaceRoot,
|
|
99
|
+
dbPath,
|
|
100
|
+
rebuild: true,
|
|
101
|
+
quiet: true,
|
|
102
|
+
onProgress: progressReporter.onProgress,
|
|
103
|
+
});
|
|
104
|
+
progressReporter.cleanup();
|
|
96
105
|
console.log("\x1b[36m│\x1b[0m \x1b[32m✓\x1b[0m AST indexing completed successfully.");
|
|
97
106
|
console.log("\x1b[36m│\x1b[0m");
|
|
98
107
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { summarizeToolCalls } from "../../core/telemetry/summary.ts";
|
|
3
|
+
|
|
4
|
+
export function handleStatsCommand(workspace: string, json: boolean): void {
|
|
5
|
+
const root = realpathSync(workspace);
|
|
6
|
+
if (!statSync(root).isDirectory()) throw new Error("Stats requires a workspace directory.");
|
|
7
|
+
const summary = summarizeToolCalls(root);
|
|
8
|
+
if (json) {
|
|
9
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
console.log(`Septum tool calls in ${root}`);
|
|
14
|
+
console.log(`${summary.calls} calls, ${summary.errors} errors (latest ${summary.sample_limit} tool events from septum.log and septum.log.1)`);
|
|
15
|
+
if (!summary.calls) return;
|
|
16
|
+
console.log(`Range: ${summary.first_timestamp ?? "unknown"} to ${summary.last_timestamp ?? "unknown"}`);
|
|
17
|
+
console.log(`Duration p50/p95: ${summary.duration_ms.p50}/${summary.duration_ms.p95} ms`);
|
|
18
|
+
if (summary.response_bytes.samples) {
|
|
19
|
+
console.log(`Response size p50/p95: ${summary.response_bytes.p50}/${summary.response_bytes.p95} bytes (${summary.response_bytes.samples} samples)`);
|
|
20
|
+
}
|
|
21
|
+
for (const [name, tool] of Object.entries(summary.tools)) {
|
|
22
|
+
console.log(` ${name}: ${tool.calls} calls, ${tool.errors} errors`);
|
|
23
|
+
for (const [action, counts] of Object.entries(tool.actions)) {
|
|
24
|
+
console.log(` ${action}: ${counts.calls} calls, ${counts.errors} errors`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (summary.recent_errors.length) {
|
|
28
|
+
console.log("Recent errors:");
|
|
29
|
+
for (const error of summary.recent_errors) {
|
|
30
|
+
console.log(` ${error.timestamp ?? "unknown"} ${error.tool} ${error.stage ?? "-"} ${error.code ?? "-"} ${error.trace_id ?? "-"}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IngestionProgressEvent } from "../../core/ingestion/pipeline.ts";
|
|
2
|
+
|
|
3
|
+
export interface SyncProgressReporterOptions {
|
|
4
|
+
/** Optional line prefix (e.g. `init` tree rail). */
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/** Override TTY detection (useful in unit tests). */
|
|
7
|
+
isTty?: boolean;
|
|
8
|
+
/** Override stdout.write for inline TTY updates. */
|
|
9
|
+
write?: (chunk: string) => void;
|
|
10
|
+
/** Override console.log for completed phase lines. */
|
|
11
|
+
log?: (line: string) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SyncProgressReporter {
|
|
15
|
+
onProgress: (event: IngestionProgressEvent) => void;
|
|
16
|
+
cleanup: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a shared CLI progress reporter for ingestion phases (`scanning`,
|
|
21
|
+
* `parsing`, `resolving`, `linking`) used by both `septum init` and `septum sync`.
|
|
22
|
+
*/
|
|
23
|
+
export function createSyncProgressReporter(options: SyncProgressReporterOptions = {}): SyncProgressReporter {
|
|
24
|
+
const prefix = options.prefix ?? "";
|
|
25
|
+
const isTty = options.isTty ?? Boolean(process.stdout.isTTY);
|
|
26
|
+
const write = options.write ?? ((chunk: string) => process.stdout.write(chunk));
|
|
27
|
+
const log = options.log ?? ((line: string) => console.log(line));
|
|
28
|
+
let activeProgressLine = false;
|
|
29
|
+
|
|
30
|
+
const cleanup = () => {
|
|
31
|
+
if (activeProgressLine) {
|
|
32
|
+
write("\r\x1b[K");
|
|
33
|
+
activeProgressLine = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const onProgress = (event: IngestionProgressEvent) => {
|
|
38
|
+
if (event.phase === "scanning") {
|
|
39
|
+
if (event.status === "start" && isTty) {
|
|
40
|
+
write(`\r${prefix}\x1b[36m◆\x1b[0m Scanning files...\x1b[K`);
|
|
41
|
+
activeProgressLine = true;
|
|
42
|
+
} else if (event.status === "done") {
|
|
43
|
+
cleanup();
|
|
44
|
+
log(`${prefix}\x1b[36m◆\x1b[0m Scanning files — ${event.total.toLocaleString()} found`);
|
|
45
|
+
}
|
|
46
|
+
} else if (event.phase === "parsing") {
|
|
47
|
+
if (event.status === "progress" && isTty) {
|
|
48
|
+
write(
|
|
49
|
+
`\r${prefix}\x1b[36m◆\x1b[0m Parsing code — ${event.processed.toLocaleString()}/${event.total.toLocaleString()}\x1b[K`
|
|
50
|
+
);
|
|
51
|
+
activeProgressLine = true;
|
|
52
|
+
} else if (event.status === "done") {
|
|
53
|
+
cleanup();
|
|
54
|
+
log(`${prefix}\x1b[36m◆\x1b[0m Parsing code — done`);
|
|
55
|
+
}
|
|
56
|
+
} else if (event.phase === "resolving" && event.status === "done") {
|
|
57
|
+
cleanup();
|
|
58
|
+
log(`${prefix}\x1b[36m◆\x1b[0m Resolving refs & domains — done`);
|
|
59
|
+
} else if (event.phase === "linking") {
|
|
60
|
+
if (event.status === "start" && isTty) {
|
|
61
|
+
write(`\r${prefix}\x1b[36m◆\x1b[0m Linking entrypoints & slices...\x1b[K`);
|
|
62
|
+
activeProgressLine = true;
|
|
63
|
+
} else if (event.status === "done") {
|
|
64
|
+
cleanup();
|
|
65
|
+
log(`${prefix}\x1b[36m◆\x1b[0m Linking entrypoints & slices — done (${event.slices.toLocaleString()} slices)`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return { onProgress, cleanup };
|
|
71
|
+
}
|
package/src/cli/commands/sync.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ConfigLoader, resolveDatabasePath } from "../../core/config/loader.ts";
|
|
2
2
|
import { SeptumDatabase } from "../../core/database/client.ts";
|
|
3
3
|
import { SeptumRepository } from "../../core/database/repository.ts";
|
|
4
|
-
import { IngestionPipeline } from "../../core/ingestion/pipeline.ts";
|
|
4
|
+
import { IngestionPipeline, type IngestionProgressEvent } from "../../core/ingestion/pipeline.ts";
|
|
5
5
|
import { resolveWorkspaceRoot } from "../../core/resolver/path-resolver.ts";
|
|
6
|
+
import { createSyncProgressReporter } from "./sync-progress.ts";
|
|
6
7
|
|
|
7
8
|
export interface SyncCommandOptions {
|
|
8
9
|
json?: boolean;
|
|
10
|
+
quiet?: boolean;
|
|
9
11
|
workspaceRoot?: string;
|
|
10
12
|
dbPath?: string;
|
|
11
13
|
rebuild?: boolean;
|
|
14
|
+
onProgress?: (info: IngestionProgressEvent) => void;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export async function handleSyncCommand(options: SyncCommandOptions = {}): Promise<void> {
|
|
@@ -20,18 +23,43 @@ export async function handleSyncCommand(options: SyncCommandOptions = {}): Promi
|
|
|
20
23
|
const repo = new SeptumRepository(db.raw);
|
|
21
24
|
const pipeline = new IngestionPipeline(repo, root);
|
|
22
25
|
|
|
23
|
-
const
|
|
26
|
+
const reporter =
|
|
27
|
+
!options.json && !options.quiet && !options.onProgress
|
|
28
|
+
? createSyncProgressReporter()
|
|
29
|
+
: undefined;
|
|
30
|
+
|
|
31
|
+
let metrics;
|
|
32
|
+
try {
|
|
33
|
+
metrics = await pipeline.run(config, {
|
|
34
|
+
rebuild: options.rebuild,
|
|
35
|
+
onProgress: options.onProgress ?? reporter?.onProgress,
|
|
36
|
+
});
|
|
37
|
+
} finally {
|
|
38
|
+
reporter?.cleanup();
|
|
39
|
+
}
|
|
24
40
|
|
|
25
41
|
if (options.json) {
|
|
26
42
|
console.log(JSON.stringify(metrics, null, 2));
|
|
27
|
-
} else {
|
|
43
|
+
} else if (!options.quiet) {
|
|
44
|
+
const sliceCount = repo.countVerticalSlices();
|
|
28
45
|
console.log(
|
|
29
46
|
`[Septum Sync] Ingested in ${metrics.duration_ms.toFixed(0)}ms: ` +
|
|
30
47
|
`${metrics.files_updated} updated/added, ` +
|
|
31
48
|
`${metrics.files_skipped} unchanged, ` +
|
|
32
49
|
`${metrics.symbols_indexed} symbols, ` +
|
|
33
|
-
`${metrics.dependencies_indexed} deps
|
|
50
|
+
`${metrics.dependencies_indexed} deps, ` +
|
|
51
|
+
`${sliceCount} slices.`
|
|
34
52
|
);
|
|
53
|
+
const unsupportedFiles = JSON.parse(repo.getMeta("unsupported_files") || "[]") as unknown[];
|
|
54
|
+
const skippedFiles = JSON.parse(repo.getMeta("skipped_files") || "[]") as unknown[];
|
|
55
|
+
const uncoveredFiles = JSON.parse(repo.getMeta("uncovered_files") || "[]") as unknown[];
|
|
56
|
+
if (unsupportedFiles.length > 0 || skippedFiles.length > 0 || uncoveredFiles.length > 0) {
|
|
57
|
+
const parts: string[] = [];
|
|
58
|
+
if (uncoveredFiles.length > 0) parts.push(`${uncoveredFiles.length} uncovered`);
|
|
59
|
+
if (skippedFiles.length > 0) parts.push(`${skippedFiles.length} skipped`);
|
|
60
|
+
if (unsupportedFiles.length > 0) parts.push(`${unsupportedFiles.length} unsupported`);
|
|
61
|
+
console.log(`[Septum Sync] Coverage: partial (${parts.join(", ")}).`);
|
|
62
|
+
}
|
|
35
63
|
}
|
|
36
64
|
} finally {
|
|
37
65
|
db.close();
|
package/src/cli/index.ts
CHANGED
|
@@ -67,6 +67,12 @@ export async function runCLI(argv: string[]): Promise<void> {
|
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
case "stats": {
|
|
71
|
+
const { handleStatsCommand } = await import("./commands/stats.ts");
|
|
72
|
+
handleStatsCommand(positionals[1] ?? process.cwd(), Boolean(flags.json));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
case "serve": {
|
|
71
77
|
const { handleServeCommand } = await import("./commands/serve.ts");
|
|
72
78
|
await handleServeCommand();
|
|
@@ -116,6 +122,7 @@ COMMANDS:
|
|
|
116
122
|
|
|
117
123
|
Daemon & Protocol:
|
|
118
124
|
serve Start Model Context Protocol (MCP) server over stdio
|
|
125
|
+
stats [workspace] Summarize recent MCP tool logs (supports --json)
|
|
119
126
|
|
|
120
127
|
GLOBAL FLAGS:
|
|
121
128
|
-h, --help Show this help message
|
|
@@ -12,18 +12,6 @@ export const SEPTUM_HOOKS_CONFIG = {
|
|
|
12
12
|
],
|
|
13
13
|
},
|
|
14
14
|
],
|
|
15
|
-
"PostToolUse": [
|
|
16
|
-
{
|
|
17
|
-
"matcher": "write_file|edit_file|write_to_file|replace_file_content|multi_replace_file_content|Write|Edit|MultiEdit|NotebookEdit",
|
|
18
|
-
"hooks": [
|
|
19
|
-
{
|
|
20
|
-
"type": "command",
|
|
21
|
-
"command": "sh -c 'ROOT=\"$(pwd -P)\"; for d in .gemini .claude .codex opencode .agents; do if [ -f \"$ROOT/$d/hooks/septum-post-write.sh\" ]; then exec \"$ROOT/$d/hooks/septum-post-write.sh\" \"$@\"; fi; done; exit 0'",
|
|
22
|
-
"timeout": 15,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
15
|
},
|
|
28
16
|
};
|
|
29
17
|
|
|
@@ -32,7 +20,7 @@ export const SEPTUM_PRE_WRITE_SCRIPT = `#!/usr/bin/env sh
|
|
|
32
20
|
# Passes supported edit payloads to the CLI before the client writes them
|
|
33
21
|
|
|
34
22
|
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd -P)"
|
|
35
|
-
if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
|
|
23
|
+
if [ ! -f "$ROOT_DIR/.septum/septum.db" ] && [ ! -f "$ROOT_DIR/septum.config.json" ]; then
|
|
36
24
|
exit 0
|
|
37
25
|
fi
|
|
38
26
|
|
|
@@ -57,12 +45,13 @@ export const SEPTUM_POST_WRITE_SCRIPT = `#!/usr/bin/env sh
|
|
|
57
45
|
# Syncs modified AST into SQLite SSOT after file mutations
|
|
58
46
|
|
|
59
47
|
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd -P)"
|
|
60
|
-
if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
|
|
48
|
+
if [ ! -f "$ROOT_DIR/.septum/septum.db" ] && [ ! -f "$ROOT_DIR/septum.config.json" ]; then
|
|
61
49
|
exit 0
|
|
62
50
|
fi
|
|
63
51
|
|
|
64
52
|
# Sync always belongs to the workspace containing this generated wrapper.
|
|
65
53
|
cd "$ROOT_DIR" || exit 1
|
|
54
|
+
mkdir -p "$ROOT_DIR/.septum" 2>/dev/null || true
|
|
66
55
|
|
|
67
56
|
LOCK_DIR="$ROOT_DIR/.septum/sync.lock"
|
|
68
57
|
PENDING_FILE="$ROOT_DIR/.septum/sync.pending"
|