fivocell 1.0.4 → 2.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 (152) hide show
  1. package/README.md +697 -505
  2. package/bin/cell.js +2 -2
  3. package/dist/behavior-intelligence.d.ts +90 -0
  4. package/dist/behavior-intelligence.d.ts.map +1 -0
  5. package/dist/behavior-intelligence.js +595 -0
  6. package/dist/behavior-intelligence.js.map +1 -0
  7. package/dist/cli.d.ts +6 -1
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +2191 -1
  10. package/dist/cli.js.map +1 -1
  11. package/dist/cloud-sync.d.ts +66 -0
  12. package/dist/cloud-sync.d.ts.map +1 -0
  13. package/dist/cloud-sync.js +328 -0
  14. package/dist/cloud-sync.js.map +1 -0
  15. package/dist/community-intelligence.d.ts +42 -0
  16. package/dist/community-intelligence.d.ts.map +1 -0
  17. package/dist/community-intelligence.js +160 -0
  18. package/dist/community-intelligence.js.map +1 -0
  19. package/dist/community-v2.d.ts +106 -0
  20. package/dist/community-v2.d.ts.map +1 -0
  21. package/dist/community-v2.js +378 -0
  22. package/dist/community-v2.js.map +1 -0
  23. package/dist/core/__tests__/chapter8-hostile.test.js +1 -1
  24. package/dist/core/__tests__/chapter8-hostile.test.js.map +1 -1
  25. package/dist/core/__tests__/chapter9-hostile.test.js +1 -1
  26. package/dist/core/__tests__/chapter9-hostile.test.js.map +1 -1
  27. package/dist/core/__tests__/complexity-analyzer.test.js +15 -15
  28. package/dist/core/__tests__/team-composer.test.js +2 -1
  29. package/dist/core/__tests__/team-composer.test.js.map +1 -1
  30. package/dist/core/convention-detector.d.ts.map +1 -1
  31. package/dist/core/convention-detector.js +11 -23
  32. package/dist/core/convention-detector.js.map +1 -1
  33. package/dist/core/cost-optimizer.d.ts.map +1 -1
  34. package/dist/core/cost-optimizer.js +13 -25
  35. package/dist/core/cost-optimizer.js.map +1 -1
  36. package/dist/core/database.d.ts +28 -0
  37. package/dist/core/database.d.ts.map +1 -0
  38. package/dist/core/database.js +587 -0
  39. package/dist/core/database.js.map +1 -0
  40. package/dist/core/knowledge-graph.d.ts.map +1 -1
  41. package/dist/core/knowledge-graph.js +9 -24
  42. package/dist/core/knowledge-graph.js.map +1 -1
  43. package/dist/core/logger.d.ts +9 -0
  44. package/dist/core/logger.d.ts.map +1 -0
  45. package/dist/core/logger.js +26 -0
  46. package/dist/core/logger.js.map +1 -0
  47. package/dist/core/playbook-generator.js +48 -48
  48. package/dist/core/privacy-manager.d.ts.map +1 -1
  49. package/dist/core/privacy-manager.js +5 -0
  50. package/dist/core/privacy-manager.js.map +1 -1
  51. package/dist/core/project-dna.d.ts.map +1 -1
  52. package/dist/core/project-dna.js +6 -19
  53. package/dist/core/project-dna.js.map +1 -1
  54. package/dist/core/prompt-builder.d.ts +18 -0
  55. package/dist/core/prompt-builder.d.ts.map +1 -0
  56. package/dist/core/prompt-builder.js +325 -0
  57. package/dist/core/prompt-builder.js.map +1 -0
  58. package/dist/core/session-memory.d.ts +90 -0
  59. package/dist/core/session-memory.d.ts.map +1 -0
  60. package/dist/core/session-memory.js +229 -0
  61. package/dist/core/session-memory.js.map +1 -0
  62. package/dist/core/signal-capture.d.ts +5 -0
  63. package/dist/core/signal-capture.d.ts.map +1 -1
  64. package/dist/core/signal-capture.js +67 -0
  65. package/dist/core/signal-capture.js.map +1 -1
  66. package/dist/core/team-composer.d.ts.map +1 -1
  67. package/dist/core/team-composer.js +16 -6
  68. package/dist/core/team-composer.js.map +1 -1
  69. package/dist/cross-model-memory.d.ts +95 -0
  70. package/dist/cross-model-memory.d.ts.map +1 -0
  71. package/dist/cross-model-memory.js +229 -0
  72. package/dist/cross-model-memory.js.map +1 -0
  73. package/dist/daemon/lifecycle.d.ts +18 -0
  74. package/dist/daemon/lifecycle.d.ts.map +1 -1
  75. package/dist/daemon/lifecycle.js +182 -5
  76. package/dist/daemon/lifecycle.js.map +1 -1
  77. package/dist/daemon/server.d.ts.map +1 -1
  78. package/dist/daemon/server.js +269 -6
  79. package/dist/daemon/server.js.map +1 -1
  80. package/dist/first-run.d.ts +8 -0
  81. package/dist/first-run.d.ts.map +1 -0
  82. package/dist/first-run.js +182 -0
  83. package/dist/first-run.js.map +1 -0
  84. package/dist/focus-report.d.ts +32 -0
  85. package/dist/focus-report.d.ts.map +1 -0
  86. package/dist/focus-report.js +293 -0
  87. package/dist/focus-report.js.map +1 -0
  88. package/dist/ide-intelligence.d.ts +118 -0
  89. package/dist/ide-intelligence.d.ts.map +1 -0
  90. package/dist/ide-intelligence.js +284 -0
  91. package/dist/ide-intelligence.js.map +1 -0
  92. package/dist/index.d.ts +22 -0
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +119 -2
  95. package/dist/index.js.map +1 -1
  96. package/dist/insight-generator.d.ts +58 -0
  97. package/dist/insight-generator.d.ts.map +1 -0
  98. package/dist/insight-generator.js +314 -0
  99. package/dist/insight-generator.js.map +1 -0
  100. package/dist/journey-memory.d.ts +75 -0
  101. package/dist/journey-memory.d.ts.map +1 -0
  102. package/dist/journey-memory.js +360 -0
  103. package/dist/journey-memory.js.map +1 -0
  104. package/dist/mcp-server.d.ts +2054 -0
  105. package/dist/mcp-server.d.ts.map +1 -0
  106. package/dist/mcp-server.js +1120 -0
  107. package/dist/mcp-server.js.map +1 -0
  108. package/dist/onboarding-scan.d.ts +174 -0
  109. package/dist/onboarding-scan.d.ts.map +1 -0
  110. package/dist/onboarding-scan.js +1039 -0
  111. package/dist/onboarding-scan.js.map +1 -0
  112. package/dist/personal-intelligence.d.ts +97 -0
  113. package/dist/personal-intelligence.d.ts.map +1 -0
  114. package/dist/personal-intelligence.js +408 -0
  115. package/dist/personal-intelligence.js.map +1 -0
  116. package/dist/predictive-intelligence.d.ts +95 -0
  117. package/dist/predictive-intelligence.d.ts.map +1 -0
  118. package/dist/predictive-intelligence.js +544 -0
  119. package/dist/predictive-intelligence.js.map +1 -0
  120. package/dist/production.d.ts +67 -0
  121. package/dist/production.d.ts.map +1 -0
  122. package/dist/production.js +333 -0
  123. package/dist/production.js.map +1 -0
  124. package/dist/senior-features.d.ts +63 -0
  125. package/dist/senior-features.d.ts.map +1 -0
  126. package/dist/senior-features.js +325 -0
  127. package/dist/senior-features.js.map +1 -0
  128. package/dist/style-pull.d.ts +40 -0
  129. package/dist/style-pull.d.ts.map +1 -0
  130. package/dist/style-pull.js +385 -0
  131. package/dist/style-pull.js.map +1 -0
  132. package/dist/team-collaboration.d.ts +116 -0
  133. package/dist/team-collaboration.d.ts.map +1 -0
  134. package/dist/team-collaboration.js +375 -0
  135. package/dist/team-collaboration.js.map +1 -0
  136. package/dist/team-intelligence.d.ts +64 -0
  137. package/dist/team-intelligence.d.ts.map +1 -0
  138. package/dist/team-intelligence.js +289 -0
  139. package/dist/team-intelligence.js.map +1 -0
  140. package/dist/test-watch.d.ts +2 -0
  141. package/dist/test-watch.d.ts.map +1 -0
  142. package/dist/test-watch.js +8 -0
  143. package/dist/test-watch.js.map +1 -0
  144. package/dist/user-intelligence.d.ts +69 -0
  145. package/dist/user-intelligence.d.ts.map +1 -0
  146. package/dist/user-intelligence.js +553 -0
  147. package/dist/user-intelligence.js.map +1 -0
  148. package/dist/work-style.d.ts +49 -0
  149. package/dist/work-style.d.ts.map +1 -0
  150. package/dist/work-style.js +247 -0
  151. package/dist/work-style.js.map +1 -0
  152. package/package.json +3 -2
