diff options
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js index 83d073a..628e68a 100644 --- a/modules/core/module-aiassist.js +++ b/modules/core/module-aiassist.js @@ -3094,9 +3094,11 @@ buildSystemPrompt() { case 'view_module': { const modName = a.name || ''; const entry = this.terminal.moduleManager.moduleRegistry.find(m => m.name === modName); - const code = this.terminal.fs.readFile(`_mods/${modName}.js`); - if (code) return code; const url = entry ? entry.url : null; + // v4.6.57: deployed source FIRST. The unversioned `_mods/<Name>.js` edit cache + // used to shadow it forever, so view_module returned pre-fix code while the + // running bundle was new (packet §10). The cache is only a labelled fallback. + const deployedVer = (typeof localStorage !== 'undefined' && localStorage.getItem('webx11_cache_ver')) || 'dev'; // Try registry URL first if (url) { try { @@ -3104,7 +3106,7 @@ buildSystemPrompt() { if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src; + return '// deployed: ' + url + ' @ ' + deployedVer + '\n' + src; } } catch (e) { /* fall through */ } } @@ -3126,11 +3128,15 @@ buildSystemPrompt() { if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src; + return '// deployed: ' + fetchUrl + ' @ ' + deployedVer + '\n' + src; } } } } catch (e) { /* fall through */ } + const cachedSrc = this.terminal.fs.readFile(`_mods/${modName}.js`); + if (cachedSrc) { + return '// VFS COPY of ' + modName + '.js — may be stale (not the deployed file)\n' + cachedSrc; + } return JSON.stringify({ error: `Cannot find source for ${modName} — not in registry, not in modules-index.json` }); } case 'edit_module': { |