@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.
Files changed (161) hide show
  1. package/README.md +46 -45
  2. package/package.json +8 -6
  3. package/src/cli/commands/check.ts +41 -26
  4. package/src/cli/commands/hook.ts +77 -105
  5. package/src/cli/commands/init.ts +35 -9
  6. package/src/cli/commands/stats.ts +33 -0
  7. package/src/cli/commands/sync-progress.ts +71 -0
  8. package/src/cli/commands/sync.ts +35 -9
  9. package/src/cli/hook-payload.ts +43 -0
  10. package/src/cli/index.ts +15 -51
  11. package/src/cli/scaffold/harness-config.ts +48 -8
  12. package/src/cli/templates/hooks.ts +51 -27
  13. package/src/cli/templates/rules.ts +34 -49
  14. package/src/cli/templates/skill.ts +46 -35
  15. package/src/core/boundary/audit.ts +383 -0
  16. package/src/core/boundary/evaluator.ts +299 -178
  17. package/src/core/boundary/staged-auditor.ts +188 -34
  18. package/src/core/config/domain-ownership.ts +47 -0
  19. package/src/core/config/domain-registration.ts +141 -0
  20. package/src/core/config/loader.ts +82 -54
  21. package/src/core/config/schema.ts +24 -46
  22. package/src/core/database/client.ts +2 -0
  23. package/src/core/database/repositories/dependency.repository.ts +326 -543
  24. package/src/core/database/repositories/domain.repository.ts +48 -4
  25. package/src/core/database/repositories/file.repository.ts +10 -0
  26. package/src/core/database/repositories/symbol.repository.ts +97 -259
  27. package/src/core/database/repository.ts +138 -24
  28. package/src/core/database/schema.ts +28 -33
  29. package/src/core/discovery/declarative-routes.ts +69 -0
  30. package/src/core/discovery/framework-detector.ts +149 -0
  31. package/src/core/discovery/navigation.ts +269 -0
  32. package/src/core/discovery/topology-detector.ts +153 -170
  33. package/src/core/errors.ts +19 -0
  34. package/src/core/ingestion/pipeline.ts +378 -212
  35. package/src/core/parser/behavioral-analyzer.ts +26 -22
  36. package/src/core/parser/boundary-tracker.ts +15 -0
  37. package/src/core/parser/extractors/base.ts +16 -4
  38. package/src/core/parser/extractors/csharp.ts +9 -5
  39. package/src/core/parser/extractors/django-routing.ts +163 -0
  40. package/src/core/parser/extractors/django-semantic.ts +400 -516
  41. package/src/core/parser/extractors/elysia-semantic.ts +172 -496
  42. package/src/core/parser/extractors/express-semantic.ts +195 -398
  43. package/src/core/parser/extractors/fastapi-semantic.ts +182 -399
  44. package/src/core/parser/extractors/fastify-semantic.ts +216 -732
  45. package/src/core/parser/extractors/flask-semantic.ts +92 -388
  46. package/src/core/parser/extractors/go-routing.ts +344 -0
  47. package/src/core/parser/extractors/go-semantic.ts +210 -508
  48. package/src/core/parser/extractors/go.ts +6 -3
  49. package/src/core/parser/extractors/graphql-entrypoint.ts +146 -0
  50. package/src/core/parser/extractors/hono-semantic.ts +132 -530
  51. package/src/core/parser/extractors/java.ts +7 -5
  52. package/src/core/parser/extractors/laravel-routing.ts +263 -0
  53. package/src/core/parser/extractors/laravel-semantic.ts +169 -333
  54. package/src/core/parser/extractors/manifest-helpers.ts +64 -0
  55. package/src/core/parser/extractors/mcp-cli-dispatch.ts +268 -0
  56. package/src/core/parser/extractors/mcp-cli-semantic.ts +84 -336
  57. package/src/core/parser/extractors/nestjs-semantic.ts +238 -510
  58. package/src/core/parser/extractors/nextjs-semantic.ts +164 -0
  59. package/src/core/parser/extractors/php-ast-helpers.ts +51 -0
  60. package/src/core/parser/extractors/php.ts +17 -1
  61. package/src/core/parser/extractors/python-route-ast.ts +249 -0
  62. package/src/core/parser/extractors/python.ts +9 -8
  63. package/src/core/parser/extractors/registry.ts +28 -5
  64. package/src/core/parser/extractors/route-prefixes.ts +43 -0
  65. package/src/core/parser/extractors/ruby.ts +10 -7
  66. package/src/core/parser/extractors/rust.ts +35 -17
  67. package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
  68. package/src/core/parser/extractors/symfony-routing.ts +114 -0
  69. package/src/core/parser/extractors/symfony-semantic.ts +75 -262
  70. package/src/core/parser/extractors/typescript-bindings.ts +333 -0
  71. package/src/core/parser/extractors/typescript-compiler-fallback.ts +380 -0
  72. package/src/core/parser/extractors/typescript-fallback.ts +207 -0
  73. package/src/core/parser/extractors/typescript-route-context.ts +58 -0
  74. package/src/core/parser/extractors/typescript.ts +36 -216
  75. package/src/core/parser/implementation-fingerprint.ts +97 -0
  76. package/src/core/parser/language-capabilities.ts +23 -7
  77. package/src/core/parser/schema/providers/laravel-migration-provider.ts +77 -51
  78. package/src/core/parser/schema/schema-provider-registry.ts +1 -3
  79. package/src/core/parser/schema/schema-provider.interface.ts +2 -1
  80. package/src/core/parser/semantic-revision.ts +3 -0
  81. package/src/core/parser/static-string.ts +51 -0
  82. package/src/core/parser/wasm-loader.ts +6 -2
  83. package/src/core/resolver/ast-method-tracer.ts +230 -0
  84. package/src/core/resolver/call-graph-helpers.ts +72 -0
  85. package/src/core/resolver/call-graph-tracer.ts +375 -311
  86. package/src/core/resolver/dependency-analysis.ts +593 -0
  87. package/src/core/resolver/import-candidates.ts +120 -0
  88. package/src/core/resolver/import-evidence.ts +88 -0
  89. package/src/core/resolver/import-resolver.ts +162 -181
  90. package/src/core/resolver/interpretation-inputs.ts +65 -0
  91. package/src/core/resolver/languages/go.ts +103 -0
  92. package/src/core/resolver/languages/managed.ts +200 -0
  93. package/src/core/resolver/languages/python.ts +133 -0
  94. package/src/core/resolver/languages/ruby.ts +40 -0
  95. package/src/core/resolver/languages/rust.ts +127 -0
  96. package/src/core/resolver/languages/shared.ts +74 -0
  97. package/src/core/resolver/module-resolver.ts +18 -7
  98. package/src/core/resolver/path-resolver.ts +6 -3
  99. package/src/core/resolver/polyglot-slice-tracer.ts +197 -0
  100. package/src/core/resolver/slice-catalog.ts +94 -0
  101. package/src/core/resolver/slice-format.ts +22 -0
  102. package/src/core/resolver/slice-selection.ts +237 -0
  103. package/src/core/resolver/symbol-impact.ts +477 -0
  104. package/src/core/resolver/symbol-locator.ts +82 -15
  105. package/src/core/resolver/vertical-slice-tracer.ts +57 -278
  106. package/src/core/resources/ignore.ts +21 -1
  107. package/src/core/resources/limits.ts +2 -1
  108. package/src/core/resources/source-files.ts +143 -20
  109. package/src/core/resources/source-inventory.ts +55 -0
  110. package/src/core/resources/work-queue.ts +167 -4
  111. package/src/core/retrieval/context-page.ts +116 -0
  112. package/src/core/retrieval/context.ts +457 -0
  113. package/src/core/retrieval/resolution-warnings.ts +21 -0
  114. package/src/core/retrieval/source-context.ts +448 -0
  115. package/src/core/retrieval/symbol-details.ts +453 -0
  116. package/src/core/retrieval/symbol-evidence.ts +97 -0
  117. package/src/core/retrieval/typescript-references.ts +293 -0
  118. package/src/core/retrieval/universal-context.ts +182 -0
  119. package/src/core/telemetry/summary.ts +114 -0
  120. package/src/core/telemetry/telemetry.ts +225 -37
  121. package/src/index.ts +0 -3
  122. package/src/mcp/formatters/compact-text.ts +439 -0
  123. package/src/mcp/resources-and-prompts.ts +253 -0
  124. package/src/mcp/schemas/boundary.ts +145 -0
  125. package/src/mcp/schemas/map.ts +250 -0
  126. package/src/mcp/schemas/shared.ts +52 -0
  127. package/src/mcp/schemas/slice.ts +60 -0
  128. package/src/mcp/schemas/symbol.ts +268 -0
  129. package/src/mcp/schemas.ts +5 -1105
  130. package/src/mcp/server.ts +263 -597
  131. package/src/mcp/tool-catalog.ts +331 -0
  132. package/src/mcp/tools/boundary.ts +69 -4
  133. package/src/mcp/tools/map.ts +126 -0
  134. package/src/mcp/tools/slice.ts +101 -3
  135. package/src/mcp/tools/symbol.ts +480 -26
  136. package/src/mcp/ui/app-client.ts +899 -0
  137. package/src/mcp/ui/app.html +478 -0
  138. package/src/mcp/workflow-playbooks.ts +181 -0
  139. package/src/mcp/workspace-boundary.ts +50 -0
  140. package/src/mcp/workspace-manager.ts +102 -18
  141. package/src/mcp/workspace-watcher.ts +38 -19
  142. package/src/types/index.ts +47 -53
  143. package/src/cli/commands/topology.ts +0 -161
  144. package/src/core/database/repositories/environment.repository.ts +0 -207
  145. package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
  146. package/src/core/session/session-manager.ts +0 -107
  147. package/src/core/topology/environment-detector.ts +0 -973
  148. package/src/core/topology/types.ts +0 -83
  149. package/src/mcp/tools/check-boundary.ts +0 -387
  150. package/src/mcp/tools/domain.ts +0 -40
  151. package/src/mcp/tools/feature.ts +0 -67
  152. package/src/mcp/tools/get-domain-catalog.ts +0 -226
  153. package/src/mcp/tools/get-environment-topology.ts +0 -138
  154. package/src/mcp/tools/get-feature-context.ts +0 -224
  155. package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
  156. package/src/mcp/tools/get-symbol-impact.ts +0 -64
  157. package/src/mcp/tools/get-symbol.ts +0 -175
  158. package/src/mcp/tools/locate-symbol.ts +0 -196
  159. package/src/mcp/tools/register-domain.ts +0 -75
  160. package/src/mcp/tools/register-feature.ts +0 -110
  161. package/src/mcp/tools/trace-vertical-slice.ts +0 -80
