aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-aiassist.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-aiassist.js')
-rw-r--r--modules/core/module-aiassist.js48
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}` });
}