snow-flow 2.6.5 โ†’ 2.6.6

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.
@@ -1,15 +1,21 @@
1
1
  /**
2
- * ServiceNow Queen Memory System
3
- * Simple SQLite-based persistent storage for the hive-mind
2
+ * ServiceNow Queen Memory System - JSON-based implementation
3
+ * Simple JSON file storage for the hive-mind - no more SQLite permission issues!
4
4
  */
5
5
  import { DeploymentPattern, ServiceNowArtifact } from './types';
6
6
  export declare class QueenMemorySystem {
7
- private db;
7
+ private memoryDir;
8
8
  private memory;
9
- private dbPath;
9
+ private storage;
10
+ private saveDebounceTimer?;
11
+ private readonly SAVE_DELAY;
10
12
  constructor(dbPath?: string);
11
- private initializeDatabase;
12
- private loadMemory;
13
+ private getFilePath;
14
+ private loadStorage;
15
+ private convertStorageToMemory;
16
+ private scheduleSave;
17
+ private saveAll;
18
+ private saveJSON;
13
19
  storePattern(pattern: DeploymentPattern): void;
14
20
  getBestPattern(taskType: string): DeploymentPattern | null;
15
21
  storeArtifact(artifact: ServiceNowArtifact): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
- * ServiceNow Queen Memory System
4
- * Simple SQLite-based persistent storage for the hive-mind
3
+ * ServiceNow Queen Memory System - JSON-based implementation
4
+ * Simple JSON file storage for the hive-mind - no more SQLite permission issues!
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
@@ -42,104 +42,167 @@ const path = __importStar(require("path"));
42
42
  const fs = __importStar(require("fs"));
43
43
  class QueenMemorySystem {
44
44
  constructor(dbPath) {
45
- const memoryDir = path.join(process.cwd(), '.snow-flow', 'queen');
46
- if (!fs.existsSync(memoryDir)) {
47
- fs.mkdirSync(memoryDir, { recursive: true });
45
+ this.SAVE_DELAY = 1000; // Debounce saves by 1 second
46
+ // Use same directory structure but with JSON files
47
+ this.memoryDir = path.dirname(dbPath || path.join(process.cwd(), '.snow-flow', 'queen', 'memory'));
48
+ // Ensure directory exists
49
+ if (!fs.existsSync(this.memoryDir)) {
50
+ fs.mkdirSync(this.memoryDir, { recursive: true });
48
51
  }
49
- this.dbPath = dbPath || path.join(memoryDir, 'queen-memory.db');
50
- this.db = new (require('better-sqlite3'))(this.dbPath);
51
- this.initializeDatabase();
52
- this.memory = this.loadMemory();
53
- }
54
- initializeDatabase() {
55
- // Simple schema - snow-flow philosophy: keep it minimal
56
- this.db.exec(`
57
- CREATE TABLE IF NOT EXISTS patterns (
58
- id INTEGER PRIMARY KEY,
59
- task_type TEXT NOT NULL,
60
- success_rate REAL NOT NULL,
61
- agent_sequence TEXT NOT NULL,
62
- mcp_sequence TEXT NOT NULL,
63
- avg_duration INTEGER NOT NULL,
64
- last_used TEXT NOT NULL,
65
- use_count INTEGER DEFAULT 0
66
- );
67
-
68
- CREATE TABLE IF NOT EXISTS artifacts (
69
- id TEXT PRIMARY KEY,
70
- type TEXT NOT NULL,
71
- name TEXT NOT NULL,
72
- sys_id TEXT,
73
- config TEXT NOT NULL,
74
- dependencies TEXT NOT NULL,
75
- created_at TEXT NOT NULL
76
- );
77
-
78
- CREATE TABLE IF NOT EXISTS learnings (
79
- key TEXT PRIMARY KEY,
80
- value TEXT NOT NULL,
81
- confidence REAL NOT NULL,
82
- updated_at TEXT NOT NULL
83
- );
84
-
85
- CREATE TABLE IF NOT EXISTS context (
86
- key TEXT PRIMARY KEY,
87
- value TEXT NOT NULL
88
- );
89
-
90
- CREATE TABLE IF NOT EXISTS task_history (
91
- id TEXT PRIMARY KEY,
92
- objective TEXT NOT NULL,
93
- type TEXT NOT NULL,
94
- agents_used TEXT NOT NULL,
95
- success BOOLEAN NOT NULL,
96
- duration INTEGER NOT NULL,
97
- completed_at TEXT NOT NULL
98
- );
99
- `);
100
- }
101
- loadMemory() {
102
- const patterns = this.db.prepare('SELECT * FROM patterns ORDER BY success_rate DESC, use_count DESC').all()
103
- .map((row) => ({
104
- taskType: row.task_type,
105
- successRate: row.success_rate,
106
- agentSequence: JSON.parse(row.agent_sequence),
107
- mcpSequence: JSON.parse(row.mcp_sequence),
108
- avgDuration: row.avg_duration,
109
- lastUsed: new Date(row.last_used)
110
- }));
52
+ // Load or initialize storage
53
+ this.storage = this.loadStorage();
54
+ // Convert storage to memory format
55
+ this.memory = this.convertStorageToMemory();
56
+ }
57
+ getFilePath(filename) {
58
+ return path.join(this.memoryDir, filename);
59
+ }
60
+ loadStorage() {
61
+ const files = {
62
+ patterns: this.getFilePath('patterns.json'),
63
+ artifacts: this.getFilePath('artifacts.json'),
64
+ learnings: this.getFilePath('learnings.json'),
65
+ context: this.getFilePath('context.json'),
66
+ taskHistory: this.getFilePath('task-history.json')
67
+ };
68
+ const storage = {
69
+ patterns: [],
70
+ artifacts: {},
71
+ learnings: {},
72
+ context: {},
73
+ taskHistory: []
74
+ };
75
+ // Load patterns
76
+ if (fs.existsSync(files.patterns)) {
77
+ try {
78
+ const data = fs.readFileSync(files.patterns, 'utf-8');
79
+ storage.patterns = JSON.parse(data);
80
+ // Convert date strings back to Date objects
81
+ storage.patterns.forEach(p => {
82
+ p.lastUsed = new Date(p.lastUsed);
83
+ });
84
+ }
85
+ catch (error) {
86
+ console.warn('โš ๏ธ Could not load patterns.json:', error);
87
+ }
88
+ }
89
+ // Load artifacts
90
+ if (fs.existsSync(files.artifacts)) {
91
+ try {
92
+ const data = fs.readFileSync(files.artifacts, 'utf-8');
93
+ storage.artifacts = JSON.parse(data);
94
+ }
95
+ catch (error) {
96
+ console.warn('โš ๏ธ Could not load artifacts.json:', error);
97
+ }
98
+ }
99
+ // Load learnings
100
+ if (fs.existsSync(files.learnings)) {
101
+ try {
102
+ const data = fs.readFileSync(files.learnings, 'utf-8');
103
+ storage.learnings = JSON.parse(data);
104
+ }
105
+ catch (error) {
106
+ console.warn('โš ๏ธ Could not load learnings.json:', error);
107
+ }
108
+ }
109
+ // Load context
110
+ if (fs.existsSync(files.context)) {
111
+ try {
112
+ const data = fs.readFileSync(files.context, 'utf-8');
113
+ storage.context = JSON.parse(data);
114
+ }
115
+ catch (error) {
116
+ console.warn('โš ๏ธ Could not load context.json:', error);
117
+ }
118
+ }
119
+ // Load task history
120
+ if (fs.existsSync(files.taskHistory)) {
121
+ try {
122
+ const data = fs.readFileSync(files.taskHistory, 'utf-8');
123
+ storage.taskHistory = JSON.parse(data);
124
+ }
125
+ catch (error) {
126
+ console.warn('โš ๏ธ Could not load task-history.json:', error);
127
+ }
128
+ }
129
+ return storage;
130
+ }
131
+ convertStorageToMemory() {
111
132
  const artifacts = new Map();
112
- this.db.prepare('SELECT * FROM artifacts').all()
113
- .forEach((row) => {
114
- artifacts.set(row.id, {
115
- type: row.type,
116
- name: row.name,
117
- sys_id: row.sys_id,
118
- config: JSON.parse(row.config),
119
- dependencies: JSON.parse(row.dependencies)
120
- });
133
+ Object.entries(this.storage.artifacts).forEach(([key, value]) => {
134
+ artifacts.set(key, value);
121
135
  });
122
136
  const learnings = new Map();
123
- this.db.prepare('SELECT * FROM learnings').all()
124
- .forEach((row) => {
125
- learnings.set(row.key, row.value);
137
+ Object.entries(this.storage.learnings).forEach(([key, value]) => {
138
+ learnings.set(key, typeof value === 'string' ? value : JSON.stringify(value));
126
139
  });
127
140
  return {
128
- patterns,
141
+ patterns: this.storage.patterns,
129
142
  artifacts,
130
143
  agentHistory: new Map(),
131
144
  learnings
132
145
  };
133
146
  }
147
+ scheduleSave() {
148
+ // Debounce saves to avoid excessive file writes
149
+ if (this.saveDebounceTimer) {
150
+ clearTimeout(this.saveDebounceTimer);
151
+ }
152
+ this.saveDebounceTimer = setTimeout(() => {
153
+ this.saveAll();
154
+ }, this.SAVE_DELAY);
155
+ }
156
+ saveAll() {
157
+ // Save patterns
158
+ this.saveJSON('patterns.json', this.storage.patterns);
159
+ // Save artifacts
160
+ this.saveJSON('artifacts.json', this.storage.artifacts);
161
+ // Save learnings
162
+ this.saveJSON('learnings.json', this.storage.learnings);
163
+ // Save context
164
+ this.saveJSON('context.json', this.storage.context);
165
+ // Save task history
166
+ this.saveJSON('task-history.json', this.storage.taskHistory);
167
+ }
168
+ saveJSON(filename, data) {
169
+ const filepath = this.getFilePath(filename);
170
+ try {
171
+ // Write to temp file first for atomicity
172
+ const tempPath = filepath + '.tmp';
173
+ fs.writeFileSync(tempPath, JSON.stringify(data, null, 2));
174
+ // Atomic rename
175
+ fs.renameSync(tempPath, filepath);
176
+ }
177
+ catch (error) {
178
+ console.error(`โŒ Failed to save ${filename}:`, error);
179
+ }
180
+ }
134
181
  // Store successful deployment pattern
135
182
  storePattern(pattern) {
136
- const stmt = this.db.prepare(`
137
- INSERT OR REPLACE INTO patterns
138
- (task_type, success_rate, agent_sequence, mcp_sequence, avg_duration, last_used, use_count)
139
- VALUES (?, ?, ?, ?, ?, ?, COALESCE((SELECT use_count FROM patterns WHERE task_type = ?) + 1, 1))
140
- `);
141
- stmt.run(pattern.taskType, pattern.successRate, JSON.stringify(pattern.agentSequence), JSON.stringify(pattern.mcpSequence), pattern.avgDuration, pattern.lastUsed.toISOString(), pattern.taskType);
142
- this.memory.patterns.push(pattern);
183
+ // Update or add pattern
184
+ const existingIndex = this.storage.patterns.findIndex(p => p.taskType === pattern.taskType);
185
+ if (existingIndex >= 0) {
186
+ // Update existing pattern
187
+ const existing = this.storage.patterns[existingIndex];
188
+ existing.successRate = pattern.successRate;
189
+ existing.agentSequence = pattern.agentSequence;
190
+ existing.mcpSequence = pattern.mcpSequence;
191
+ existing.avgDuration = pattern.avgDuration;
192
+ existing.lastUsed = pattern.lastUsed;
193
+ existing.useCount = (existing.useCount || 0) + 1;
194
+ }
195
+ else {
196
+ // Add new pattern
197
+ this.storage.patterns.push({
198
+ ...pattern,
199
+ useCount: 1
200
+ });
201
+ }
202
+ // Update memory
203
+ this.memory.patterns = this.storage.patterns;
204
+ // Schedule save
205
+ this.scheduleSave();
143
206
  }
144
207
  // Get best pattern for task type
145
208
  getBestPattern(taskType) {
@@ -148,12 +211,11 @@ class QueenMemorySystem {
148
211
  // Store artifact information
149
212
  storeArtifact(artifact) {
150
213
  const id = `${artifact.type}_${artifact.name}`;
151
- const stmt = this.db.prepare(`
152
- INSERT OR REPLACE INTO artifacts (id, type, name, sys_id, config, dependencies, created_at)
153
- VALUES (?, ?, ?, ?, ?, ?, ?)
154
- `);
155
- stmt.run(id, artifact.type, artifact.name, artifact.sys_id || null, JSON.stringify(artifact.config), JSON.stringify(artifact.dependencies), new Date().toISOString());
214
+ // Store in both storage and memory
215
+ this.storage.artifacts[id] = artifact;
156
216
  this.memory.artifacts.set(id, artifact);
217
+ // Schedule save
218
+ this.scheduleSave();
157
219
  }
158
220
  // Find similar artifacts
159
221
  findSimilarArtifacts(type, namePattern) {
@@ -167,13 +229,17 @@ class QueenMemorySystem {
167
229
  }
168
230
  // Store learning from task execution
169
231
  storeLearning(key, value, confidence = 1.0) {
170
- const stmt = this.db.prepare(`
171
- INSERT OR REPLACE INTO learnings (key, value, confidence, updated_at)
172
- VALUES (?, ?, ?, ?)
173
- `);
174
232
  const valueStr = typeof value === 'string' ? value : JSON.stringify(value);
175
- stmt.run(key, valueStr, confidence, new Date().toISOString());
233
+ // Store with metadata
234
+ this.storage.learnings[key] = {
235
+ value: valueStr,
236
+ confidence,
237
+ updatedAt: new Date().toISOString()
238
+ };
239
+ // Update memory
176
240
  this.memory.learnings.set(key, valueStr);
241
+ // Schedule save
242
+ this.scheduleSave();
177
243
  }
178
244
  // Get learning
179
245
  getLearning(key) {
@@ -193,74 +259,83 @@ class QueenMemorySystem {
193
259
  }
194
260
  // Record task completion for learning
195
261
  recordTaskCompletion(taskId, objective, type, agentsUsed, success, duration) {
196
- const stmt = this.db.prepare(`
197
- INSERT INTO task_history (id, objective, type, agents_used, success, duration, completed_at)
198
- VALUES (?, ?, ?, ?, ?, ?, ?)
199
- `);
200
- stmt.run(taskId, objective, type, JSON.stringify(agentsUsed), success ? 1 : 0, // Convert boolean to integer for SQLite
201
- duration, new Date().toISOString());
262
+ const entry = {
263
+ id: taskId,
264
+ objective,
265
+ type,
266
+ agentsUsed,
267
+ success,
268
+ duration,
269
+ completedAt: new Date().toISOString()
270
+ };
271
+ // Add to history
272
+ this.storage.taskHistory.push(entry);
273
+ // Keep only last 1000 entries to prevent unbounded growth
274
+ if (this.storage.taskHistory.length > 1000) {
275
+ this.storage.taskHistory = this.storage.taskHistory.slice(-1000);
276
+ }
277
+ // Schedule save
278
+ this.scheduleSave();
202
279
  }
203
280
  // Get success rate for task type
204
281
  getSuccessRate(taskType) {
205
- const result = this.db.prepare(`
206
- SELECT
207
- COUNT(CASE WHEN success = 1 THEN 1 END) as successes,
208
- COUNT(*) as total
209
- FROM task_history
210
- WHERE type = ?
211
- `).get(taskType);
212
- if (result && result.total > 0) {
213
- return result.successes / result.total;
282
+ const relevantTasks = this.storage.taskHistory.filter(t => t.type === taskType);
283
+ if (relevantTasks.length === 0) {
284
+ return 0.5; // Default success rate
214
285
  }
215
- return 0.5; // Default success rate
286
+ const successes = relevantTasks.filter(t => t.success).length;
287
+ return successes / relevantTasks.length;
216
288
  }
217
289
  // Export memory for backup
218
290
  exportMemory() {
219
291
  return JSON.stringify({
220
- patterns: this.memory.patterns,
221
- artifacts: Array.from(this.memory.artifacts.entries()),
222
- learnings: Array.from(this.memory.learnings.entries())
223
- });
292
+ patterns: this.storage.patterns,
293
+ artifacts: Object.entries(this.storage.artifacts),
294
+ learnings: Object.entries(this.storage.learnings),
295
+ context: Object.entries(this.storage.context),
296
+ taskHistory: this.storage.taskHistory
297
+ }, null, 2);
224
298
  }
225
299
  // Import memory from backup
226
300
  importMemory(memoryData) {
227
301
  try {
228
302
  const data = JSON.parse(memoryData);
229
- // Clear existing data
230
- this.clearMemory();
231
303
  // Import patterns
232
304
  if (data.patterns) {
233
- data.patterns.forEach((pattern) => {
234
- const stmt = this.db.prepare(`
235
- INSERT OR REPLACE INTO patterns
236
- (task_type, success_rate, agent_sequence, mcp_sequence, avg_duration, last_used, use_count)
237
- VALUES (?, ?, ?, ?, ?, ?, ?)
238
- `);
239
- stmt.run(pattern.taskType, pattern.successRate, JSON.stringify(pattern.agentSequence), JSON.stringify(pattern.mcpSequence), pattern.avgDuration, pattern.lastUsed, 1);
240
- });
305
+ this.storage.patterns = data.patterns.map((p) => ({
306
+ ...p,
307
+ lastUsed: new Date(p.lastUsed)
308
+ }));
241
309
  }
242
310
  // Import artifacts
243
311
  if (data.artifacts) {
244
- data.artifacts.forEach(([id, artifact]) => {
245
- const stmt = this.db.prepare(`
246
- INSERT OR REPLACE INTO artifacts (id, type, name, sys_id, config, dependencies, created_at)
247
- VALUES (?, ?, ?, ?, ?, ?, ?)
248
- `);
249
- stmt.run(id, artifact.type, artifact.name, artifact.sys_id || null, JSON.stringify(artifact.config), JSON.stringify(artifact.dependencies), new Date().toISOString());
312
+ this.storage.artifacts = {};
313
+ data.artifacts.forEach(([key, value]) => {
314
+ this.storage.artifacts[key] = value;
250
315
  });
251
316
  }
252
317
  // Import learnings
253
318
  if (data.learnings) {
319
+ this.storage.learnings = {};
254
320
  data.learnings.forEach(([key, value]) => {
255
- const stmt = this.db.prepare(`
256
- INSERT OR REPLACE INTO learnings (key, value, confidence, updated_at)
257
- VALUES (?, ?, ?, ?)
258
- `);
259
- stmt.run(key, value, 1.0, new Date().toISOString());
321
+ this.storage.learnings[key] = value;
322
+ });
323
+ }
324
+ // Import context
325
+ if (data.context) {
326
+ this.storage.context = {};
327
+ data.context.forEach(([key, value]) => {
328
+ this.storage.context[key] = value;
260
329
  });
261
330
  }
262
- // Reload memory from database
263
- this.memory = this.loadMemory();
331
+ // Import task history
332
+ if (data.taskHistory) {
333
+ this.storage.taskHistory = data.taskHistory;
334
+ }
335
+ // Update memory from storage
336
+ this.memory = this.convertStorageToMemory();
337
+ // Save all
338
+ this.saveAll();
264
339
  }
265
340
  catch (error) {
266
341
  throw new Error(`Failed to import memory: ${error.message}`);
@@ -268,31 +343,32 @@ class QueenMemorySystem {
268
343
  }
269
344
  // Clear all memory (reset learning)
270
345
  clearMemory() {
271
- // Clear database tables
272
- this.db.exec(`
273
- DELETE FROM patterns;
274
- DELETE FROM artifacts;
275
- DELETE FROM learnings;
276
- DELETE FROM task_history;
277
- `);
278
- // Reset in-memory storage
346
+ // Reset storage
347
+ this.storage = {
348
+ patterns: [],
349
+ artifacts: {},
350
+ learnings: {},
351
+ context: {},
352
+ taskHistory: []
353
+ };
354
+ // Reset memory
279
355
  this.memory = {
280
356
  patterns: [],
281
357
  artifacts: new Map(),
282
358
  agentHistory: new Map(),
283
359
  learnings: new Map()
284
360
  };
361
+ // Save empty state
362
+ this.saveAll();
285
363
  }
286
364
  // Store data in context (key-value store)
287
365
  storeInContext(key, value) {
288
- const stmt = this.db.prepare('INSERT OR REPLACE INTO context (key, value) VALUES (?, ?)');
289
- stmt.run(key, JSON.stringify(value));
366
+ this.storage.context[key] = value;
367
+ this.scheduleSave();
290
368
  }
291
369
  // Get data from context
292
370
  getFromContext(key) {
293
- const stmt = this.db.prepare('SELECT value FROM context WHERE key = ?');
294
- const row = stmt.get(key);
295
- return row ? JSON.parse(row.value) : null;
371
+ return this.storage.context[key] || null;
296
372
  }
297
373
  // Store generic data (alias for storeInContext for compatibility)
298
374
  store(key, value) {
@@ -302,34 +378,33 @@ class QueenMemorySystem {
302
378
  get(key) {
303
379
  return this.getFromContext(key);
304
380
  }
305
- // Get database path
381
+ // Get database path (for compatibility)
306
382
  getDbPath() {
307
- return this.dbPath;
383
+ return this.memoryDir;
308
384
  }
309
- // Close database connection
385
+ // Close database connection (no-op for JSON, but kept for compatibility)
310
386
  close() {
311
- this.db.close();
387
+ // Save any pending changes
388
+ if (this.saveDebounceTimer) {
389
+ clearTimeout(this.saveDebounceTimer);
390
+ this.saveAll();
391
+ }
312
392
  }
313
393
  // Additional methods needed by other components
314
394
  /**
315
395
  * Find similar patterns for a given task type
316
396
  */
317
397
  findSimilarPatterns(taskType) {
318
- const stmt = this.db.prepare(`
319
- SELECT * FROM patterns
320
- WHERE task_type LIKE ?
321
- ORDER BY success_rate DESC, use_count DESC
322
- LIMIT 5
323
- `);
324
- const rows = stmt.all(`%${taskType}%`);
325
- return rows.map(row => ({
326
- taskType: row.task_type,
327
- successRate: row.success_rate,
328
- agentSequence: JSON.parse(row.agent_sequence),
329
- mcpSequence: JSON.parse(row.mcp_sequence),
330
- avgDuration: row.avg_duration,
331
- lastUsed: new Date(row.last_used)
332
- }));
398
+ return this.storage.patterns
399
+ .filter(p => p.taskType.toLowerCase().includes(taskType.toLowerCase()))
400
+ .sort((a, b) => {
401
+ // Sort by success rate first, then by use count
402
+ if (b.successRate !== a.successRate) {
403
+ return b.successRate - a.successRate;
404
+ }
405
+ return (b.useCount || 0) - (a.useCount || 0);
406
+ })
407
+ .slice(0, 5);
333
408
  }
334
409
  /**
335
410
  * Store a decision made by the Queen
@@ -351,17 +426,22 @@ class QueenMemorySystem {
351
426
  * Get memory statistics
352
427
  */
353
428
  getStats() {
354
- const patternCount = this.db.prepare('SELECT COUNT(*) as count FROM patterns').get();
355
- const artifactCount = this.db.prepare('SELECT COUNT(*) as count FROM artifacts').get();
356
- const taskCount = this.db.prepare('SELECT COUNT(*) as count FROM task_history').get();
357
- const learningCount = this.db.prepare('SELECT COUNT(*) as count FROM learnings').get();
358
- return {
359
- patterns: patternCount.count,
360
- artifacts: artifactCount.count,
361
- tasks: taskCount.count,
362
- learnings: learningCount.count,
363
- databaseSize: fs.statSync(this.dbPath).size
429
+ const stats = {
430
+ patterns: this.storage.patterns.length,
431
+ artifacts: Object.keys(this.storage.artifacts).length,
432
+ tasks: this.storage.taskHistory.length,
433
+ learnings: Object.keys(this.storage.learnings).length,
434
+ databaseSize: 0
364
435
  };
436
+ // Calculate total file sizes
437
+ const files = ['patterns.json', 'artifacts.json', 'learnings.json', 'context.json', 'task-history.json'];
438
+ for (const file of files) {
439
+ const filepath = this.getFilePath(file);
440
+ if (fs.existsSync(filepath)) {
441
+ stats.databaseSize += fs.statSync(filepath).size;
442
+ }
443
+ }
444
+ return stats;
365
445
  }
366
446
  /**
367
447
  * Store progress information
@@ -379,11 +459,8 @@ class QueenMemorySystem {
379
459
  * Store failure pattern for learning
380
460
  */
381
461
  storeFailurePattern(pattern) {
382
- const stmt = this.db.prepare(`
383
- INSERT INTO learnings (key, value, confidence, updated_at)
384
- VALUES (?, ?, ?, ?)
385
- `);
386
- stmt.run(`failure_${Date.now()}`, JSON.stringify(pattern), 0.8, new Date().toISOString());
462
+ const key = `failure_${Date.now()}`;
463
+ this.storeLearning(key, pattern, 0.8);
387
464
  }
388
465
  }
389
466
  exports.QueenMemorySystem = QueenMemorySystem;
@@ -32,6 +32,7 @@ export interface DeploymentPattern {
32
32
  lastUsed: Date;
33
33
  decision?: string;
34
34
  outcome?: string;
35
+ useCount?: number;
35
36
  }
36
37
  export interface QueenMemory {
37
38
  patterns: DeploymentPattern[];
package/dist/version.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const VERSION_INFO: {
7
7
  name: string;
8
8
  description: string;
9
9
  features: {
10
+ '2.6.6': string[];
10
11
  '1.4.39': string[];
11
12
  '1.4.38': string[];
12
13
  '1.4.37': string[];
package/dist/version.js CHANGED
@@ -14,6 +14,15 @@ exports.VERSION_INFO = {
14
14
  name: 'Snow-Flow',
15
15
  description: 'ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development',
16
16
  features: {
17
+ '2.6.6': [
18
+ '๐Ÿš€ JSON-BASED QUEEN MEMORY: Replaced SQLite with simple JSON file storage',
19
+ 'โœ… NO MORE PERMISSION ERRORS: Fixed SQLITE_READONLY_DBMOVED database issues permanently',
20
+ '๐Ÿ“ TRANSPARENT STORAGE: All memory data in readable JSON files (.snow-flow/queen/*.json)',
21
+ '๐Ÿ”ง ATOMIC SAVES: Safe file writes with temp file + rename for data integrity',
22
+ '๐Ÿ’พ DEBOUNCED PERSISTENCE: 1-second delay prevents excessive file writes',
23
+ '๐Ÿงน CLEANER SYSTEM: Removed better-sqlite3 dependency from Queen memory',
24
+ '๐Ÿ“Š BACKWARDS COMPATIBLE: Same API, just simpler storage backend',
25
+ ],
17
26
  '1.4.39': [
18
27
  '๐Ÿงน NEO4J REMOVAL: Removed Neo4j graph memory from available tools (implementation preserved)',
19
28
  'โœ… NEW TOOLS: Implemented neural_status and token_usage in snow-flow-mcp',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "description": "Snow-Flow: ServiceNow Advanced Intelligence Platform - 100+ real MCP tools with AI-powered swarm orchestration and neural networks. Dynamic task categorization using AI. Machine learning for incident classification, change risk prediction, and anomaly detection. Zero Mock Data, 100% Real API Integration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",