@@ -2,7 +2,7 @@ export const SEPTUM_HOOKS_CONFIG = {
2
2
  "septum-boundary-guard": {
3
3
  "PreToolUse": [
4
4
  {
5
- "matcher": "write_to_file|replace_file_content|multi_replace_file_content|Write|Edit|MultiEdit",
5
+ "matcher": "write_file|edit_file|write_to_file|replace_file_content|multi_replace_file_content|Write|Edit|MultiEdit|NotebookEdit",
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
@@ -12,31 +12,21 @@ export const SEPTUM_HOOKS_CONFIG = {
12
12
  ],
13
13
  },
14
14
  ],
15
- "PostToolUse": [
16
- {
17
- "matcher": "write_to_file|replace_file_content|multi_replace_file_content|Write|Edit|MultiEdit",
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
 
30
18
  export const SEPTUM_PRE_WRITE_SCRIPT = `#!/usr/bin/env sh
31
- # Septum 3-Gate Boundary Guard Pre-Write Hook
32
- # Intercepts write_to_file and replace_file_content before disk mutation
19
+ # Septum candidate import policy hook
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
 
39
- # Delegate directly to Septum's active 3-gate hook engine
27
+ export SEPTUM_HOOK_ROOT="$ROOT_DIR"
28
+
29
+ # Invoke the available Septum CLI hook command
40
30
  if command -v bun >/dev/null 2>&1 && [ -f "$ROOT_DIR/bin/septum.ts" ]; then
41
31
  exec bun run "$ROOT_DIR/bin/septum.ts" hook pre-write "$@"
42
32
  elif command -v septum >/dev/null 2>&1; then
@@ -55,21 +45,55 @@ export const SEPTUM_POST_WRITE_SCRIPT = `#!/usr/bin/env sh
55
45
  # Syncs modified AST into SQLite SSOT after file mutations
56
46
 
57
47
  ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd -P)"
58
- if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
48
+ if [ ! -f "$ROOT_DIR/.septum/septum.db" ] && [ ! -f "$ROOT_DIR/septum.config.json" ]; then
59
49
  exit 0
60
50
  fi
61
51
 
62
- # Trigger background incremental sync
63
- if command -v bun >/dev/null 2>&1 && [ -f "$ROOT_DIR/bin/septum.ts" ]; then
64
- bun run "$ROOT_DIR/bin/septum.ts" sync >/dev/null 2>&1 &
65
- elif command -v septum >/dev/null 2>&1; then
66
- septum sync >/dev/null 2>&1 &
67
- elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
68
- "$ROOT_DIR/node_modules/.bin/septum" sync >/dev/null 2>&1 &
69
- elif command -v bunx >/dev/null 2>&1; then
70
- bunx septum sync >/dev/null 2>&1 &
52
+ # Sync always belongs to the workspace containing this generated wrapper.
53
+ cd "$ROOT_DIR" || exit 1
54
+ mkdir -p "$ROOT_DIR/.septum" 2>/dev/null || true
55
+
56
+ LOCK_DIR="$ROOT_DIR/.septum/sync.lock"
57
+ PENDING_FILE="$ROOT_DIR/.septum/sync.pending"
58
+
59
+ # Mark workspace as needing sync so an active lock holder coalesces burst edits
60
+ : > "$PENDING_FILE" 2>/dev/null || true
61
+
62
+ # Recover stale lock if holder PID is no longer alive
63
+ if [ -d "$LOCK_DIR" ] && [ -f "$LOCK_DIR/pid" ]; then
64
+ LOCK_PID="$(cat "$LOCK_DIR/pid" 2>/dev/null)"
65
+ if [ -n "$LOCK_PID" ] && ! kill -0 "$LOCK_PID" 2>/dev/null; then
66
+ rm -rf "$LOCK_DIR" 2>/dev/null || true
67
+ fi
71
68
  fi
72
69
 
70
+ # Non-blocking lock acquisition: if another background sync is active, exit 0
71
+ if ! mkdir "$LOCK_DIR" 2>/dev/null; then
72
+ exit 0
73
+ fi
74
+
75
+ run_septum_sync() {
76
+ if command -v bun >/dev/null 2>&1 && [ -f "$ROOT_DIR/bin/septum.ts" ]; then
77
+ bun run "$ROOT_DIR/bin/septum.ts" sync >/dev/null 2>&1
78
+ elif command -v septum >/dev/null 2>&1; then
79
+ septum sync >/dev/null 2>&1
80
+ elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
81
+ "$ROOT_DIR/node_modules/.bin/septum" sync >/dev/null 2>&1
82
+ elif command -v bunx >/dev/null 2>&1; then
83
+ bunx septum sync >/dev/null 2>&1
84
+ fi
85
+ }
86
+
87
+ # Trigger coalesced background incremental sync
88
+ (
89
+ trap 'rm -rf "$LOCK_DIR" 2>/dev/null || true' EXIT INT TERM
90
+ while [ -f "$PENDING_FILE" ]; do
91
+ rm -f "$PENDING_FILE" 2>/dev/null || true
92
+ run_septum_sync
93
+ done
94
+ ) >/dev/null 2>&1 &
95
+ echo "$!" > "$LOCK_DIR/pid" 2>/dev/null || true
96
+
73
97
  exit 0
74
98
  `;
75
99
 
@@ -1,50 +1,35 @@
1
- export const SEPTUM_RULES_TEMPLATE = `# Software Architecture, Modular Boundaries & Symbol Reuse Guidelines
2
-
3
- > **Core Principle:** This codebase enforces modular architecture and the DRY (Don't Repeat Yourself) principle. An embedded database (\`.septum/septum.db\`) maintains the Single Source of Truth (SSOT) for the project symbol table, call graph, and dependency graph. Code modifications must respect module boundaries and reuse existing abstractions.
4
-
5
- ---
6
-
7
- ## 1. Symbol Reuse & Module Discovery (Before Writing New Code)
8
-
9
- Before declaring a new class, interface, function, method, or shared type:
10
- 1. **Inspect Module Catalog & File Dependencies:**
11
- Call \`septum_domain({ action: "catalog", domain: "<domain_name>", detail_level: "compact" })\` (or omit \`domain\` for the top-level architecture overview).
12
- * Review existing declarations (\`class\`, \`interface\`, \`struct\`, \`function\`, \`type\`, \`constant\`, \`variable\`) and their line span.
13
- * Review imported modules (\`connections.imports_from\`) and consumer count (\`connections.imported_by_count\`).
14
- * For complete method signatures of a specific component, call \`septum_symbol({ action: "inspect", query: "<SymbolName>" })\`.
15
- 2. **Search for Existing Utilities and Abstractions:**
16
- Call \`septum_symbol({ action: "locate", query: "<keyword>" })\` to verify whether a utility, service, or helper already exists before implementing duplicate logic.
17
- 3. **Scope Constraints for Features:**
18
- When working within an assigned feature branch or task, call \`septum_feature({ action: "get", feature_key: "<feature_name>" })\`:
19
- * **Respect \`allowed_touchpoints\`:** Restrict modifications strictly to files within the designated module scope.
20
- * **Reuse \`reuse_symbols\`:** Import and extend registered components from \`reuse_symbols\` instead of re-implementing them.
21
-
22
- ---
23
-
24
- ## 2. Impact Analysis & Breaking Change Prevention (Before Refactoring)
25
-
26
- 1. **Analyze Call Graph Dependencies (\`inbound_callers\`):**
27
- Before altering method signatures, changing parameter contracts, or deprecating public symbols, check all dependents:
28
- \`\`\`json
29
- septum_symbol({ "action": "impact", "query": "ClassNameOrFunction" })
30
- \`\`\`
31
- Review all \`inbound_callers\` (direct callers and cross-module named imports) to prevent breaking upstream consumers.
32
- 2. **Trace End-to-End Execution Flow (Vertical Slices):**
33
- Call \`septum_slice({ query: "<route|command|handler>", max_depth: 5 })\` (scale up to \`max_depth: 8\` for asynchronous events, message queues, or layered middleware) to trace call chains from API ingress down to data persistence.
34
-
35
- ---
36
-
37
- ## 3. Dependency Validation & Static Boundary Checks
38
-
39
- 1. **Pre-Validate Proposed Module Imports:**
40
- Before adding new cross-module dependencies, validate whether the dependency direction conforms to the architecture:
41
- \`\`\`json
42
- septum_boundary({
43
- "file_path": "src/modules/order/service.ts",
44
- "proposed_imports": ["../billing/service"],
45
- "feature_key": "optional_feature_key"
46
- })
47
- \`\`\`
48
- 2. **Verify Against Circular Dependencies and Boundary Leaks:**
49
- Run \`septum_boundary({ scope: "staged" })\` or \`septum_boundary({ scope: "all" })\` prior to committing changes. If the check returns \`rejected\` (due to \`forbidden_dependency\`, \`disallowed_dependency\`, \`touchpoint_violation\`, or \`circular_dependency\`), refactor the import hierarchy to preserve clean dependency inversion.
1
+ export const SEPTUM_RULES_TEMPLATE = `# Septum: static code navigation and boundary checks
2
+
3
+ Use Septum to inspect indexed declarations, imports, domains and supported entrypoints. Its SQLite database stores extracted static evidence. Read freshness, coverage, diagnostics and omissions before relying on a result.
4
+
5
+ ## Tool routing
6
+
7
+ | Task | Tool | Result |
8
+ | --- | --- | --- |
9
+ | Find domains and files | \`septum_map({action: "catalog", detail_level: "compact"})\` | Domain/file navigation, directed import relationships, static entrypoints and index health |
10
+ | Inspect a declaration | \`septum_symbol({action: "locate", query: "<name>"})\` | Indexed coordinates, declaration reference, candidates or suggestions |
11
+ | Read implementation and supporting declarations | \`septum_symbol({action: "context", query: "<name>", file_path: "<path>"})\` | Deep TypeScript context or bounded source inspection, according to the selected mode |
12
+ | Inspect potential consumers | \`septum_symbol({action: "impact", query: "<name>"})\` | Import dependents, supported static call sites and inferred caller hints |
13
+ | Inspect an entrypoint | \`septum_slice({query: "<route or handler>", max_depth: 5})\` | Static catalog match and related nodes with relationship evidence |
14
+ | Check proposed imports | \`septum_boundary({scope: "file", file_path: "<path>", proposed_imports: [...]})\` | Proposal decision and diagnostics under configured domain rules |
15
+ | Check the Git index | \`septum_boundary({scope: "staged"})\` | Boundary analysis using frozen staged source and interpretation files |
16
+
17
+ ## Reading and acting on results
18
+
19
+ - Start with map when the relevant domain/file is unknown. Follow \`dependencies\`, \`entrypoints\`, \`health\` and \`next\`. Full detail expands navigation selection; use symbol for declaration bodies.
20
+ - Narrow ambiguous declarations with \`file_path\` or a returned \`symbol_ref\`. A found indexed declaration can still have stale or unavailable source.
21
+ - Choose \`context_mode: "deep"\` for supported TypeScript reference context. Choose \`context_mode: "source"\` for bounded source inspection. On the source path, \`include_source: false\` requests signature/dependency details.
22
+ - Deep-context \`budget_bytes\` controls response serialization. Source-mode line limits are a different contract. A setting is not a guarantee of task completeness.
23
+ - Continue deep context with the returned \`continuation\` and unchanged selection/options. Inspect omission accounting and diagnostics.
24
+ - Before changing a public contract, inspect impact and the relevant consumers. Read \`inbound_callers_complete\` and the limits of \`inbound_callers\`; static caller evidence requires application checks.
25
+ - Proposal approval does not audit existing imports. Use all/domain/staged scopes for their corresponding audits.
26
+ - \`unknown\` is not approval. \`rejected\` reports detected violations such as \`forbidden_dependency\`, \`disallowed_dependency\` or \`circular_dependency\`. \`approved\` concerns only the evaluated static scope.
27
+ - Slice confidence describes query-to-catalog matching. Imports do not prove calls; related nodes do not establish execution order or runtime dispatch.
28
+ - If tools are unavailable or evidence is incomplete, inspect relevant source directly and verify the behavior with appropriate project checks.
29
+
30
+ ## Language and workspace scope
31
+
32
+ Declaration extraction and import resolution have separate language-specific limits. Python, Go, Rust, Ruby, Java and C# resolve supported local/manifest patterns; dynamic configuration, conditional builds, binary classpaths and runtime loading can remain unresolved or unsupported. Set \`workspace_path\` explicitly when selecting among repositories.
33
+
34
+ Generated client hooks need client enablement and a matching tool payload. Their presence does not prove that an edit was intercepted.
50
35
  `;
@@ -1,51 +1,62 @@
1
- export const SEPTUM_MAP_SKILL_TEMPLATE = `---
2
- name: septum-map
3
- description: Framework-agnostic codebase architecture and dependency graph analysis. Use when initializing project boundaries, inspecting the symbol table, validating cross-module imports, or reviewing static analysis check results.
1
+ export const USE_SEPTUM_SKILL_TEMPLATE = `---
2
+ name: use-septum
3
+ description: >-
4
+ Inspect backend declarations, imports, domain boundaries and supported static entrypoints with Septum MCP. Use for code navigation, consumer inspection and proposed/staged import checks; inspect coverage and freshness before using results to plan edits.
4
5
  ---
5
6
 
6
- # \`septum-map\` — Codebase Architecture & Static Analysis
7
+ # use-septum
7
8
 
8
- > **Core Principle:** Static analysis indexes AST declarations and dependency graphs to provide deterministic structural evidence. Treat index data as static structural facts, not full runtime trace validation.
9
+ Septum indexes selected source declarations, imports, domain ownership and static entrypoints. It returns static evidence and diagnostics. It does not run the analyzed application or provide a complete runtime caller graph.
9
10
 
10
- ## Scope
11
+ ## Select the tool
11
12
 
12
- Use this skill to navigate the project architecture, verify module boundaries, locate reusable symbols, trace execution flows, and validate dependency rules. This skill guides architectural compliance; domain business decisions remain governed by project specifications.
13
+ All 4 tools default to \`format: "text"\` (token-efficient compact markdown summary); pass \`format: "json"\` when structured JSON is required.
13
14
 
14
- ## Tool & Command Reference
15
+ | Need | Request | Read from the result |
16
+ | --- | --- | --- |
17
+ | Workspace/domain/file navigation | \`septum_map\`, \`action: "catalog"\`, \`detail_level: "compact"\`, optional \`domain\`/\`file_filter\`/\`format\` | \`submodules\` + aggregated dependencies (for large domains >25 files), files/anchors, directed \`dependencies\`, static \`entrypoints\`, \`health\`, \`next\` |
18
+ | Domain policy registration | \`septum_map\`, \`action: "register"\`, \`domain\`, \`root\`, dependency lists | Recorded policy, \`policy_owner\` and any ingestion result |
19
+ | Declaration lookup | \`septum_symbol\`, \`action: "locate"\`, \`query\` | Indexed coordinates, \`symbol_ref\`, token/camelCase-ranked suggestions and retrieval freshness |
20
+ | TypeScript reference context | \`septum_symbol\`, \`action: "context"\`, \`context_mode: "deep"\`, optional \`max_depth\` (1–4, default 2) | True hop-ordered (\`hop 0→1→2\`, direct local/imported callees & contracts first) source/contracts, diagnostics, accounting and continuation |
21
+ | Source/signature inspection | \`septum_symbol\`, \`action: "context"\`, \`context_mode: "source"\` | Source slice or signature/dependency details and source status |
22
+ | Potential consumers | \`septum_symbol\`, \`action: "impact"\` | Separated \`call_sites\`, \`runtime_imports\`, \`type_only_imports\`, warnings and uncertainty |
23
+ | Supported route/handler/job/CLI/event | \`septum_slice\`, \`query\`, optional \`controller_file\`, \`max_depth\`, \`format\` | Catalog target (\`exact\` match for \`METHOD target\`), indented parent-attributed chain and diagnostics |
24
+ | Proposed imports | \`septum_boundary\`, \`scope: "file"\`, \`file_path\`, \`proposed_imports\` | Proposal decision and evaluated scope |
25
+ | Existing indexed or staged imports | \`septum_boundary\`, \`scope: "all" / "domain" / "staged"\` | Scoped violations, incomplete resolution and recovery hints |
15
26
 
16
- The active MCP schema and \`septum --help\` represent the authoritative interface contracts:
27
+ ## Context selection
17
28
 
18
- | Tool | Capability | Considerations |
19
- |---|---|---|
20
- | \`septum_domain\` | \`catalog\` inspects module architecture (supports \`detail_level: "compact"\`); \`register\` defines domain roots; \`topology\` logs infrastructure layers. | Domain registration mutates database state. Directory structures serve as modular hints. |
21
- | \`septum_symbol\` | \`locate\`, \`inspect\`, \`impact\`, or \`hotspots\` across the project symbol table. | Backed by Tree-Sitter AST parsers. Impact analysis reports static inbound callers across the dependency graph. |
22
- | \`septum_slice\` | Traces end-to-end execution paths from ingress handlers down through services and repositories; \`max_depth\` bounds call graph traversal. | Returns matched call graph chains; confidence metrics reflect static AST resolution depth. |
23
- | \`septum_boundary\` | Validates proposed imports and detects \`circular_dependency\` cycles across scopes (\`file\`, \`staged\`, \`domain\`, \`all\`). | Evaluates allowed/forbidden dependency rules. Status \`approved\` confirms zero policy violations in the checked scope. |
24
- | \`septum_feature\` | \`get\` retrieves active task context; \`lock\` registers task touchpoints; \`release\` clears locks. | Restricts edits to authorized module touchpoints during concurrent development sessions. |
29
+ Deep context supports indexed \`.ts\`, \`.tsx\`, \`.mts\` and \`.cts\` declarations. It follows bounded supported references up to \`max_depth\` import edges (default \`2\`, max \`4\`), ranks items hop-first (\`depth 0 → 1 → 2\`, direct calls and contracts ahead of transitive helpers), and can project public type contracts. It does not establish a complete business dependency closure.
25
30
 
26
- Common CLI commands: \`septum init\` initializes project configuration and agent hooks; \`septum sync\` updates the AST index; \`septum check\` runs static boundary checks on staged or workspace files.
31
+ Use \`budget_bytes\` and \`max_depth\` only for deep context. Do not combine them with \`include_source\`, \`source_start_line\` or \`source_line_limit\`. Those options select bounded source inspection when no explicit mode is supplied. \`inspect\` is an alias for \`context\`.
27
32
 
28
- ## Architectural Review Workflow
33
+ Source mode includes target source by default. Use \`include_source: false\` for signature/dependency details. When a source slice is truncated, follow \`next_start_line\`. One-hop delegation expansion (including same-file local helper delegation for polyglot files) is heuristic; inspect the selected dependency before treating it as a callee.
29
34
 
30
- 1. **Verify Project Context:** Ensure working directory is aligned. Check that \`.septum/septum.db\` is present. Pass \`workspace_path\` when operating in multi-root workspaces.
31
- 2. **Inspect Module Inventory:** Query the domain catalog to determine registered modules, AST index status, and file coverage metrics. If files are marked unsupported or skipped, note partial coverage.
32
- 3. **Differentiate Evidence from Assumptions:** Use concrete AST symbols, public exports, and declared configuration as evidence. Never guess interfaces or assume unverified dependencies.
33
- 4. **Identify Reusable Components:** Search existing services, models, and utility classes before introducing new declarations to adhere to the DRY principle.
34
- 5. **Analyze Refactoring Blast Radius:** Check inbound callers (\`septum_symbol impact\`) before modifying public method signatures or removing exported declarations.
35
- 6. **Validate Dependency Boundaries:** Run pre-commit checks (\`septum_boundary\`) to ensure proposed imports avoid circular dependencies and respect architectural layering.
35
+ For deep-context pages, pass the returned \`continuation\` with unchanged target, workspace, configuration, \`max_depth\` and budget. Restart retrieval on invalid/stale continuation. Capacity omissions are distinct from pagination.
36
36
 
37
- ## Interpreting Analysis Results
37
+ ## Workflow and evidence limits
38
38
 
39
- - \`approved\`: No architectural violations or circular dependencies detected within the evaluated scope.
40
- - \`rejected\`: A boundary violation (\`forbidden_dependency\`, \`disallowed_dependency\`, or \`circular_dependency\`) occurred. The import hierarchy must be refactored.
41
- - \`unknown\` or partial index status: Indexing is incomplete; review unsupported files before concluding compliance.
42
- - Absence of a symbol: Indicates no match in the current AST index, signaling an opportunity to implement or check naming spelling.
39
+ 1. Use map when the target domain or file is unknown. Full map detail expands navigation selection, not declaration detail.
40
+ 2. Locate a declaration and resolve ambiguity through \`file_path\` or \`symbol_ref\`. Read freshness before using indexed coordinates.
41
+ 3. Retrieve the relevant source/contracts. Inspect diagnostics and omissions, and read further source when needed.
42
+ 4. Before a public-contract change, inspect impact and relevant consumers. \`inbound_callers_complete: false\` means the caller list is incomplete; risk is advisory.
43
+ 5. Evaluate proposed imports against policy. Proposal approval does not certify existing imports or all possible cycles.
44
+ 6. Check the relevant workspace/domain/staged scope and run application checks for behavior affected by the edit.
43
45
 
44
- ## Standardized Reporting Format
46
+ A slice's exact match applies to its catalog target. Imports do not prove calls; static relationships do not prove execution order or runtime dispatch. Validation/schema/entity nodes are context, not a required executed sequence.
45
47
 
46
- When summarizing architectural checks:
47
- - **Scope & Action:** Audited file path or module, tool invoked, and whether database state was modified.
48
- - **Structural Evidence:** Exact symbol declarations, caller counts, or dependency paths identified.
49
- - **Status & Violations:** Clear pass/fail outcome with specific rule violations or circular dependency paths if detected.
50
- - **Recommended Action:** Remediation steps (e.g. dependency inversion, extracting shared interfaces, or reusing existing utilities).
48
+ Boundary \`approved\` describes the evaluated static scope. \`rejected\` reports known violations, including \`circular_dependency\`. \`unknown\` requires inspecting or recovering missing evidence. Resolve ambiguity by narrowing the request.
49
+
50
+ Language declaration support does not imply equivalent module resolution. Rust/Cargo, Ruby requires, Java source projects and C# namespaces have bounded resolver support; dynamic loaders, macros, conditional builds and missing binary metadata remain limited.
51
+
52
+ Set \`workspace_path\` when selecting among repositories. If the MCP tools are unavailable or insufficient, use direct source inspection and appropriate project verification.
53
+
54
+ ## Resources & Prompts
55
+
56
+ - **MCP Resources (initial workspace):** \`septum://domains\`, \`septum://health\`, \`septum://boundaries\`, and \`septum://domain/{name}\` provide read-only JSON snapshots for the server's initial workspace; use the 4 MCP tools with \`workspace_path\` for multi-root queries.
57
+ - **MCP Prompts:** \`septum-pre-edit-check\` and \`septum-architecture-audit\` provide step-by-step verification playbooks.
58
+
59
+ Describe the operation and observed result. Do not promise token savings, response speed, memory savings, complete caller discovery or universal language/framework coverage.
51
60
  `;
61
+
62
+ export const SEPTUM_MAP_SKILL_TEMPLATE = USE_SEPTUM_SKILL_TEMPLATE;