noormme 1.1.0 → 1.2.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 (225) hide show
  1. package/README.md +84 -65
  2. package/dist/cjs/agentic/ActionJournal.js +13 -9
  3. package/dist/cjs/agentic/CapabilityManager.js +35 -21
  4. package/dist/cjs/agentic/CognitiveRepository.js +19 -9
  5. package/dist/cjs/agentic/ContextBuffer.js +24 -12
  6. package/dist/cjs/agentic/Cortex.js +11 -4
  7. package/dist/cjs/agentic/EpisodicMemory.js +7 -5
  8. package/dist/cjs/agentic/PersonaManager.js +16 -8
  9. package/dist/cjs/agentic/PolicyEnforcer.js +31 -12
  10. package/dist/cjs/agentic/ResourceMonitor.js +4 -4
  11. package/dist/cjs/agentic/SessionCompressor.js +22 -14
  12. package/dist/cjs/agentic/SessionManager.js +36 -18
  13. package/dist/cjs/agentic/VectorIndexer.js +22 -18
  14. package/dist/cjs/agentic/improvement/AblationEngine.js +22 -15
  15. package/dist/cjs/agentic/improvement/ActionRefiner.js +12 -10
  16. package/dist/cjs/agentic/improvement/ConflictResolver.js +5 -5
  17. package/dist/cjs/agentic/improvement/CortexJanitor.js +30 -9
  18. package/dist/cjs/agentic/improvement/CuriosityEngine.js +27 -23
  19. package/dist/cjs/agentic/improvement/EvolutionRitual.js +4 -4
  20. package/dist/cjs/agentic/improvement/EvolutionaryPilot.js +16 -6
  21. package/dist/cjs/agentic/improvement/GoalArchitect.d.ts +2 -2
  22. package/dist/cjs/agentic/improvement/GoalArchitect.js +20 -18
  23. package/dist/cjs/agentic/improvement/GovernanceManager.js +19 -11
  24. package/dist/cjs/agentic/improvement/HiveLink.js +22 -15
  25. package/dist/cjs/agentic/improvement/KnowledgeDistiller.js +48 -32
  26. package/dist/cjs/agentic/improvement/RecursiveReasoner.js +40 -17
  27. package/dist/cjs/agentic/improvement/ReflectionEngine.js +10 -8
  28. package/dist/cjs/agentic/improvement/RitualOrchestrator.js +28 -22
  29. package/dist/cjs/agentic/improvement/RuleEngine.js +22 -17
  30. package/dist/cjs/agentic/improvement/SelfEvolution.js +24 -18
  31. package/dist/cjs/agentic/improvement/SelfTestRegistry.js +18 -15
  32. package/dist/cjs/agentic/improvement/SkillSynthesizer.js +42 -27
  33. package/dist/cjs/agentic/improvement/SovereignMetrics.js +19 -17
  34. package/dist/cjs/agentic/improvement/StrategicPlanner.js +120 -55
  35. package/dist/cjs/agentic/telemetry/CognitiveSynthesizer.js +26 -12
  36. package/dist/cjs/agentic/telemetry/EventHarvester.js +3 -2
  37. package/dist/cjs/agentic/telemetry/ResearchAlchemist.js +5 -2
  38. package/dist/cjs/cache/cache-manager.js +7 -4
  39. package/dist/cjs/cli/commands/analyze.js +5 -4
  40. package/dist/cjs/cli/commands/generate.js +81 -44
  41. package/dist/cjs/cli/commands/init.js +7 -3
  42. package/dist/cjs/cli/commands/inspect.js +139 -36
  43. package/dist/cjs/cli/commands/migrate.js +5 -4
  44. package/dist/cjs/cli/commands/optimize.js +4 -4
  45. package/dist/cjs/cli/commands/status.js +9 -7
  46. package/dist/cjs/cli/commands/watch.js +7 -6
  47. package/dist/cjs/cli/index.js +2 -2
  48. package/dist/cjs/cli/ui/spinner.d.ts +15 -0
  49. package/dist/cjs/cli/ui/spinner.js +76 -0
  50. package/dist/cjs/dialect/database-introspector.js +3 -1
  51. package/dist/cjs/dialect/postgresql/postgresql-driver.js +3 -1
  52. package/dist/cjs/dialect/postgresql/postgresql-features.js +18 -8
  53. package/dist/cjs/dialect/postgresql/postgresql-introspector.js +2 -2
  54. package/dist/cjs/dialect/sqlite/sqlite-auto-indexer.js +47 -33
  55. package/dist/cjs/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
  56. package/dist/cjs/dialect/sqlite/sqlite-driver.js +2 -2
  57. package/dist/cjs/dialect/sqlite/sqlite-introspector.js +15 -12
  58. package/dist/cjs/edge-runtime/edge-config.js +21 -19
  59. package/dist/cjs/errors/NoormError.js +22 -20
  60. package/dist/cjs/helpers/agent-schema.js +2 -0
  61. package/dist/cjs/helpers/postgresql.js +7 -4
  62. package/dist/cjs/helpers/schema-evolution.js +31 -6
  63. package/dist/cjs/index.d.ts +3 -3
  64. package/dist/cjs/logging/logger.js +8 -4
  65. package/dist/cjs/migration/data_migrator.js +12 -11
  66. package/dist/cjs/migration/database_migration_manager.js +17 -13
  67. package/dist/cjs/migration/schema_differ.js +22 -14
  68. package/dist/cjs/migration/schema_introspector.js +8 -8
  69. package/dist/cjs/migration/type_mapper.js +68 -67
  70. package/dist/cjs/noormme.js +52 -37
  71. package/dist/cjs/performance/index.js +5 -5
  72. package/dist/cjs/performance/query-optimizer.js +26 -21
  73. package/dist/cjs/performance/services/cache-service.js +26 -16
  74. package/dist/cjs/performance/services/connection-factory.js +28 -23
  75. package/dist/cjs/performance/services/metrics-collector.js +41 -36
  76. package/dist/cjs/performance/utils/query-parser.js +15 -16
  77. package/dist/cjs/relationships/relationship-engine.js +10 -8
  78. package/dist/cjs/repository/repository-factory.js +97 -38
  79. package/dist/cjs/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
  80. package/dist/cjs/schema/core/discovery/relationship-discovery.js +16 -16
  81. package/dist/cjs/schema/core/discovery/table-metadata-discovery.js +9 -9
  82. package/dist/cjs/schema/core/discovery/view-discovery.js +5 -4
  83. package/dist/cjs/schema/core/factories/discovery-factory.js +4 -4
  84. package/dist/cjs/schema/core/utils/name-generator.js +14 -5
  85. package/dist/cjs/schema/core/utils/type-mapper.js +24 -24
  86. package/dist/cjs/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
  87. package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
  88. package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
  89. package/dist/cjs/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
  90. package/dist/cjs/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
  91. package/dist/cjs/schema/test/basic-schema-test.js +11 -9
  92. package/dist/cjs/schema/test/dialect-capabilities.test.js +6 -6
  93. package/dist/cjs/schema/test/discovery-factory.test.js +2 -2
  94. package/dist/cjs/schema/test/error-handling.test.js +8 -6
  95. package/dist/cjs/schema/test/integration.test.js +24 -18
  96. package/dist/cjs/schema/test/schema-discovery-coordinator.test.js +9 -9
  97. package/dist/cjs/schema/test/simple-schema-test.js +9 -9
  98. package/dist/cjs/schema/test/sqlite-discovery-coordinator.test.js +64 -48
  99. package/dist/cjs/schema/test/test-runner.js +3 -3
  100. package/dist/cjs/sqlite-migration/index.d.ts +2 -2
  101. package/dist/cjs/sqlite-migration/sqlite-migration-manager.js +21 -17
  102. package/dist/cjs/sqlite-migration/sqlite-migration-provider.js +38 -34
  103. package/dist/cjs/testing/test-utils.js +36 -34
  104. package/dist/cjs/types/index.d.ts +5 -2
  105. package/dist/cjs/types/index.js +6 -3
  106. package/dist/cjs/types/type-generator.js +46 -42
  107. package/dist/cjs/util/safe-sql-helpers.js +1 -1
  108. package/dist/cjs/util/security-validator.js +20 -9
  109. package/dist/cjs/utils/errorHelpers.js +20 -10
  110. package/dist/cjs/watch/schema-watcher.js +22 -23
  111. package/dist/esm/agentic/ActionJournal.js +13 -9
  112. package/dist/esm/agentic/CapabilityManager.js +35 -21
  113. package/dist/esm/agentic/CognitiveRepository.js +19 -9
  114. package/dist/esm/agentic/ContextBuffer.js +24 -12
  115. package/dist/esm/agentic/Cortex.js +11 -4
  116. package/dist/esm/agentic/EpisodicMemory.js +7 -5
  117. package/dist/esm/agentic/PersonaManager.js +16 -8
  118. package/dist/esm/agentic/PolicyEnforcer.js +31 -12
  119. package/dist/esm/agentic/ResourceMonitor.js +4 -4
  120. package/dist/esm/agentic/SessionCompressor.js +22 -14
  121. package/dist/esm/agentic/SessionManager.js +36 -18
  122. package/dist/esm/agentic/VectorIndexer.js +22 -18
  123. package/dist/esm/agentic/improvement/AblationEngine.js +22 -15
  124. package/dist/esm/agentic/improvement/ActionRefiner.js +12 -10
  125. package/dist/esm/agentic/improvement/ConflictResolver.js +5 -5
  126. package/dist/esm/agentic/improvement/CortexJanitor.js +30 -9
  127. package/dist/esm/agentic/improvement/CuriosityEngine.js +27 -23
  128. package/dist/esm/agentic/improvement/EvolutionRitual.js +4 -4
  129. package/dist/esm/agentic/improvement/EvolutionaryPilot.js +16 -6
  130. package/dist/esm/agentic/improvement/GoalArchitect.d.ts +2 -2
  131. package/dist/esm/agentic/improvement/GoalArchitect.js +20 -18
  132. package/dist/esm/agentic/improvement/GovernanceManager.js +19 -11
  133. package/dist/esm/agentic/improvement/HiveLink.js +22 -15
  134. package/dist/esm/agentic/improvement/KnowledgeDistiller.js +48 -32
  135. package/dist/esm/agentic/improvement/RecursiveReasoner.js +40 -17
  136. package/dist/esm/agentic/improvement/ReflectionEngine.js +10 -8
  137. package/dist/esm/agentic/improvement/RitualOrchestrator.js +28 -22
  138. package/dist/esm/agentic/improvement/RuleEngine.js +22 -17
  139. package/dist/esm/agentic/improvement/SelfEvolution.js +24 -18
  140. package/dist/esm/agentic/improvement/SelfTestRegistry.js +18 -15
  141. package/dist/esm/agentic/improvement/SkillSynthesizer.js +42 -27
  142. package/dist/esm/agentic/improvement/SovereignMetrics.js +19 -17
  143. package/dist/esm/agentic/improvement/StrategicPlanner.js +120 -55
  144. package/dist/esm/agentic/telemetry/CognitiveSynthesizer.js +26 -12
  145. package/dist/esm/agentic/telemetry/EventHarvester.js +3 -2
  146. package/dist/esm/agentic/telemetry/ResearchAlchemist.js +5 -2
  147. package/dist/esm/cache/cache-manager.js +7 -4
  148. package/dist/esm/cli/commands/analyze.js +5 -4
  149. package/dist/esm/cli/commands/generate.js +82 -45
  150. package/dist/esm/cli/commands/init.js +8 -4
  151. package/dist/esm/cli/commands/inspect.js +140 -37
  152. package/dist/esm/cli/commands/migrate.js +5 -4
  153. package/dist/esm/cli/commands/optimize.js +4 -4
  154. package/dist/esm/cli/commands/status.js +9 -7
  155. package/dist/esm/cli/commands/watch.js +7 -6
  156. package/dist/esm/cli/index.js +2 -2
  157. package/dist/esm/cli/ui/spinner.d.ts +15 -0
  158. package/dist/esm/cli/ui/spinner.js +70 -0
  159. package/dist/esm/dialect/database-introspector.js +3 -1
  160. package/dist/esm/dialect/postgresql/postgresql-driver.js +3 -1
  161. package/dist/esm/dialect/postgresql/postgresql-features.js +18 -8
  162. package/dist/esm/dialect/postgresql/postgresql-introspector.js +2 -2
  163. package/dist/esm/dialect/sqlite/sqlite-auto-indexer.js +47 -33
  164. package/dist/esm/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
  165. package/dist/esm/dialect/sqlite/sqlite-driver.js +2 -2
  166. package/dist/esm/dialect/sqlite/sqlite-introspector.js +15 -12
  167. package/dist/esm/dynamic/dynamic.js +1 -1
  168. package/dist/esm/edge-runtime/edge-config.js +21 -19
  169. package/dist/esm/errors/NoormError.js +22 -20
  170. package/dist/esm/helpers/agent-schema.js +2 -0
  171. package/dist/esm/helpers/postgresql.js +7 -4
  172. package/dist/esm/helpers/schema-evolution.js +31 -6
  173. package/dist/esm/index.d.ts +3 -3
  174. package/dist/esm/index.js +2 -2
  175. package/dist/esm/logging/logger.js +8 -4
  176. package/dist/esm/migration/data_migrator.js +12 -11
  177. package/dist/esm/migration/database_migration_manager.js +18 -14
  178. package/dist/esm/migration/schema_differ.js +22 -14
  179. package/dist/esm/migration/schema_introspector.js +8 -8
  180. package/dist/esm/migration/type_mapper.js +68 -67
  181. package/dist/esm/noormme.js +52 -37
  182. package/dist/esm/performance/index.js +5 -5
  183. package/dist/esm/performance/query-optimizer.js +26 -21
  184. package/dist/esm/performance/services/cache-service.js +26 -16
  185. package/dist/esm/performance/services/connection-factory.js +28 -23
  186. package/dist/esm/performance/services/metrics-collector.js +41 -36
  187. package/dist/esm/performance/utils/query-parser.js +15 -16
  188. package/dist/esm/raw-builder/sql.js +1 -1
  189. package/dist/esm/relationships/relationship-engine.js +10 -8
  190. package/dist/esm/repository/repository-factory.js +98 -39
  191. package/dist/esm/schema/builders/alter-table-add-index-builder.js +1 -1
  192. package/dist/esm/schema/builders/create-index-builder.js +2 -2
  193. package/dist/esm/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
  194. package/dist/esm/schema/core/discovery/relationship-discovery.js +16 -16
  195. package/dist/esm/schema/core/discovery/table-metadata-discovery.js +9 -9
  196. package/dist/esm/schema/core/discovery/view-discovery.js +5 -4
  197. package/dist/esm/schema/core/factories/discovery-factory.js +4 -4
  198. package/dist/esm/schema/core/utils/name-generator.js +14 -5
  199. package/dist/esm/schema/core/utils/type-mapper.js +24 -24
  200. package/dist/esm/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
  201. package/dist/esm/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
  202. package/dist/esm/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
  203. package/dist/esm/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
  204. package/dist/esm/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
  205. package/dist/esm/schema/test/basic-schema-test.js +11 -9
  206. package/dist/esm/schema/test/dialect-capabilities.test.js +6 -6
  207. package/dist/esm/schema/test/discovery-factory.test.js +2 -2
  208. package/dist/esm/schema/test/error-handling.test.js +8 -6
  209. package/dist/esm/schema/test/integration.test.js +24 -18
  210. package/dist/esm/schema/test/schema-discovery-coordinator.test.js +9 -9
  211. package/dist/esm/schema/test/simple-schema-test.js +9 -9
  212. package/dist/esm/schema/test/sqlite-discovery-coordinator.test.js +64 -48
  213. package/dist/esm/schema/test/test-runner.js +3 -3
  214. package/dist/esm/sqlite-migration/index.d.ts +2 -2
  215. package/dist/esm/sqlite-migration/sqlite-migration-manager.js +21 -17
  216. package/dist/esm/sqlite-migration/sqlite-migration-provider.js +38 -34
  217. package/dist/esm/testing/test-utils.js +36 -34
  218. package/dist/esm/types/index.d.ts +5 -2
  219. package/dist/esm/types/index.js +6 -3
  220. package/dist/esm/types/type-generator.js +46 -42
  221. package/dist/esm/util/safe-sql-helpers.js +1 -1
  222. package/dist/esm/util/security-validator.js +20 -9
  223. package/dist/esm/utils/errorHelpers.js +21 -11
  224. package/dist/esm/watch/schema-watcher.js +22 -23
  225. package/package.json +40 -44
