sqlew 1.0.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 (47) hide show
  1. package/ARCHITECTURE.md +636 -0
  2. package/CHANGELOG.md +107 -0
  3. package/LICENSE +21 -0
  4. package/README.md +359 -0
  5. package/assets/schema.sql +320 -0
  6. package/assets/sqlew-logo.png +0 -0
  7. package/dist/constants.d.ts +146 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +230 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/database.d.ts +94 -0
  12. package/dist/database.d.ts.map +1 -0
  13. package/dist/database.js +214 -0
  14. package/dist/database.js.map +1 -0
  15. package/dist/index.d.ts +7 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +771 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/schema.d.ts +50 -0
  20. package/dist/schema.d.ts.map +1 -0
  21. package/dist/schema.js +161 -0
  22. package/dist/schema.js.map +1 -0
  23. package/dist/tools/constraints.d.ts +29 -0
  24. package/dist/tools/constraints.d.ts.map +1 -0
  25. package/dist/tools/constraints.js +192 -0
  26. package/dist/tools/constraints.js.map +1 -0
  27. package/dist/tools/context.d.ts +56 -0
  28. package/dist/tools/context.d.ts.map +1 -0
  29. package/dist/tools/context.js +442 -0
  30. package/dist/tools/context.js.map +1 -0
  31. package/dist/tools/files.d.ts +30 -0
  32. package/dist/tools/files.d.ts.map +1 -0
  33. package/dist/tools/files.js +201 -0
  34. package/dist/tools/files.js.map +1 -0
  35. package/dist/tools/messaging.d.ts +50 -0
  36. package/dist/tools/messaging.d.ts.map +1 -0
  37. package/dist/tools/messaging.js +151 -0
  38. package/dist/tools/messaging.js.map +1 -0
  39. package/dist/tools/utils.d.ts +29 -0
  40. package/dist/tools/utils.d.ts.map +1 -0
  41. package/dist/tools/utils.js +131 -0
  42. package/dist/tools/utils.js.map +1 -0
  43. package/dist/types.d.ts +388 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +50 -0
  46. package/dist/types.js.map +1 -0
  47. package/package.json +60 -0
