filemayor 2.1.0 → 4.0.5
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/LICENSE +90 -90
- package/README.md +96 -96
- package/core/ai/planner.js +42 -0
- package/core/ai/sentry.js +92 -0
- package/core/ai/strategist.js +186 -0
- package/core/ai/validator.js +116 -0
- package/core/analyzer.js +163 -152
- package/core/categories.js +235 -235
- package/core/cleaner.js +527 -527
- package/core/config.js +562 -562
- package/core/emergency-halt.js +104 -0
- package/core/engine/apply-engine.js +69 -0
- package/core/engine/cure-engine.js +70 -0
- package/core/engine/dedupe-engine.js +77 -0
- package/core/engine/explain-engine.js +114 -0
- package/core/engine/preview-engine.js +49 -0
- package/core/fs-abstraction.js +271 -0
- package/core/guardrail.js +115 -0
- package/core/index.js +135 -79
- package/core/intent-interpreter.js +301 -0
- package/core/jailer.js +151 -0
- package/core/license.js +403 -337
- package/core/metadata-store.js +104 -0
- package/core/organizer.js +414 -528
- package/core/reporter.js +783 -653
- package/core/scanner.js +466 -436
- package/core/security.js +370 -317
- package/core/sop-parser.js +564 -564
- package/core/telemetry.js +74 -0
- package/core/vault.js +179 -0
- package/core/watcher.js +478 -478
- package/index.js +895 -685
- package/package.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ═══════════════════════════════════════════════════════════════════
|
|
5
|
+
* FILEMAYOR CORE — METADATA STORE
|
|
6
|
+
* Lightweight, persistent indexing for S2 compliance (<300ms search).
|
|
7
|
+
* ═══════════════════════════════════════════════════════════════════
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const fs = require('fs').promises;
|
|
13
|
+
const fssync = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
const crypto = require('crypto');
|
|
17
|
+
|
|
18
|
+
class MetadataStore {
|
|
19
|
+
constructor(dbPath) {
|
|
20
|
+
this.rootPath = dbPath || path.join(os.homedir(), '.filemayor', 'metadata_index.json');
|
|
21
|
+
this.index = {
|
|
22
|
+
version: '1.0',
|
|
23
|
+
lastUpdated: null,
|
|
24
|
+
files: {} // path -> metadata
|
|
25
|
+
};
|
|
26
|
+
this._ensureDir();
|
|
27
|
+
this.load();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_ensureDir() {
|
|
31
|
+
const dir = path.dirname(this.rootPath);
|
|
32
|
+
if (!fssync.existsSync(dir)) {
|
|
33
|
+
fssync.mkdirSync(dir, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
load() {
|
|
38
|
+
try {
|
|
39
|
+
if (fssync.existsSync(this.rootPath)) {
|
|
40
|
+
const data = fssync.readFileSync(this.rootPath, 'utf8');
|
|
41
|
+
this.index = JSON.parse(data);
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error('[IDX] Failed to load index:', err.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async save() {
|
|
49
|
+
try {
|
|
50
|
+
this.index.lastUpdated = new Date().toISOString();
|
|
51
|
+
await fs.writeFile(this.rootPath, JSON.stringify(this.index, null, 2));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error('[IDX] Failed to save index:', err.message);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Update the index with fresh file metadata
|
|
59
|
+
* @param {Object[]} files
|
|
60
|
+
*/
|
|
61
|
+
update(files) {
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
this.index.files[file.path] = {
|
|
64
|
+
name: file.name,
|
|
65
|
+
size: file.size,
|
|
66
|
+
mtime: file.modified,
|
|
67
|
+
category: file.category,
|
|
68
|
+
ext: file.ext
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Search the index with < 300ms latency
|
|
75
|
+
* @param {string} query
|
|
76
|
+
* @returns {Object[]}
|
|
77
|
+
*/
|
|
78
|
+
search(query) {
|
|
79
|
+
const startTime = Date.now();
|
|
80
|
+
const results = [];
|
|
81
|
+
const lowerQuery = query.toLowerCase();
|
|
82
|
+
|
|
83
|
+
for (const [filePath, meta] of Object.entries(this.index.files)) {
|
|
84
|
+
if (meta.name.toLowerCase().includes(lowerQuery) || filePath.toLowerCase().includes(lowerQuery)) {
|
|
85
|
+
results.push({ path: filePath, ...meta });
|
|
86
|
+
}
|
|
87
|
+
if (results.length > 100) break; // Cap results for performance
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const duration = Date.now() - startTime;
|
|
91
|
+
return {
|
|
92
|
+
results,
|
|
93
|
+
duration,
|
|
94
|
+
totalFound: results.length
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
clear() {
|
|
99
|
+
this.index.files = {};
|
|
100
|
+
this.save();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = new MetadataStore();
|