#!/usr/bin/env python3 """ Rebuild the core and critical-ext bundles for newOS4. Run this whenever a file in modules/core/ or one of the critical ext modules changes. """ import os ROOT = '/var/www/webx11.duckdns.org/spaces/newos4' CORE_FILES = [ 'virtual-fs.js', 'module-manager.js', 'ollama-manager.js', 'terminal.js', 'module-system.js', 'module-fs.js', 'module-ollama.js', 'module-billing.js', 'module-modmgr.js', 'module-searxng.js', 'module-servermon.js', 'module-config.js', 'module-simplegui.js', 'module-aiassist.js', 'module-aiasm.js', 'module-fetcher.js', 'secret-vault.js', 'module-chatstudio.js', 'module-agent-registry.js', 'module-leases.js', 'module-orchestrator.js', 'module-sandbox.js', 'module-memory-graph.js', 'module-predictor.js', 'module-world-model.js', 'module-neural-vfs.js', 'module-smartctx.js', 'module-debug-supervisor.js', ] CRITICAL_EXT_FILES = [ 'editor.js', 'shell.js', 'alias.js', 'finder.js', 'filemgr.js', 'diff.js', 'busybox.js' ] def build_bundle(source_dir, files, output_path, label): parts = [f'// {label} bundle', f'// Generated from {source_dir}', ''] for f in files: src = os.path.join(source_dir, f) if not os.path.exists(src): print(f' WARNING: {src} not found, skipping') continue with open(src, 'r', encoding='utf-8') as fh: code = fh.read() parts.append(f'\n/* === {f} === */\n') parts.append(code) if not code.endswith('\n'): parts.append('\n') parts.append(f'\n/* === end {label.lower()} bundle === */\n') out = ''.join(parts) with open(output_path, 'w', encoding='utf-8') as fh: fh.write(out) print(f'{output_path}: {len(out)} bytes ({len(out)/1024:.1f} KB)') def main(): build_bundle( os.path.join(ROOT, 'modules/core'), CORE_FILES, os.path.join(ROOT, 'modules/core/core-bundle.js'), 'Core module' ) build_bundle( os.path.join(ROOT, 'modules/ext'), CRITICAL_EXT_FILES, os.path.join(ROOT, 'modules/ext/critical-ext-bundle.js'), 'Critical ext module' ) if __name__ == '__main__': main()