@@ -113,7 +113,10 @@ const recommendation_store_1 = require("../core/recommendation-store");
113
113
  const community_intelligence_1 = require("../core/community-intelligence");
114
114
  const org_intelligence_1 = require("../core/org-intelligence");
115
115
  const cross_layer_intelligence_1 = require("../core/cross-layer-intelligence");
116
+ const database_1 = require("../core/database");
117
+ const logger_1 = require("../core/logger");
116
118
  const CELL_DIR = path.join(os.homedir(), '.fivo', 'cell');
119
+ (0, database_1.initializeDatabase)();
117
120
  const META_PATH = path.join(CELL_DIR, 'cell-meta.json');
118
121
  const PORT = 9876;
119
122
  function getCloudConfig() {
@@ -121,7 +124,9 @@ function getCloudConfig() {
121
124
  if (fs.existsSync(META_PATH))
122
125
  return JSON.parse(fs.readFileSync(META_PATH, 'utf-8'));
123
126
  }
124
- catch { }
127
+ catch (e) {
128
+ logger_1.logger.warn('Failed to read cell-meta.json: ' + String(e));
129
+ }
125
130
  return { cloudSyncEnabled: true };
126
131
  }
127
132
  const app = (0, express_1.default)();
@@ -318,15 +323,25 @@ app.get('/confidence/:patternId', (req, res) => {
318
323
  });
