diff options
| author | Agando <roduccomm@gmail.com> | 2026-06-05 18:01:01 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-06-05 18:01:01 +0200 |
| commit | b538577cd0a4292e4cd4ca1c9f9829fc7e133caa (patch) | |
| tree | 04d76bf4f0d680cdb26b1a205481bc8628cd77b4 /modules/core/module-aiassist.js | |
| parent | 5092f9a0ce02691dc476d7b64fa731a1518dd834 (diff) | |
auto: 2026-06-05_18:01 changes
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js index cb1482f..b93b12d 100644 --- a/modules/core/module-aiassist.js +++ b/modules/core/module-aiassist.js @@ -572,6 +572,28 @@ RULES: } catch (e) {} } + // Inject memory graph context for cross-session awareness + try { + const memgraph = this.terminal.moduleManager.modules['MemoryGraphModule']; + if (memgraph) { + const mctx = memgraph.getContextForPrompt(); + if (mctx) { + messages.push({ role: 'system', content: mctx }); + } + } + } catch (e) { /* memory graph not available */ } + + // Inject world model context for system self-awareness + try { + const wm = this.terminal.moduleManager.modules['WorldModelModule']; + if (wm) { + const wctx = wm.getContextForPrompt(); + if (wctx) { + messages.push({ role: 'system', content: wctx }); + } + } + } catch (e) { /* world model not available */ } + loopResult = await this.agenticLoop(messages); this.context.push({ role: 'user', content: userMessage }); if (loopResult.finalAnswer) { @@ -1497,7 +1519,7 @@ RULES: if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src.substring(0, 8000); + return src; } } catch (e) { /* fall through */ } } @@ -1519,7 +1541,7 @@ RULES: if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src.substring(0, 8000); + return src; } } } @@ -1542,6 +1564,28 @@ RULES: } } catch (e) {} } + // Fallback: use modules-index.json for core modules (not in registry) + if (!code) { + try { + const idxResp = await fetch('/spaces/newos4/modules-index.json?v=' + (localStorage.getItem('webx11_cache_ver') || '')); + if (idxResp.ok) { + const idx = await idxResp.json(); + let match = Object.values(idx.modules).find(m => m.class === modName); + if (!match) match = idx.modules[modName]; + if (match) { + const filePath = match.file; + const fetchUrl = `/spaces/newos4/${filePath}`; + const resp = await fetch(fetchUrl); + if (resp.ok) { + code = await resp.text(); + this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, code); + this.terminal.fs.writeFile(`_mods/${modName}.js`, code); + this.terminal.fs.writeFile(`_mods/${modName}.meta.json`, JSON.stringify({ originalUrl: fetchUrl, modifiedAt: new Date().toISOString(), editCount: 0 })); + } + } + } + } catch (e) {} + } if (code) this.terminal.openCodeEditor(modName, url || '', code); return code ? `Editor opened for ${modName} (${code.length} chars)` : JSON.stringify({ error: `Could not load source for ${modName}` }); } |