replica-omnisciente/.mimocode/plans/1783706347356-quick-nebula.md
2026-07-12 20:53:24 +01:00

6.6 KiB

Eclipse Theia Migration Plan — CT 207

Goal: Replace code-server with a custom Eclipse Theia IDE on CT 207, serving as the centralized development environment for all Portugal Futurista projects.

[S1] Current State

CT 207 (192.168.0.17) runs:

  • code-server v4.117.0 on port 8443 (VS Code in browser, no auth)
  • Aurelio extension v0.12.0 (50+ commands: brain sync, realms, heteronyms, Immich, EDA, MCP)
  • aurelio-web on port 3100 (React SPA portal)
  • aurelio-api (Svelte/Fastify backend)
  • bolsa-do-mundial (C++ HFT + FastAPI)

Resources: 2 cores, 2 GB RAM, 16 GB disk (5.4 GB used).

[S2] Target State

  • Eclipse Theia (custom fork) on port 8443 (same URL)
  • Aurelio extension ported to Theia extension API
  • All repos migrated to new centralized repository
  • Resources: 4 cores, 6 GB RAM, 32 GB disk

[S3] Removal — code-server cleanup

# On CT 207
systemctl stop code-server@root
systemctl disable code-server@root
apt purge -y code-server
rm -rf /root/.config/code-server /root/.local/share/code-server

Keep aurelio-web, aurelio-api, bolsa-* services untouched.

[S4] Resize CT 207

# On ASUS (Proxmox host)
pct stop 207
pct set 207 --memory 6142 --cores 4 --swap 1024
pct resize 207 rootfs +16G  # 16G → 32G
pct start 207

Verify: pct exec 207 -- free -h && df -h /

[S5] Install build prerequisites

# On CT 207
apt update && apt install -y curl git build-essential python3 python3-pip libsecret-1-dev libx11-dev libxkbfile-dev

# Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs

# Yarn (Theia requires it)
npm install -g yarn

# Verify
node --version  # v20.x
yarn --version  # 1.x
python3 --version

[S6] Clone and configure Theia fork

The user will create a new repo. Initial structure:

<new-repo>/
├── package.json          # Theia product definition
├── yarn.lock
├── Dockerfile            # Optional: for reproducible builds
├── lerna.json
├── tsconfig.json
├── AurelioTheia/         # Custom Aurelio Theia extension
│   ├── package.json
│   └── src/
│       ├── browser/
│       └── node/
├── aurelio-backend/      # Backend services (MCP, brain, sync)
│   └── ...
└── README.md

Theia product package.json:

{
  "private": true,
  "dependencies": [
    "@theia/core": "latest",
    "@theia/editor": "latest",
    "@theia/terminal": "latest",
    "@theia/filesystem": "latest",
    "@theia/git": "latest",
    "@theia/search-in-workspace": "latest",
    "@theia/outline": "latest",
    "@theia/markers": "latest",
    "@theia/output": "latest",
    "@theia/debug": "latest",
    "@theia/call-hierarchy": "latest",
    "@theia/typehierarchy": "latest",
    "@theia/workspace": "latest",
    "@theia/ai-core": "latest",
    "@theia/ai-chat": "latest",
    "aurelio-theia-extension": "workspace:*"
  ],
  "devDependencies": [
    "@theia/cli": "latest"
  ]
}

[S7] Port Aurelio extension to Theia

The current extension is VS Code API-compatible. Theia supports VS Code extensions natively, but for deeper integration (custom views, sidebar, MCP), a Theia-specific extension is better.

Migration path:

  1. Wrap existing VS Code extension as a Theia extension (Theia can consume VS Code extensions)
  2. For custom features (chat view, brain sync sidebar, Immich browser), port to Theia extension API
  3. Use Theia's @theia/ai-core for AI integration instead of custom chat panel

Key differences:

  • VS Code window.createTreeView → Theia TreeWidget contribution
  • VS Code webviewView → Theia Widget with custom panel
  • VS Code commands.registerCommand → Theia CommandContribution
  • VS Code workspace.getConfiguration → Theia PreferenceService

Files to port:

  • aurelio.commands.ts → Theia command contributions
  • aurelio.treeDataProvider.* → Theia tree widget contributions
  • aurelio.webview.* → Theia widget contributions
  • aurelio.sync.ts → Node.js backend service (MCP-compatible)

[S8] Build Theia

cd /opt/aurelio-theia
yarn install
yarn theia rebuild  # Rebuild native modules
yarn theia build --mode production

Build time: ~15-20 min on 4 cores. Output: ./applications/electron/ or ./lib/.

[S9] Systemd service

# /etc/systemd/system/aurelio-theia.service
[Unit]
Description=Eclipse Theia — Aurelio IDE
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/aurelio-theia/lib
ExecStart=/usr/bin/node /opt/aurelio-theia/lib/backend/main.js
Restart=always
Environment=NODE_ENV=production
Environment=THEIA_PORT=8443

[Install]
WantedBy=multi-user.target

[S10] Cloudflare tunnel

No change needed — aurelio.portugalfuturista.org already points to 192.168.0.17:8443.

[S11] Repo migration

The user will create a new centralized repo. Repos to migrate:

Repo Current location What migrates
replica-omnisciente /home/fabiorafaelcoutada/portugalfuturista/replica-omnisciente .aurelio/, scripts/, realms/, shared/
nervura-electrica /home/fabiorafaelcoutada/portugalfuturista/nervura-electrica infrastructure/proxmox/, scripts/
extensions/aurelio-vscode gitignored, local only Port to Theia extension
extensions/kimi-interceptor replica-omnisciente/extensions/ Keep as-is
aurelio-web CT 207 /opt/aurelio-web Source in new repo
aurelio-api CT 207 /opt/aurelio-api Source in new repo

[S12] Verification

  1. curl -s -o /dev/null -w "%{http_code}" https://aurelio.portugalfuturista.org → 200 or 302
  2. Open aurelio.portugalfuturista.org in browser — Theia IDE loads
  3. Aurelio sidebar visible with Chat, Sessions, Realms, Heterónimos panels
  4. Brain sync commands work (push/pull)
  5. Terminal works inside Theia
  6. All repos visible in file explorer

Implementation order

  1. Phase 1: Remove code-server, resize CT (S3-S4)
  2. Phase 2: Install build tools, clone Theia (S5-S6)
  3. Phase 3: Port Aurelio extension (S7) — largest effort
  4. Phase 4: Build and deploy Theia (S8-S9)
  5. Phase 5: Migrate repos to new centralized repo (S11)
  6. Phase 6: Verify everything works (S12)

Repo location

Forgejo at code.portugalfuturista.org/portugalfuturista/<repo-name>. User is creating the repo now — name TBD.

Open questions

  • Aurelio extension port to Theia: VS Code extension may work directly via @theia/vscode-extension-support — needs testing before full port
  • Build time on CT 207 with 4 cores: may need to pre-build on a more powerful machine and deploy the artifact