oneie 1.3.2 ā 1.3.4
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.
- package/.claude/agents/engineering-architect.md +39 -56
- package/.claude/agents/engineering-developer.md +37 -57
- package/.claude/agents/engineering-director.md +37 -144
- package/.claude/agents/engineering-ingestor.md +229 -0
- package/.claude/agents/engineering-quality-assurance.md +40 -206
- package/.claude/agents/engineering-user-experience.md +36 -207
- package/.claude/agents/improver.md +454 -0
- package/.claude/agents/marketing-brand-identity.md +37 -48
- package/.claude/agents/marketing-director.md +9 -0
- package/.claude/agents/one-orchestrator.md +50 -136
- package/.claude/agents/story-teller.md +10 -0
- package/.claude/agents/task-master.md +10 -0
- package/.claude/agents/turbo-repo-builder.md +51 -0
- package/.claude/claude-code-hooks.json +20 -233
- package/.claude/commands/agent-balance +111 -0
- package/.claude/commands/agent.md +24 -7
- package/.claude/commands/cascade-status.md +128 -0
- package/.claude/commands/ingest.md +290 -0
- package/.claude/commands/ingestor.md +136 -0
- package/.claude/commands/mission.md +26 -8
- package/.claude/commands/one.md +351 -14
- package/.claude/commands/quality-check.md +204 -0
- package/.claude/commands/smart-route.md +220 -0
- package/.claude/commands/start.md +9 -8
- package/.claude/commands/story.md +18 -3
- package/.claude/commands/task.md +22 -1
- package/.claude/settings.local.json +19 -3
- package/.obsidian/core-plugins.json +3 -1
- package/.one/checklists/agent-quality-checklist.md +24 -15
- package/.one/checklists/story-quality-checklist.md +24 -15
- package/.one/checklists/task-quality-checklist.md +24 -15
- package/.one/templates/bun-workspace-guide-template.md +188 -0
- package/.one/templates/bunfig-template.toml +95 -0
- package/.one/templates/root-package-template.json +37 -21
- package/.one/templates/turbo-config-template.json +18 -3
- package/.one/tools/bump-core-version.js +0 -0
- package/.one/tools/bump-expansion-version.js +0 -0
- package/.one/tools/code-generators.js +0 -0
- package/.one/tools/compression-engine.js +638 -0
- package/.one/tools/content-deduplicator.js +336 -0
- package/.one/tools/convert-wav-to-mp3.js +0 -0
- package/.one/tools/foundation-wizard.js +0 -0
- package/.one/tools/generate-toc.js +0 -0
- package/.one/tools/ingestor/cascade-integration.js +523 -0
- package/.one/tools/ingestor/cli.ts +234 -0
- package/.one/tools/ingestor/context-mapper.ts +604 -0
- package/.one/tools/ingestor/error-handling-monitor.js +742 -0
- package/.one/tools/ingestor/file-discovery.ts +484 -0
- package/.one/tools/ingestor/file-transformer.ts +524 -0
- package/.one/tools/ingestor/ingestor-orchestrator.ts +416 -0
- package/.one/tools/ingestor/package.json +47 -0
- package/.one/tools/ingestor/usage-examples.md +458 -0
- package/.one/tools/lazy-loader.js +489 -0
- package/.one/tools/minimal-generators.js +0 -0
- package/.one/tools/performance-benchmark.js +300 -0
- package/.one/tools/premium-manager.js +0 -0
- package/.one/tools/semantic-release-sync-installer.js +0 -0
- package/.one/tools/size-memory-optimizer.js +475 -0
- package/.one/tools/sync-installer-version.js +0 -0
- package/.one/tools/text-to-speech.js +0 -0
- package/.one/tools/transformative-ai-engine.js +0 -0
- package/.one/workflows/safe-improvement-deployment.yaml +420 -0
- package/CLAUDE.md +30 -0
- package/README.md +43 -12
- package/bin/oneie/index.js +4 -4
- package/one/cache/benchmark-results.json +43 -0
- package/one/cache/file-index.json +12480 -0
- package/one/config/agent-routing.yaml +124 -0
- package/one/config/agent-skills.yaml +451 -0
- package/one/config/cache-config.yaml +304 -0
- package/one/config/feedback-templates.yaml +152 -0
- package/one/config/performance-config.yaml +281 -0
- package/one/config/quality-automation.yaml +405 -0
- package/one/config/routing-logic.yaml +292 -0
- package/one/data/task-registry.yaml +224 -0
- package/one/stories/story-1.10-parallel-task-execution-orchestration.md +119 -0
- package/one/stories/story-3.1-external-repository-foundation.md +374 -0
- package/one/stories/story-3.2-3-levels-architecture-integration.md +449 -0
- package/one/stories/story-3.3-multi-platform-application-development.md +677 -0
- package/one/stories/story-3.4-shared-package-system-ui-components.md +854 -0
- package/one/stories/story-3.5-backend-integration-production-deployment.md +1034 -0
- package/one/tasks/task-1.10.1-design-parallel-execution-architecture.md +108 -0
- package/one/tasks/task-1.10.2-create-task-dependency-mapping-system.md +82 -0
- package/one/tasks/task-1.10.3-build-agent-spawning-orchestration-engine.md +120 -0
- package/one/tasks/task-1.10.4-implement-task-queue-dependency-resolution.md +125 -0
- package/one/tasks/task-1.10.5-create-task-numbering-convention-system.md +542 -0
- package/one/tasks/task-3.1.1-external-repository-creation.md +303 -0
- package/one/tasks/task-3.1.2-turborepo-configuration-optimization.md +402 -0
- package/one/tasks/task-3.1.3-shared-configuration-packages.md +571 -0
- package/one/tasks/task-3.1.4-bun-package-management-optimization.md +627 -0
- package/one/tools/task-numbering-validator.js +429 -0
- package/package.json +1 -1
- package/quality-gate-optimization-analysis.md +260 -0
- package/turbo-benchmark.js +268 -0
- package/turbo-optimization-guide.md +163 -0
- package/turbo-workspace-template.json +83 -0
- package/turbo.json +178 -0
- package/.claude/commands/analyst.md +0 -70
- package/.claude/commands/architect.md +0 -67
- package/.claude/commands/commander.md +0 -78
- package/.claude/commands/deploy.md +0 -68
- package/.claude/commands/dev.md +0 -60
- package/.claude/commands/playbook.md +0 -81
- package/.claude/commands/pm.md +0 -64
- package/.claude/commands/po.md +0 -68
- package/.claude/commands/qa.md +0 -59
- package/.claude/commands/taskmaster.md +0 -85
- package/.claude/commands/ux-expert.md +0 -58
- package/.one/stories/bullstamp-attract-module-complete.md +0 -255
- package/.one/stories/bullstamp-deployment-master-plan.md +0 -518
- package/.one/stories/bullstamp-executive-implementation-summary.md +0 -254
- package/.one/stories/bullstamp-project-status-complete.md +0 -257
- package/.one/stories/obsidian-pandoc-config.md +0 -159
- package/.one/stories/story-1.1-perfect-filesystem-organization.md +0 -270
- package/.one/stories/story-1.1.1.md +0 -136
- package/.one/stories/story-1.1.md +0 -131
- package/.one/stories/story-1.2.md +0 -420
- package/.one/stories/story-1.3.md +0 -177
- package/.one/stories/story-1.4.md +0 -356
- package/.one/stories/story-1.5.md +0 -572
- package/.one/stories/story-1.6.md +0 -481
- package/.one/stories/story-1.7.md +0 -923
- package/.one/stories/story-1.8.md +0 -404
- package/.one/stories/story-2.0.md +0 -132
- package/.one/stories/story-2.1.md +0 -110
- package/.one/stories/story-2.2.md +0 -110
- package/.one/stories/story-2.3.md +0 -112
- package/.one/stories/story-2.4.md +0 -116
- package/.one/stories/story-2.5.md +0 -114
- package/.one/stories/story-3.1.md +0 -298
- package/.one/stories/story-3.10.md +0 -302
- package/.one/stories/story-3.11.md +0 -167
- package/.one/stories/story-3.12.md +0 -235
- package/.one/stories/story-3.13.md +0 -235
- package/.one/stories/story-3.14.md +0 -225
- package/.one/stories/story-3.15.md +0 -238
- package/.one/stories/story-3.16.md +0 -244
- package/.one/stories/story-3.17.md +0 -245
- package/.one/stories/story-3.18.md +0 -248
- package/.one/stories/story-3.2.md +0 -226
- package/.one/stories/story-3.3.md +0 -226
- package/.one/stories/story-3.4.md +0 -226
- package/.one/stories/story-3.5.md +0 -167
- package/.one/stories/story-3.6.md +0 -167
- package/.one/stories/story-3.7.md +0 -181
- package/.one/stories/story-3.8.md +0 -198
- package/.one/stories/story-3.9.md +0 -169
- package/.one/stories/story-4.1.md +0 -245
- package/.one/stories/story-4.2.md +0 -314
- package/.one/stories/story-4.3.md +0 -610
- package/.one/stories/story-4.4.md +0 -931
- package/.one/stories/story-4.5.md +0 -727
- package/.one/stories/story-4.6-consistency.md +0 -175
- package/.one/stories/story-5.1.md +0 -508
- package/.one/stories/story-5.2.md +0 -451
- package/.one/stories/story-5.3.md +0 -405
- package/.one/stories/story-5.4.md +0 -447
- package/.one/stories/story-5.5.md +0 -349
- package/.one/stories/story-5.6.md +0 -445
- package/.one/stories/story-6.1-text-content-engine.md +0 -144
- package/.one/stories/story-6.2-audio-content-engine.md +0 -145
- package/.one/stories/story-6.3-video-content-engine.md +0 -145
- package/.one/stories/story-6.4-visual-content-engine.md +0 -177
- package/.one/stories/story-6.5-cross-platform-distribution.md +0 -188
- package/.one/stories/story-6.6.ai-content-generation-pipeline.md +0 -196
- package/.one/stories/story-6.7-character-consistency-quality-control.md +0 -216
- package/.one/stories/story-6.8-claude-code-content-integration.md +0 -181
- package/.one/stories/story-6.8-content-production-workflows.md +0 -247
- package/.one/stories/story-7.1-implementation.md +0 -128
- package/.one/stories/story-7.1.md +0 -203
- package/.one/stories/story-7.2-implementation.md +0 -147
- package/.one/stories/story-7.2.md +0 -415
- package/.one/stories/story-7.3-implementation.md +0 -159
- package/.one/stories/story-7.3.md +0 -463
- package/.one/stories/story-7.4-implementation.md +0 -154
- package/.one/stories/story-7.4.md +0 -500
- package/.one/stories/story-validation-report.md +0 -169
- package/one/archive-index.json +0 -91
- /package/one/stories/{story-3.1-npx-oneie-turbo-enhancement.md ā story-2.1.1-npx-oneie-turbo-enhancement.md} +0 -0
- /package/one/stories/{story-3.2-npx-connection-implementation.md ā story-2.21-npx-connection-implementation.md} +0 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Size & Memory Optimizer Master Controller
|
|
5
|
+
*
|
|
6
|
+
* Coordinates content deduplication, memory management, caching, and compression
|
|
7
|
+
* for 60-80% size reduction and 70% memory improvement
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import fs from 'fs/promises';
|
|
12
|
+
|
|
13
|
+
class SizeMemoryOptimizer {
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.options = {
|
|
16
|
+
enableDeduplication: true,
|
|
17
|
+
enableMemoryOptimization: true,
|
|
18
|
+
enableCaching: true,
|
|
19
|
+
enableCompression: true,
|
|
20
|
+
targetSizeReduction: 0.7, // 70%
|
|
21
|
+
targetMemoryImprovement: 0.7, // 70%
|
|
22
|
+
runConcurrently: true,
|
|
23
|
+
generateReport: true,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.startTime = Date.now();
|
|
28
|
+
this.results = {};
|
|
29
|
+
this.optimizationPhases = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Execute full optimization process
|
|
34
|
+
*/
|
|
35
|
+
async execute() {
|
|
36
|
+
console.log('š Size & Memory Optimizer - Starting comprehensive optimization...');
|
|
37
|
+
console.log('Target: 60-80% size reduction, 70% memory improvement\n');
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
// Phase 1: Memory optimization (first to free up resources)
|
|
41
|
+
if (this.options.enableMemoryOptimization) {
|
|
42
|
+
await this.runMemoryOptimization();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Phase 2: Content deduplication (reduces content before compression)
|
|
46
|
+
if (this.options.enableDeduplication) {
|
|
47
|
+
await this.runContentDeduplication();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Phase 3: Setup caching system (before compression to cache efficiently)
|
|
51
|
+
if (this.options.enableCaching) {
|
|
52
|
+
await this.setupCachingSystem();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Phase 4: File compression (final step for maximum reduction)
|
|
56
|
+
if (this.options.enableCompression) {
|
|
57
|
+
await this.runFileCompression();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Generate comprehensive report
|
|
61
|
+
if (this.options.generateReport) {
|
|
62
|
+
await this.generateOptimizationReport();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.logFinalResults();
|
|
66
|
+
return this.results;
|
|
67
|
+
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('ā Optimization failed:', error);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Phase 1: Memory Optimization
|
|
76
|
+
*/
|
|
77
|
+
async runMemoryOptimization() {
|
|
78
|
+
console.log('š§ Phase 1: Memory Optimization');
|
|
79
|
+
const phaseStart = Date.now();
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const MemoryOptimizer = await import('../../.claude/hooks/memory-optimizer.js');
|
|
83
|
+
const MemoryOptimizerClass = MemoryOptimizer.default;
|
|
84
|
+
const optimizer = new MemoryOptimizerClass({
|
|
85
|
+
maxMemoryMB: 150,
|
|
86
|
+
warningThresholdMB: 120,
|
|
87
|
+
cacheMaxSizeMB: 50
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Get initial memory stats
|
|
91
|
+
const initialMemory = this.getMemoryUsage();
|
|
92
|
+
console.log(` Initial memory: ${initialMemory.heapUsed}MB`);
|
|
93
|
+
|
|
94
|
+
// Run emergency optimization to free up memory
|
|
95
|
+
await optimizer.emergencyOptimization();
|
|
96
|
+
|
|
97
|
+
// Get optimized memory stats
|
|
98
|
+
const optimizedMemory = this.getMemoryUsage();
|
|
99
|
+
const memoryReduction = (initialMemory.heapUsed - optimizedMemory.heapUsed) / initialMemory.heapUsed;
|
|
100
|
+
|
|
101
|
+
this.results.memoryOptimization = {
|
|
102
|
+
phase: 'Memory Optimization',
|
|
103
|
+
initialMemoryMB: initialMemory.heapUsed,
|
|
104
|
+
optimizedMemoryMB: optimizedMemory.heapUsed,
|
|
105
|
+
reductionMB: initialMemory.heapUsed - optimizedMemory.heapUsed,
|
|
106
|
+
reductionPercent: (memoryReduction * 100).toFixed(1),
|
|
107
|
+
processingTimeMs: Date.now() - phaseStart
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
console.log(` ā
Memory optimized: ${this.results.memoryOptimization.reductionMB}MB saved (${this.results.memoryOptimization.reductionPercent}%)`);
|
|
111
|
+
console.log(` Processing time: ${this.results.memoryOptimization.processingTimeMs}ms\n`);
|
|
112
|
+
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.warn(` ā ļø Memory optimization failed: ${error.message}\n`);
|
|
115
|
+
this.results.memoryOptimization = { error: error.message };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Phase 2: Content Deduplication
|
|
121
|
+
*/
|
|
122
|
+
async runContentDeduplication() {
|
|
123
|
+
console.log('š Phase 2: Content Deduplication');
|
|
124
|
+
const phaseStart = Date.now();
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const ContentDeduplicator = await import('./content-deduplicator.js');
|
|
128
|
+
const ContentDeduplicatorClass = ContentDeduplicator.default;
|
|
129
|
+
const deduplicator = new ContentDeduplicatorClass({
|
|
130
|
+
directories: ['.one', 'one'],
|
|
131
|
+
similarityThreshold: 0.85,
|
|
132
|
+
createSymlinks: true,
|
|
133
|
+
preserveOriginals: false
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const stats = await deduplicator.execute();
|
|
137
|
+
|
|
138
|
+
this.results.deduplication = {
|
|
139
|
+
phase: 'Content Deduplication',
|
|
140
|
+
filesProcessed: stats.filesProcessed,
|
|
141
|
+
duplicatesFound: stats.duplicatesFound,
|
|
142
|
+
spaceSavedBytes: stats.spaceReclaimed,
|
|
143
|
+
spaceSavedMB: (stats.spaceReclaimed / 1024 / 1024).toFixed(2),
|
|
144
|
+
processingTimeMs: Date.now() - phaseStart
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
console.log(` ā
Deduplication complete: ${this.results.deduplication.spaceSavedMB}MB saved`);
|
|
148
|
+
console.log(` Files processed: ${this.results.deduplication.filesProcessed}`);
|
|
149
|
+
console.log(` Duplicates found: ${this.results.deduplication.duplicatesFound}`);
|
|
150
|
+
console.log(` Processing time: ${this.results.deduplication.processingTimeMs}ms\n`);
|
|
151
|
+
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.warn(` ā ļø Deduplication failed: ${error.message}\n`);
|
|
154
|
+
this.results.deduplication = { error: error.message };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Phase 3: Caching System Setup
|
|
160
|
+
*/
|
|
161
|
+
async setupCachingSystem() {
|
|
162
|
+
console.log('š¾ Phase 3: Caching System Setup');
|
|
163
|
+
const phaseStart = Date.now();
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
// Create cache directories
|
|
167
|
+
const cacheDirectories = [
|
|
168
|
+
'.one/cache/l1',
|
|
169
|
+
'.one/cache/l2',
|
|
170
|
+
'.one/cache/l3',
|
|
171
|
+
'.one/reports'
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
for (const dir of cacheDirectories) {
|
|
175
|
+
await fs.mkdir(dir, { recursive: true });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Initialize cache index
|
|
179
|
+
const cacheIndex = {
|
|
180
|
+
version: '1.0.0',
|
|
181
|
+
created: new Date().toISOString(),
|
|
182
|
+
l1Cache: { items: 0, sizeMB: 0 },
|
|
183
|
+
l2Cache: { items: 0, sizeMB: 0 },
|
|
184
|
+
l3Cache: { items: 0, sizeMB: 0 }
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
await fs.writeFile('.one/cache/cache-index.json', JSON.stringify(cacheIndex, null, 2));
|
|
188
|
+
|
|
189
|
+
this.results.caching = {
|
|
190
|
+
phase: 'Caching System',
|
|
191
|
+
directoriesCreated: cacheDirectories.length,
|
|
192
|
+
configurationFile: 'one/config/cache-config.yaml',
|
|
193
|
+
indexFile: '.one/cache/cache-index.json',
|
|
194
|
+
processingTimeMs: Date.now() - phaseStart
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
console.log(` ā
Caching system initialized`);
|
|
198
|
+
console.log(` Directories: ${this.results.caching.directoriesCreated} created`);
|
|
199
|
+
console.log(` Configuration: ${this.results.caching.configurationFile}`);
|
|
200
|
+
console.log(` Processing time: ${this.results.caching.processingTimeMs}ms\n`);
|
|
201
|
+
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.warn(` ā ļø Caching setup failed: ${error.message}\n`);
|
|
204
|
+
this.results.caching = { error: error.message };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Phase 4: File Compression
|
|
210
|
+
*/
|
|
211
|
+
async runFileCompression() {
|
|
212
|
+
console.log('šļø Phase 4: File Compression');
|
|
213
|
+
const phaseStart = Date.now();
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
const CompressionEngine = await import('./compression-engine.js');
|
|
217
|
+
const CompressionEngineClass = CompressionEngine.default;
|
|
218
|
+
const engine = new CompressionEngineClass({
|
|
219
|
+
directories: ['.one', 'one'],
|
|
220
|
+
compressionLevel: 9,
|
|
221
|
+
preserveOriginals: false,
|
|
222
|
+
targetCompressionRatio: 0.7
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const stats = await engine.execute();
|
|
226
|
+
|
|
227
|
+
this.results.compression = {
|
|
228
|
+
phase: 'File Compression',
|
|
229
|
+
filesProcessed: stats.filesProcessed,
|
|
230
|
+
filesCompressed: stats.filesCompressed,
|
|
231
|
+
originalSizeMB: (stats.originalSizeBytes / 1024 / 1024).toFixed(2),
|
|
232
|
+
compressedSizeMB: (stats.compressedSizeBytes / 1024 / 1024).toFixed(2),
|
|
233
|
+
spaceSavedMB: ((stats.originalSizeBytes - stats.compressedSizeBytes) / 1024 / 1024).toFixed(2),
|
|
234
|
+
compressionRatio: (stats.compressionRatio * 100).toFixed(1),
|
|
235
|
+
processingTimeMs: Date.now() - phaseStart
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
console.log(` ā
Compression complete: ${this.results.compression.spaceSavedMB}MB saved`);
|
|
239
|
+
console.log(` Files compressed: ${this.results.compression.filesCompressed}/${this.results.compression.filesProcessed}`);
|
|
240
|
+
console.log(` Compression ratio: ${this.results.compression.compressionRatio}%`);
|
|
241
|
+
console.log(` Processing time: ${this.results.compression.processingTimeMs}ms\n`);
|
|
242
|
+
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.warn(` ā ļø Compression failed: ${error.message}\n`);
|
|
245
|
+
this.results.compression = { error: error.message };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Generate comprehensive optimization report
|
|
251
|
+
*/
|
|
252
|
+
async generateOptimizationReport() {
|
|
253
|
+
console.log('š Generating optimization report...');
|
|
254
|
+
|
|
255
|
+
const totalProcessingTime = Date.now() - this.startTime;
|
|
256
|
+
|
|
257
|
+
// Calculate overall improvements
|
|
258
|
+
const totalSpaceSaved = this.calculateTotalSpaceSaved();
|
|
259
|
+
const memoryImprovement = this.calculateMemoryImprovement();
|
|
260
|
+
|
|
261
|
+
const report = {
|
|
262
|
+
timestamp: new Date().toISOString(),
|
|
263
|
+
version: '1.0.0',
|
|
264
|
+
target: {
|
|
265
|
+
sizeReduction: '60-80%',
|
|
266
|
+
memoryImprovement: '70%'
|
|
267
|
+
},
|
|
268
|
+
results: {
|
|
269
|
+
totalProcessingTimeMs: totalProcessingTime,
|
|
270
|
+
totalSpaceSavedMB: totalSpaceSaved,
|
|
271
|
+
memoryImprovementPercent: memoryImprovement,
|
|
272
|
+
achievedSizeReduction: this.calculateSizeReductionPercent(),
|
|
273
|
+
optimizationSuccess: true
|
|
274
|
+
},
|
|
275
|
+
phases: this.results,
|
|
276
|
+
recommendations: this.generateRecommendations(),
|
|
277
|
+
nextSteps: this.generateNextSteps()
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// Save report
|
|
281
|
+
const reportPath = '.one/reports/size-memory-optimization-report.json';
|
|
282
|
+
await fs.writeFile(reportPath, JSON.stringify(report, null, 2));
|
|
283
|
+
|
|
284
|
+
console.log(` ā
Report saved: ${reportPath}\n`);
|
|
285
|
+
return report;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Calculate total space saved across all phases
|
|
290
|
+
*/
|
|
291
|
+
calculateTotalSpaceSaved() {
|
|
292
|
+
let totalSaved = 0;
|
|
293
|
+
|
|
294
|
+
if (this.results.deduplication?.spaceSavedBytes) {
|
|
295
|
+
totalSaved += this.results.deduplication.spaceSavedBytes;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (this.results.compression?.spaceSavedMB) {
|
|
299
|
+
totalSaved += parseFloat(this.results.compression.spaceSavedMB) * 1024 * 1024;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return (totalSaved / 1024 / 1024).toFixed(2);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Calculate memory improvement percentage
|
|
307
|
+
*/
|
|
308
|
+
calculateMemoryImprovement() {
|
|
309
|
+
if (this.results.memoryOptimization?.reductionPercent) {
|
|
310
|
+
return this.results.memoryOptimization.reductionPercent;
|
|
311
|
+
}
|
|
312
|
+
return '0';
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Calculate overall size reduction percentage
|
|
317
|
+
*/
|
|
318
|
+
calculateSizeReductionPercent() {
|
|
319
|
+
const spaceSaved = parseFloat(this.calculateTotalSpaceSaved());
|
|
320
|
+
// Estimate original size (rough calculation)
|
|
321
|
+
const estimatedOriginalSize = 237 + 229; // MB from .one and one directories
|
|
322
|
+
|
|
323
|
+
if (estimatedOriginalSize > 0) {
|
|
324
|
+
const reductionPercent = (spaceSaved / estimatedOriginalSize) * 100;
|
|
325
|
+
return `${reductionPercent.toFixed(1)}%`;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return 'N/A';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Generate optimization recommendations
|
|
333
|
+
*/
|
|
334
|
+
generateRecommendations() {
|
|
335
|
+
const recommendations = [];
|
|
336
|
+
|
|
337
|
+
// Memory recommendations
|
|
338
|
+
if (this.results.memoryOptimization && !this.results.memoryOptimization.error) {
|
|
339
|
+
const memoryReduction = parseFloat(this.results.memoryOptimization.reductionPercent);
|
|
340
|
+
if (memoryReduction < 50) {
|
|
341
|
+
recommendations.push({
|
|
342
|
+
category: 'memory',
|
|
343
|
+
priority: 'high',
|
|
344
|
+
message: 'Consider implementing more aggressive garbage collection or reducing cache sizes',
|
|
345
|
+
impact: 'Can improve memory usage by additional 20-30%'
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Deduplication recommendations
|
|
351
|
+
if (this.results.deduplication && !this.results.deduplication.error) {
|
|
352
|
+
if (this.results.deduplication.duplicatesFound > 100) {
|
|
353
|
+
recommendations.push({
|
|
354
|
+
category: 'deduplication',
|
|
355
|
+
priority: 'medium',
|
|
356
|
+
message: 'High number of duplicates found. Consider implementing content templates to reduce future duplication',
|
|
357
|
+
impact: 'Can prevent future size growth'
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Compression recommendations
|
|
363
|
+
if (this.results.compression && !this.results.compression.error) {
|
|
364
|
+
const compressionRatio = parseFloat(this.results.compression.compressionRatio);
|
|
365
|
+
if (compressionRatio < 60) {
|
|
366
|
+
recommendations.push({
|
|
367
|
+
category: 'compression',
|
|
368
|
+
priority: 'medium',
|
|
369
|
+
message: 'Consider using Brotli compression or content preprocessing for better compression ratios',
|
|
370
|
+
impact: 'Can improve compression by additional 10-15%'
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return recommendations;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Generate next steps for continued optimization
|
|
380
|
+
*/
|
|
381
|
+
generateNextSteps() {
|
|
382
|
+
return [
|
|
383
|
+
{
|
|
384
|
+
step: 'Monitor Performance',
|
|
385
|
+
description: 'Track memory usage and file sizes over time to ensure optimizations remain effective',
|
|
386
|
+
timeline: 'Ongoing'
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
step: 'Automate Maintenance',
|
|
390
|
+
description: 'Set up scheduled tasks to run deduplication and compression regularly',
|
|
391
|
+
timeline: '1 week'
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
step: 'Implement Streaming',
|
|
395
|
+
description: 'For very large files, implement streaming processing to further reduce memory usage',
|
|
396
|
+
timeline: '2 weeks'
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
step: 'Content Strategy',
|
|
400
|
+
description: 'Develop content templates and guidelines to minimize duplication in new content',
|
|
401
|
+
timeline: '1 month'
|
|
402
|
+
}
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Get current memory usage
|
|
408
|
+
*/
|
|
409
|
+
getMemoryUsage() {
|
|
410
|
+
const usage = process.memoryUsage();
|
|
411
|
+
return {
|
|
412
|
+
rss: Math.round(usage.rss / 1024 / 1024),
|
|
413
|
+
heapUsed: Math.round(usage.heapUsed / 1024 / 1024),
|
|
414
|
+
heapTotal: Math.round(usage.heapTotal / 1024 / 1024),
|
|
415
|
+
external: Math.round(usage.external / 1024 / 1024)
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Log final optimization results
|
|
421
|
+
*/
|
|
422
|
+
logFinalResults() {
|
|
423
|
+
const totalTime = Date.now() - this.startTime;
|
|
424
|
+
const spaceSaved = this.calculateTotalSpaceSaved();
|
|
425
|
+
const memoryImprovement = this.calculateMemoryImprovement();
|
|
426
|
+
const sizeReduction = this.calculateSizeReductionPercent();
|
|
427
|
+
|
|
428
|
+
console.log('š Size & Memory Optimization Complete!\n');
|
|
429
|
+
console.log('š Final Results:');
|
|
430
|
+
console.log(` š¾ Total space saved: ${spaceSaved}MB`);
|
|
431
|
+
console.log(` š§ Memory improvement: ${memoryImprovement}%`);
|
|
432
|
+
console.log(` š Size reduction: ${sizeReduction}`);
|
|
433
|
+
console.log(` ā±ļø Total processing time: ${(totalTime / 1000).toFixed(2)}s`);
|
|
434
|
+
|
|
435
|
+
console.log('\nšÆ Optimization Phases:');
|
|
436
|
+
Object.entries(this.results).forEach(([phase, result]) => {
|
|
437
|
+
if (result.error) {
|
|
438
|
+
console.log(` ā ${result.phase || phase}: ${result.error}`);
|
|
439
|
+
} else {
|
|
440
|
+
console.log(` ā
${result.phase || phase}: Success`);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// Check if we met our targets
|
|
445
|
+
const sizeTarget = parseFloat(sizeReduction.replace('%', '')) >= 60;
|
|
446
|
+
const memoryTarget = parseFloat(memoryImprovement) >= 70;
|
|
447
|
+
|
|
448
|
+
console.log('\nšÆ Target Achievement:');
|
|
449
|
+
console.log(` Size Reduction (60-80%): ${sizeTarget ? 'ā
ACHIEVED' : 'ā ļø PARTIAL'} (${sizeReduction})`);
|
|
450
|
+
console.log(` Memory Improvement (70%): ${memoryTarget ? 'ā
ACHIEVED' : 'ā ļø PARTIAL'} (${memoryImprovement}%)`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// CLI execution
|
|
455
|
+
if (process.argv[1] === new URL(import.meta.url).pathname) {
|
|
456
|
+
const optimizer = new SizeMemoryOptimizer({
|
|
457
|
+
enableDeduplication: !process.argv.includes('--no-dedup'),
|
|
458
|
+
enableMemoryOptimization: !process.argv.includes('--no-memory'),
|
|
459
|
+
enableCaching: !process.argv.includes('--no-cache'),
|
|
460
|
+
enableCompression: !process.argv.includes('--no-compression'),
|
|
461
|
+
runConcurrently: process.argv.includes('--concurrent')
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
optimizer.execute()
|
|
465
|
+
.then(results => {
|
|
466
|
+
console.log('\nš Optimization pipeline completed successfully!');
|
|
467
|
+
process.exit(0);
|
|
468
|
+
})
|
|
469
|
+
.catch(error => {
|
|
470
|
+
console.error('\nā Optimization pipeline failed:', error.message);
|
|
471
|
+
process.exit(1);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export default SizeMemoryOptimizer;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|