aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/finder.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-05-25 18:02:02 +0200
committerAgando <roduccomm@gmail.com>2026-05-25 18:02:02 +0200
commit4baa484b84c5184286cac2743575251454a5ee2b (patch)
treecb9002f93644f363d0f35831dc97e6492bbb0ed6 /modules/ext/finder.js
auto: 2026-05-25_18:02 changes
Diffstat (limited to 'modules/ext/finder.js')
-rw-r--r--modules/ext/finder.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/ext/finder.js b/modules/ext/finder.js
new file mode 100644
index 0000000..1ca8cf7
--- /dev/null
+++ b/modules/ext/finder.js
@@ -0,0 +1,47 @@
+class FinderModule {
+ constructor() {
+ this.commands = {};
+ this.terminal = null;
+ }
+
+ requirements() {
+ return { met: true, missing: [] };
+ }
+
+ getHelpInfo() {
+ return {
+ 'find': 'Recursively search VFS files/directories by name (usage: find <query>)',
+ };
+ }
+
+ registerCommands() {
+ this.commands['find'] = (args) => this.find(args);
+ }
+ find(args) {
+ if (!args[0]) return this.terminal.print('Usage: find <query> — recursively searches VFS files/dirs matching query', 'warning');
+ const query = args.join(' ').toLowerCase();
+ const results = [];
+ this._recurse(this.terminal.fs.root, [], query, results);
+ if (results.length === 0) return this.terminal.print(`No matches for "${query}"`, 'warning');
+ this.terminal.print(`=== Found ${results.length} match(es) for "${query}" ===`, 'info');
+ results.forEach(r => {
+ const icon = r.type === 'dir' ? '📁' : '📄';
+ this.terminal.print(` ${icon} ${r.path}`);
+ });
+ }
+ _recurse(node, pathParts, query, results) {
+ if (!node || !node.content) return;
+ for (const [name, child] of Object.entries(node.content)) {
+ const fullPath = '/' + [...pathParts, name].join('/');
+ if (name.toLowerCase().includes(query)) {
+ results.push({ name, path: fullPath, type: child.type || (child.content ? 'dir' : 'file') });
+ }
+ if (child.content && typeof child.content === 'object') {
+ this._recurse(child, [...pathParts, name], query, results);
+ }
+ }
+ }
+}
+if (typeof window.webx11 !== 'undefined' && window.webx11) {
+ webx11.moduleManager.registerModule(new FinderModule(), 'https://webx11.duckdns.org/spaces/chatstudio/newos4/modules/finder.js');
+}