fivocell 4.9.0 → 5.1.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 (71) hide show
  1. package/dist/__tests__/code-health.test.d.ts +2 -0
  2. package/dist/__tests__/code-health.test.d.ts.map +1 -0
  3. package/dist/__tests__/code-health.test.js +90 -0
  4. package/dist/__tests__/code-health.test.js.map +1 -0
  5. package/dist/__tests__/context-compression.test.d.ts +2 -0
  6. package/dist/__tests__/context-compression.test.d.ts.map +1 -0
  7. package/dist/__tests__/context-compression.test.js +77 -0
  8. package/dist/__tests__/context-compression.test.js.map +1 -0
  9. package/dist/__tests__/developer-velocity.test.d.ts +2 -0
  10. package/dist/__tests__/developer-velocity.test.d.ts.map +1 -0
  11. package/dist/__tests__/developer-velocity.test.js +66 -0
  12. package/dist/__tests__/developer-velocity.test.js.map +1 -0
  13. package/dist/__tests__/error-trends.test.d.ts +2 -0
  14. package/dist/__tests__/error-trends.test.d.ts.map +1 -0
  15. package/dist/__tests__/error-trends.test.js +61 -0
  16. package/dist/__tests__/error-trends.test.js.map +1 -0
  17. package/dist/__tests__/memory-automation.test.d.ts +2 -0
  18. package/dist/__tests__/memory-automation.test.d.ts.map +1 -0
  19. package/dist/__tests__/memory-automation.test.js +136 -0
  20. package/dist/__tests__/memory-automation.test.js.map +1 -0
  21. package/dist/__tests__/memory-growth.test.d.ts +2 -0
  22. package/dist/__tests__/memory-growth.test.d.ts.map +1 -0
  23. package/dist/__tests__/memory-growth.test.js +61 -0
  24. package/dist/__tests__/memory-growth.test.js.map +1 -0
  25. package/dist/__tests__/memory-health.test.d.ts +2 -0
  26. package/dist/__tests__/memory-health.test.d.ts.map +1 -0
  27. package/dist/__tests__/memory-health.test.js +66 -0
  28. package/dist/__tests__/memory-health.test.js.map +1 -0
  29. package/dist/__tests__/smart-recommendations.test.d.ts +2 -0
  30. package/dist/__tests__/smart-recommendations.test.d.ts.map +1 -0
  31. package/dist/__tests__/smart-recommendations.test.js +74 -0
  32. package/dist/__tests__/smart-recommendations.test.js.map +1 -0
  33. package/dist/walls/06-memory/automation/memory-automation.d.ts +49 -0
  34. package/dist/walls/06-memory/automation/memory-automation.d.ts.map +1 -0
  35. package/dist/walls/06-memory/automation/memory-automation.js +396 -0
  36. package/dist/walls/06-memory/automation/memory-automation.js.map +1 -0
  37. package/dist/walls/06-memory/stores/code-health.d.ts +40 -0
  38. package/dist/walls/06-memory/stores/code-health.d.ts.map +1 -0
  39. package/dist/walls/06-memory/stores/code-health.js +344 -0
  40. package/dist/walls/06-memory/stores/code-health.js.map +1 -0
  41. package/dist/walls/06-memory/stores/context-compression.d.ts +33 -0
  42. package/dist/walls/06-memory/stores/context-compression.d.ts.map +1 -0
  43. package/dist/walls/06-memory/stores/context-compression.js +265 -0
  44. package/dist/walls/06-memory/stores/context-compression.js.map +1 -0
  45. package/dist/walls/06-memory/stores/developer-velocity.d.ts +53 -0
  46. package/dist/walls/06-memory/stores/developer-velocity.d.ts.map +1 -0
  47. package/dist/walls/06-memory/stores/developer-velocity.js +225 -0
  48. package/dist/walls/06-memory/stores/developer-velocity.js.map +1 -0
  49. package/dist/walls/06-memory/stores/error-trends.d.ts +53 -0
  50. package/dist/walls/06-memory/stores/error-trends.d.ts.map +1 -0
  51. package/dist/walls/06-memory/stores/error-trends.js +232 -0
  52. package/dist/walls/06-memory/stores/error-trends.js.map +1 -0
  53. package/dist/walls/06-memory/stores/memory-growth.d.ts +34 -0
  54. package/dist/walls/06-memory/stores/memory-growth.d.ts.map +1 -0
  55. package/dist/walls/06-memory/stores/memory-growth.js +150 -0
  56. package/dist/walls/06-memory/stores/memory-growth.js.map +1 -0
  57. package/dist/walls/06-memory/stores/memory-health.d.ts +32 -0
  58. package/dist/walls/06-memory/stores/memory-health.d.ts.map +1 -0
  59. package/dist/walls/06-memory/stores/memory-health.js +221 -0
  60. package/dist/walls/06-memory/stores/memory-health.js.map +1 -0
  61. package/dist/walls/06-memory/stores/smart-recommendations.d.ts +30 -0
  62. package/dist/walls/06-memory/stores/smart-recommendations.d.ts.map +1 -0
  63. package/dist/walls/06-memory/stores/smart-recommendations.js +222 -0
  64. package/dist/walls/06-memory/stores/smart-recommendations.js.map +1 -0
  65. package/dist/walls/06-memory/stores/weekly-report.js +1 -1
  66. package/dist/walls/07-runtime/cli/cli.js +159 -0
  67. package/dist/walls/07-runtime/cli/cli.js.map +1 -1
  68. package/dist/walls/07-runtime/daemon/server.d.ts.map +1 -1
  69. package/dist/walls/07-runtime/daemon/server.js +61 -0
  70. package/dist/walls/07-runtime/daemon/server.js.map +1 -1
  71. package/package.json +1 -1
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeMemoryHealth = computeMemoryHealth;
4
+ exports.formatHealthReport = formatHealthReport;
5
+ const database_1 = require("../database/database");
6
+ function computeMemoryHealth(project) {
7
+ const db = (0, database_1.getDb)();
8
+ const suggestions = [];
9
+ // Metrics
10
+ const totalRow = db.prepare('SELECT COUNT(*) as c FROM memory_events WHERE project = ?').get(project);
11
+ const since7d = new Date(Date.now() - 7 * 86400000).toISOString();
12
+ const since30d = new Date(Date.now() - 30 * 86400000).toISOString();
13
+ const recentRow = db.prepare('SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND created_at >= ?').get(project, since7d);
14
+ const avgRow = db.prepare('SELECT AVG(importance) as a FROM memory_events WHERE project = ?').get(project);
15
+ const decisionsRow = db.prepare("SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND type = 'decision'").get(project);
16
+ const errorsRow = db.prepare("SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND type = 'error'").get(project);
17
+ const fixesRow = db.prepare("SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND type = 'fix'").get(project);
18
+ const verificationsRow = db.prepare("SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND type = 'verification'").get(project);
19
+ const patternsRow = db.prepare('SELECT COUNT(*) as c FROM memory_patterns WHERE project = ?').get(project);
20
+ const topicsRow = db.prepare('SELECT COUNT(DISTINCT topic) as c FROM memory_events WHERE project = ? AND topic IS NOT NULL').get(project);
21
+ const oldestRow = db.prepare('SELECT MIN(created_at) as o FROM memory_events WHERE project = ?').get(project);
22
+ const newestRow = db.prepare('SELECT MAX(created_at) as n FROM memory_events WHERE project = ?').get(project);
23
+ const daysSinceFirst = oldestRow.o ? Math.round((Date.now() - new Date(oldestRow.o).getTime()) / 86400000) : 0;
24
+ const daysSinceLast = newestRow.n ? Math.round((Date.now() - new Date(newestRow.n).getTime()) / 86400000) : 999;
25
+ // Handoff check
26
+ let handoffCurrent = false;
27
+ try {
28
+ const fs = require('fs');
29
+ const path = require('path');
30
+ const cellDir = path.join(process.cwd(), '.cell', 'handoff', 'current.md');
31
+ handoffCurrent = fs.existsSync(cellDir);
32
+ }
33
+ catch { }
34
+ // Style check
35
+ let styleProfileExists = false;
36
+ try {
37
+ const styleRow = db.prepare('SELECT COUNT(*) as c FROM style_profiles WHERE project = ?').get(project);
38
+ styleProfileExists = styleRow.c > 0;
39
+ }
40
+ catch { }
41
+ const metrics = {
42
+ totalEvents: totalRow.c,
43
+ recentEvents7d: recentRow.c,
44
+ avgImportance: Math.round((avgRow.a || 0) * 10) / 10,
45
+ decisionsLogged: decisionsRow.c,
46
+ errorsLogged: errorsRow.c,
47
+ fixesLogged: fixesRow.c,
48
+ verificationsLogged: verificationsRow.c,
49
+ patternsLearned: patternsRow.c,
50
+ handoffCurrent,
51
+ styleProfileExists,
52
+ uniqueTopics: topicsRow.c,
53
+ daysSinceFirstEvent: daysSinceFirst,
54
+ daysSinceLastEvent: daysSinceLast,
55
+ };
56
+ // Completeness score (0-100): do you have all event types?
57
+ let completeness = 0;
58
+ if (metrics.totalEvents > 0)
59
+ completeness += 10;
60
+ if (metrics.decisionsLogged > 0)
61
+ completeness += 20;
62
+ if (metrics.errorsLogged > 0)
63
+ completeness += 15;
64
+ if (metrics.fixesLogged > 0)
65
+ completeness += 15;
66
+ if (metrics.verificationsLogged > 0)
67
+ completeness += 15;
68
+ if (metrics.patternsLearned > 0)
69
+ completeness += 15;
70
+ if (metrics.handoffCurrent)
71
+ completeness += 10;
72
+ if (metrics.decisionsLogged === 0)
73
+ suggestions.push('Log decisions with `cell memory record --type decision`');
74
+ if (metrics.verificationsLogged === 0)
75
+ suggestions.push('Log test runs with `cell memory record --type verification`');
76
+ if (metrics.patternsLearned === 0)
77
+ suggestions.push('Learn patterns with `cell memory record --type pattern`');
78
+ // Freshness score (0-100): how recent is data?
79
+ let freshness = 100;
80
+ if (metrics.daysSinceLastEvent > 1)
81
+ freshness -= 10;
82
+ if (metrics.daysSinceLastEvent > 3)
83
+ freshness -= 20;
84
+ if (metrics.daysSinceLastEvent > 7)
85
+ freshness -= 30;
86
+ if (metrics.daysSinceLastEvent > 14)
87
+ freshness -= 20;
88
+ if (metrics.recentEvents7d === 0)
89
+ freshness -= 20;
90
+ if (metrics.daysSinceLastEvent > 7)
91
+ suggestions.push('Update handoff context — it may be stale');
92
+ // Quality score (0-100): avg importance + error ratio
93
+ let quality = 50;
94
+ if (metrics.avgImportance > 5)
95
+ quality += 20;
96
+ else if (metrics.avgImportance > 3)
97
+ quality += 10;
98
+ if (metrics.avgImportance > 7)
99
+ quality += 10;
100
+ const errorRate = metrics.totalEvents > 0 ? metrics.errorsLogged / metrics.totalEvents : 0;
101
+ if (errorRate < 0.1)
102
+ quality += 20;
103
+ else if (errorRate < 0.2)
104
+ quality += 10;
105
+ else
106
+ quality -= 10;
107
+ if (metrics.fixesLogged > metrics.errorsLogged)
108
+ quality += 10;
109
+ // Balance score (0-100): ratio of different event types
110
+ const typeCounts = {};
111
+ const typeRows = db.prepare('SELECT type, COUNT(*) as c FROM memory_events WHERE project = ? GROUP BY type').all(project);
112
+ for (const r of typeRows)
113
+ typeCounts[r.type] = r.c;
114
+ const types = Object.keys(typeCounts).length;
115
+ let balance = Math.min(types * 12, 60);
116
+ if (types >= 5)
117
+ balance += 20;
118
+ if (types >= 8)
119
+ balance += 20;
120
+ if (types < 3)
121
+ suggestions.push('Record more diverse event types (errors, fixes, decisions)');
122
+ // Engagement score (0-100): consistency of recording
123
+ let engagement = 0;
124
+ if (metrics.totalEvents > 5)
125
+ engagement += 20;
126
+ if (metrics.totalEvents > 20)
127
+ engagement += 20;
128
+ if (metrics.totalEvents > 50)
129
+ engagement += 20;
130
+ if (metrics.recentEvents7d > 0)
131
+ engagement += 20;
132
+ if (metrics.recentEvents7d > 5)
133
+ engagement += 10;
134
+ if (metrics.uniqueTopics > 3)
135
+ engagement += 10;
136
+ if (metrics.totalEvents < 10)
137
+ suggestions.push('Record more events to build memory depth');
138
+ // Overall score
139
+ const overallScore = Math.round(completeness * 0.25 +
140
+ freshness * 0.20 +
141
+ quality * 0.20 +
142
+ balance * 0.15 +
143
+ engagement * 0.20);
144
+ const grade = scoreToGrade(overallScore);
145
+ if (overallScore < 50)
146
+ suggestions.push('Memory system needs attention — run `cell memory health` regularly');
147
+ if (!metrics.handoffCurrent)
148
+ suggestions.push('Create a handoff with `cell handoff --log`');
149
+ if (!metrics.styleProfileExists)
150
+ suggestions.push('Set up your style profile with `cell style update`');
151
+ return {
152
+ project,
153
+ overallScore,
154
+ grade,
155
+ breakdown: {
156
+ completeness,
157
+ freshness,
158
+ quality,
159
+ balance,
160
+ engagement,
161
+ },
162
+ suggestions: [...new Set(suggestions)].slice(0, 8),
163
+ metrics,
164
+ computedAt: new Date().toISOString(),
165
+ };
166
+ }
167
+ function scoreToGrade(score) {
168
+ if (score >= 95)
169
+ return 'A+';
170
+ if (score >= 90)
171
+ return 'A';
172
+ if (score >= 85)
173
+ return 'B+';
174
+ if (score >= 75)
175
+ return 'B';
176
+ if (score >= 70)
177
+ return 'C+';
178
+ if (score >= 60)
179
+ return 'C';
180
+ if (score >= 40)
181
+ return 'D';
182
+ return 'F';
183
+ }
184
+ function formatHealthReport(health) {
185
+ const lines = [];
186
+ lines.push(`## Memory Health — ${health.project}`);
187
+ lines.push(`**Score: ${health.overallScore}/100 (${health.grade})**\n`);
188
+ lines.push('### Breakdown');
189
+ lines.push(`| Dimension | Score |`);
190
+ lines.push(`|-----------|-------|`);
191
+ lines.push(`| Completeness | ${health.breakdown.completeness} |`);
192
+ lines.push(`| Freshness | ${health.breakdown.freshness} |`);
193
+ lines.push(`| Quality | ${health.breakdown.quality} |`);
194
+ lines.push(`| Balance | ${health.breakdown.balance} |`);
195
+ lines.push(`| Engagement | ${health.breakdown.engagement} |`);
196
+ lines.push('');
197
+ lines.push('### Metrics');
198
+ lines.push(`| Metric | Value |`);
199
+ lines.push(`|--------|-------|`);
200
+ lines.push(`| Total events | ${health.metrics.totalEvents} |`);
201
+ lines.push(`| Last 7d events | ${health.metrics.recentEvents7d} |`);
202
+ lines.push(`| Avg importance | ${health.metrics.avgImportance} |`);
203
+ lines.push(`| Decisions | ${health.metrics.decisionsLogged} |`);
204
+ lines.push(`| Errors | ${health.metrics.errorsLogged} |`);
205
+ lines.push(`| Fixes | ${health.metrics.fixesLogged} |`);
206
+ lines.push(`| Verifications | ${health.metrics.verificationsLogged} |`);
207
+ lines.push(`| Patterns | ${health.metrics.patternsLearned} |`);
208
+ lines.push(`| Unique topics | ${health.metrics.uniqueTopics} |`);
209
+ lines.push(`| Handoff current | ${health.metrics.handoffCurrent ? 'yes' : 'no'} |`);
210
+ lines.push(`| Style profile | ${health.metrics.styleProfileExists ? 'yes' : 'no'} |`);
211
+ lines.push(`| Days tracked | ${health.metrics.daysSinceFirstEvent} |`);
212
+ lines.push('');
213
+ if (health.suggestions.length > 0) {
214
+ lines.push('### Suggestions');
215
+ for (const s of health.suggestions)
216
+ lines.push(`- ${s}`);
217
+ lines.push('');
218
+ }
219
+ return lines.join('\n');
220
+ }
221
+ //# sourceMappingURL=memory-health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-health.js","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/memory-health.ts"],"names":[],"mappings":";;AAgCA,kDAqLC;AAaD,gDAuC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IAAI,CAAC,CAAC;IACvE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface SmartRecommendation {
2
+ id: string;
3
+ category: 'action' | 'focus' | 'improve' | 'learn' | 'prevent' | 'optimize';
4
+ priority: 'high' | 'medium' | 'low';
5
+ title: string;
6
+ description: string;
7
+ rationale: string;
8
+ confidence: number;
9
+ relatedFiles: string[];
10
+ relatedTopics: string[];
11
+ createdAt: string;
12
+ }
13
+ export interface RecommendationContext {
14
+ project: string;
15
+ recentActivity?: boolean;
16
+ errorPatterns?: boolean;
17
+ codeQuality?: boolean;
18
+ workflow?: boolean;
19
+ learning?: boolean;
20
+ }
21
+ export declare function generateSmartRecommendations(project: string, context?: RecommendationContext): SmartRecommendation[];
22
+ export declare function getRecommendationSummary(project: string): {
23
+ total: number;
24
+ high: number;
25
+ medium: number;
26
+ low: number;
27
+ byCategory: Record<string, number>;
28
+ top3: SmartRecommendation[];
29
+ };
30
+ //# sourceMappingURL=smart-recommendations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-recommendations.d.ts","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/smart-recommendations.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;IAC5E,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,qBAAqB,GAC9B,mBAAmB,EAAE,CAoMvB;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,EAAE,mBAAmB,EAAE,CAAC;CAC7B,CAaA"}
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSmartRecommendations = generateSmartRecommendations;
4
+ exports.getRecommendationSummary = getRecommendationSummary;
5
+ const database_1 = require("../database/database");
6
+ function generateSmartRecommendations(project, context) {
7
+ const db = (0, database_1.getDb)();
8
+ const recs = [];
9
+ const since7d = new Date(Date.now() - 7 * 86400000).toISOString();
10
+ const since30d = new Date(Date.now() - 30 * 86400000).toISOString();
11
+ // 1. Unfixed errors — suggest fix priority
12
+ const unfixedErrors = db.prepare(`
13
+ SELECT id, summary, topic, files_json, importance, created_at FROM memory_events
14
+ WHERE project = ? AND type = 'error'
15
+ AND id NOT IN (
16
+ SELECT DISTINCT e2.id FROM memory_events e2
17
+ WHERE e2.project = ? AND e2.type = 'fix'
18
+ )
19
+ ORDER BY importance DESC, created_at DESC LIMIT 10
20
+ `).all(project, project);
21
+ for (const err of unfixedErrors) {
22
+ recs.push({
23
+ id: `fix-${err.id}`,
24
+ category: 'action',
25
+ priority: err.importance >= 8 ? 'high' : err.importance >= 6 ? 'medium' : 'low',
26
+ title: `Fix: ${err.summary.slice(0, 80)}`,
27
+ description: `Error logged ${formatAge(err.created_at)} ago without a corresponding fix. Importance: ${err.importance}/10.`,
28
+ rationale: `Unresolved errors accumulate and become harder to fix over time.`,
29
+ confidence: 0.85,
30
+ relatedFiles: parseFiles(err.files_json),
31
+ relatedTopics: err.topic ? [err.topic] : [],
32
+ createdAt: new Date().toISOString(),
33
+ });
34
+ }
35
+ // 2. High-frequency files need refactoring
36
+ const hotFiles = db.prepare(`
37
+ SELECT files_json, COUNT(*) as c, MAX(importance) as maxImp FROM memory_events
38
+ WHERE project = ? AND files_json IS NOT NULL AND created_at >= ?
39
+ GROUP BY files_json HAVING c >= 8 ORDER BY c DESC LIMIT 5
40
+ `).all(project, since30d);
41
+ for (const hf of hotFiles) {
42
+ const files = parseFiles(hf.files_json);
43
+ if (files.length > 0) {
44
+ recs.push({
45
+ id: `refactor-${hashStr(files[0])}`,
46
+ category: 'optimize',
47
+ priority: hf.c > 15 ? 'high' : 'medium',
48
+ title: `Consider refactoring: ${files[0]}`,
49
+ description: `File touched ${hf.c} times in 30 days — may be a hotspot needing decomposition.`,
50
+ rationale: `High edit frequency suggests the file has too many responsibilities.`,
51
+ confidence: 0.7,
52
+ relatedFiles: files,
53
+ relatedTopics: ['refactor'],
54
+ createdAt: new Date().toISOString(),
55
+ });
56
+ }
57
+ }
58
+ // 3. Missing tests for error-prone files
59
+ const errorFiles = db.prepare(`
60
+ SELECT files_json, COUNT(*) as c FROM memory_events
61
+ WHERE project = ? AND type = 'error' AND files_json IS NOT NULL AND created_at >= ?
62
+ GROUP BY files_json ORDER BY c DESC LIMIT 5
63
+ `).all(project, since30d);
64
+ const testFiles = db.prepare(`
65
+ SELECT files_json FROM memory_events
66
+ WHERE project = ? AND type = 'verification' AND files_json IS NOT NULL AND created_at >= ?
67
+ `).all(project, since30d);
68
+ const testedPaths = new Set();
69
+ for (const tf of testFiles) {
70
+ for (const f of parseFiles(tf.files_json))
71
+ testedPaths.add(f);
72
+ }
73
+ for (const ef of errorFiles) {
74
+ const files = parseFiles(ef.files_json);
75
+ for (const f of files) {
76
+ if (!testedPaths.has(f) && !f.includes('.test.') && !f.includes('.spec.')) {
77
+ recs.push({
78
+ id: `test-${hashStr(f)}`,
79
+ category: 'prevent',
80
+ priority: ef.c > 3 ? 'high' : 'medium',
81
+ title: `Add tests for: ${f}`,
82
+ description: `File has ${ef.c} errors but no test coverage logged.`,
83
+ rationale: `Files with repeated errors should have tests to prevent regressions.`,
84
+ confidence: 0.75,
85
+ relatedFiles: [f],
86
+ relatedTopics: ['testing'],
87
+ createdAt: new Date().toISOString(),
88
+ });
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ // 4. Decision gaps — too many events without decisions
94
+ const eventCount = db.prepare(`SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND created_at >= ?`).get(project, since7d);
95
+ const decisionCount = db.prepare(`SELECT COUNT(*) as c FROM memory_events WHERE project = ? AND type = 'decision' AND created_at >= ?`).get(project, since7d);
96
+ if (eventCount.c > 20 && decisionCount.c < 3) {
97
+ recs.push({
98
+ id: 'decision-gap',
99
+ category: 'improve',
100
+ priority: 'medium',
101
+ title: 'Log more decisions',
102
+ description: `${eventCount.c} events but only ${decisionCount.c} decisions in 7 days. Decisions help AI understand your reasoning.`,
103
+ rationale: `Decision memory is critical for context continuity and AI recommendations.`,
104
+ confidence: 0.65,
105
+ relatedFiles: [],
106
+ relatedTopics: ['memory-system'],
107
+ createdAt: new Date().toISOString(),
108
+ });
109
+ }
110
+ // 5. Handoff staleness — suggest update
111
+ const lastHandoff = db.prepare(`
112
+ SELECT created_at FROM memory_events
113
+ WHERE project = ? AND type = 'handoff' ORDER BY created_at DESC LIMIT 1
114
+ `).get(project);
115
+ if (lastHandoff) {
116
+ const daysSince = (Date.now() - new Date(lastHandoff.created_at).getTime()) / 86400000;
117
+ if (daysSince > 5) {
118
+ recs.push({
119
+ id: 'stale-handoff',
120
+ category: 'action',
121
+ priority: 'medium',
122
+ title: 'Update handoff context',
123
+ description: `Last handoff was ${Math.round(daysSince)} days ago. Context may be stale.`,
124
+ rationale: `Fresh handoff context helps AI understand current project state.`,
125
+ confidence: 0.7,
126
+ relatedFiles: [],
127
+ relatedTopics: ['handoff'],
128
+ createdAt: new Date().toISOString(),
129
+ });
130
+ }
131
+ }
132
+ // 6. Error patterns — suggest systematic fix
133
+ const errorPatterns = db.prepare(`
134
+ SELECT topic, COUNT(*) as c FROM memory_events
135
+ WHERE project = ? AND type = 'error' AND topic IS NOT NULL AND created_at >= ?
136
+ GROUP BY topic HAVING c >= 3 ORDER BY c DESC LIMIT 3
137
+ `).all(project, since30d);
138
+ for (const ep of errorPatterns) {
139
+ recs.push({
140
+ id: `pattern-${hashStr(ep.topic)}`,
141
+ category: 'prevent',
142
+ priority: ep.c > 5 ? 'high' : 'medium',
143
+ title: `Systematic fix for "${ep.topic}" errors`,
144
+ description: `${ep.c} errors in the "${ep.topic}" area suggest a systemic issue.`,
145
+ rationale: `Addressing root cause prevents repeated fixes on the same problem.`,
146
+ confidence: 0.75,
147
+ relatedFiles: [],
148
+ relatedTopics: [ep.topic],
149
+ createdAt: new Date().toISOString(),
150
+ });
151
+ }
152
+ // 7. Learning suggestions — based on patterns you use
153
+ const typeCounts = db.prepare(`
154
+ SELECT type, COUNT(*) as c FROM memory_events
155
+ WHERE project = ? AND created_at >= ?
156
+ GROUP BY type ORDER BY c DESC
157
+ `).all(project, since30d);
158
+ const typeMap = {};
159
+ for (const t of typeCounts)
160
+ typeMap[t.type] = t.c;
161
+ if ((typeMap.fix || 0) > (typeMap.verification || 0) * 3) {
162
+ recs.push({
163
+ id: 'learn-testing',
164
+ category: 'learn',
165
+ priority: 'medium',
166
+ title: 'Improve verification coverage',
167
+ description: 'You fix errors 3x more often than you verify. Consider adding more test runs.',
168
+ rationale: 'Balanced fix/verification ratio leads to more stable code.',
169
+ confidence: 0.6,
170
+ relatedFiles: [],
171
+ relatedTopics: ['testing', 'verification'],
172
+ createdAt: new Date().toISOString(),
173
+ });
174
+ }
175
+ return recs.sort((a, b) => {
176
+ const prioOrder = { high: 0, medium: 1, low: 2 };
177
+ return prioOrder[a.priority] - prioOrder[b.priority];
178
+ });
179
+ }
180
+ function getRecommendationSummary(project) {
181
+ const recs = generateSmartRecommendations(project);
182
+ const byCategory = {};
183
+ for (const r of recs)
184
+ byCategory[r.category] = (byCategory[r.category] || 0) + 1;
185
+ return {
186
+ total: recs.length,
187
+ high: recs.filter(r => r.priority === 'high').length,
188
+ medium: recs.filter(r => r.priority === 'medium').length,
189
+ low: recs.filter(r => r.priority === 'low').length,
190
+ byCategory,
191
+ top3: recs.slice(0, 3),
192
+ };
193
+ }
194
+ function parseFiles(filesJson) {
195
+ if (!filesJson)
196
+ return [];
197
+ try {
198
+ const parsed = JSON.parse(filesJson);
199
+ return Array.isArray(parsed) ? parsed : [];
200
+ }
201
+ catch {
202
+ return [];
203
+ }
204
+ }
205
+ function formatAge(dateStr) {
206
+ const ms = Date.now() - new Date(dateStr).getTime();
207
+ const hours = Math.round(ms / 3600000);
208
+ if (hours < 1)
209
+ return 'just now';
210
+ if (hours < 24)
211
+ return `${hours}h`;
212
+ const days = Math.round(hours / 24);
213
+ return `${days}d`;
214
+ }
215
+ function hashStr(s) {
216
+ let hash = 0;
217
+ for (let i = 0; i < s.length; i++) {
218
+ hash = ((hash << 5) - hash + s.charCodeAt(i)) | 0;
219
+ }
220
+ return Math.abs(hash).toString(36);
221
+ }
222
+ //# sourceMappingURL=smart-recommendations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-recommendations.js","sourceRoot":"","sources":["../../../../src/walls/06-memory/stores/smart-recommendations.ts"],"names":[],"mappings":";;AAwBA,oEAuMC;AAED,4DAoBC;AArPD,mDAA6C;AAwB7C,SAAgB,4BAA4B,CAC1C,OAAe,EACf,OAA+B;IAE/B,MAAM,EAAE,GAAG,IAAA,gBAAK,GAAE,CAAC;IACnB,MAAM,IAAI,GAA0B,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAEpE,2CAA2C;IAC3C,MAAM,aAAa,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;;;;GAQhC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAErB,CAAC;IAEH,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC;YACR,EAAE,EAAE,OAAO,GAAG,CAAC,EAAE,EAAE;YACnB,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;YAC/E,KAAK,EAAE,QAAQ,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE;YACzC,WAAW,EAAE,gBAAgB,SAAS,CAAC,GAA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GAAG,EAAE,CAAC,CAAC;IACpC,OAAO,GAAG,IAAI,GAAG,CAAC;AACpB,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;IACxB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC"}
@@ -200,7 +200,7 @@ function buildMarkdownReport(project, weekStart, weekEnd, totalEvents, avgImport
200
200
  lines.push(handoffSummary);
201
201
  lines.push('```\n');
202
202
  lines.push(`---`);
203
- lines.push(`*Generated by FIVO Cell v4.8.0*`);
203
+ lines.push(`*Generated by FIVO Cell v5.0.0*`);
204
204
  return lines.join('\n');
205
205
  }
206
206
  //# sourceMappingURL=weekly-report.js.map