septum 0.1.4 → 0.1.5

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 (67) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +105 -105
  3. package/bin/septum.ts +4 -4
  4. package/package.json +63 -63
  5. package/src/cli/commands/check.ts +161 -161
  6. package/src/cli/commands/hook.ts +188 -188
  7. package/src/cli/commands/ingest.ts +29 -29
  8. package/src/cli/commands/init.ts +211 -211
  9. package/src/cli/commands/locate.ts +61 -61
  10. package/src/cli/commands/query.ts +64 -64
  11. package/src/cli/commands/serve.ts +5 -5
  12. package/src/cli/commands/slice.ts +48 -48
  13. package/src/cli/commands/sync.ts +31 -31
  14. package/src/cli/index.ts +210 -210
  15. package/src/cli/templates/hooks.ts +75 -75
  16. package/src/cli/templates/rules.ts +38 -38
  17. package/src/cli/templates/skill.ts +69 -69
  18. package/src/core/boundary/evaluator.ts +232 -210
  19. package/src/core/config/loader.ts +97 -97
  20. package/src/core/config/schema.ts +39 -39
  21. package/src/core/database/client.ts +44 -44
  22. package/src/core/database/repositories/dependency.repository.ts +366 -349
  23. package/src/core/database/repositories/domain.repository.ts +218 -198
  24. package/src/core/database/repositories/file.repository.ts +116 -106
  25. package/src/core/database/repositories/meta.repository.ts +33 -33
  26. package/src/core/database/repositories/symbol.repository.ts +443 -443
  27. package/src/core/database/repository.ts +264 -260
  28. package/src/core/database/schema.ts +153 -153
  29. package/src/core/discovery/topology-detector.ts +486 -486
  30. package/src/core/ingestion/hasher.ts +5 -5
  31. package/src/core/ingestion/pipeline.ts +584 -535
  32. package/src/core/parser/boundary-tracker.ts +288 -288
  33. package/src/core/parser/extractors/base.ts +62 -62
  34. package/src/core/parser/extractors/blade.ts +158 -158
  35. package/src/core/parser/extractors/frontend.ts +194 -194
  36. package/src/core/parser/extractors/go.ts +229 -180
  37. package/src/core/parser/extractors/laravel-semantic.ts +1039 -901
  38. package/src/core/parser/extractors/mcp-cli-semantic.ts +199 -199
  39. package/src/core/parser/extractors/nestjs-semantic.ts +119 -119
  40. package/src/core/parser/extractors/php.ts +153 -153
  41. package/src/core/parser/extractors/python.ts +228 -228
  42. package/src/core/parser/extractors/registry.ts +70 -70
  43. package/src/core/parser/extractors/semantic-extractor.interface.ts +21 -21
  44. package/src/core/parser/extractors/typescript.ts +181 -181
  45. package/src/core/parser/tree-sitter.ts +41 -41
  46. package/src/core/resolver/call-graph-tracer.ts +666 -668
  47. package/src/core/resolver/module-resolver.ts +408 -342
  48. package/src/core/resolver/path-resolver.ts +147 -147
  49. package/src/core/resolver/symbol-locator.ts +543 -543
  50. package/src/core/resolver/vertical-slice-tracer.ts +301 -285
  51. package/src/core/session/session-manager.ts +56 -56
  52. package/src/core/telemetry/telemetry.ts +86 -86
  53. package/src/index.ts +21 -21
  54. package/src/mcp/schemas.ts +578 -286
  55. package/src/mcp/server.ts +875 -716
  56. package/src/mcp/tools/check-boundary.ts +171 -152
  57. package/src/mcp/tools/get-domain-catalog.ts +145 -121
  58. package/src/mcp/tools/get-feature-context.ts +212 -116
  59. package/src/mcp/tools/get-symbol-hotspots.ts +60 -59
  60. package/src/mcp/tools/get-symbol-impact.ts +28 -26
  61. package/src/mcp/tools/get-symbol.ts +65 -63
  62. package/src/mcp/tools/locate-symbol.ts +171 -190
  63. package/src/mcp/tools/register-domain.ts +68 -64
  64. package/src/mcp/tools/register-feature.ts +100 -0
  65. package/src/mcp/tools/trace-vertical-slice.ts +74 -48
  66. package/src/types/index.ts +335 -315
  67. package/src/version.ts +3 -3
