aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-neural-vfs.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-06-10 06:00:30 +0200
committerAgando <roduccomm@gmail.com>2026-06-10 06:00:30 +0200
commit39b2df36ee5ccea52558d0537bfee87058558e94 (patch)
tree7cac66cf09b128c07fa0300da0a46d016d4459e5 /modules/core/module-neural-vfs.js
parente8d4985bbb60797936d31b65604a7f94c76bf623 (diff)
auto: 2026-06-10_06:00 changes
Diffstat (limited to 'modules/core/module-neural-vfs.js')
-rw-r--r--modules/core/module-neural-vfs.js44
1 files changed, 42 insertions, 2 deletions
diff --git a/modules/core/module-neural-vfs.js b/modules/core/module-neural-vfs.js
index bdf1ffb..613d53a 100644
--- a/modules/core/module-neural-vfs.js
+++ b/modules/core/module-neural-vfs.js
@@ -7,6 +7,7 @@ class NeuralVFSModule {
'nvfs-tree': { argType: 'file' }, 'nvfs-config': { argType: 'file' },
'nvfs-alias': { argType: 'file' },
'nvfs-sync': { argType: 'file' },
+ 'nvfs-save': { argType: 'none' },
};
this.terminal = null;
this.index = {};
@@ -55,7 +56,8 @@ class NeuralVFSModule {
'nvfs-tree': 'nvfs-tree [concept] — Show concept-to-file mapping as a tree',
'nvfs-config': 'nvfs-config [key] [value] — View or set Neural VFS config (fuzzy-limit, tree-files, tree-concepts, resolve-files, deep-index, deep-model)',
'nvfs-alias': 'nvfs-alias list|add|remove|clear — Manage concept aliases',
- 'nvfs-sync': 'nvfs-sync [--deep] — Incremental background sync (auto-sync dirty files)'
+ 'nvfs-sync': 'nvfs-sync [--deep] — Incremental background sync (auto-sync dirty files)',
+ 'nvfs-save': 'nvfs-save — Force-save current in-memory index to VFS (survives refresh)'
};
}
@@ -67,6 +69,7 @@ class NeuralVFSModule {
this.commands['nvfs-config'] = (args) => this.nvfsConfig(args);
this.commands['nvfs-alias'] = (args) => this.nvfsAlias(args);
this.commands['nvfs-sync'] = async (args) => this.nvfsSync(args);
+ this.commands['nvfs-save'] = (args) => this.nvfsSave();
}
// ── Core Index Builder (async, chunked) ──
@@ -76,6 +79,19 @@ class NeuralVFSModule {
const fs = this.terminal.fs;
if (!fs) return this.terminal.print('VFS not available', 'error');
+ // Safety guard: warn if deep mode is off but the saved index has LLM concepts
+ if (!useDeep) {
+ const prevIndex = fs.fsReadJSON(this.indexPath) || {};
+ const hasLLM = Object.values(prevIndex).some(entries =>
+ Array.isArray(entries) && entries.some(e => e.source === 'llm')
+ );
+ if (hasLLM) {
+ this.terminal.print('⚠️ Deep indexing is OFF but the saved index contains LLM-generated concepts.', 'warning');
+ this.terminal.print(' Running nvfs-index without --deep will STRIP all LLM concepts from re-indexed files.', 'warning');
+ this.terminal.print(' To keep them: nvfs-config deep-index on or nvfs-index --deep', 'warning');
+ }
+ }
+
this.terminal.print(`🔍 Scanning VFS for semantic concepts${useDeep ? ' (deep mode)' : ''}...`, 'info');
const start = Date.now();
@@ -634,7 +650,7 @@ class NeuralVFSModule {
const hash = this._contentHash(content);
const cached = this._getCached(path, hash);
if (!cached) {
- this._reindexFile(path, content, this.index);
+ this._reindexFile(path, content, this.index, this._deepIndexEnabled);
this._hashCache[path] = { hash };
reindexed++;
}
@@ -768,6 +784,30 @@ Concepts:`;
const llmConcepts = results.reduce((s, r) => s + r.concepts.length, 0);
this.terminal?.print(`🧠 Deep pass complete: ${llmConcepts} LLM-generated concepts across ${results.length} files`, 'success');
}
+ // Persist LLM-generated concepts to disk so they survive page refresh
+ // Must force-save because _saveIndex() calls saveToStorage() which has a
+ // debounce guard (_storageSavePending) that may still be set from the
+ // initial buildIndex() save — without clearing it, the LLM concepts are
+ // never written to localStorage and are lost on page refresh.
+ const vfs = this.terminal?.fs;
+ if (vfs) {
+ vfs._storageSavePending = false;
+ this._saveIndex(vfs);
+ }
+ }
+
+ // ── Nvfs Save (force-persist in-memory index) ──
+
+ nvfsSave() {
+ const fs = this.terminal?.fs;
+ if (!fs) return this.terminal?.print('VFS not available', 'error');
+ const count = Object.keys(this.index).length;
+ if (count === 0) return this.terminal?.print('No index in memory to save', 'warning');
+ // Bypass debounce guard to ensure write
+ fs._storageSavePending = false;
+ this._saveIndex(fs);
+ this.terminal?.print(`✅ Saved ${count} concepts to ${this.indexPath}`, 'success');
+ this.terminal?.print(' Index will survive page refresh', 'info');
}
// ── Nvfs Sync (incremental background) ──