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.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js
index 303f9c2..ac8d297 100644
--- a/modules/core/module-aiassist.js
+++ b/modules/core/module-aiassist.js
@@ -2379,10 +2379,11 @@ buildSystemPrompt() {
// MAINT-011: readDir() resolves the virtual mounts and returns null for a
// path that does not exist. The old hand-rolled walk over root.content could
// not see /sys, so a directory the UI shows answered "Directory not found".
- const entries = fsapi.readDir(p || '/');
+ // No argument means "the current directory", which ls() already does.
+ const entries = p ? fsapi.readDir(p) : fsapi.ls();
fsapi.currentPath = saved;
if (entries === null || entries === undefined) {
- return JSON.stringify({ error: `Directory not found: ${p || '/'}` });
+ return JSON.stringify({ error: `Directory not found: ${originalPath || p}` });
}
return JSON.stringify(entries.map(f => ({ name: f.name, type: f.type, size: f.size })));
}
@@ -2430,9 +2431,12 @@ buildSystemPrompt() {
const wrote = this.terminal.fs.writeFile(path, content);
this.terminal.fs.currentPath = savedW;
if (!wrote) {
- return `Write FAILED: ${path} — parent directory missing or target is a directory; nothing was written`;
+ const why = (typeof this.terminal.fs._isVirtualPath === 'function' && this.terminal.fs._isVirtualPath(wp))
+ ? 'read-only virtual path'
+ : 'parent directory missing or target is a directory';
+ return `Write FAILED: ${wp} — ${why}; nothing was written`;
}
- return `File written: ${path} (${content.length} chars)`;
+ return `File written: ${wp} (${content.length} chars)`;
}
case 'make_directory': {
const mp = a.path || '';