aboutsummaryrefslogtreecommitdiff
path: root/scripts/rebuild-bundles.py
blob: a231e32dfeb4edd1733d8ca4f2116e2e2bb0658f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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()