@@ -53,7 +53,12 @@ export function validateIdentifier(identifier, context = 'identifier') {
53
53
  }
54
54
  // Additional check: prevent reserved SQLite keywords that could be dangerous
55
55
  const reservedKeywords = [
56
- 'PRAGMA', 'ATTACH', 'DETACH', 'VACUUM', 'ANALYZE', 'REINDEX'
56
+ 'PRAGMA',
57
+ 'ATTACH',
58
+ 'DETACH',
59
+ 'VACUUM',
60
+ 'ANALYZE',
61
+ 'REINDEX',
57
62
  ];
58
63
  for (const keyword of reservedKeywords) {
59
64
  if (identifier.toUpperCase() === keyword) {
@@ -74,7 +79,11 @@ export function validateTableReference(tableRef) {
74
79
  }
75
80
  // Validate each part
76
81
  parts.forEach((part, index) => {
77
- const context = index === 0 ? (parts.length === 2 ? 'schema name' : 'table name') : 'table name';
82
+ const context = index === 0
83
+ ? parts.length === 2
84
+ ? 'schema name'
85
+ : 'table name'
86
+ : 'table name';
78
87
  validateIdentifier(part, context);
79
88
  });
80
89
  }
@@ -99,7 +108,8 @@ export function validateColumnReference(columnRef) {
99
108
  context = index === 0 ? 'table name' : 'column name';
100
109
  }
101
110
  else {
102
- context = index === 0 ? 'schema name' : (index === 1 ? 'table name' : 'column name');
111
+ context =
112
+ index === 0 ? 'schema name' : index === 1 ? 'table name' : 'column name';
103
113
  }
104
114
  validateIdentifier(part, context);
105
115
  });