@@ -0,0 +1,320 @@
1
+ -- MCP Shared Context Server - Database Schema
2
+ -- Version: 1.1.0 (with metadata support)
3
+
4
+ -- ============================================================================
5
+ -- マスターテーブル群(正規化)
6
+ -- ============================================================================
7
+
8
+ -- エージェント管理
9
+ CREATE TABLE IF NOT EXISTS agents (
10
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
11
+ name TEXT UNIQUE NOT NULL
12
+ );
13
+
14
+ -- ファイルパス管理
15
+ CREATE TABLE IF NOT EXISTS files (
16
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17
+ path TEXT UNIQUE NOT NULL
18
+ );
19
+
20
+ -- コンテキストキー管理
21
+ CREATE TABLE IF NOT EXISTS context_keys (
22
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
23
+ key TEXT UNIQUE NOT NULL
24
+ );
25
+
26
+ -- 制約カテゴリ管理
27
+ CREATE TABLE IF NOT EXISTS constraint_categories (
28
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
29
+ name TEXT UNIQUE NOT NULL
30
+ );
31
+
32
+ -- レイヤー管理
33
+ CREATE TABLE IF NOT EXISTS layers (
34
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
35
+ name TEXT UNIQUE NOT NULL
36
+ );
37
+
38
+ -- タグ管理
39
+ CREATE TABLE IF NOT EXISTS tags (
40
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
41
+ name TEXT UNIQUE NOT NULL
42
+ );
43
+
44
+ -- スコープ管理(モジュール・コンポーネント)
45
+ CREATE TABLE IF NOT EXISTS scopes (
46
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
47
+ name TEXT UNIQUE NOT NULL
48
+ );
49
+
50
+ -- ============================================================================
51
+ -- トランザクションテーブル群
52
+ -- ============================================================================
53
+
54
+ -- 決定事項(文字列値)
55
+ CREATE TABLE IF NOT EXISTS decisions (
56
+ key_id INTEGER PRIMARY KEY REFERENCES context_keys(id),
57
+ value TEXT NOT NULL,
58
+ agent_id INTEGER REFERENCES agents(id),
59
+ layer_id INTEGER REFERENCES layers(id),
60
+ version TEXT DEFAULT '1.0.0',
61
+ status INTEGER DEFAULT 1, -- 1=active, 2=deprecated, 3=draft
62
+ ts INTEGER DEFAULT (unixepoch())
63
+ );
64
+
65
+ -- 決定事項(数値)
66
+ CREATE TABLE IF NOT EXISTS decisions_numeric (
67
+ key_id INTEGER PRIMARY KEY REFERENCES context_keys(id),
68
+ value REAL NOT NULL,
69
+ agent_id INTEGER REFERENCES agents(id),
70
+ layer_id INTEGER REFERENCES layers(id),
71
+ version TEXT DEFAULT '1.0.0',
72
+ status INTEGER DEFAULT 1,
73
+ ts INTEGER DEFAULT (unixepoch())
74
+ );
75
+
76
+ -- 決定事項のバージョン履歴
77
+ CREATE TABLE IF NOT EXISTS decision_history (
78
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
79
+ key_id INTEGER REFERENCES context_keys(id),
80
+ version TEXT NOT NULL,
81
+ value TEXT NOT NULL,
82
+ agent_id INTEGER REFERENCES agents(id),
83
+ ts INTEGER NOT NULL
84
+ );
85
+
86
+ -- 決定事項へのタグ付け(多対多)
87
+ CREATE TABLE IF NOT EXISTS decision_tags (
88
+ decision_key_id INTEGER REFERENCES context_keys(id),
89
+ tag_id INTEGER REFERENCES tags(id),
90
+ PRIMARY KEY (decision_key_id, tag_id)
91
+ );
92
+
93
+ -- 決定事項のスコープ(多対多)
94
+ CREATE TABLE IF NOT EXISTS decision_scopes (
95
+ decision_key_id INTEGER REFERENCES context_keys(id),
96
+ scope_id INTEGER REFERENCES scopes(id),
97
+ PRIMARY KEY (decision_key_id, scope_id)
98
+ );
99
+
100
+ -- エージェント間メッセージ
101
+ CREATE TABLE IF NOT EXISTS agent_messages (
102
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
103
+ from_agent_id INTEGER NOT NULL REFERENCES agents(id),
104
+ to_agent_id INTEGER REFERENCES agents(id), -- NULL = broadcast
105
+ msg_type INTEGER NOT NULL, -- 1=decision, 2=warning, 3=request, 4=info
106
+ priority INTEGER DEFAULT 2, -- 1=low, 2=medium, 3=high, 4=critical
107
+ payload TEXT, -- JSON文字列(必要な場合のみ)
108
+ ts INTEGER DEFAULT (unixepoch()),
109
+ read INTEGER DEFAULT 0
110
+ );
111
+
112
+ -- ファイル変更履歴
113
+ CREATE TABLE IF NOT EXISTS file_changes (
114
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
115
+ file_id INTEGER NOT NULL REFERENCES files(id),
116
+ agent_id INTEGER NOT NULL REFERENCES agents(id),
117
+ layer_id INTEGER REFERENCES layers(id),
118
+ change_type INTEGER NOT NULL, -- 1=created, 2=modified, 3=deleted
119
+ description TEXT,
120
+ ts INTEGER DEFAULT (unixepoch())
121
+ );
122
+
123
+ -- 制約・要件
124
+ CREATE TABLE IF NOT EXISTS constraints (
125
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
126
+ category_id INTEGER NOT NULL REFERENCES constraint_categories(id),
127
+ layer_id INTEGER REFERENCES layers(id),
128
+ constraint_text TEXT NOT NULL,
129
+ priority INTEGER DEFAULT 2, -- 1=low, 2=medium, 3=high, 4=critical
130
+ active INTEGER DEFAULT 1,
131
+ created_by INTEGER REFERENCES agents(id),
132
+ ts INTEGER DEFAULT (unixepoch())
133
+ );
134
+
135
+ -- 制約へのタグ付け(多対多)
136
+ CREATE TABLE IF NOT EXISTS constraint_tags (
137
+ constraint_id INTEGER REFERENCES constraints(id),
138
+ tag_id INTEGER REFERENCES tags(id),
139
+ PRIMARY KEY (constraint_id, tag_id)
140
+ );
141
+
142
+ -- ============================================================================
143
+ -- インデックス
144
+ -- ============================================================================
145
+
146
+ CREATE INDEX IF NOT EXISTS idx_decisions_ts ON decisions(ts DESC);
147
+ CREATE INDEX IF NOT EXISTS idx_decisions_layer ON decisions(layer_id);
148
+ CREATE INDEX IF NOT EXISTS idx_decisions_status ON decisions(status);
149
+ CREATE INDEX IF NOT EXISTS idx_messages_to_agent ON agent_messages(to_agent_id, read);
150
+ CREATE INDEX IF NOT EXISTS idx_messages_ts ON agent_messages(ts DESC);
151
+ CREATE INDEX IF NOT EXISTS idx_messages_priority ON agent_messages(priority DESC);
152
+ CREATE INDEX IF NOT EXISTS idx_file_changes_ts ON file_changes(ts DESC);
153
+ CREATE INDEX IF NOT EXISTS idx_file_changes_file ON file_changes(file_id);
154
+ CREATE INDEX IF NOT EXISTS idx_file_changes_layer ON file_changes(layer_id);
155
+ CREATE INDEX IF NOT EXISTS idx_constraints_active ON constraints(active, category_id);
156
+ CREATE INDEX IF NOT EXISTS idx_constraints_priority ON constraints(priority DESC);
157
+ CREATE INDEX IF NOT EXISTS idx_decision_tags_tag ON decision_tags(tag_id);
158
+ CREATE INDEX IF NOT EXISTS idx_decision_scopes_scope ON decision_scopes(scope_id);
159
+
160
+ -- ============================================================================
161
+ -- ビュー(トークン効率化)
162
+ -- ============================================================================
163
+
164
+ -- タグ付き決定事項(最も効率的なビュー)
165
+ CREATE VIEW IF NOT EXISTS tagged_decisions AS
166
+ SELECT
167
+ k.key,
168
+ d.value,
169
+ d.version,
170
+ CASE d.status WHEN 1 THEN 'active' WHEN 2 THEN 'deprecated' ELSE 'draft' END as status,
171
+ l.name as layer,
172
+ (SELECT GROUP_CONCAT(t2.name, ',') FROM decision_tags dt2
173
+ JOIN tags t2 ON dt2.tag_id = t2.id
174
+ WHERE dt2.decision_key_id = d.key_id) as tags,
175
+ (SELECT GROUP_CONCAT(s2.name, ',') FROM decision_scopes ds2
176
+ JOIN scopes s2 ON ds2.scope_id = s2.id
177
+ WHERE ds2.decision_key_id = d.key_id) as scopes,
178
+ a.name as decided_by,
179
+ datetime(d.ts, 'unixepoch') as updated
180
+ FROM decisions d
181
+ JOIN context_keys k ON d.key_id = k.id
182
+ LEFT JOIN layers l ON d.layer_id = l.id
183
+ LEFT JOIN agents a ON d.agent_id = a.id;
184
+
185
+ -- アクティブなコンテキスト(直近1時間、アクティブのみ)
186
+ CREATE VIEW IF NOT EXISTS active_context AS
187
+ SELECT
188
+ k.key,
189
+ d.value,
190
+ d.version,
191
+ l.name as layer,
192
+ a.name as decided_by,
193
+ datetime(d.ts, 'unixepoch') as updated
194
+ FROM decisions d
195
+ JOIN context_keys k ON d.key_id = k.id
196
+ LEFT JOIN layers l ON d.layer_id = l.id
197
+ LEFT JOIN agents a ON d.agent_id = a.id
198
+ WHERE d.status = 1 AND d.ts > unixepoch() - 3600
199
+ ORDER BY d.ts DESC;
200
+
201
+ -- レイヤー別サマリー
202
+ CREATE VIEW IF NOT EXISTS layer_summary AS
203
+ SELECT
204
+ l.name as layer,
205
+ COUNT(DISTINCT d.key_id) as decisions_count,
206
+ COUNT(DISTINCT fc.id) as file_changes_count,
207
+ COUNT(DISTINCT c.id) as constraints_count
208
+ FROM layers l
209
+ LEFT JOIN decisions d ON l.id = d.layer_id AND d.status = 1
210
+ LEFT JOIN file_changes fc ON l.id = fc.layer_id AND fc.ts > unixepoch() - 3600
211
+ LEFT JOIN constraints c ON l.id = c.layer_id AND c.active = 1
212
+ GROUP BY l.id;
213
+
214
+ -- 優先度別未読メッセージ
215
+ CREATE VIEW IF NOT EXISTS unread_messages_by_priority AS
216
+ SELECT
217
+ a.name as agent,
218
+ CASE m.priority WHEN 4 THEN 'critical' WHEN 3 THEN 'high' WHEN 2 THEN 'medium' ELSE 'low' END as priority,
219
+ COUNT(*) as count
220
+ FROM agent_messages m
221
+ JOIN agents a ON m.to_agent_id = a.id
222
+ WHERE m.read = 0
223
+ GROUP BY m.to_agent_id, m.priority
224
+ ORDER BY m.priority DESC;
225
+
226
+ -- 最近のファイル変更(レイヤー付き)
227
+ CREATE VIEW IF NOT EXISTS recent_file_changes AS
228
+ SELECT
229
+ f.path,
230
+ a.name as changed_by,
231
+ l.name as layer,
232
+ CASE fc.change_type WHEN 1 THEN 'created' WHEN 2 THEN 'modified' ELSE 'deleted' END as change_type,
233
+ fc.description,
234
+ datetime(fc.ts, 'unixepoch') as changed_at
235
+ FROM file_changes fc
236
+ JOIN files f ON fc.file_id = f.id
237
+ JOIN agents a ON fc.agent_id = a.id
238
+ LEFT JOIN layers l ON fc.layer_id = l.id
239
+ WHERE fc.ts > unixepoch() - 3600
240
+ ORDER BY fc.ts DESC;
241
+
242
+ -- タグ付き制約
243
+ CREATE VIEW IF NOT EXISTS tagged_constraints AS
244
+ SELECT
245
+ c.id,
246
+ cc.name as category,
247
+ l.name as layer,
248
+ c.constraint_text,
249
+ CASE c.priority WHEN 4 THEN 'critical' WHEN 3 THEN 'high' WHEN 2 THEN 'medium' ELSE 'low' END as priority,
250
+ (SELECT GROUP_CONCAT(t2.name, ',') FROM constraint_tags ct2
251
+ JOIN tags t2 ON ct2.tag_id = t2.id
252
+ WHERE ct2.constraint_id = c.id) as tags,
253
+ a.name as created_by,
254
+ datetime(c.ts, 'unixepoch') as created_at
255
+ FROM constraints c
256
+ JOIN constraint_categories cc ON c.category_id = cc.id
257
+ LEFT JOIN layers l ON c.layer_id = l.id
258
+ LEFT JOIN agents a ON c.created_by = a.id
259
+ WHERE c.active = 1
260
+ ORDER BY c.priority DESC, cc.name, c.ts DESC;
261
+
262
+ -- ============================================================================
263
+ -- トリガー(自動処理)
264
+ -- ============================================================================
265
+
266
+ -- 古いメッセージの自動削除(24時間以上前)
267
+ CREATE TRIGGER IF NOT EXISTS cleanup_old_messages
268
+ AFTER INSERT ON agent_messages
269
+ BEGIN
270
+ DELETE FROM agent_messages
271
+ WHERE ts < unixepoch() - 86400;
272
+ END;
273
+
274
+ -- 古いファイル変更履歴の削除(7日以上前)
275
+ CREATE TRIGGER IF NOT EXISTS cleanup_old_file_changes
276
+ AFTER INSERT ON file_changes
277
+ BEGIN
278
+ DELETE FROM file_changes
279
+ WHERE ts < unixepoch() - 604800;
280
+ END;
281
+
282
+ -- バージョン履歴の自動記録
283
+ CREATE TRIGGER IF NOT EXISTS record_decision_history
284
+ AFTER UPDATE ON decisions
285
+ WHEN OLD.value != NEW.value OR OLD.version != NEW.version
286
+ BEGIN
287
+ INSERT INTO decision_history (key_id, version, value, agent_id, ts)
288
+ VALUES (OLD.key_id, OLD.version, OLD.value, OLD.agent_id, OLD.ts);
289
+ END;
290
+
291
+ -- ============================================================================
292
+ -- 初期データ
293
+ -- ============================================================================
294
+
295
+ -- 標準レイヤー
296
+ INSERT OR IGNORE INTO layers (name) VALUES
297
+ ('presentation'),
298
+ ('business'),
299
+ ('data'),
300
+ ('infrastructure'),
301
+ ('cross-cutting');
302
+
303
+ -- 標準カテゴリ
304
+ INSERT OR IGNORE INTO constraint_categories (name) VALUES
305
+ ('performance'),
306
+ ('architecture'),
307
+ ('security');
308
+
309
+ -- よくあるタグ
310
+ INSERT OR IGNORE INTO tags (name) VALUES
311
+ ('authentication'),
312
+ ('authorization'),
313
+ ('performance'),
314
+ ('security'),
315
+ ('api'),
316
+ ('database'),
317
+ ('caching'),
318
+ ('testing'),
319
+ ('validation'),
320
+ ('error-handling');
Binary file
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Constants for MCP Shared Context Server
3
+ * Enum mappings, default values, and standard data
4
+ */
5
+ import { Status, MessageType, Priority, ChangeType } from './types.js';
6
+ /**
7
+ * Default database folder (relative to project root)
8
+ */
9
+ export declare const DEFAULT_DB_FOLDER = ".sqlew";
10
+ /**
11
+ * Default database file name
12
+ */
13
+ export declare const DEFAULT_DB_FILENAME = "sqlew.db";
14
+ /**
15
+ * Default database path (relative to project root)
16
+ */
17
+ export declare const DEFAULT_DB_PATH = ".sqlew/sqlew.db";
18
+ /**
19
+ * Database busy timeout (milliseconds)
20
+ */
21
+ export declare const DB_BUSY_TIMEOUT = 5000;
22
+ /**
23
+ * Map status integer to string
24
+ */
25
+ export declare const STATUS_TO_STRING: Record<Status, string>;
26
+ /**
27
+ * Map status string to integer
28
+ */
29
+ export declare const STRING_TO_STATUS: Record<string, Status>;
30
+ /**
31
+ * Map message type integer to string
32
+ */
33
+ export declare const MESSAGE_TYPE_TO_STRING: Record<MessageType, string>;
34
+ /**
35
+ * Map message type string to integer
36
+ */
37
+ export declare const STRING_TO_MESSAGE_TYPE: Record<string, MessageType>;
38
+ /**
39
+ * Map priority integer to string
40
+ */
41
+ export declare const PRIORITY_TO_STRING: Record<Priority, string>;
42
+ /**
43
+ * Map priority string to integer
44
+ */
45
+ export declare const STRING_TO_PRIORITY: Record<string, Priority>;
46
+ /**
47
+ * Map change type integer to string
48
+ */
49
+ export declare const CHANGE_TYPE_TO_STRING: Record<ChangeType, string>;
50
+ /**
51
+ * Map change type string to integer
52
+ */
53
+ export declare const STRING_TO_CHANGE_TYPE: Record<string, ChangeType>;
54
+ /**
55
+ * Default version for new decisions
56
+ */
57
+ export declare const DEFAULT_VERSION = "1.0.0";
58
+ /**
59
+ * Default status for new decisions
60
+ */
61
+ export declare const DEFAULT_STATUS = Status.ACTIVE;
62
+ /**
63
+ * Default priority for messages and constraints
64
+ */
65
+ export declare const DEFAULT_PRIORITY = Priority.MEDIUM;
66
+ /**
67
+ * Default active state for constraints
68
+ */
69
+ export declare const DEFAULT_ACTIVE = 1;
70
+ /**
71
+ * 1 hour in seconds
72
+ */
73
+ export declare const ONE_HOUR = 3600;
74
+ /**
75
+ * 24 hours in seconds
76
+ */
77
+ export declare const ONE_DAY = 86400;
78
+ /**
79
+ * 7 days in seconds
80
+ */
81
+ export declare const ONE_WEEK = 604800;
82
+ /**
83
+ * Default retention period for messages (24 hours)
84
+ */
85
+ export declare const MESSAGE_RETENTION_SECONDS = 86400;
86
+ /**
87
+ * Default retention period for file changes (7 days)
88
+ */
89
+ export declare const FILE_CHANGE_RETENTION_SECONDS = 604800;
90
+ /**
91
+ * Default active context window (1 hour)
92
+ */
93
+ export declare const ACTIVE_CONTEXT_WINDOW_SECONDS = 3600;
94
+ /**
95
+ * Standard architecture layers
96
+ */
97
+ export declare const STANDARD_LAYERS: readonly ["presentation", "business", "data", "infrastructure", "cross-cutting"];
98
+ export type StandardLayer = typeof STANDARD_LAYERS[number];
99
+ /**
100
+ * Standard constraint categories
101
+ */
102
+ export declare const STANDARD_CATEGORIES: readonly ["performance", "architecture", "security"];
103
+ export type StandardCategory = typeof STANDARD_CATEGORIES[number];
104
+ /**
105
+ * Common tags for decisions and constraints
106
+ */
107
+ export declare const COMMON_TAGS: readonly ["authentication", "authorization", "performance", "security", "api", "database", "caching", "testing", "validation", "error-handling"];
108
+ export type CommonTag = typeof COMMON_TAGS[number];
109
+ /**
110
+ * Default limit for query results
111
+ */
112
+ export declare const DEFAULT_QUERY_LIMIT = 100;
113
+ /**
114
+ * Default tag match mode
115
+ */
116
+ export declare const DEFAULT_TAG_MATCH_MODE = "OR";
117
+ /**
118
+ * Default hours to look back for file changes
119
+ */
120
+ export declare const DEFAULT_FILE_CHANGES_HOURS = 24;
121
+ /**
122
+ * SQLite boolean true value
123
+ */
124
+ export declare const SQLITE_TRUE = 1;
125
+ /**
126
+ * SQLite boolean false value
127
+ */
128
+ export declare const SQLITE_FALSE = 0;
129
+ export declare const ERROR_MESSAGES: {
130
+ readonly DB_INIT_FAILED: "Failed to initialize database";
131
+ readonly DB_CONNECTION_FAILED: "Failed to connect to database";
132
+ readonly SCHEMA_INIT_FAILED: "Failed to initialize schema";
133
+ readonly INVALID_ENUM_VALUE: "Invalid enum value";
134
+ readonly FOREIGN_KEY_VIOLATION: "Foreign key constraint violation";
135
+ readonly UNIQUE_CONSTRAINT_VIOLATION: "Unique constraint violation";
136
+ readonly INVALID_PARAMETER: "Invalid parameter";
137
+ readonly DECISION_NOT_FOUND: "Decision not found";
138
+ readonly MESSAGE_NOT_FOUND: "Message not found";
139
+ readonly CONSTRAINT_NOT_FOUND: "Constraint not found";
140
+ readonly AGENT_NOT_FOUND: "Agent not found";
141
+ readonly FILE_NOT_FOUND: "File not found";
142
+ readonly LAYER_NOT_FOUND: "Layer not found";
143
+ readonly TAG_NOT_FOUND: "Tag not found";
144
+ readonly SCOPE_NOT_FOUND: "Scope not found";
145
+ };
146
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMvE;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,eAAe,oBAAgD,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,eAAe,OAAO,CAAC;AAMpC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAInD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAInD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAK9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAK9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAKvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAKvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAI5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAI5D,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAMhC;;GAEG;AACH,eAAO,MAAM,QAAQ,OAAO,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,OAAO,QAAQ,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAS,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAU,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,6BAA6B,SAAW,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,6BAA6B,OAAW,CAAC;AAMtD;;GAEG;AACH,eAAO,MAAM,eAAe,kFAMlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAM3D;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAItB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAMlE;;GAEG;AACH,eAAO,MAAM,WAAW,kJAWd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAMnD;;GAEG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAM7C;;GAEG;AACH,eAAO,MAAM,WAAW,IAAI,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,YAAY,IAAI,CAAC;AAM9B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAgBjB,CAAC"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Constants for MCP Shared Context Server
3
+ * Enum mappings, default values, and standard data
4
+ */
5
+ import { Status, MessageType, Priority, ChangeType } from './types.js';
6
+ // ============================================================================
7
+ // Database Configuration
8
+ // ============================================================================
9
+ /**
10
+ * Default database folder (relative to project root)
11
+ */
12
+ export const DEFAULT_DB_FOLDER = '.sqlew';
13
+ /**
14
+ * Default database file name
15
+ */
16
+ export const DEFAULT_DB_FILENAME = 'sqlew.db';
17
+ /**
18
+ * Default database path (relative to project root)
19
+ */
20
+ export const DEFAULT_DB_PATH = `${DEFAULT_DB_FOLDER}/${DEFAULT_DB_FILENAME}`;
21
+ /**
22
+ * Database busy timeout (milliseconds)
23
+ */
24
+ export const DB_BUSY_TIMEOUT = 5000;
25
+ // ============================================================================
26
+ // Enum String Mappings
27
+ // ============================================================================
28
+ /**
29
+ * Map status integer to string
30
+ */
31
+ export const STATUS_TO_STRING = {
32
+ [Status.ACTIVE]: 'active',
33
+ [Status.DEPRECATED]: 'deprecated',
34
+ [Status.DRAFT]: 'draft',
35
+ };
36
+ /**
37
+ * Map status string to integer
38
+ */
39
+ export const STRING_TO_STATUS = {
40
+ 'active': Status.ACTIVE,
41
+ 'deprecated': Status.DEPRECATED,
42
+ 'draft': Status.DRAFT,
43
+ };
44
+ /**
45
+ * Map message type integer to string
46
+ */
47
+ export const MESSAGE_TYPE_TO_STRING = {
48
+ [MessageType.DECISION]: 'decision',
49
+ [MessageType.WARNING]: 'warning',
50
+ [MessageType.REQUEST]: 'request',
51
+ [MessageType.INFO]: 'info',
52
+ };
53
+ /**
54
+ * Map message type string to integer
55
+ */
56
+ export const STRING_TO_MESSAGE_TYPE = {
57
+ 'decision': MessageType.DECISION,
58
+ 'warning': MessageType.WARNING,
59
+ 'request': MessageType.REQUEST,
60
+ 'info': MessageType.INFO,
61
+ };
62
+ /**
63
+ * Map priority integer to string
64
+ */
65
+ export const PRIORITY_TO_STRING = {
66
+ [Priority.LOW]: 'low',
67
+ [Priority.MEDIUM]: 'medium',
68
+ [Priority.HIGH]: 'high',
69
+ [Priority.CRITICAL]: 'critical',
70
+ };
71
+ /**
72
+ * Map priority string to integer
73
+ */
74
+ export const STRING_TO_PRIORITY = {
75
+ 'low': Priority.LOW,
76
+ 'medium': Priority.MEDIUM,
77
+ 'high': Priority.HIGH,
78
+ 'critical': Priority.CRITICAL,
79
+ };
80
+ /**
81
+ * Map change type integer to string
82
+ */
83
+ export const CHANGE_TYPE_TO_STRING = {
84
+ [ChangeType.CREATED]: 'created',
85
+ [ChangeType.MODIFIED]: 'modified',
86
+ [ChangeType.DELETED]: 'deleted',
87
+ };
88
+ /**
89
+ * Map change type string to integer
90
+ */
91
+ export const STRING_TO_CHANGE_TYPE = {
92
+ 'created': ChangeType.CREATED,
93
+ 'modified': ChangeType.MODIFIED,
94
+ 'deleted': ChangeType.DELETED,
95
+ };
96
+ // ============================================================================
97
+ // Default Values
98
+ // ============================================================================
99
+ /**
100
+ * Default version for new decisions
101
+ */
102
+ export const DEFAULT_VERSION = '1.0.0';
103
+ /**
104
+ * Default status for new decisions
105
+ */
106
+ export const DEFAULT_STATUS = Status.ACTIVE;
107
+ /**
108
+ * Default priority for messages and constraints
109
+ */
110
+ export const DEFAULT_PRIORITY = Priority.MEDIUM;
111
+ /**
112
+ * Default active state for constraints
113
+ */
114
+ export const DEFAULT_ACTIVE = 1;
115
+ // ============================================================================
116
+ // Time Constants (seconds)
117
+ // ============================================================================
118
+ /**
119
+ * 1 hour in seconds
120
+ */
121
+ export const ONE_HOUR = 3600;
122
+ /**
123
+ * 24 hours in seconds
124
+ */
125
+ export const ONE_DAY = 86400;
126
+ /**
127
+ * 7 days in seconds
128
+ */
129
+ export const ONE_WEEK = 604800;
130
+ /**
131
+ * Default retention period for messages (24 hours)
132
+ */
133
+ export const MESSAGE_RETENTION_SECONDS = ONE_DAY;
134
+ /**
135
+ * Default retention period for file changes (7 days)
136
+ */
137
+ export const FILE_CHANGE_RETENTION_SECONDS = ONE_WEEK;
138
+ /**
139
+ * Default active context window (1 hour)
140
+ */
141
+ export const ACTIVE_CONTEXT_WINDOW_SECONDS = ONE_HOUR;
142
+ // ============================================================================
143
+ // Standard Layers
144
+ // ============================================================================
145
+ /**
146
+ * Standard architecture layers
147
+ */
148
+ export const STANDARD_LAYERS = [
149
+ 'presentation',
150
+ 'business',
151
+ 'data',
152
+ 'infrastructure',
153
+ 'cross-cutting',
154
+ ];
155
+ // ============================================================================
156
+ // Standard Categories
157
+ // ============================================================================
158
+ /**
159
+ * Standard constraint categories
160
+ */
161
+ export const STANDARD_CATEGORIES = [
162
+ 'performance',
163
+ 'architecture',
164
+ 'security',
165
+ ];
166
+ // ============================================================================
167
+ // Common Tags
168
+ // ============================================================================
169
+ /**
170
+ * Common tags for decisions and constraints
171
+ */
172
+ export const COMMON_TAGS = [
173
+ 'authentication',
174
+ 'authorization',
175
+ 'performance',
176
+ 'security',
177
+ 'api',
178
+ 'database',
179
+ 'caching',
180
+ 'testing',
181
+ 'validation',
182
+ 'error-handling',
183
+ ];
184
+ // ============================================================================
185
+ // Query Defaults
186
+ // ============================================================================
187
+ /**
188
+ * Default limit for query results
189
+ */
190
+ export const DEFAULT_QUERY_LIMIT = 100;
191
+ /**
192
+ * Default tag match mode
193
+ */
194
+ export const DEFAULT_TAG_MATCH_MODE = 'OR';
195
+ /**
196
+ * Default hours to look back for file changes
197
+ */
198
+ export const DEFAULT_FILE_CHANGES_HOURS = 24;
199
+ // ============================================================================
200
+ // SQLite Constants
201
+ // ============================================================================
202
+ /**
203
+ * SQLite boolean true value
204
+ */
205
+ export const SQLITE_TRUE = 1;
206
+ /**
207
+ * SQLite boolean false value
208
+ */
209
+ export const SQLITE_FALSE = 0;
210
+ // ============================================================================
211
+ // Error Messages
212
+ // ============================================================================
213
+ export const ERROR_MESSAGES = {
214
+ DB_INIT_FAILED: 'Failed to initialize database',
215
+ DB_CONNECTION_FAILED: 'Failed to connect to database',
216
+ SCHEMA_INIT_FAILED: 'Failed to initialize schema',
217
+ INVALID_ENUM_VALUE: 'Invalid enum value',
218
+ FOREIGN_KEY_VIOLATION: 'Foreign key constraint violation',
219
+ UNIQUE_CONSTRAINT_VIOLATION: 'Unique constraint violation',
220
+ INVALID_PARAMETER: 'Invalid parameter',
221
+ DECISION_NOT_FOUND: 'Decision not found',
222
+ MESSAGE_NOT_FOUND: 'Message not found',
223
+ CONSTRAINT_NOT_FOUND: 'Constraint not found',
224
+ AGENT_NOT_FOUND: 'Agent not found',
225
+ FILE_NOT_FOUND: 'File not found',
226
+ LAYER_NOT_FOUND: 'Layer not found',
227
+ TAG_NOT_FOUND: 'Tag not found',
228
+ SCOPE_NOT_FOUND: 'Scope not found',
229
+ };
230
+ //# sourceMappingURL=constants.js.map