bobs-workshop 0.1.8 โ†’ 0.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.
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Cleanup Script: Remove Empty System Activity Logs
4
+ *
5
+ * This script scans all SPEC files and removes "System activity logged" entries
6
+ * from the enhanced_activities array. These are noise logs created by
7
+ * bob.dashboard.update calls without meaningful summaries.
8
+ *
9
+ * Usage: npm run cleanup:system-logs
10
+ */
11
+
12
+ import fs from 'fs-extra';
13
+ import path from 'path';
14
+
15
+ interface EnhancedActivity {
16
+ id: string;
17
+ timestamp: string;
18
+ role: string;
19
+ type: string;
20
+ summary: string;
21
+ files_changed?: any[];
22
+ [key: string]: any;
23
+ }
24
+
25
+ interface SpecData {
26
+ spec_id: string;
27
+ enhanced_activities?: EnhancedActivity[];
28
+ [key: string]: any;
29
+ }
30
+
31
+ async function cleanupSystemLogs() {
32
+ console.log('๐Ÿงน Starting cleanup of empty system activity logs...\n');
33
+
34
+ const specsDir = path.resolve(process.cwd(), '.bob/specs');
35
+
36
+ // Check if specs directory exists
37
+ if (!await fs.pathExists(specsDir)) {
38
+ console.error(`โŒ Specs directory not found: ${specsDir}`);
39
+ process.exit(1);
40
+ }
41
+
42
+ const allFiles = await fs.readdir(specsDir);
43
+ const specFiles = allFiles
44
+ .filter(file => file.startsWith('SPEC-') && file.endsWith('.json'))
45
+ .map(file => path.join(specsDir, file));
46
+
47
+ if (specFiles.length === 0) {
48
+ console.log('โ„น๏ธ No SPEC files found.');
49
+ return;
50
+ }
51
+
52
+ console.log(`๐Ÿ“‚ Found ${specFiles.length} SPEC files to process\n`);
53
+
54
+ let totalRemoved = 0;
55
+ let filesModified = 0;
56
+
57
+ for (const specFile of specFiles) {
58
+ try {
59
+ const specData: SpecData = await fs.readJson(specFile);
60
+
61
+ if (!specData.enhanced_activities || specData.enhanced_activities.length === 0) {
62
+ continue;
63
+ }
64
+
65
+ const originalLength = specData.enhanced_activities.length;
66
+
67
+ // Filter out empty system logs
68
+ specData.enhanced_activities = specData.enhanced_activities.filter((activity: EnhancedActivity) => {
69
+ // Keep activity if ANY of these conditions are true:
70
+ // 1. Role is NOT system
71
+ // 2. Has a meaningful summary (not "System activity logged" and not empty)
72
+ // 3. Has file changes
73
+ const keepActivity = !(
74
+ activity.role === 'system' &&
75
+ (activity.summary === 'System activity logged' || !activity.summary || activity.summary.trim() === '') &&
76
+ (!activity.files_changed || activity.files_changed.length === 0)
77
+ );
78
+
79
+ return keepActivity;
80
+ });
81
+
82
+ const removed = originalLength - specData.enhanced_activities.length;
83
+
84
+ if (removed > 0) {
85
+ // Update timestamp
86
+ specData.updated_at = new Date().toISOString();
87
+
88
+ // Write back to file
89
+ await fs.writeJson(specFile, specData, { spaces: 2 });
90
+
91
+ totalRemoved += removed;
92
+ filesModified++;
93
+
94
+ const fileName = path.basename(specFile);
95
+ console.log(`โœ“ ${fileName}: Removed ${removed} empty system log${removed > 1 ? 's' : ''}`);
96
+ }
97
+ } catch (error) {
98
+ console.error(`โŒ Error processing ${path.basename(specFile)}:`, error);
99
+ }
100
+ }
101
+
102
+ console.log('\n' + '='.repeat(60));
103
+ console.log('โœ… Cleanup complete!');
104
+ console.log('='.repeat(60));
105
+ console.log(`๐Ÿ“Š Files modified: ${filesModified}`);
106
+ console.log(`๐Ÿ—‘๏ธ Empty system logs removed: ${totalRemoved}`);
107
+ console.log(`๐Ÿ“ Files unchanged: ${specFiles.length - filesModified}`);
108
+ console.log('='.repeat(60) + '\n');
109
+
110
+ if (totalRemoved === 0) {
111
+ console.log('๐ŸŽ‰ No empty system logs found - your SPEC files are already clean!');
112
+ } else {
113
+ console.log('๐ŸŽ‰ Dashboard activity timeline should now be cleaner!');
114
+ }
115
+ }
116
+
117
+ // Run the cleanup
118
+ cleanupSystemLogs().catch((error) => {
119
+ console.error('โŒ Fatal error during cleanup:', error);
120
+ process.exit(1);
121
+ });