package/src/cli/index.ts CHANGED
@@ -1,210 +1,210 @@
1
- import { parseArgs } from "node:util";
2
- import { SessionManager } from "../core/session/session-manager.ts";
3
- import { SEPTUM_VERSION } from "../version.ts";
4
- import { handleCheckCommand } from "./commands/check.ts";
5
- import { handleHookCommand } from "./commands/hook.ts";
6
- import { handleIngestCommand } from "./commands/ingest.ts";
7
- import { handleInitCommand } from "./commands/init.ts";
8
- import { handleTopologyCommand } from "./commands/topology.ts";
9
- import { handleLocateCommand } from "./commands/locate.ts";
10
- import { handleQueryCommand } from "./commands/query.ts";
11
- import { handleServeCommand } from "./commands/serve.ts";
12
- import { handleSliceCommand } from "./commands/slice.ts";
13
- import { handleSyncCommand } from "./commands/sync.ts";
14
-
15
- export async function runCLI(argv: string[]): Promise<void> {
16
- let parsed;
17
- try {
18
- parsed = parseArgs({
19
- args: argv.slice(2),
20
- options: {
21
- help: { type: "boolean", short: "h" },
22
- version: { type: "boolean", short: "v" },
23
- force: { type: "boolean", short: "f" },
24
- json: { type: "boolean" },
25
- strict: { type: "boolean" },
26
- staged: { type: "boolean" },
27
- domain: { type: "string", short: "d" },
28
- archetype: { type: "string", short: "a" },
29
- feature: { type: "string" },
30
- },
31
- allowPositionals: true,
32
- strict: false,
33
- });
34
- } catch (err) {
35
- const message = err instanceof Error ? err.message : String(err);
36
- console.error(`\x1b[31m[Septum Error]\x1b[0m ${message}`);
37
- process.exit(1);
38
- }
39
-
40
- const { values: flags, positionals } = parsed;
41
- const command = positionals[0];
42
-
43
- if (flags.version || command === "version") {
44
- console.log(`Septum v${SEPTUM_VERSION}`);
45
- return;
46
- }
47
-
48
- if (flags.help || !command || command === "help") {
49
- printHelp();
50
- return;
51
- }
52
-
53
- try {
54
- switch (command) {
55
- case "init": {
56
- const force = Boolean(flags.force);
57
- await handleInitCommand(force);
58
- break;
59
- }
60
-
61
- case "ingest": {
62
- await handleIngestCommand();
63
- break;
64
- }
65
-
66
- case "sync": {
67
- const json = Boolean(flags.json);
68
- await handleSyncCommand({ json });
69
- break;
70
- }
71
-
72
- case "query": {
73
- const domainName = positionals[1];
74
- const archetype = typeof flags.archetype === "string" ? flags.archetype : undefined;
75
- const jsonOutput = Boolean(flags.json);
76
- await handleQueryCommand(domainName, archetype, jsonOutput);
77
- break;
78
- }
79
-
80
- case "locate": {
81
- const query = positionals[1];
82
- if (!query) {
83
- console.error("Usage: septum locate <symbol-or-error> [--domain <domain>] [--json]");
84
- process.exit(1);
85
- }
86
- const domain = typeof flags.domain === "string" ? flags.domain : undefined;
87
- const json = Boolean(flags.json);
88
- await handleLocateCommand(query, { domain, json });
89
- break;
90
- }
91
-
92
- case "slice": {
93
- const query = positionals[1];
94
- if (!query) {
95
- console.error("Usage: septum slice <route-or-intent> [--json]");
96
- process.exit(1);
97
- }
98
- const json = Boolean(flags.json);
99
- await handleSliceCommand(query, { json });
100
- break;
101
- }
102
-
103
- case "check": {
104
- const strict = Boolean(flags.strict);
105
- const staged = Boolean(flags.staged);
106
- const feature = typeof flags.feature === "string" ? flags.feature : undefined;
107
- await handleCheckCommand({ strict, staged, feature });
108
- break;
109
- }
110
-
111
- case "serve": {
112
- await handleServeCommand();
113
- break;
114
- }
115
-
116
- case "topology":
117
- case "env": {
118
- await handleTopologyCommand(positionals[1], positionals[2], positionals[3], positionals[4], positionals[5]);
119
- break;
120
- }
121
-
122
- case "feature": {
123
- const sub = positionals[1];
124
- if (sub === "clear") {
125
- const cleared = SessionManager.clearActiveSession(process.cwd());
126
- if (cleared) {
127
- console.log("✓ Active feature session successfully cleared.");
128
- } else {
129
- console.log("ℹ No active feature session found.");
130
- }
131
- } else if (sub === "status" || !sub) {
132
- const current = SessionManager.getActiveSession(process.cwd());
133
- if (current) {
134
- console.log(`\nActive Feature Session:`);
135
- console.log(`▶ Feature Key : ${current.feature_key}`);
136
- console.log(`▶ Domain : ${current.domain}`);
137
- console.log(`▶ Locked At : ${current.locked_at}`);
138
- console.log(`▶ Touchpoints : ${current.touchpoints.join(", ")}\n`);
139
- } else {
140
- console.log("ℹ No active feature session. All domain files accessible according to boundary rules.");
141
- }
142
- } else {
143
- console.error(`Unknown feature subcommand: '${sub}'. Use 'status' or 'clear'.`);
144
- process.exit(1);
145
- }
146
- break;
147
- }
148
-
149
- case "hook": {
150
- await handleHookCommand(argv.slice(2));
151
- break;
152
- }
153
-
154
- default: {
155
- console.error(`[Septum] Unknown command: '${command}'`);
156
- console.error("Run 'septum --help' for available commands.");
157
- process.exit(1);
158
- }
159
- }
160
- } catch (err) {
161
- const message = err instanceof Error ? err.message : String(err);
162
- console.error(`\x1b[31m[Septum Error]\x1b[0m ${message}`);
163
- process.exit(1);
164
- }
165
- }
166
-
167
- function printHelp(): void {
168
- console.log(`
169
- Septum — Deterministic Bounded-Context & Structural File Catalog
170
- Version: v${SEPTUM_VERSION}
171
-
172
- USAGE:
173
- septum <command> [options]
174
- septum [flags]
175
-
176
- COMMANDS:
177
- Catalog & Ingestion:
178
- init Initialize configuration, gitignore, pre-commit hook, and catalog
179
- Flags: -f, --force
180
- ingest Full AST scan and synchronization to SQLite database
181
- sync Incremental fast synchronization of modified files
182
- Flags: --json
183
-
184
- Structural Discovery:
185
- query [domain] Query structural catalog for a domain or whole project
186
- Flags: -a, --archetype <name>, --json
187
- locate <query> Locate symbol, class, interface, method, or error source
188
- Flags: -d, --domain <name>, --json
189
- slice <route|intent> Trace end-to-end vertical execution slice for route/intent
190
- Flags: --json
191
-
192
- Boundary & Enforcement:
193
- check Audit codebase for cross-domain boundary violations
194
- Flags: --strict, --staged, --feature <name>
195
- feature [status|clear] View or release active feature context session lock
196
- hook [subhook] Internal pre-tool guardrail hook (e.g. pre-write)
197
-
198
- Environment & Topology:
199
- topology [action] Inspect 6-layer environment topology & distributed nodes
200
- Subcommands: resolve <layer> <platform>, add-node, remove-node, clear
201
-
202
- Daemon & Protocol:
203
- serve Start Model Context Protocol (MCP) server over stdio
204
-
205
- GLOBAL FLAGS:
206
- -h, --help Show this help message
207
- -v, --version Show current version
208
- --json Output formatted JSON metrics / results
209
- `);
210
- }
1
+ import { parseArgs } from "node:util";
2
+ import { SessionManager } from "../core/session/session-manager.ts";
3
+ import { SEPTUM_VERSION } from "../version.ts";
4
+ import { handleCheckCommand } from "./commands/check.ts";
5
+ import { handleHookCommand } from "./commands/hook.ts";
6
+ import { handleIngestCommand } from "./commands/ingest.ts";
7
+ import { handleInitCommand } from "./commands/init.ts";
8
+ import { handleTopologyCommand } from "./commands/topology.ts";
9
+ import { handleLocateCommand } from "./commands/locate.ts";
10
+ import { handleQueryCommand } from "./commands/query.ts";
11
+ import { handleServeCommand } from "./commands/serve.ts";
12
+ import { handleSliceCommand } from "./commands/slice.ts";
13
+ import { handleSyncCommand } from "./commands/sync.ts";
14
+
15
+ export async function runCLI(argv: string[]): Promise<void> {
16
+ let parsed;
17
+ try {
18
+ parsed = parseArgs({
19
+ args: argv.slice(2),
20
+ options: {
21
+ help: { type: "boolean", short: "h" },
22
+ version: { type: "boolean", short: "v" },
23
+ force: { type: "boolean", short: "f" },
24
+ json: { type: "boolean" },
25
+ strict: { type: "boolean" },
26
+ staged: { type: "boolean" },
27
+ domain: { type: "string", short: "d" },
28
+ archetype: { type: "string", short: "a" },
29
+ feature: { type: "string" },
30
+ },
31
+ allowPositionals: true,
32
+ strict: false,
33
+ });
34
+ } catch (err) {
35
+ const message = err instanceof Error ? err.message : String(err);
36
+ console.error(`\x1b[31m[Septum Error]\x1b[0m ${message}`);
37
+ process.exit(1);
38
+ }
39
+
40
+ const { values: flags, positionals } = parsed;
41
+ const command = positionals[0];
42
+
43
+ if (flags.version || command === "version") {
44
+ console.log(`Septum v${SEPTUM_VERSION}`);
45
+ return;
46
+ }
47
+
48
+ if (flags.help || !command || command === "help") {
49
+ printHelp();
50
+ return;
51
+ }
52
+
53
+ try {
54
+ switch (command) {
55
+ case "init": {
56
+ const force = Boolean(flags.force);
57
+ await handleInitCommand(force);
58
+ break;
59
+ }
60
+
61
+ case "ingest": {
62
+ await handleIngestCommand();
63
+ break;
64
+ }
65
+
66
+ case "sync": {
67
+ const json = Boolean(flags.json);
68
+ await handleSyncCommand({ json });
69
+ break;
70
+ }
71
+
72
+ case "query": {
73
+ const domainName = positionals[1];
74
+ const archetype = typeof flags.archetype === "string" ? flags.archetype : undefined;
75
+ const jsonOutput = Boolean(flags.json);
76
+ await handleQueryCommand(domainName, archetype, jsonOutput);
77
+ break;
78
+ }
79
+
80
+ case "locate": {
81
+ const query = positionals[1];
82
+ if (!query) {
83
+ console.error("Usage: septum locate <symbol-or-error> [--domain <domain>] [--json]");
84
+ process.exit(1);
85
+ }
86
+ const domain = typeof flags.domain === "string" ? flags.domain : undefined;
87
+ const json = Boolean(flags.json);
88
+ await handleLocateCommand(query, { domain, json });
89
+ break;
90
+ }
91
+
92
+ case "slice": {
93
+ const query = positionals[1];
94
+ if (!query) {
95
+ console.error("Usage: septum slice <route-or-intent> [--json]");
96
+ process.exit(1);
97
+ }
98
+ const json = Boolean(flags.json);
99
+ await handleSliceCommand(query, { json });
100
+ break;
101
+ }
102
+
103
+ case "check": {
104
+ const strict = Boolean(flags.strict);
105
+ const staged = Boolean(flags.staged);
106
+ const feature = typeof flags.feature === "string" ? flags.feature : undefined;
107
+ await handleCheckCommand({ strict, staged, feature });
108
+ break;
109
+ }
110
+
111
+ case "serve": {
112
+ await handleServeCommand();
113
+ break;
114
+ }
115
+
116
+ case "topology":
117
+ case "env": {
118
+ await handleTopologyCommand(positionals[1], positionals[2], positionals[3], positionals[4], positionals[5]);
119
+ break;
120
+ }
121
+
122
+ case "feature": {
123
+ const sub = positionals[1];
124
+ if (sub === "clear") {
125
+ const cleared = SessionManager.clearActiveSession(process.cwd());
126
+ if (cleared) {
127
+ console.log("✓ Active feature session successfully cleared.");
128
+ } else {
129
+ console.log("ℹ No active feature session found.");
130
+ }
131
+ } else if (sub === "status" || !sub) {
132
+ const current = SessionManager.getActiveSession(process.cwd());
133
+ if (current) {
134
+ console.log(`\nActive Feature Session:`);
135
+ console.log(`▶ Feature Key : ${current.feature_key}`);
136
+ console.log(`▶ Domain : ${current.domain}`);
137
+ console.log(`▶ Locked At : ${current.locked_at}`);
138
+ console.log(`▶ Touchpoints : ${current.touchpoints.join(", ")}\n`);
139
+ } else {
140
+ console.log("ℹ No active feature session. All domain files accessible according to boundary rules.");
141
+ }
142
+ } else {
143
+ console.error(`Unknown feature subcommand: '${sub}'. Use 'status' or 'clear'.`);
144
+ process.exit(1);
145
+ }
146
+ break;
147
+ }
148
+
149
+ case "hook": {
150
+ await handleHookCommand(argv.slice(2));
151
+ break;
152
+ }
153
+
154
+ default: {
155
+ console.error(`[Septum] Unknown command: '${command}'`);
156
+ console.error("Run 'septum --help' for available commands.");
157
+ process.exit(1);
158
+ }
159
+ }
160
+ } catch (err) {
161
+ const message = err instanceof Error ? err.message : String(err);
162
+ console.error(`\x1b[31m[Septum Error]\x1b[0m ${message}`);
163
+ process.exit(1);
164
+ }
165
+ }
166
+
167
+ function printHelp(): void {
168
+ console.log(`
169
+ Septum — Deterministic Bounded-Context & Structural File Catalog
170
+ Version: v${SEPTUM_VERSION}
171
+
172
+ USAGE:
173
+ septum <command> [options]
174
+ septum [flags]
175
+
176
+ COMMANDS:
177
+ Catalog & Ingestion:
178
+ init Initialize configuration, gitignore, pre-commit hook, and catalog
179
+ Flags: -f, --force
180
+ ingest Full AST scan and synchronization to SQLite database
181
+ sync Incremental fast synchronization of modified files
182
+ Flags: --json
183
+
184
+ Structural Discovery:
185
+ query [domain] Query structural catalog for a domain or whole project
186
+ Flags: -a, --archetype <name>, --json
187
+ locate <query> Locate symbol, class, interface, method, or error source
188
+ Flags: -d, --domain <name>, --json
189
+ slice <route|intent> Trace end-to-end vertical execution slice for route/intent
190
+ Flags: --json
191
+
192
+ Boundary & Enforcement:
193
+ check Audit codebase for cross-domain boundary violations
194
+ Flags: --strict, --staged, --feature <name>
195
+ feature [status|clear] View or release active feature context session lock
196
+ hook [subhook] Internal pre-tool guardrail hook (e.g. pre-write)
197
+
198
+ Environment & Topology:
199
+ topology [action] Inspect 6-layer environment topology & distributed nodes
200
+ Subcommands: resolve <layer> <platform>, add-node, remove-node, clear
201
+
202
+ Daemon & Protocol:
203
+ serve Start Model Context Protocol (MCP) server over stdio
204
+
205
+ GLOBAL FLAGS:
206
+ -h, --help Show this help message
207
+ -v, --version Show current version
208
+ --json Output formatted JSON metrics / results
209
+ `);
210
+ }
@@ -1,75 +1,75 @@
1
- export const SEPTUM_HOOKS_CONFIG = {
2
- "septum-boundary-guard": {
3
- "PreToolUse": [
4
- {
5
- "matcher": "write_to_file|replace_file_content",
6
- "hooks": [
7
- {
8
- "type": "command",
9
- "command": "sh -c 'HOOK=\"$(git rev-parse --show-toplevel 2>/dev/null)/.agents/hooks/septum-pre-write.sh\"; if [ -f \"$HOOK\" ]; then exec \"$HOOK\"; else exit 0; fi'",
10
- "timeout": 10,
11
- },
12
- ],
13
- },
14
- ],
15
- "PostToolUse": [
16
- {
17
- "matcher": "write_to_file|replace_file_content",
18
- "hooks": [
19
- {
20
- "type": "command",
21
- "command": "sh -c 'HOOK=\"$(git rev-parse --show-toplevel 2>/dev/null)/.agents/hooks/septum-post-write.sh\"; if [ -f \"$HOOK\" ]; then exec \"$HOOK\"; else exit 0; fi'",
22
- "timeout": 15,
23
- },
24
- ],
25
- },
26
- ],
27
- },
28
- };
29
-
30
- 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
33
-
34
- ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
35
- if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
36
- exit 0
37
- fi
38
-
39
- # Delegate directly to Septum's active 3-gate hook engine
40
- if command -v bun >/dev/null 2>&1 && [ -f "$ROOT_DIR/bin/septum.ts" ]; then
41
- exec bun run "$ROOT_DIR/bin/septum.ts" hook pre-write
42
- elif command -v septum >/dev/null 2>&1; then
43
- exec septum hook pre-write
44
- elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
45
- exec "$ROOT_DIR/node_modules/.bin/septum" hook pre-write
46
- elif command -v bunx >/dev/null 2>&1; then
47
- exec bunx septum hook pre-write
48
- fi
49
-
50
- exit 0
51
- `;
52
-
53
- export const SEPTUM_POST_WRITE_SCRIPT = `#!/usr/bin/env sh
54
- # Septum Automated Incremental Post-Write Hook
55
- # Syncs modified AST into SQLite SSOT after file mutations
56
-
57
- ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
58
- if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
59
- exit 0
60
- fi
61
-
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 --json >/dev/null 2>&1 &
65
- elif command -v septum >/dev/null 2>&1; then
66
- septum sync --json >/dev/null 2>&1 &
67
- elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
68
- "$ROOT_DIR/node_modules/.bin/septum" sync --json >/dev/null 2>&1 &
69
- elif command -v bunx >/dev/null 2>&1; then
70
- bunx septum sync --json >/dev/null 2>&1 &
71
- fi
72
-
73
- exit 0
74
- `;
75
-
1
+ export const SEPTUM_HOOKS_CONFIG = {
2
+ "septum-boundary-guard": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "write_to_file|replace_file_content",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "sh -c 'HOOK=\"$(git rev-parse --show-toplevel 2>/dev/null)/.agents/hooks/septum-pre-write.sh\"; if [ -f \"$HOOK\" ]; then exec \"$HOOK\"; else exit 0; fi'",
10
+ "timeout": 10,
11
+ },
12
+ ],
13
+ },
14
+ ],
15
+ "PostToolUse": [
16
+ {
17
+ "matcher": "write_to_file|replace_file_content",
18
+ "hooks": [
19
+ {
20
+ "type": "command",
21
+ "command": "sh -c 'HOOK=\"$(git rev-parse --show-toplevel 2>/dev/null)/.agents/hooks/septum-post-write.sh\"; if [ -f \"$HOOK\" ]; then exec \"$HOOK\"; else exit 0; fi'",
22
+ "timeout": 15,
23
+ },
24
+ ],
25
+ },
26
+ ],
27
+ },
28
+ };
29
+
30
+ 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
33
+
34
+ ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
35
+ if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
36
+ exit 0
37
+ fi
38
+
39
+ # Delegate directly to Septum's active 3-gate hook engine
40
+ if command -v bun >/dev/null 2>&1 && [ -f "$ROOT_DIR/bin/septum.ts" ]; then
41
+ exec bun run "$ROOT_DIR/bin/septum.ts" hook pre-write
42
+ elif command -v septum >/dev/null 2>&1; then
43
+ exec septum hook pre-write
44
+ elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
45
+ exec "$ROOT_DIR/node_modules/.bin/septum" hook pre-write
46
+ elif command -v bunx >/dev/null 2>&1; then
47
+ exec bunx septum hook pre-write
48
+ fi
49
+
50
+ exit 0
51
+ `;
52
+
53
+ export const SEPTUM_POST_WRITE_SCRIPT = `#!/usr/bin/env sh
54
+ # Septum Automated Incremental Post-Write Hook
55
+ # Syncs modified AST into SQLite SSOT after file mutations
56
+
57
+ ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
58
+ if [ ! -f "$ROOT_DIR/.septum/septum.db" ]; then
59
+ exit 0
60
+ fi
61
+
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 --json >/dev/null 2>&1 &
65
+ elif command -v septum >/dev/null 2>&1; then
66
+ septum sync --json >/dev/null 2>&1 &
67
+ elif [ -f "$ROOT_DIR/node_modules/.bin/septum" ]; then
68
+ "$ROOT_DIR/node_modules/.bin/septum" sync --json >/dev/null 2>&1 &
69
+ elif command -v bunx >/dev/null 2>&1; then
70
+ bunx septum sync --json >/dev/null 2>&1 &
71
+ fi
72
+
73
+ exit 0
74
+ `;
75
+
@@ -1,38 +1,38 @@
1
- export const SEPTUM_RULES_TEMPLATE = `# Septum Bounded-Context & Anti-Poisoning Partition Rules
2
-
3
- > **Prinsip Utama:** Proyek ini menggunakan **Septum** untuk menegakkan batasan arsitektur (bounded-context) secara deterministik. Setiap AI Coding Agent wajib mematuhi aturan batas domain dan touchpoint berikut.
4
-
5
- ---
6
-
7
- ## 1. Single Source of Truth (SSOT) via Septum MCP
8
-
9
- Sebelum menulis atau mengedit file backend/domain:
10
- 1. **Dilarang Menebak Kontrak Domain:**
11
- Gunakan tool MCP \`septum_get_domain_catalog(domain: "...")\` untuk memeriksa file, arketipe, dan signature publik yang sah di dalam domain tersebut.
12
- 2. **Kunci Scope pada Fitur Aktif:**
13
- Jika sedang mengerjakan fitur spesifik yang terdaftar di katalog Septum, panggil \`septum_get_feature_context(feature: "...")\`.
14
- * **Wajib patuhi \`allowed_touchpoints\`:** Jangan menyentuh atau memodifikasi file di luar daftar yang diizinkan untuk fitur tersebut.
15
- * **Wajib gunakan ulang \`reuse_symbols\`:** Jangan membuat fungsi atau helper duplikat jika simbol tersebut sudah terdaftar di \`reuse_symbols\`.
16
-
17
- ---
18
-
19
- ## 2. Pre-Flight Boundary Check Sebelum Menulis Kode
20
-
21
- Sebelum mengeksekusi penulisan file (\`write_to_file\` atau \`replace_file_content\`):
22
- 1. Panggil tool MCP:
23
- \`\`\`json
24
- septum_check_boundary({
25
- "file_path": "path/ke/file.ts",
26
- "proposed_imports": ["target_import_statement"],
27
- "feature_key": "nama_fitur_opsional"
28
- })
29
- \`\`\`
30
- 2. **Rejection Handling:** Jika Septum mengembalikan status \`rejected\` (\`forbidden_dependency\`, \`disallowed_dependency\`, atau \`touchpoint_violation\`), **BATALKAN** rencana penulisan tersebut dan cari rute arsitektur yang sah (misal melalui Interface/Shared-Kernel yang diizinkan).
31
-
32
- ---
33
-
34
- ## 3. Anti Local Scope Myopia
35
-
36
- * Dilarang menghapus fungsi publik atau mengubah signature class hanya karena fungsi tersebut tidak terlihat dipanggil di file lokal yang sedang diedit.
37
- * Pastikan seluruh dependensi inbound/outbound mematuhi batasan domain yang terdaftar di database Septum (\`.septum/septum.db\`).
38
- `;
1
+ export const SEPTUM_RULES_TEMPLATE = `# Septum Bounded-Context & Anti-Poisoning Partition Rules
2
+
3
+ > **Prinsip Utama:** Proyek ini menggunakan **Septum** untuk menegakkan batasan arsitektur (bounded-context) secara deterministik. Setiap AI Coding Agent wajib mematuhi aturan batas domain dan touchpoint berikut.
4
+
5
+ ---
6
+
7
+ ## 1. Single Source of Truth (SSOT) via Septum MCP
8
+
9
+ Sebelum menulis atau mengedit file backend/domain:
10
+ 1. **Dilarang Menebak Kontrak Domain:**
11
+ Gunakan tool MCP \`septum_get_domain_catalog(domain: "...")\` untuk memeriksa file, arketipe, dan signature publik yang sah di dalam domain tersebut.
12
+ 2. **Kunci Scope pada Fitur Aktif:**
13
+ Jika sedang mengerjakan fitur spesifik yang terdaftar di katalog Septum, panggil \`septum_get_feature_context(feature: "...")\`.
14
+ * **Wajib patuhi \`allowed_touchpoints\`:** Jangan menyentuh atau memodifikasi file di luar daftar yang diizinkan untuk fitur tersebut.
15
+ * **Wajib gunakan ulang \`reuse_symbols\`:** Jangan membuat fungsi atau helper duplikat jika simbol tersebut sudah terdaftar di \`reuse_symbols\`.
16
+
17
+ ---
18
+
19
+ ## 2. Pre-Flight Boundary Check Sebelum Menulis Kode
20
+
21
+ Sebelum mengeksekusi penulisan file (\`write_to_file\` atau \`replace_file_content\`):
22
+ 1. Panggil tool MCP:
23
+ \`\`\`json
24
+ septum_check_boundary({
25
+ "file_path": "path/ke/file.ts",
26
+ "proposed_imports": ["target_import_statement"],
27
+ "feature_key": "nama_fitur_opsional"
28
+ })
29
+ \`\`\`
30
+ 2. **Rejection Handling:** Jika Septum mengembalikan status \`rejected\` (\`forbidden_dependency\`, \`disallowed_dependency\`, atau \`touchpoint_violation\`), **BATALKAN** rencana penulisan tersebut dan cari rute arsitektur yang sah (misal melalui Interface/Shared-Kernel yang diizinkan).
31
+
32
+ ---
33
+
34
+ ## 3. Anti Local Scope Myopia
35
+
36
+ * Dilarang menghapus fungsi publik atau mengubah signature class hanya karena fungsi tersebut tidak terlihat dipanggil di file lokal yang sedang diedit.
37
+ * Pastikan seluruh dependensi inbound/outbound mematuhi batasan domain yang terdaftar di database Septum (\`.septum/septum.db\`).
38
+ `;