319
324
  // ─── IMPACT TRACKING ──────────────────────────────────
320
325
  const impactLog = [];
326
+ function persistImpact(entry) {
327
+ try {
328
+ const db = (0, database_1.getDb)();
329
+ db.prepare('INSERT INTO outcomes (outcome_type, pattern_id, project, description, created_at) VALUES (?, ?, ?, ?, ?)')
330
+ .run('impact', entry.patternId, '', `Applied via ${entry.surface}`, new Date(entry.timestamp).toISOString());
331
+ }
332
+ catch { /* best-effort */ }
333
+ }
321
334
  app.post('/impact/record', (req, res) => {
322
335
  const { patternId, surface } = req.body;
323
336
  if (!patternId) {
324
337
  res.status(400).json({ error: 'patternId required' });
325
338
  return;
326
339
  }
327
- impactLog.push({ patternId, timestamp: Date.now(), surface: surface || 'unknown' });
340
+ const entry = { patternId, timestamp: Date.now(), surface: surface || 'unknown' };
341
+ impactLog.push(entry);
328
342
  if (impactLog.length > 10000)
329
343
  impactLog.splice(0, impactLog.length - 10000);
344
+ persistImpact(entry);
330
345
  res.json({ recorded: true });
331
346
  });
332
347
  app.get('/impact/weekly', (_req, res) => {
@@ -368,7 +383,9 @@ app.post('/onboarding/scan', (req, res) => {
368
383
  insights.push('TypeScript strict mode → You likely prefer const over let');
369
384
  }
370
385
  }
371
- catch { }
386
+ catch (e) {
387
+ logger_1.logger.warn('Failed to read tsconfig: ' + String(e));
388
+ }
372
389
  try {
373
390
  const eslintPaths = ['.eslintrc.json', '.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', 'eslint.config.js'];
374
391
  for (const eslintFile of eslintPaths) {
@@ -379,12 +396,16 @@ app.post('/onboarding/scan', (req, res) => {
379
396
  if (JSON.stringify(eslint).includes('singlequote') || JSON.stringify(eslint).includes('single'))
380
397
  insights.push('ESLint single quotes → You prefer \' over \"');
381
398
  }
382
- catch { }
399
+ catch (e) {
400
+ logger_1.logger.warn('Failed to parse eslint config: ' + String(e));
401
+ }
383
402
  break;
384
403
  }
385
404
  }
386
405
  }
387
- catch { }
406
+ catch (e) {
407
+ logger_1.logger.warn('Failed to read eslint: ' + String(e));
408
+ }
388
409
  try {
389
410
  const pkgPath = path.join(dir, 'package.json');
390
411
  if (fs.existsSync(pkgPath)) {
@@ -404,7 +425,9 @@ app.post('/onboarding/scan', (req, res) => {
404
425
  insights.push('Zod → You prefer schema validation');
405
426
  }
406
427
  }
407
- catch { }
428
+ catch (e) {
429
+ logger_1.logger.warn('Failed to read package.json: ' + String(e));
430
+ }
408
431
  res.json({ insights, count: insights.length, projectPath: dir });
409
432
  });
410
433
  // ─── LOCAL DASHBOARD HTML ─────────────────────────────
@@ -1299,6 +1322,246 @@ app.post('/intelligence/reset', (_req, res) => {
1299
1322
  (0, cross_layer_intelligence_1.resetCrossLayer)();
1300
1323
  res.json({ reset: true });
1301
1324
  });
1325
+ // ─── CONTEXT INJECTION ───────────────────────────────
1326
+ const prompt_builder_1 = require("../core/prompt-builder");
1327
+ const session_memory_1 = require("../core/session-memory");
1328
+ const sessionMemory = new session_memory_1.SessionMemory();
1329
+ app.post('/session/start', (req, res) => {
1330
+ const { toolName, project } = req.body;
1331
+ const id = sessionMemory.startSession(toolName || 'unknown', project || 'unknown');
1332
+ res.json({ sessionId: id });
1333
+ });
1334
+ app.post('/session/end', (req, res) => {
1335
+ const { sessionId, filesTouched, keyDecisions, contextSnapshot } = req.body;
1336
+ sessionMemory.endSession(Number(sessionId), { filesTouched, keyDecisions, contextSnapshot });
1337
+ res.json({ ended: true });
1338
+ });
1339
+ app.get('/session/history', (req, res) => {
1340
+ const limit = Number(req.query.limit) || 10;
1341
+ const sessions = sessionMemory.getRecentSessions(limit);
1342
+ const stats = sessionMemory.getSessionStats();
1343
+ const chain = sessionMemory.buildContextChain();
1344
+ res.json({ sessions, stats, contextChain: chain });
1345
+ });
1346
+ app.get('/session/search', (req, res) => {
1347
+ const query = String(req.query.q || '');
1348
+ const results = query ? sessionMemory.searchSessions(query) : [];
1349
+ res.json({ query, results: results.slice(0, 10) });
1350
+ });
1351
+ app.get('/session/bugs', (req, res) => {
1352
+ const bugs = sessionMemory.getBugHistory(String(req.query.project || ''));
1353
+ const repeats = sessionMemory.getRepeatBugs();
1354
+ res.json({ bugs: bugs.slice(0, 20), repeatBugs: repeats });
1355
+ });
1356
+ app.get('/session/decisions', (req, res) => {
1357
+ const decisions = sessionMemory.getDecisionHistory(String(req.query.project || ''));
1358
+ const summary = sessionMemory.getDecisionSummary();
1359
+ res.json({ decisions: decisions.slice(0, 20), summary });
1360
+ });
1361
+ app.get('/context/inject', (req, res) => {
1362
+ const projectPath = req.query.projectPath;
1363
+ const toolName = req.query.tool;
1364
+ const compact = req.query.compact === 'true' || req.query.compact === '1';
1365
+ const ctx = (0, prompt_builder_1.buildContext)(projectPath, toolName);
1366
+ const text = (0, prompt_builder_1.formatContextForInjection)(ctx, compact);
1367
+ res.json({ content: [{ type: 'text', text }], context: ctx });
1368
+ });
1369
+ app.get('/predict', (req, res) => {
1370
+ const project = String(req.query.project || '');
1371
+ const type = String(req.query.type || '');
1372
+ Promise.resolve().then(() => __importStar(require('../predictive-intelligence'))).then(({ getAllPredictions }) => {
1373
+ const predictions = getAllPredictions(project || undefined);
1374
+ const filtered = type ? predictions.filter(p => p.type === type) : predictions;
1375
+ res.json({ predictions: filtered, count: filtered.length });
1376
+ }).catch(e => res.status(500).json({ error: String(e) }));
1377
+ });
1378
+ app.get('/predict-risk/:file', (req, res) => {
1379
+ const file = req.params.file;
1380
+ Promise.resolve().then(() => __importStar(require('../predictive-intelligence'))).then(({ calculateFileRisk }) => {
1381
+ res.json(calculateFileRisk(file));
1382
+ }).catch(e => res.status(500).json({ error: String(e) }));
1383
+ });
1384
+ app.get('/predict-time/:feature', (req, res) => {
1385
+ const feature = req.params.feature;
1386
+ Promise.resolve().then(() => __importStar(require('../predictive-intelligence'))).then(({ estimateFeatureTime }) => {
1387
+ res.json(estimateFeatureTime(feature));
1388
+ }).catch(e => res.status(500).json({ error: String(e) }));
1389
+ });
1390
+ app.get('/tools/compare', (_req, res) => {
1391
+ Promise.resolve().then(() => __importStar(require('../cross-model-memory'))).then(({ compareTools }) => {
1392
+ res.json({ tools: compareTools() });
1393
+ }).catch(e => res.status(500).json({ error: String(e) }));
1394
+ });
1395
+ app.get('/tools/suggest', (req, res) => {
1396
+ const taskType = String(req.query.task || '');
1397
+ if (!taskType) {
1398
+ res.status(400).json({ error: 'task query param required' });
1399
+ return;
1400
+ }
1401
+ Promise.resolve().then(() => __importStar(require('../cross-model-memory'))).then(({ suggestTool }) => {
1402
+ res.json({ suggestions: suggestTool(taskType) });
1403
+ }).catch(e => res.status(500).json({ error: String(e) }));
1404
+ });
1405
+ app.get('/tools/history', (_req, res) => {
1406
+ Promise.resolve().then(() => __importStar(require('../cross-model-memory'))).then(({ getModelHistory }) => {
1407
+ res.json({ history: getModelHistory() });
1408
+ }).catch(e => res.status(500).json({ error: String(e) }));
1409
+ });
1410
+ app.get('/tools/context/:tool', (req, res) => {
1411
+ const tool = req.params.tool;
1412
+ Promise.resolve().then(() => __importStar(require('../cross-model-memory'))).then(({ buildToolSpecificContext }) => {
1413
+ res.json({ context: buildToolSpecificContext(tool) });
1414
+ }).catch(e => res.status(500).json({ error: String(e) }));
1415
+ });
1416
+ app.get('/team/health', (req, res) => {
1417
+ const project = String(req.query.project || '') || undefined;
1418
+ Promise.resolve().then(() => __importStar(require('../team-collaboration'))).then(({ getTeamHealth }) => {
1419
+ res.json(getTeamHealth(project));
1420
+ }).catch(e => res.status(500).json({ error: String(e) }));
1421
+ });
1422
+ app.get('/team/silos', (_req, res) => {
1423
+ Promise.resolve().then(() => __importStar(require('../team-collaboration'))).then(({ detectKnowledgeSilos, calculateBusFactor, suggestKnowledgeTransfer }) => {
1424
+ res.json({ silos: detectKnowledgeSilos(), busFactor: calculateBusFactor(), transfers: suggestKnowledgeTransfer() });
1425
+ }).catch(e => res.status(500).json({ error: String(e) }));
1426
+ });
1427
+ app.get('/team/style', (req, res) => {
1428
+ const project = String(req.query.project || '') || undefined;
1429
+ Promise.resolve().then(() => __importStar(require('../team-collaboration'))).then(({ composeTeamStyle }) => {
1430
+ res.json(composeTeamStyle(project));
1431
+ }).catch(e => res.status(500).json({ error: String(e) }));
1432
+ });
1433
+ app.get('/team/retro', (req, res) => {
1434
+ const days = parseInt(String(req.query.days || '14')) || 14;
1435
+ const project = String(req.query.project || '') || undefined;
1436
+ Promise.resolve().then(() => __importStar(require('../team-collaboration'))).then(({ generateSprintRetro }) => {
1437
+ res.json(generateSprintRetro(days, project));
1438
+ }).catch(e => res.status(500).json({ error: String(e) }));
1439
+ });
1440
+ app.get('/team/onboard/:team', (req, res) => {
1441
+ const team = req.params.team;
1442
+ const project = String(req.query.project || '') || undefined;
1443
+ Promise.resolve().then(() => __importStar(require('../team-collaboration'))).then(({ generateOnboardingDoc }) => {
1444
+ res.json(generateOnboardingDoc(team, project));
1445
+ }).catch(e => res.status(500).json({ error: String(e) }));
1446
+ });
1447
+ app.get('/community/compare', (_req, res) => {
1448
+ Promise.resolve().then(() => __importStar(require('../community-v2'))).then(({ benchmarkPersonal, benchmarkBlindSpots }) => {
1449
+ res.json({ benchmarks: benchmarkPersonal(), blindSpots: benchmarkBlindSpots() });
1450
+ }).catch(e => res.status(500).json({ error: String(e) }));
1451
+ });
1452
+ app.get('/community/trends', (_req, res) => {
1453
+ Promise.resolve().then(() => __importStar(require('../community-v2'))).then(({ detectTrends, getCommunityStats }) => {
1454
+ res.json({ trends: detectTrends(), stats: getCommunityStats() });
1455
+ }).catch(e => res.status(500).json({ error: String(e) }));
1456
+ });
1457
+ app.get('/community/insights', (_req, res) => {
1458
+ Promise.resolve().then(() => __importStar(require('../community-v2'))).then(({ generateInsights }) => {
1459
+ res.json({ insights: generateInsights() });
1460
+ }).catch(e => res.status(500).json({ error: String(e) }));
1461
+ });
1462
+ app.get('/personal/rhythm', (_req, res) => {
1463
+ Promise.resolve().then(() => __importStar(require('../personal-intelligence'))).then(({ detectCodingRhythm }) => {
1464
+ res.json(detectCodingRhythm());
1465
+ }).catch(e => res.status(500).json({ error: String(e) }));
1466
+ });
1467
+ app.get('/personal/burnout', (_req, res) => {
1468
+ Promise.resolve().then(() => __importStar(require('../personal-intelligence'))).then(({ detectBurnout }) => {
1469
+ res.json(detectBurnout());
1470
+ }).catch(e => res.status(500).json({ error: String(e) }));
1471
+ });
1472
+ app.get('/personal/mastery', (_req, res) => {
1473
+ Promise.resolve().then(() => __importStar(require('../personal-intelligence'))).then(({ getTechMasteryMap }) => {
1474
+ res.json({ mastery: getTechMasteryMap() });
1475
+ }).catch(e => res.status(500).json({ error: String(e) }));
1476
+ });
1477
+ app.get('/personal/growth', (_req, res) => {
1478
+ Promise.resolve().then(() => __importStar(require('../personal-intelligence'))).then(({ getCareerTrajectory }) => {
1479
+ res.json(getCareerTrajectory());
1480
+ }).catch(e => res.status(500).json({ error: String(e) }));
1481
+ });
1482
+ app.get('/personal/weekly', (_req, res) => {
1483
+ Promise.resolve().then(() => __importStar(require('../personal-intelligence'))).then(({ generateWeeklyDigest }) => {
1484
+ res.json(generateWeeklyDigest());
1485
+ }).catch(e => res.status(500).json({ error: String(e) }));
1486
+ });
1487
+ app.get('/production/health', (_req, res) => {
1488
+ Promise.resolve().then(() => __importStar(require('../production'))).then(({ getHealthStatus }) => {
1489
+ res.json(getHealthStatus());
1490
+ }).catch(e => res.status(500).json({ error: String(e) }));
1491
+ });
1492
+ app.get('/production/metrics', (_req, res) => {
1493
+ Promise.resolve().then(() => __importStar(require('../production'))).then(({ getMetrics }) => {
1494
+ res.json(getMetrics());
1495
+ }).catch(e => res.status(500).json({ error: String(e) }));
1496
+ });
1497
+ app.get('/production/security', (_req, res) => {
1498
+ Promise.resolve().then(() => __importStar(require('../production'))).then(() => {
1499
+ const fs = require('fs');
1500
+ const path = require('path');
1501
+ const os = require('os');
1502
+ const secFile = path.join(os.homedir(), '.fivo', 'cell', 'security.json');
1503
+ if (fs.existsSync(secFile)) {
1504
+ res.json(JSON.parse(fs.readFileSync(secFile, 'utf-8')));
1505
+ }
1506
+ else {
1507
+ res.status(404).json({ error: 'no security config' });
1508
+ }
1509
+ }).catch(e => res.status(500).json({ error: String(e) }));
1510
+ });
1511
+ app.post('/production/backup', (_req, res) => {
1512
+ Promise.resolve().then(() => __importStar(require('../production'))).then(({ autoBackup }) => {
1513
+ res.json(autoBackup());
1514
+ }).catch(e => res.status(500).json({ error: String(e) }));
1515
+ });
1516
+ app.post('/production/optimize', (_req, res) => {
1517
+ Promise.resolve().then(() => __importStar(require('../production'))).then(({ optimizeDatabase }) => {
1518
+ res.json(optimizeDatabase());
1519
+ }).catch(e => res.status(500).json({ error: String(e) }));
1520
+ });
1521
+ app.get('/ide/debug-style', (_req, res) => {
1522
+ Promise.resolve().then(() => __importStar(require('../ide-intelligence'))).then(({ initializeIDETables, getDebugStyle }) => {
1523
+ initializeIDETables();
1524
+ res.json(getDebugStyle());
1525
+ }).catch(e => res.status(500).json({ error: String(e) }));
1526
+ });
1527
+ app.get('/ide/prompt-style', (_req, res) => {
1528
+ Promise.resolve().then(() => __importStar(require('../ide-intelligence'))).then(({ initializeIDETables, getPromptStyle }) => {
1529
+ initializeIDETables();
1530
+ res.json(getPromptStyle());
1531
+ }).catch(e => res.status(500).json({ error: String(e) }));
1532
+ });
1533
+ app.get('/ide/focus', (_req, res) => {
1534
+ Promise.resolve().then(() => __importStar(require('../ide-intelligence'))).then(({ initializeIDETables, getFocusAnalysis }) => {
1535
+ initializeIDETables();
1536
+ res.json(getFocusAnalysis());
1537
+ }).catch(e => res.status(500).json({ error: String(e) }));
1538
+ });
1539
+ app.get('/ide/insights', (_req, res) => {
1540
+ Promise.resolve().then(() => __importStar(require('../ide-intelligence'))).then(({ initializeIDETables, getIDEInsights }) => {
1541
+ initializeIDETables();
1542
+ res.json(getIDEInsights());
1543
+ }).catch(e => res.status(500).json({ error: String(e) }));
1544
+ });
1545
+ app.get('/cloud/status', (_req, res) => {
1546
+ Promise.resolve().then(() => __importStar(require('../cloud-sync'))).then(({ getSyncStatus }) => {
1547
+ res.json(getSyncStatus());
1548
+ }).catch(e => res.status(500).json({ error: String(e) }));
1549
+ });
1550
+ app.post('/cloud/validate', (req, res) => {
1551
+ Promise.resolve().then(() => __importStar(require('../cloud-sync'))).then(({ validatePayload }) => {
1552
+ res.json(validatePayload(req.body || {}));
1553
+ }).catch(e => res.status(500).json({ error: String(e) }));
1554
+ });
1555
+ app.get('/cloud/queue', (_req, res) => {
1556
+ Promise.resolve().then(() => __importStar(require('../cloud-sync'))).then(({ getPendingQueue, retryFailedEntries }) => {
1557
+ res.json({ pending: getPendingQueue(), retryable: retryFailedEntries() });
1558
+ }).catch(e => res.status(500).json({ error: String(e) }));
1559
+ });
1560
+ app.post('/cloud/push', (req, res) => {
1561
+ Promise.resolve().then(() => __importStar(require('../cloud-sync'))).then(({ pushToCloud }) => {
1562
+ pushToCloud(req.body?.data || {}, req.body?.type || 'pattern').then(r => res.json(r));
1563
+ }).catch(e => res.status(500).json({ error: String(e) }));
1564
+ });
1302
1565
  app.use((_req, res) => { res.status(404).json({ error: 'not found' }); });
1303
1566
  app.use((err, _req, res, _next) => {
1304
1567
  console.error('Daemon error:', err.message);