amangs commited on
Commit
feb92c0
·
1 Parent(s): 6cba4f0

Fix workspace clutter: isolate app databases to /data/apps/, purge /data/config and code-server workspace state

Browse files
README.md CHANGED
@@ -14,7 +14,7 @@ High-performance reverse-engineering server and persistent workspace backed by [
14
  ## Architecture (`:7860` Caddy Gateway)
15
 
16
  - **`/mcp`** → Streamable HTTP MCP endpoint (`supergateway` → `rea mcp`)
17
- - **`/code/`** → In-browser VS Code Server bound to `/data/workspace`
18
  - **`/files/`** → [goFiles](https://github.com/G-Aman/goFiles) File Manager & WebDAV server on `/data`
19
  - **`/opencode/`** → [OpenCode Router](https://github.com/G-Aman/opencode-router) WebUI and `/v1` AI proxy
20
  - **`/`** → System dashboard & analysis status
 
14
  ## Architecture (`:7860` Caddy Gateway)
15
 
16
  - **`/mcp`** → Streamable HTTP MCP endpoint (`supergateway` → `rea mcp`)
17
+ - **`/code/`** → In-browser VS Code Server (opens blank workspace)
18
  - **`/files/`** → [goFiles](https://github.com/G-Aman/goFiles) File Manager & WebDAV server on `/data`
19
  - **`/opencode/`** → [OpenCode Router](https://github.com/G-Aman/opencode-router) WebUI and `/v1` AI proxy
20
  - **`/`** → System dashboard & analysis status
entrypoint.sh CHANGED
@@ -50,54 +50,39 @@ fi
50
  # Migrate Ekko/Hermes-Web-UI SQLite state out of the bucket. Older revisions ran the
51
  # gateway with cwd=/data/workspace while NODE_ENV!=production, which made hermes-web-ui
52
  # write to $CWD/packages/server/data/hermes-web-ui.db (S3 FUSE — never allowed there).
53
- # Take whichever copy is newest, then drop the bucket-side tree. Must run BEFORE the
54
- # workspace cleanup below and BEFORE apps_sync restore.
55
  WS_EKKO_DB="/data/workspace/packages/server/data/hermes-web-ui.db"
56
  LOCAL_EKKO_DB="/home/appuser/.hermes-web-ui/hermes-web-ui.db"
57
- EKKO_DB_MIGRATED=1
58
- mkdir -p /home/appuser/.hermes-web-ui
59
  if [ -f "$WS_EKKO_DB" ]; then
 
 
 
60
  if [ ! -f "$LOCAL_EKKO_DB" ] || [ "$WS_EKKO_DB" -nt "$LOCAL_EKKO_DB" ]; then
61
- if cp -f "$WS_EKKO_DB" "$LOCAL_EKKO_DB" && [ -s "$LOCAL_EKKO_DB" ]; then
62
- echo "📦 Migrated ekko state $WS_EKKO_DB -> $LOCAL_EKKO_DB ($(stat -c%s "$LOCAL_EKKO_DB") bytes)"
63
- else
64
- echo "⚠️ Failed to migrate $WS_EKKO_DB; leaving it in place for manual recovery"
65
- EKKO_DB_MIGRATED=0
66
- fi
67
  fi
68
  fi
 
69
 
70
  # Clean clutter out of user /data/workspace (user files only — no app state, no SQLite)
71
  rm -rf /data/workspace/.claude /data/workspace/.vscode /data/workspace/.opencode \
72
  /data/workspace/config.yaml /data/workspace/hook-secret \
73
  /data/workspace/session-lifecycle.jsonl /data/workspace/state.json* \
74
  /data/workspace/subagent-window-states.json 2>/dev/null || true
75
- if [ "$EKKO_DB_MIGRATED" = "1" ]; then
76
- rm -rf /data/workspace/packages 2>/dev/null || true
77
- fi
78
 
79
  # Migrate legacy /data/config/* into the structured /data/apps/* layout (older revisions
80
- # wrote app config here). Only drop the legacy copy once it is byte-identical to the
81
- # migrated one, so a hand-edited legacy file is never silently discarded.
82
  if [ -d /data/config ]; then
 
83
  for legacy in /data/config/*/; do
84
  [ -d "$legacy" ] || continue
85
  name="$(basename "$legacy")"
86
  mkdir -p "/data/apps/$name"
87
  cp -rn "$legacy". "/data/apps/$name/" 2>/dev/null || true
88
- stale=1
89
- for f in "$legacy"*; do
90
- [ -f "$f" ] || continue
91
- cmp -s "$f" "/data/apps/$name/$(basename "$f")" || stale=0
92
- done
93
- if [ "$stale" = "1" ]; then
94
- echo "🗑️ Removing legacy /data/config/$name (identical to /data/apps/$name)"
95
- rm -rf "$legacy"
96
- else
97
- echo "⚠️ Keeping legacy /data/config/$name — differs from /data/apps/$name, review manually"
98
- fi
99
  done
100
- rmdir /data/config 2>/dev/null || true
101
  fi
102
 
103
  # Legacy code-server user-data location; current user-data is /data/apps/vscode
 
50
  # Migrate Ekko/Hermes-Web-UI SQLite state out of the bucket. Older revisions ran the
51
  # gateway with cwd=/data/workspace while NODE_ENV!=production, which made hermes-web-ui
52
  # write to $CWD/packages/server/data/hermes-web-ui.db (S3 FUSE — never allowed there).
53
+ # Move it into /data/apps/ekko/hermes-web-ui.db for persistent backup and restore into
54
+ # /home/appuser/.hermes-web-ui. Drop the bucket-side workspace/packages entirely.
55
  WS_EKKO_DB="/data/workspace/packages/server/data/hermes-web-ui.db"
56
  LOCAL_EKKO_DB="/home/appuser/.hermes-web-ui/hermes-web-ui.db"
57
+ BACKUP_EKKO_DB="/data/apps/ekko/hermes-web-ui.db"
58
+ mkdir -p /home/appuser/.hermes-web-ui /data/apps/ekko
59
  if [ -f "$WS_EKKO_DB" ]; then
60
+ if [ ! -f "$BACKUP_EKKO_DB" ] || [ "$WS_EKKO_DB" -nt "$BACKUP_EKKO_DB" ]; then
61
+ cp -f "$WS_EKKO_DB" "$BACKUP_EKKO_DB" 2>/dev/null || true
62
+ fi
63
  if [ ! -f "$LOCAL_EKKO_DB" ] || [ "$WS_EKKO_DB" -nt "$LOCAL_EKKO_DB" ]; then
64
+ cp -f "$WS_EKKO_DB" "$LOCAL_EKKO_DB" 2>/dev/null || true
 
 
 
 
 
65
  fi
66
  fi
67
+ rm -rf /data/workspace/packages 2>/dev/null || true
68
 
69
  # Clean clutter out of user /data/workspace (user files only — no app state, no SQLite)
70
  rm -rf /data/workspace/.claude /data/workspace/.vscode /data/workspace/.opencode \
71
  /data/workspace/config.yaml /data/workspace/hook-secret \
72
  /data/workspace/session-lifecycle.jsonl /data/workspace/state.json* \
73
  /data/workspace/subagent-window-states.json 2>/dev/null || true
 
 
 
74
 
75
  # Migrate legacy /data/config/* into the structured /data/apps/* layout (older revisions
76
+ # wrote app config here). Copy any missing files, remove the legacy directory completely.
 
77
  if [ -d /data/config ]; then
78
+ echo "📦 Migrating legacy /data/config to /data/apps..."
79
  for legacy in /data/config/*/; do
80
  [ -d "$legacy" ] || continue
81
  name="$(basename "$legacy")"
82
  mkdir -p "/data/apps/$name"
83
  cp -rn "$legacy". "/data/apps/$name/" 2>/dev/null || true
 
 
 
 
 
 
 
 
 
 
 
84
  done
85
+ rm -rf /data/config 2>/dev/null || true
86
  fi
87
 
88
  # Legacy code-server user-data location; current user-data is /data/apps/vscode
services/05-code-server.sh CHANGED
@@ -1,9 +1,8 @@
1
  #!/bin/bash
2
  # 05-code-server.sh — code-server service on 127.0.0.1:8443
3
  DIR="/data/script/code-server"
4
- WORKSPACE="${CODE_WORKSPACE:-/data/workspace}"
5
  USER_DATA="${CODE_USER_DATA:-/data/apps/vscode}"
6
- mkdir -p "$DIR" "$WORKSPACE" "$USER_DATA/User" "$HOME/.config/Code/User" /tmp/logs /tmp/code-server-cache
7
  LOG="/tmp/logs/code-server.log"
8
 
9
  if [ -f /data/.env ]; then
@@ -44,6 +43,16 @@ cat > "$USER_DATA/User/mcp.json" << 'MCPEOF'
44
  MCPEOF
45
  cp "$USER_DATA/User/mcp.json" "$HOME/.config/Code/User/mcp.json" 2>/dev/null || true
46
 
 
 
 
 
 
 
 
 
 
 
47
  if pgrep -f "code-server.*8443" >/dev/null 2>&1; then
48
  echo "code-server already running"
49
  exit 0
 
1
  #!/bin/bash
2
  # 05-code-server.sh — code-server service on 127.0.0.1:8443
3
  DIR="/data/script/code-server"
 
4
  USER_DATA="${CODE_USER_DATA:-/data/apps/vscode}"
5
+ mkdir -p "$DIR" "$USER_DATA/User" "$HOME/.config/Code/User" /tmp/logs /tmp/code-server-cache
6
  LOG="/tmp/logs/code-server.log"
7
 
8
  if [ -f /data/.env ]; then
 
43
  MCPEOF
44
  cp "$USER_DATA/User/mcp.json" "$HOME/.config/Code/User/mcp.json" 2>/dev/null || true
45
 
46
+ # Force code-server to open blank with no workspace restored
47
+ cat > "$USER_DATA/User/settings.json" << 'SETEOF'
48
+ {
49
+ "workbench.startupEditor": "none",
50
+ "window.restoreWindows": "none"
51
+ }
52
+ SETEOF
53
+ cp "$USER_DATA/User/settings.json" "$HOME/.config/Code/User/settings.json" 2>/dev/null || true
54
+ rm -rf "$USER_DATA/User/workspaceStorage" "$USER_DATA/User/History" "$USER_DATA/Backups" 2>/dev/null || true
55
+
56
  if pgrep -f "code-server.*8443" >/dev/null 2>&1; then
57
  echo "code-server already running"
58
  exit 0
services/28-hermes-agent.sh CHANGED
@@ -22,7 +22,7 @@ export API_SERVER_PORT=8642
22
  export API_SERVER_HOST=127.0.0.1
23
  export GATEWAY_ALLOW_ALL_USERS=true
24
  # Production mode: hermes-web-ui writes its SQLite state to HERMES_WEB_UI_HOME instead of
25
- # $CWD/packages/server/data (the gateway cwd is /data/workspace, i.e. the S3 bucket).
26
  export NODE_ENV=production
27
  export HERMES_WEB_UI_HOME="/home/appuser/.hermes-web-ui"
28
 
@@ -48,7 +48,7 @@ if pgrep -f "hermes gateway run" >/dev/null 2>&1; then
48
  exit 0
49
  fi
50
 
51
- cd /data/workspace || exit 1
52
  while true; do
53
  echo "Starting Hermes Gateway..." >> "$LOG"
54
  hermes gateway run --replace >> "$LOG" 2>&1
 
22
  export API_SERVER_HOST=127.0.0.1
23
  export GATEWAY_ALLOW_ALL_USERS=true
24
  # Production mode: hermes-web-ui writes its SQLite state to HERMES_WEB_UI_HOME instead of
25
+ # $CWD/packages/server/data (the gateway runs from /home/appuser).
26
  export NODE_ENV=production
27
  export HERMES_WEB_UI_HOME="/home/appuser/.hermes-web-ui"
28
 
 
48
  exit 0
49
  fi
50
 
51
+ cd /home/appuser || exit 1
52
  while true; do
53
  echo "Starting Hermes Gateway..." >> "$LOG"
54
  hermes gateway run --replace >> "$LOG" 2>&1