aboutsummaryrefslogtreecommitdiff
path: root/modules/core/virtual-fs.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/virtual-fs.js')
-rw-r--r--modules/core/virtual-fs.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/modules/core/virtual-fs.js b/modules/core/virtual-fs.js
index 3ab25b1..59ab18b 100644
--- a/modules/core/virtual-fs.js
+++ b/modules/core/virtual-fs.js
@@ -520,15 +520,25 @@ class VirtualFileSystem {
checkpoint(name) {
if (!name) name = new Date().toISOString();
const createdAt = new Date().toISOString();
+ // Strip system dirs to avoid fractal bloat — snapshots/sessions/trash
+ // don't belong inside a checkpoint of user data
+ const root = JSON.parse(JSON.stringify(this.root));
+ if (root && root.content) {
+ delete root.content['_snapshots'];
+ delete root.content['_sessions'];
+ delete root.content['.trash'];
+ }
const data = {
version: 1,
createdAt,
- root: JSON.parse(JSON.stringify(this.root)),
+ root,
currentPath: [...this.currentPath]
};
if (!this.readDir('/_snapshots')) {
this.mkdirRecursive('/_snapshots');
}
+ // Strip _snapshots from the serialized data too (redundant safety)
+ data.root = root;
this.fsWriteJSON('/_snapshots/checkpoint-' + name + '.json', data);
this.saveToStorage();
// Auto-manage: keep max 10 checkpoints, delete oldest
@@ -568,6 +578,26 @@ class VirtualFileSystem {
}
return false;
}
+ // Reset VFS — wipes everything, removes localStorage keys
+ reset() {
+ this.root = { type: 'dir', content: {} };
+ this.currentPath = [];
+ this._conceptCache = null;
+ try {
+ localStorage.removeItem('webx11_filesystem_v2');
+ localStorage.removeItem('webx11_filesystem');
+ } catch (e) {}
+ return true;
+ }
+ // Empty trash — permanently delete all trashed files
+ emptyTrash() {
+ if (this.root.content['.trash']) {
+ delete this.root.content['.trash'];
+ this.saveToStorage();
+ return true;
+ }
+ return false;
+ }
// Old-compat aliases for agent tools and SkillsModule
read(path) { return this.readFile(path); }
write(path, content) { return this.writeFile(path, content); }