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,336 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Content Deduplication System
|
|
5
|
+
*
|
|
6
|
+
* Eliminates redundancy in 237M one/ and 229M .one/ directories
|
|
7
|
+
* Implements smart content fingerprinting and deduplication strategies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'fs/promises';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import crypto from 'crypto';
|
|
13
|
+
|
|
14
|
+
class ContentDeduplicator {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.options = {
|
|
17
|
+
directories: ['.one', 'one'],
|
|
18
|
+
extensions: ['.md', '.yaml', '.json', '.txt'],
|
|
19
|
+
minFileSize: 100, // bytes
|
|
20
|
+
similarityThreshold: 0.85,
|
|
21
|
+
preserveOriginals: true,
|
|
22
|
+
createSymlinks: true,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
this.contentMap = new Map();
|
|
27
|
+
this.duplicateGroups = new Map();
|
|
28
|
+
this.stats = {
|
|
29
|
+
filesProcessed: 0,
|
|
30
|
+
duplicatesFound: 0,
|
|
31
|
+
spaceReclaimed: 0,
|
|
32
|
+
processingTime: 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Generate content fingerprint using multiple hashing strategies
|
|
38
|
+
*/
|
|
39
|
+
generateFingerprint(content, filePath) {
|
|
40
|
+
// Clean content for comparison (remove whitespace variations)
|
|
41
|
+
const cleanContent = content
|
|
42
|
+
.replace(/\r\n/g, '\n') // Normalize line endings
|
|
43
|
+
.replace(/[ \t]+$/gm, '') // Remove trailing whitespace
|
|
44
|
+
.replace(/\n{3,}/g, '\n\n') // Normalize multiple newlines
|
|
45
|
+
.trim();
|
|
46
|
+
|
|
47
|
+
// Generate multiple hash types for better deduplication
|
|
48
|
+
const md5Hash = crypto.createHash('md5').update(cleanContent).digest('hex');
|
|
49
|
+
const contentLength = cleanContent.length;
|
|
50
|
+
|
|
51
|
+
// Semantic fingerprint (first/last 100 chars + length)
|
|
52
|
+
const semantic = cleanContent.slice(0, 100) + contentLength + cleanContent.slice(-100);
|
|
53
|
+
const semanticHash = crypto.createHash('sha256').update(semantic).digest('hex').slice(0, 16);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
md5: md5Hash,
|
|
57
|
+
semantic: semanticHash,
|
|
58
|
+
length: contentLength,
|
|
59
|
+
cleanContent: cleanContent,
|
|
60
|
+
originalPath: filePath
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Calculate similarity between two content strings
|
|
66
|
+
*/
|
|
67
|
+
calculateSimilarity(content1, content2) {
|
|
68
|
+
if (content1 === content2) return 1.0;
|
|
69
|
+
|
|
70
|
+
const longer = content1.length > content2.length ? content1 : content2;
|
|
71
|
+
const shorter = content1.length > content2.length ? content2 : content1;
|
|
72
|
+
|
|
73
|
+
if (longer.length === 0) return 1.0;
|
|
74
|
+
|
|
75
|
+
// Simple character-based similarity
|
|
76
|
+
let matches = 0;
|
|
77
|
+
const minLength = Math.min(longer.length, shorter.length);
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < minLength; i++) {
|
|
80
|
+
if (longer[i] === shorter[i]) matches++;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return matches / longer.length;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Scan directories for content analysis
|
|
88
|
+
*/
|
|
89
|
+
async scanDirectories() {
|
|
90
|
+
console.log('š Scanning directories for content analysis...');
|
|
91
|
+
const startTime = Date.now();
|
|
92
|
+
|
|
93
|
+
for (const dir of this.options.directories) {
|
|
94
|
+
await this.scanDirectory(dir);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.stats.processingTime = Date.now() - startTime;
|
|
98
|
+
console.log(`ā
Scanned ${this.stats.filesProcessed} files in ${this.stats.processingTime}ms`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Recursively scan directory
|
|
103
|
+
*/
|
|
104
|
+
async scanDirectory(dirPath) {
|
|
105
|
+
try {
|
|
106
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
107
|
+
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
110
|
+
|
|
111
|
+
if (entry.isDirectory()) {
|
|
112
|
+
// Skip node_modules and .git
|
|
113
|
+
if (!['node_modules', '.git', '.next', 'dist', 'build'].includes(entry.name)) {
|
|
114
|
+
await this.scanDirectory(fullPath);
|
|
115
|
+
}
|
|
116
|
+
} else if (entry.isFile()) {
|
|
117
|
+
const ext = path.extname(entry.name);
|
|
118
|
+
if (this.options.extensions.includes(ext)) {
|
|
119
|
+
await this.processFile(fullPath);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.warn(`ā ļø Cannot scan directory ${dirPath}: ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Process individual file for deduplication
|
|
130
|
+
*/
|
|
131
|
+
async processFile(filePath) {
|
|
132
|
+
try {
|
|
133
|
+
const stats = await fs.stat(filePath);
|
|
134
|
+
|
|
135
|
+
// Skip small files
|
|
136
|
+
if (stats.size < this.options.minFileSize) return;
|
|
137
|
+
|
|
138
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
139
|
+
const fingerprint = this.generateFingerprint(content, filePath);
|
|
140
|
+
|
|
141
|
+
this.stats.filesProcessed++;
|
|
142
|
+
|
|
143
|
+
// Check for exact matches first
|
|
144
|
+
if (this.contentMap.has(fingerprint.md5)) {
|
|
145
|
+
const existing = this.contentMap.get(fingerprint.md5);
|
|
146
|
+
this.addToDuplicateGroup(fingerprint.md5, [existing, fingerprint]);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Check for similar content
|
|
151
|
+
for (const [hash, existing] of this.contentMap) {
|
|
152
|
+
const similarity = this.calculateSimilarity(
|
|
153
|
+
fingerprint.cleanContent,
|
|
154
|
+
existing.cleanContent
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
if (similarity >= this.options.similarityThreshold) {
|
|
158
|
+
this.addToDuplicateGroup(hash, [existing, fingerprint]);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// No duplicates found, add to map
|
|
164
|
+
this.contentMap.set(fingerprint.md5, fingerprint);
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.warn(`ā ļø Cannot process file ${filePath}: ${error.message}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Add files to duplicate group
|
|
173
|
+
*/
|
|
174
|
+
addToDuplicateGroup(key, files) {
|
|
175
|
+
if (!this.duplicateGroups.has(key)) {
|
|
176
|
+
this.duplicateGroups.set(key, new Set());
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
files.forEach(file => {
|
|
180
|
+
this.duplicateGroups.get(key).add(file);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
this.stats.duplicatesFound++;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Execute deduplication process
|
|
188
|
+
*/
|
|
189
|
+
async deduplicate() {
|
|
190
|
+
console.log('š Starting deduplication process...');
|
|
191
|
+
|
|
192
|
+
let spaceSaved = 0;
|
|
193
|
+
let filesProcessed = 0;
|
|
194
|
+
|
|
195
|
+
for (const [key, duplicateSet] of this.duplicateGroups) {
|
|
196
|
+
const duplicates = Array.from(duplicateSet);
|
|
197
|
+
|
|
198
|
+
if (duplicates.length < 2) continue;
|
|
199
|
+
|
|
200
|
+
// Sort by file path to get consistent ordering
|
|
201
|
+
duplicates.sort((a, b) => a.originalPath.localeCompare(b.originalPath));
|
|
202
|
+
|
|
203
|
+
// Keep the first file as the canonical version
|
|
204
|
+
const canonical = duplicates[0];
|
|
205
|
+
const toDedup = duplicates.slice(1);
|
|
206
|
+
|
|
207
|
+
console.log(`š Found ${duplicates.length} duplicates of: ${canonical.originalPath}`);
|
|
208
|
+
|
|
209
|
+
for (const duplicate of toDedup) {
|
|
210
|
+
try {
|
|
211
|
+
const stats = await fs.stat(duplicate.originalPath);
|
|
212
|
+
spaceSaved += stats.size;
|
|
213
|
+
|
|
214
|
+
if (this.options.createSymlinks) {
|
|
215
|
+
// Create symlink to canonical file
|
|
216
|
+
const backupPath = duplicate.originalPath + '.dedup-backup';
|
|
217
|
+
|
|
218
|
+
if (this.options.preserveOriginals) {
|
|
219
|
+
await fs.rename(duplicate.originalPath, backupPath);
|
|
220
|
+
} else {
|
|
221
|
+
await fs.unlink(duplicate.originalPath);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Create relative symlink
|
|
225
|
+
const relativePath = path.relative(
|
|
226
|
+
path.dirname(duplicate.originalPath),
|
|
227
|
+
canonical.originalPath
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
await fs.symlink(relativePath, duplicate.originalPath);
|
|
231
|
+
|
|
232
|
+
console.log(` š ${duplicate.originalPath} -> ${canonical.originalPath}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
filesProcessed++;
|
|
236
|
+
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.warn(`ā ļø Cannot deduplicate ${duplicate.originalPath}: ${error.message}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.stats.spaceReclaimed = spaceSaved;
|
|
244
|
+
|
|
245
|
+
console.log(`ā
Deduplication complete:`);
|
|
246
|
+
console.log(` š Files processed: ${filesProcessed}`);
|
|
247
|
+
console.log(` š¾ Space reclaimed: ${this.formatBytes(spaceSaved)}`);
|
|
248
|
+
console.log(` š Symlinks created: ${filesProcessed}`);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Generate deduplication report
|
|
253
|
+
*/
|
|
254
|
+
async generateReport() {
|
|
255
|
+
const report = {
|
|
256
|
+
timestamp: new Date().toISOString(),
|
|
257
|
+
stats: this.stats,
|
|
258
|
+
duplicateGroups: Array.from(this.duplicateGroups.entries()).map(([key, duplicates]) => ({
|
|
259
|
+
hash: key,
|
|
260
|
+
count: duplicates.size,
|
|
261
|
+
files: Array.from(duplicates).map(d => ({
|
|
262
|
+
path: d.originalPath,
|
|
263
|
+
size: d.length
|
|
264
|
+
}))
|
|
265
|
+
})),
|
|
266
|
+
spaceOptimization: {
|
|
267
|
+
totalSizeBefore: this.stats.filesProcessed * 1000, // Rough estimate
|
|
268
|
+
spaceSaved: this.stats.spaceReclaimed,
|
|
269
|
+
compressionRatio: this.stats.spaceReclaimed / (this.stats.filesProcessed * 1000)
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const reportPath = path.join('.one', 'reports', 'deduplication-report.json');
|
|
274
|
+
await fs.mkdir(path.dirname(reportPath), { recursive: true });
|
|
275
|
+
await fs.writeFile(reportPath, JSON.stringify(report, null, 2));
|
|
276
|
+
|
|
277
|
+
console.log(`š Report saved to: ${reportPath}`);
|
|
278
|
+
return report;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Format bytes to human readable
|
|
283
|
+
*/
|
|
284
|
+
formatBytes(bytes) {
|
|
285
|
+
if (bytes === 0) return '0 B';
|
|
286
|
+
const k = 1024;
|
|
287
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
288
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
289
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Main execution method
|
|
294
|
+
*/
|
|
295
|
+
async execute() {
|
|
296
|
+
try {
|
|
297
|
+
console.log('šÆ Content Deduplication System - Starting optimization...');
|
|
298
|
+
|
|
299
|
+
await this.scanDirectories();
|
|
300
|
+
await this.deduplicate();
|
|
301
|
+
await this.generateReport();
|
|
302
|
+
|
|
303
|
+
console.log('ā
Content deduplication completed successfully!');
|
|
304
|
+
return this.stats;
|
|
305
|
+
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.error('ā Deduplication failed:', error);
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// CLI execution
|
|
314
|
+
if (process.argv[1] === new URL(import.meta.url).pathname) {
|
|
315
|
+
const deduplicator = new ContentDeduplicator({
|
|
316
|
+
directories: process.argv.includes('--one-only') ? ['one'] : ['.one', 'one'],
|
|
317
|
+
preserveOriginals: !process.argv.includes('--no-backup'),
|
|
318
|
+
createSymlinks: !process.argv.includes('--no-symlinks'),
|
|
319
|
+
similarityThreshold: parseFloat(process.argv.find(arg => arg.startsWith('--threshold='))?.split('=')[1]) || 0.85
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
deduplicator.execute()
|
|
323
|
+
.then(stats => {
|
|
324
|
+
console.log('\nš Final Statistics:');
|
|
325
|
+
console.log(` Files processed: ${stats.filesProcessed}`);
|
|
326
|
+
console.log(` Duplicates found: ${stats.duplicatesFound}`);
|
|
327
|
+
console.log(` Space reclaimed: ${deduplicator.formatBytes(stats.spaceReclaimed)}`);
|
|
328
|
+
console.log(` Processing time: ${stats.processingTime}ms`);
|
|
329
|
+
})
|
|
330
|
+
.catch(error => {
|
|
331
|
+
console.error('ā Error:', error.message);
|
|
332
|
+
process.exit(1);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export default ContentDeduplicator;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|