summaryrefslogtreecommitdiff
path: root/modules/core/module-fetcher.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-fetcher.js')
-rw-r--r--modules/core/module-fetcher.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/core/module-fetcher.js b/modules/core/module-fetcher.js
index 45505a7..d1b7bcc 100644
--- a/modules/core/module-fetcher.js
+++ b/modules/core/module-fetcher.js
@@ -5,7 +5,7 @@ class WebFetcherModule {
}
getHelpInfo() {
return {
- 'fetch': 'fetch <url> [--post=BODY] [--type=CT] [--raw] — Fetch URL (raw HTML/text); --post enables POST with body, --type sets Content-Type, --raw shows untruncated content',
+ 'fetch': 'fetch <url> [--post=BODY] [--type=CT] [--raw] [--save=FILE] — Fetch URL (raw HTML/text); --post enables POST with body, --type sets Content-Type, --raw shows untruncated content, --save writes it to the VFS',
'extract': 'extract <url> — Extract readable article content (title + body text) from a URL',
};
}
@@ -69,6 +69,21 @@ class WebFetcherModule {
return;
}
const text = await resp.text();
+ // --save: the only terminal path from a remote URL to the VFS. Without it a
+ // 100 KB source page can only be read through 3 000-char scrollback, which is
+ // what sent the in-OS agent looking for a shell redirect (reported 2026-11-06).
+ if (flags.save) {
+ const path = String(flags.save === true ? (url.split('/').pop().split('?')[0] || 'fetch.txt') : flags.save);
+ const dir = path.includes('/') ? path.slice(0, path.lastIndexOf('/')) : '';
+ if (dir) { try { this.terminal.fs.mkdir(dir); } catch (e) {} }
+ const wrote = this.terminal.fs.writeFile(path, text);
+ if (!wrote || this.terminal.fs.readFile(path) !== text) {
+ this.terminal.print(`Save failed: could not write ${path}`, 'error');
+ return;
+ }
+ this.terminal.print(`💾 Saved ${text.length} chars to ${path}`, 'success');
+ return;
+ }
const limit = showRaw ? text.length : 3000;
this.terminal.print(`\n=== Content from ${url} (${method}) ===\n`, 'success');
this.terminal.print(text.substring(0, limit) + (text.length > limit && !showRaw ? '...' : ''));