@@ -131,7 +141,7 @@ export function validateFilePath(filePath, allowedExtensions) {
131
141
  }
132
142
  // Validate file extension if specified
133
143
  if (allowedExtensions && allowedExtensions.length > 0) {
134
- const hasValidExtension = allowedExtensions.some(ext => filePath.toLowerCase().endsWith(ext.toLowerCase()));
144
+ const hasValidExtension = allowedExtensions.some((ext) => filePath.toLowerCase().endsWith(ext.toLowerCase()));
135
145
  if (!hasValidExtension) {
136
146
  throw new Error(`Invalid file extension for "${filePath}". ` +
137
147
  `Allowed extensions: ${allowedExtensions.join(', ')}`);
@@ -155,7 +165,9 @@ export function validateFilePath(filePath, allowedExtensions) {
155
165
  export function sanitizeDatabasePath(dbPath) {
156
166
  validateFilePath(dbPath, ['.db', '.sqlite', '.sqlite3', '.db3']);
157
167
  // Ensure the path doesn't escape current directory
158
- if (dbPath.includes('..') || dbPath.startsWith('/') || /^[a-zA-Z]:/.test(dbPath)) {
168
+ if (dbPath.includes('..') ||
169
+ dbPath.startsWith('/') ||
170
+ /^[a-zA-Z]:/.test(dbPath)) {
159
171
  throw new Error(`Database path "${dbPath}" must be a relative path within the current directory`);
160
172
  }
161
173
  return dbPath;
@@ -212,8 +224,7 @@ export class RateLimiter {
212
224
  maxAttempts;
213
225
  windowMs;
214
226
  attempts = new Map();
215
- constructor(maxAttempts = 10, windowMs = 60000 // 1 minute
216
- ) {
227
+ constructor(maxAttempts = 10, windowMs = 60000) {
217
228
  this.maxAttempts = maxAttempts;
218
229
  this.windowMs = windowMs;
219
230
  }
@@ -221,7 +232,7 @@ export class RateLimiter {
221
232
  const now = Date.now();
222
233
  const attempts = this.attempts.get(key) || [];
223
234
  // Remove old attempts outside the window
224
- const recentAttempts = attempts.filter(time => now - time < this.windowMs);
235
+ const recentAttempts = attempts.filter((time) => now - time < this.windowMs);
225
236
  if (recentAttempts.length >= this.maxAttempts) {
226
237
  throw new Error(`Rate limit exceeded for ${key}. Please wait before trying again.`);
227
238
  }
@@ -234,7 +245,7 @@ export class RateLimiter {
234
245
  }
235
246
  cleanup(now) {
236
247
  for (const [key, attempts] of this.attempts.entries()) {
237
- const recentAttempts = attempts.filter(time => now - time < this.windowMs);
248
+ const recentAttempts = attempts.filter((time) => now - time < this.windowMs);
238
249
  if (recentAttempts.length === 0) {
239
250
  this.attempts.delete(key);
240
251
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./errorHelpers.d.ts" />
2
- import { NoormError, ColumnNotFoundError, TableNotFoundError, ConnectionError } from '../errors/NoormError.js';
2
+ import { NoormError, ColumnNotFoundError, TableNotFoundError, ConnectionError, } from '../errors/NoormError.js';
3
3
  /**
4
4
  * Wraps Kysely errors with more context-aware NoormError instances
5
5
  */
@@ -20,11 +20,15 @@ export function wrapKyselyError(error, context) {
20
20
  }
21
21
  }
22
22
  // Handle connection errors
23
- if (message.includes('connect') || message.includes('ECONNREFUSED') || message.includes('ENOTFOUND')) {
23
+ if (message.includes('connect') ||
24
+ message.includes('ECONNREFUSED') ||
25
+ message.includes('ENOTFOUND')) {
24
26
  return new ConnectionError(message, error);
25
27
  }
26
28
  // Handle authentication errors
27
- if (message.includes('authentication') || message.includes('password') || message.includes('SASL')) {
29
+ if (message.includes('authentication') ||
30
+ message.includes('password') ||
31
+ message.includes('SASL')) {
28
32
  return new ConnectionError('Authentication failed. Check your username and password.', error);
29
33
  }
30
34
  // Handle syntax errors
@@ -32,17 +36,19 @@ export function wrapKyselyError(error, context) {
32
36
  return new NoormError(`SQL syntax error: ${message}`, {
33
37
  table: context.table,
34
38
  operation: context.operation,
35
- suggestion: 'Check your query syntax or report this as a bug if you\'re using NOORMME methods',
36
- originalError: error
39
+ suggestion: "Check your query syntax or report this as a bug if you're using NOORMME methods",
40
+ originalError: error,
37
41
  });
38
42
  }
39
43
  // Handle constraint violations
40
- if (message.includes('constraint') || message.includes('duplicate') || message.includes('unique')) {
44
+ if (message.includes('constraint') ||
45
+ message.includes('duplicate') ||
46
+ message.includes('unique')) {
41
47
  return new NoormError(`Database constraint violation: ${extractConstraintMessage(message)}`, {
42
48
  table: context.table,
43
49
  operation: context.operation,
44
50
  suggestion: 'Check for duplicate values or foreign key violations',
45
- originalError: error
51
+ originalError: error,
46
52
  });
47
53
  }
48
54
  // Generic wrapper for other errors
@@ -50,7 +56,7 @@ export function wrapKyselyError(error, context) {
50
56
  table: context.table,
51
57
  operation: context.operation,
52
58
  suggestion: 'Check the database connection and query parameters',
53
- originalError: error
59
+ originalError: error,
54
60
  });
55
61
  }
56
62
  /**
@@ -115,14 +121,15 @@ export function suggestCorrections(input, available, maxSuggestions = 3) {
115
121
  const suggestions = [];
116
122
  for (const option of available) {
117
123
  const score = calculateSimilarity(input.toLowerCase(), option.toLowerCase());
118
- if (score > 0.3) { // Only suggest if similarity > 30%
124
+ if (score > 0.3) {
125
+ // Only suggest if similarity > 30%
119
126
  suggestions.push({ name: option, score });
120
127
  }
121
128
  }
122
129
  return suggestions
123
130
  .sort((a, b) => b.score - a.score)
124
131
  .slice(0, maxSuggestions)
125
- .map(s => s.name);
132
+ .map((s) => s.name);
126
133
  }
127
134
  /**
128
135
  * Calculate string similarity using Jaro-Winkler algorithm (simplified)
@@ -167,7 +174,10 @@ function calculateSimilarity(str1, str2) {
167
174
  transpositions++;
168
175
  k++;
169
176
  }
170
- const jaro = (matches / len1 + matches / len2 + (matches - transpositions / 2) / matches) / 3;
177
+ const jaro = (matches / len1 +
178
+ matches / len2 +
179
+ (matches - transpositions / 2) / matches) /
180
+ 3;
171
181
  // Jaro-Winkler bonus for common prefix
172
182
  let prefix = 0;
173
183
  for (let i = 0; i < Math.min(len1, len2, 4); i++) {
@@ -25,7 +25,7 @@ export class SchemaWatcher {
25
25
  ignoreViews: true,
26
26
  ignoredTables: [],
27
27
  enabled: options.enabled !== undefined ? options.enabled : defaultEnabled,
28
- ...options
28
+ ...options,
29
29
  };
30
30
  }
31
31
  /**
@@ -55,7 +55,7 @@ export class SchemaWatcher {
55
55
  }
56
56
  this.isWatching = true;
57
57
  this.intervalId = setInterval(() => {
58
- this.checkForChanges().catch(error => {
58
+ this.checkForChanges().catch((error) => {
59
59
  this.logger.error('Error checking for schema changes:', error);
60
60
  });
61
61
  }, this.options.pollInterval);
@@ -139,23 +139,22 @@ export class SchemaWatcher {
139
139
  // Create a deterministic string representation of the schema
140
140
  const schemaString = JSON.stringify({
141
141
  tables: schema.tables
142
- .filter(table => !this.options.ignoredTables?.includes(table.name))
143
- .map(table => ({
142
+ .filter((table) => !this.options.ignoredTables?.includes(table.name))
143
+ .map((table) => ({
144
144
  name: table.name,
145
- columns: table.columns.map(col => ({
145
+ columns: table.columns.map((col) => ({
146
146
  name: col.name,
147
147
  type: col.type,
148
148
  nullable: col.nullable,
149
149
  isPrimaryKey: col.isPrimaryKey,
150
- defaultValue: col.defaultValue
150
+ defaultValue: col.defaultValue,
151
151
  })),
152
152
  primaryKey: table.primaryKey,
153
153
  foreignKeys: table.foreignKeys,
154
- indexes: table.indexes
154
+ indexes: table.indexes,
155
155
  }))
156
156
  .sort((a, b) => a.name.localeCompare(b.name)),
157
- relationships: schema.relationships
158
- .sort((a, b) => `${a.fromTable}.${a.name}`.localeCompare(`${b.fromTable}.${b.name}`))
157
+ relationships: schema.relationships.sort((a, b) => `${a.fromTable}.${a.name}`.localeCompare(`${b.fromTable}.${b.name}`)),
159
158
  });
160
159
  return createHash('sha256').update(schemaString).digest('hex');
161
160
  }
@@ -173,20 +172,20 @@ export class SchemaWatcher {
173
172
  changes.push({
174
173
  type: 'table_added',
175
174
  table: table.name,
176
- details: { columns: table.columns.length }
175
+ details: { columns: table.columns.length },
177
176
  });
178
177
  }
179
178
  return changes;
180
179
  }
181
- const oldTablesMap = new Map(oldSchema.tables.map(t => [t.name, t]));
182
- const newTablesMap = new Map(newSchema.tables.map(t => [t.name, t]));
180
+ const oldTablesMap = new Map(oldSchema.tables.map((t) => [t.name, t]));
181
+ const newTablesMap = new Map(newSchema.tables.map((t) => [t.name, t]));
183
182
  // Check for added tables
184
183
  for (const table of newSchema.tables) {
185
184
  if (!oldTablesMap.has(table.name)) {
186
185
  changes.push({
187
186
  type: 'table_added',
188
187
  table: table.name,
189
- details: { columns: table.columns.length }
188
+ details: { columns: table.columns.length },
190
189
  });
191
190
  }
192
191
  }
@@ -195,7 +194,7 @@ export class SchemaWatcher {
195
194
  if (!newTablesMap.has(table.name)) {
196
195
  changes.push({
197
196
  type: 'table_removed',
198
- table: table.name
197
+ table: table.name,
199
198
  });
200
199
  }
201
200
  }
@@ -203,8 +202,8 @@ export class SchemaWatcher {
203
202
  for (const newTable of newSchema.tables) {
204
203
  const oldTable = oldTablesMap.get(newTable.name);
205
204
  if (oldTable) {
206
- const oldColumnsMap = new Map(oldTable.columns.map(c => [c.name, c]));
207
- const newColumnsMap = new Map(newTable.columns.map(c => [c.name, c]));
205
+ const oldColumnsMap = new Map(oldTable.columns.map((c) => [c.name, c]));
206
+ const newColumnsMap = new Map(newTable.columns.map((c) => [c.name, c]));
208
207
  // Check for added columns
209
208
  for (const column of newTable.columns) {
210
209
  if (!oldColumnsMap.has(column.name)) {
@@ -212,7 +211,7 @@ export class SchemaWatcher {
212
211
  type: 'column_added',
213
212
  table: newTable.name,
214
213
  column: column.name,
215
- details: { type: column.type }
214
+ details: { type: column.type },
216
215
  });
217
216
  }
218
217
  }
@@ -222,7 +221,7 @@ export class SchemaWatcher {
222
221
  changes.push({
223
222
  type: 'column_removed',
224
223
  table: newTable.name,
225
- column: column.name
224
+ column: column.name,
226
225
  });
227
226
  }
228
227
  else {
@@ -235,8 +234,8 @@ export class SchemaWatcher {
235
234
  column: column.name,
236
235
  details: {
237
236
  old: { type: column.type, nullable: column.nullable },
238
- new: { type: newColumn.type, nullable: newColumn.nullable }
239
- }
237
+ new: { type: newColumn.type, nullable: newColumn.nullable },
238
+ },
240
239
  });
241
240
  }
242
241
  }
@@ -246,15 +245,15 @@ export class SchemaWatcher {
246
245
  return changes;
247
246
  }
248
247
  isColumnModified(oldCol, newCol) {
249
- return oldCol.type !== newCol.type ||
248
+ return (oldCol.type !== newCol.type ||
250
249
  oldCol.nullable !== newCol.nullable ||
251
- oldCol.isPrimaryKey !== newCol.isPrimaryKey;
250
+ oldCol.isPrimaryKey !== newCol.isPrimaryKey);
252
251
  }
253
252
  /**
254
253
  * Notify all registered callbacks about schema changes
255
254
  */
256
255
  notifyCallbacks(changes) {
257
- this.callbacks.forEach(callback => {
256
+ this.callbacks.forEach((callback) => {
258
257
  try {
259
258
  callback(changes);
260
259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noormme",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "NOORMME - The Agentic Data Engine. High-fidelity persistence and cognitive governance for Autonomous AI Agents.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,48 +60,6 @@
60
60
  "default": "./dist/cjs/cli/index.js"
61
61
  }
62
62
  },
63
- "scripts": {
64
- "clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js & rm -rf helpers",
65
- "bench:ts": "pnpm build && cd ./test/ts-benchmarks && node --experimental-strip-types ./index.ts",
66
- "test": "jest",
67
- "test:watch": "jest --watch",
68
- "test:coverage": "jest --coverage",
69
- "test:unit": "jest tests/unit",
70
- "test:integration": "jest tests/integration",
71
- "test:cli": "jest tests/cli",
72
- "test:original": "pnpm build && pnpm test:node:build && pnpm test:node:run && pnpm test:typings && pnpm test:esmimports && pnpm test:exports",
73
- "test:node:build": "tsc -p test/node",
74
- "test:node": "pnpm build && pnpm test:node:build && pnpm test:node:run",
75
- "test:node:run": "mocha --timeout 15000 test/node/dist/**/*.test.js",
76
- "test:browser:build": "rm -rf test/browser/bundle.js && esbuild test/browser/main.ts --bundle --outfile=test/browser/bundle.js",
77
- "test:browser": "pnpm build && pnpm test:browser:build && node test/browser/test.js",
78
- "test:bun": "pnpm build && bun link && cd test/bun && bun install && bun run test",
79
- "test:cloudflare-workers": "pnpm build && pnpm -r test --filter kysely-cloudflare-workers-test",
80
- "test:deno": "deno run --allow-env --allow-read --allow-net --no-lock test/deno/local.test.ts && deno run --allow-env --allow-read --allow-net --no-lock test/deno/cdn.test.ts",
81
- "test:typings": "tsd test/typings",
82
- "test:esmimports": "node scripts/check-esm-imports.js",
83
- "test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
84
- "test:exports": "attw --pack . && node scripts/check-exports.js",
85
- "test:jsdocs": "deno check --doc-only --no-lock --unstable-sloppy-imports --config=\"deno.check.json\" ./src",
86
- "test:outdatedts": "pnpm build && cd test/outdated-ts && pnpm i && pnpm test",
87
- "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
88
- "build": "pnpm clean && (pnpm build:esm & pnpm build:cjs) && pnpm script:module-fixup && pnpm script:copy-interface-doc",
89
- "build:esm": "tsc -p tsconfig.json && pnpm script:add-deno-type-references",
90
- "build:cjs": "tsc -p tsconfig-cjs.json",
91
- "script:module-fixup": "node scripts/module-fixup.js",
92
- "script:copy-interface-doc": "node scripts/copy-interface-documentation.js",
93
- "script:add-deno-type-references": "node scripts/add-deno-type-references.js",
94
- "script:align-site-version": "node --experimental-strip-types scripts/align-site-version.mts",
95
- "script:generate-site-examples": "node scripts/generate-site-examples.js",
96
- "script:exclude-test-files-for-backwards-compat": "node --experimental-strip-types scripts/exclude-test-files-for-backwards-compat.mts",
97
- "prepublishOnly": "pnpm build",
98
- "version": "pnpm script:align-site-version && git add .",
99
- "postversion": "pnpm publish --no-git-checks",
100
- "prepack": "pnpm build",
101
- "postpack": "echo 'Package ready for npm publish'",
102
- "publish:dry-run": "pnpm build && npm pack --dry-run",
103
- "publish:check": "pnpm build && npm publish --dry-run"
104
- },
105
63
  "author": "NOORMME Team",
106
64
  "license": "MIT",
107
65
  "devDependencies": {
@@ -136,7 +94,6 @@
136
94
  "tsd": "^0.33.0",
137
95
  "typescript": "~5.9.2"
138
96
  },
139
- "packageManager": "pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706",
140
97
  "dependencies": {
141
98
  "better-sqlite3": "^12.4.1",
142
99
  "chalk": "^5.0.0",
@@ -149,5 +106,44 @@
149
106
  },
150
107
  "bin": {
151
108
  "noormme": "./dist/cjs/cli/index.js"
109
+ },
110
+ "scripts": {
111
+ "clean": "rm -rf dist & rm -rf test/node/dist & rm -rf test/browser/bundle.js & rm -rf helpers",
112
+ "bench:ts": "pnpm build && cd ./test/ts-benchmarks && node --experimental-strip-types ./index.ts",
113
+ "test": "jest",
114
+ "test:watch": "jest --watch",
115
+ "test:coverage": "jest --coverage",
116
+ "test:unit": "jest tests/unit",
117
+ "test:integration": "jest tests/integration",
118
+ "test:cli": "jest tests/cli",
119
+ "test:original": "pnpm build && pnpm test:node:build && pnpm test:node:run && pnpm test:typings && pnpm test:esmimports && pnpm test:exports",
120
+ "test:node:build": "tsc -p test/node",
121
+ "test:node": "pnpm build && pnpm test:node:build && pnpm test:node:run",
122
+ "test:node:run": "mocha --timeout 15000 test/node/dist/**/*.test.js",
123
+ "test:browser:build": "rm -rf test/browser/bundle.js && esbuild test/browser/main.ts --bundle --outfile=test/browser/bundle.js",
124
+ "test:browser": "pnpm build && pnpm test:browser:build && node test/browser/test.js",
125
+ "test:bun": "pnpm build && bun link && cd test/bun && bun install && bun run test",
126
+ "test:cloudflare-workers": "pnpm build && pnpm -r test --filter kysely-cloudflare-workers-test",
127
+ "test:deno": "deno run --allow-env --allow-read --allow-net --no-lock test/deno/local.test.ts && deno run --allow-env --allow-read --allow-net --no-lock test/deno/cdn.test.ts",
128
+ "test:typings": "tsd test/typings",
129
+ "test:esmimports": "node scripts/check-esm-imports.js",
130
+ "test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
131
+ "test:exports": "attw --pack . && node scripts/check-exports.js",
132
+ "test:jsdocs": "deno check --doc-only --no-lock --unstable-sloppy-imports --config=\"deno.check.json\" ./src",
133
+ "test:outdatedts": "pnpm build && cd test/outdated-ts && pnpm i && pnpm test",
134
+ "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
135
+ "build": "pnpm clean && (pnpm build:esm & pnpm build:cjs) && pnpm script:module-fixup && pnpm script:copy-interface-doc",
136
+ "build:esm": "tsc -p tsconfig.json && pnpm script:add-deno-type-references",
137
+ "build:cjs": "tsc -p tsconfig-cjs.json",
138
+ "script:module-fixup": "node scripts/module-fixup.js",
139
+ "script:copy-interface-doc": "node scripts/copy-interface-documentation.js",
140
+ "script:add-deno-type-references": "node scripts/add-deno-type-references.js",
141
+ "script:align-site-version": "node --experimental-strip-types scripts/align-site-version.mts",
142
+ "script:generate-site-examples": "node scripts/generate-site-examples.js",
143
+ "script:exclude-test-files-for-backwards-compat": "node --experimental-strip-types scripts/exclude-test-files-for-backwards-compat.mts",
144
+ "version": "pnpm script:align-site-version && git add .",
145
+ "postversion": "pnpm publish --no-git-checks",
146
+ "publish:dry-run": "pnpm build && npm pack --dry-run",
147
+ "publish:check": "pnpm build && npm publish --dry-run"
152
148
  }
153
149
  }