omni-catalyst 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1137 -0
- package/core/bin/core +85 -0
- package/core/bin/omni +21 -0
- package/core/cli/commands/--version.sh +8 -0
- package/core/cli/commands/brain.sh +1549 -0
- package/core/cli/commands/doctor.sh +834 -0
- package/core/cli/commands/env.sh +226 -0
- package/core/cli/commands/init.sh +1266 -0
- package/core/cli/commands/install.sh +759 -0
- package/core/cli/commands/list.sh +397 -0
- package/core/cli/commands/open.sh +71 -0
- package/core/cli/commands/pg.sh +761 -0
- package/core/cli/commands/reinstall.sh +694 -0
- package/core/cli/commands/show.sh +90 -0
- package/core/cli/commands/uninstall.sh +700 -0
- package/core/cli/commands/update.sh +754 -0
- package/core/cli/commands/voice.sh +170 -0
- package/core/cli/core.sh +82 -0
- package/core/cli/omni.sh +634 -0
- package/core/modules/ai.sh +152 -0
- package/core/modules/auto.sh +90 -0
- package/core/modules/db.sh +94 -0
- package/core/modules/deploy.sh +50 -0
- package/core/modules/dev.sh +126 -0
- package/core/modules/editor.sh +101 -0
- package/core/modules/lang.sh +100 -0
- package/core/modules/npm.sh +122 -0
- package/core/modules/shell.sh +312 -0
- package/core/modules/ui.sh +115 -0
- package/core/tools/ai/all.sh +63 -0
- package/core/tools/ai/antigravity-cli/README.md +45 -0
- package/core/tools/ai/antigravity-cli/bin/agy +28 -0
- package/core/tools/ai/antigravity-cli/helper/agy_helper.c +39 -0
- package/core/tools/ai/antigravity-cli/install.sh +469 -0
- package/core/tools/ai/claude-code/README.md +45 -0
- package/core/tools/ai/claude-code/bin/claude +29 -0
- package/core/tools/ai/claude-code/helper/claude_helper.c +42 -0
- package/core/tools/ai/claude-code/install.sh +278 -0
- package/core/tools/ai/codegraph/README.md +43 -0
- package/core/tools/ai/codegraph/bin/codegraph +3 -0
- package/core/tools/ai/codegraph/install.sh +149 -0
- package/core/tools/ai/codex/README.md +44 -0
- package/core/tools/ai/codex/install.sh +104 -0
- package/core/tools/ai/command-code/README.md +62 -0
- package/core/tools/ai/command-code/install.sh +136 -0
- package/core/tools/ai/engram/README.md +44 -0
- package/core/tools/ai/engram/install.sh +127 -0
- package/core/tools/ai/freebuff/README.md +52 -0
- package/core/tools/ai/freebuff/bin/freebuff +28 -0
- package/core/tools/ai/freebuff/helper/freebuff_helper.c +47 -0
- package/core/tools/ai/freebuff/install.sh +301 -0
- package/core/tools/ai/gemini-cli/README.md +46 -0
- package/core/tools/ai/gemini-cli/install.sh +111 -0
- package/core/tools/ai/gentle-ai/README.md +42 -0
- package/core/tools/ai/gentle-ai/install.sh +253 -0
- package/core/tools/ai/gentle-ai/termux-patches.go +256 -0
- package/core/tools/ai/gga/README.md +49 -0
- package/core/tools/ai/gga/install.sh +134 -0
- package/core/tools/ai/hermes-agent/README.md +50 -0
- package/core/tools/ai/hermes-agent/install.sh +80 -0
- package/core/tools/ai/heygen/README.md +24 -0
- package/core/tools/ai/heygen/install.sh +126 -0
- package/core/tools/ai/kilocode-cli/README.md +45 -0
- package/core/tools/ai/kilocode-cli/bin/kilocode +21 -0
- package/core/tools/ai/kilocode-cli/helper/kilocode_helper.c +47 -0
- package/core/tools/ai/kilocode-cli/install.sh +179 -0
- package/core/tools/ai/kimchi-code/README.md +8 -0
- package/core/tools/ai/kimchi-code/install.sh +120 -0
- package/core/tools/ai/kimi-code/README.md +45 -0
- package/core/tools/ai/kimi-code/install.sh +111 -0
- package/core/tools/ai/kiro-cli/README.md +23 -0
- package/core/tools/ai/kiro-cli/install.sh +127 -0
- package/core/tools/ai/mimocode/README.md +43 -0
- package/core/tools/ai/mimocode/bin/mimo +28 -0
- package/core/tools/ai/mimocode/helper/mimocode_helper.c +47 -0
- package/core/tools/ai/mimocode/install.sh +287 -0
- package/core/tools/ai/minimax-cli/README.md +45 -0
- package/core/tools/ai/minimax-cli/install.sh +111 -0
- package/core/tools/ai/mistral-vibe/README.md +46 -0
- package/core/tools/ai/mistral-vibe/install.sh +119 -0
- package/core/tools/ai/odysseus/README.md +35 -0
- package/core/tools/ai/odysseus/install.sh +163 -0
- package/core/tools/ai/ollama/README.md +44 -0
- package/core/tools/ai/ollama/install.sh +78 -0
- package/core/tools/ai/openclaude/README.md +46 -0
- package/core/tools/ai/openclaude/install.sh +110 -0
- package/core/tools/ai/openclaw/README.md +47 -0
- package/core/tools/ai/openclaw/install.sh +112 -0
- package/core/tools/ai/opencode/README.md +51 -0
- package/core/tools/ai/opencode/bin/opencode +28 -0
- package/core/tools/ai/opencode/helper/opencode_helper.c +57 -0
- package/core/tools/ai/opencode/install.sh +290 -0
- package/core/tools/ai/pi/README.md +46 -0
- package/core/tools/ai/pi/install.sh +104 -0
- package/core/tools/ai/qwen-code/README.md +45 -0
- package/core/tools/ai/qwen-code/install.sh +111 -0
- package/core/tools/ai/seedance/README.md +22 -0
- package/core/tools/ai/seedance/install.sh +134 -0
- package/core/tools/ai/veo3/README.md +36 -0
- package/core/tools/ai/veo3/install.sh +151 -0
- package/core/tools/auto/all.sh +57 -0
- package/core/tools/auto/n8n/README.md +47 -0
- package/core/tools/auto/n8n/install.sh +102 -0
- package/core/tools/db/all.sh +60 -0
- package/core/tools/db/mariadb/README.md +43 -0
- package/core/tools/db/mariadb/install.sh +65 -0
- package/core/tools/db/mongodb/README.md +42 -0
- package/core/tools/db/mongodb/install.sh +73 -0
- package/core/tools/db/postgresql/README.md +45 -0
- package/core/tools/db/postgresql/install.sh +65 -0
- package/core/tools/db/sqlite/README.md +44 -0
- package/core/tools/db/sqlite/install.sh +65 -0
- package/core/tools/deploy/all.sh +39 -0
- package/core/tools/deploy/netlify/install.sh +41 -0
- package/core/tools/deploy/railway/install.sh +47 -0
- package/core/tools/deploy/vercel/install.sh +43 -0
- package/core/tools/dev/all.sh +75 -0
- package/core/tools/dev/bat/README.md +44 -0
- package/core/tools/dev/bat/install.sh +82 -0
- package/core/tools/dev/bc/README.md +44 -0
- package/core/tools/dev/bc/install.sh +82 -0
- package/core/tools/dev/cloudflared/README.md +43 -0
- package/core/tools/dev/cloudflared/install.sh +82 -0
- package/core/tools/dev/curl/README.md +43 -0
- package/core/tools/dev/curl/install.sh +82 -0
- package/core/tools/dev/fzf/README.md +44 -0
- package/core/tools/dev/fzf/install.sh +82 -0
- package/core/tools/dev/gh/README.md +43 -0
- package/core/tools/dev/gh/install.sh +82 -0
- package/core/tools/dev/html2text/README.md +44 -0
- package/core/tools/dev/html2text/install.sh +82 -0
- package/core/tools/dev/imagemagick/README.md +44 -0
- package/core/tools/dev/imagemagick/install.sh +82 -0
- package/core/tools/dev/jq/README.md +44 -0
- package/core/tools/dev/jq/install.sh +82 -0
- package/core/tools/dev/lsd/README.md +44 -0
- package/core/tools/dev/lsd/install.sh +82 -0
- package/core/tools/dev/make/README.md +44 -0
- package/core/tools/dev/make/install.sh +82 -0
- package/core/tools/dev/ncurses/README.md +42 -0
- package/core/tools/dev/ncurses/install.sh +82 -0
- package/core/tools/dev/proot/README.md +43 -0
- package/core/tools/dev/proot/install.sh +82 -0
- package/core/tools/dev/shfmt/README.md +44 -0
- package/core/tools/dev/shfmt/install.sh +82 -0
- package/core/tools/dev/tmate/README.md +44 -0
- package/core/tools/dev/tmate/install.sh +82 -0
- package/core/tools/dev/translate/README.md +44 -0
- package/core/tools/dev/translate/install.sh +82 -0
- package/core/tools/dev/tree/README.md +44 -0
- package/core/tools/dev/tree/install.sh +82 -0
- package/core/tools/dev/udocker/README.md +44 -0
- package/core/tools/dev/udocker/install.sh +82 -0
- package/core/tools/dev/wget/README.md +44 -0
- package/core/tools/dev/wget/install.sh +82 -0
- package/core/tools/editor/all.sh +58 -0
- package/core/tools/editor/neovim/README.md +43 -0
- package/core/tools/editor/neovim/install.sh +66 -0
- package/core/tools/editor/nvchad/README.md +45 -0
- package/core/tools/editor/nvchad/install.sh +110 -0
- package/core/tools/lang/all.sh +63 -0
- package/core/tools/lang/clang/README.md +43 -0
- package/core/tools/lang/clang/install.sh +79 -0
- package/core/tools/lang/golang/README.md +43 -0
- package/core/tools/lang/golang/install.sh +79 -0
- package/core/tools/lang/nodejs/README.md +43 -0
- package/core/tools/lang/nodejs/install.sh +79 -0
- package/core/tools/lang/perl/README.md +43 -0
- package/core/tools/lang/perl/install.sh +79 -0
- package/core/tools/lang/php/README.md +43 -0
- package/core/tools/lang/php/install.sh +79 -0
- package/core/tools/lang/python/README.md +43 -0
- package/core/tools/lang/python/install.sh +79 -0
- package/core/tools/lang/rust/README.md +43 -0
- package/core/tools/lang/rust/install.sh +79 -0
- package/core/tools/npm/all.sh +67 -0
- package/core/tools/npm/live-server/README.md +43 -0
- package/core/tools/npm/live-server/install.sh +95 -0
- package/core/tools/npm/localtunnel/README.md +43 -0
- package/core/tools/npm/localtunnel/install.sh +111 -0
- package/core/tools/npm/markserv/README.md +43 -0
- package/core/tools/npm/markserv/install.sh +94 -0
- package/core/tools/npm/ncu/README.md +43 -0
- package/core/tools/npm/ncu/install.sh +94 -0
- package/core/tools/npm/nestjs/README.md +43 -0
- package/core/tools/npm/nestjs/install.sh +94 -0
- package/core/tools/npm/ngrok/README.md +44 -0
- package/core/tools/npm/ngrok/install.sh +94 -0
- package/core/tools/npm/prettier/README.md +43 -0
- package/core/tools/npm/prettier/install.sh +94 -0
- package/core/tools/npm/psqlformat/README.md +43 -0
- package/core/tools/npm/psqlformat/install.sh +94 -0
- package/core/tools/npm/turbopack/README.md +8 -0
- package/core/tools/npm/turbopack/install.sh +41 -0
- package/core/tools/npm/typescript/README.md +43 -0
- package/core/tools/npm/typescript/install.sh +94 -0
- package/core/tools/npm/vercel/README.md +43 -0
- package/core/tools/npm/vercel/install.sh +94 -0
- package/core/tools/shell/all.sh +67 -0
- package/core/tools/shell/better-npm/README.md +43 -0
- package/core/tools/shell/better-npm/install.sh +85 -0
- package/core/tools/shell/fzf-tab/README.md +44 -0
- package/core/tools/shell/fzf-tab/install.sh +85 -0
- package/core/tools/shell/history-substring/README.md +43 -0
- package/core/tools/shell/history-substring/install.sh +85 -0
- package/core/tools/shell/powerlevel10k/README.md +43 -0
- package/core/tools/shell/powerlevel10k/install.sh +85 -0
- package/core/tools/shell/you-should-use/README.md +43 -0
- package/core/tools/shell/you-should-use/install.sh +85 -0
- package/core/tools/shell/zsh-autopair/README.md +44 -0
- package/core/tools/shell/zsh-autopair/install.sh +85 -0
- package/core/tools/shell/zsh-autosuggestions/README.md +43 -0
- package/core/tools/shell/zsh-autosuggestions/install.sh +85 -0
- package/core/tools/shell/zsh-completions/README.md +43 -0
- package/core/tools/shell/zsh-completions/install.sh +85 -0
- package/core/tools/shell/zsh-defer/README.md +43 -0
- package/core/tools/shell/zsh-defer/install.sh +85 -0
- package/core/tools/shell/zsh-syntax-highlighting/README.md +43 -0
- package/core/tools/shell/zsh-syntax-highlighting/install.sh +72 -0
- package/core/tools/ui/all.sh +61 -0
- package/core/tools/ui/banner/README.md +42 -0
- package/core/tools/ui/banner/install.sh +151 -0
- package/core/tools/ui/cursor/README.md +42 -0
- package/core/tools/ui/cursor/install.sh +58 -0
- package/core/tools/ui/extra-keys/README.md +43 -0
- package/core/tools/ui/extra-keys/install.sh +62 -0
- package/core/tools/ui/font/README.md +43 -0
- package/core/tools/ui/font/install.sh +63 -0
- package/core/utils/banner.sh +519 -0
- package/core/utils/bootstrap.sh +25 -0
- package/core/utils/colors.sh +31 -0
- package/core/utils/dialogrc +30 -0
- package/core/utils/env.sh +53 -0
- package/core/utils/log.sh +598 -0
- package/install.sh +272 -0
- package/package.json +43 -0
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
import "@/utils/colors"
|
|
5
|
+
|
|
6
|
+
doctor_main() {
|
|
7
|
+
echo
|
|
8
|
+
box "◈ OMNI DOCTOR ◈"
|
|
9
|
+
echo
|
|
10
|
+
log_info "Diagnosing your Termux and Omni environment..."
|
|
11
|
+
echo
|
|
12
|
+
|
|
13
|
+
local warnings=0
|
|
14
|
+
local errors=0
|
|
15
|
+
local fixed=0
|
|
16
|
+
local -a fix_commands=()
|
|
17
|
+
local -a fix_descriptions=()
|
|
18
|
+
local -a fix_callbacks=()
|
|
19
|
+
|
|
20
|
+
# ===== 1. SYSTEM INFO =====
|
|
21
|
+
local arch
|
|
22
|
+
arch=$(uname -m)
|
|
23
|
+
|
|
24
|
+
local android_ver
|
|
25
|
+
android_ver=$(getprop ro.build.version.release 2>/dev/null)
|
|
26
|
+
android_ver="${android_ver:-Unknown}"
|
|
27
|
+
|
|
28
|
+
local termux_ver=""
|
|
29
|
+
if command -v termux-info &>/dev/null; then
|
|
30
|
+
termux_ver=$(termux-info 2>/dev/null | grep -i "termux_version" | head -n1 | cut -d'=' -f2)
|
|
31
|
+
fi
|
|
32
|
+
if [[ -z "$termux_ver" ]]; then
|
|
33
|
+
termux_ver=$(dpkg -s termux-tools 2>/dev/null | grep -i version | awk '{print $2}')
|
|
34
|
+
fi
|
|
35
|
+
termux_ver="${termux_ver:-Unknown}"
|
|
36
|
+
|
|
37
|
+
log_success "Android Version: $android_ver"
|
|
38
|
+
log_success "Termux Version: $termux_ver"
|
|
39
|
+
log_success "CPU Architecture: $arch"
|
|
40
|
+
|
|
41
|
+
# ===== 2. DISK SPACE & RAM =====
|
|
42
|
+
echo
|
|
43
|
+
separator_section "System Resources"
|
|
44
|
+
echo
|
|
45
|
+
|
|
46
|
+
local free_space
|
|
47
|
+
free_space=$(df -h "$HOME" | awk 'NR==2 {print $4}')
|
|
48
|
+
log_success "Available disk space: $free_space"
|
|
49
|
+
|
|
50
|
+
local ram_total="Unknown"
|
|
51
|
+
local ram_free="Unknown"
|
|
52
|
+
if [[ -f /proc/meminfo ]]; then
|
|
53
|
+
local total_kb free_kb
|
|
54
|
+
total_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
|
55
|
+
ram_total="$((total_kb / 1024)) MB"
|
|
56
|
+
free_kb=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
|
57
|
+
ram_free="$((free_kb / 1024)) MB"
|
|
58
|
+
log_success "RAM: Total: $ram_total | Available: $ram_free"
|
|
59
|
+
|
|
60
|
+
# Warn if low memory
|
|
61
|
+
local free_mb=$((free_kb / 1024))
|
|
62
|
+
if (( free_mb < 200 )); then
|
|
63
|
+
log_warn "Low available memory (${ram_free}). Some tools may fail."
|
|
64
|
+
((warnings++))
|
|
65
|
+
fi
|
|
66
|
+
else
|
|
67
|
+
log_warn "Could not read RAM details"
|
|
68
|
+
((warnings++))
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# ===== 3. STORAGE & PERMISSIONS =====
|
|
72
|
+
echo
|
|
73
|
+
separator_section "Storage & Permissions"
|
|
74
|
+
echo
|
|
75
|
+
|
|
76
|
+
local storage_status="Accessible"
|
|
77
|
+
if ls /sdcard &>/dev/null || [ -d "$HOME/storage" ]; then
|
|
78
|
+
log_success "Shared storage is accessible"
|
|
79
|
+
else
|
|
80
|
+
log_warn "Shared storage is not linked"
|
|
81
|
+
storage_status="Not Linked"
|
|
82
|
+
((warnings++))
|
|
83
|
+
fix_commands+=("termux-setup-storage")
|
|
84
|
+
fix_descriptions+=("Link shared storage for file access")
|
|
85
|
+
fix_callbacks+=("_fix_storage")
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
if [ -w "$OMNI_PATH" ]; then
|
|
89
|
+
log_success "Write permission in Omni path: $OMNI_PATH"
|
|
90
|
+
else
|
|
91
|
+
log_error "No write permission in Omni path!"
|
|
92
|
+
((errors++))
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
local dirs=("$OMNI_CONFIG" "$OMNI_CACHE" "$OMNI_DATA")
|
|
96
|
+
for dir in "${dirs[@]}"; do
|
|
97
|
+
if [ -d "$dir" ] && [ -w "$dir" ]; then
|
|
98
|
+
log_success "Directory OK: $(basename "$dir")"
|
|
99
|
+
else
|
|
100
|
+
log_warn "Directory missing or read-only: $(basename "$dir")"
|
|
101
|
+
((warnings++))
|
|
102
|
+
fix_commands+=("mkdir -p \"$dir\" && chmod 755 \"$dir\"")
|
|
103
|
+
fix_descriptions+=("Recreate directory: $(basename "$dir")")
|
|
104
|
+
fix_callbacks+=("_fix_mkdir")
|
|
105
|
+
fi
|
|
106
|
+
done
|
|
107
|
+
|
|
108
|
+
# ===== 4. LANGUAGES & CRITICAL TOOLS =====
|
|
109
|
+
echo
|
|
110
|
+
separator_section "Languages & Critical Tools"
|
|
111
|
+
echo
|
|
112
|
+
|
|
113
|
+
local -a critical_deps=("git" "rg" "jq" "curl" "tar" "node" "python" "rustc" "go" "clang" "make")
|
|
114
|
+
for dep in "${critical_deps[@]}"; do
|
|
115
|
+
if command -v "$dep" &>/dev/null; then
|
|
116
|
+
local version=""
|
|
117
|
+
case "$dep" in
|
|
118
|
+
git) version=$(git --version | awk '{print $3}') ;;
|
|
119
|
+
node) version=$(node --version) ;;
|
|
120
|
+
python) version=$(python3 --version 2>/dev/null || python --version 2>/dev/null | awk '{print $2}') ;;
|
|
121
|
+
rustc) version=$(rustc --version | awk '{print $2}') ;;
|
|
122
|
+
go) version=$(go version | awk '{print $3}') ;;
|
|
123
|
+
clang) version=$(clang --version | head -1 | awk '{print $3}') ;;
|
|
124
|
+
*) version="installed" ;;
|
|
125
|
+
esac
|
|
126
|
+
log_success "$dep: $version"
|
|
127
|
+
else
|
|
128
|
+
log_warn "$dep is not installed"
|
|
129
|
+
((warnings++))
|
|
130
|
+
local pkg_to_install="$dep"
|
|
131
|
+
[[ "$dep" == "rg" ]] && pkg_to_install="ripgrep"
|
|
132
|
+
[[ "$dep" == "rustc" ]] && pkg_to_install="rust"
|
|
133
|
+
[[ "$dep" == "go" ]] && pkg_to_install="golang"
|
|
134
|
+
[[ "$dep" == "python" ]] && pkg_to_install="python"
|
|
135
|
+
fix_commands+=("pkg install -y $pkg_to_install")
|
|
136
|
+
fix_descriptions+=("Install missing: $pkg_to_install")
|
|
137
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
138
|
+
fi
|
|
139
|
+
done
|
|
140
|
+
|
|
141
|
+
# ===== 5. PACKAGE MANAGER HEALTH =====
|
|
142
|
+
echo
|
|
143
|
+
separator_section "Package Manager & System Health"
|
|
144
|
+
echo
|
|
145
|
+
|
|
146
|
+
if dpkg --audit &>/dev/null; then
|
|
147
|
+
log_success "dpkg package manager is healthy"
|
|
148
|
+
else
|
|
149
|
+
log_error "dpkg has interrupted installations!"
|
|
150
|
+
((errors++))
|
|
151
|
+
fix_commands+=("dpkg --configure -a && apt-get -f install -y")
|
|
152
|
+
fix_descriptions+=("Fix broken dpkg/apt state")
|
|
153
|
+
fix_callbacks+=("_fix_dpkg")
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
# Check for held packages
|
|
157
|
+
local held_pkgs
|
|
158
|
+
held_pkgs=$(dpkg --get-selections 2>/dev/null | grep -c "hold" || true)
|
|
159
|
+
if (( held_pkgs > 0 )); then
|
|
160
|
+
log_warn "$held_pkgs package(s) are held back"
|
|
161
|
+
((warnings++))
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Check apt sources
|
|
165
|
+
if [[ -f "$PREFIX/etc/apt/sources.list" ]]; then
|
|
166
|
+
local source_lines
|
|
167
|
+
source_lines=$(wc -l < "$PREFIX/etc/apt/sources.list")
|
|
168
|
+
if (( source_lines == 0 )); then
|
|
169
|
+
log_error "APT sources list is empty!"
|
|
170
|
+
((errors++))
|
|
171
|
+
fix_commands+=("pkg update -y")
|
|
172
|
+
fix_descriptions+=("Refresh APT sources")
|
|
173
|
+
fix_callbacks+=("_fix_apt_update")
|
|
174
|
+
else
|
|
175
|
+
log_success "APT sources configured ($source_lines entries)"
|
|
176
|
+
fi
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
# ===== 6. NODE.JS / NPM =====
|
|
180
|
+
echo
|
|
181
|
+
separator_section "Node.js & NPM"
|
|
182
|
+
echo
|
|
183
|
+
|
|
184
|
+
if command -v node &>/dev/null; then
|
|
185
|
+
local node_ver
|
|
186
|
+
node_ver=$(node --version)
|
|
187
|
+
log_success "Node.js: $node_ver"
|
|
188
|
+
|
|
189
|
+
if command -v npm &>/dev/null; then
|
|
190
|
+
local npm_ver
|
|
191
|
+
npm_ver=$(npm --version)
|
|
192
|
+
log_success "NPM: $npm_ver"
|
|
193
|
+
|
|
194
|
+
# Check npm global prefix permissions
|
|
195
|
+
local npm_prefix
|
|
196
|
+
npm_prefix=$(npm config get prefix 2>/dev/null)
|
|
197
|
+
if [[ -n "$npm_prefix" ]] && [[ -d "$npm_prefix" ]]; then
|
|
198
|
+
if [[ -w "$npm_prefix" ]]; then
|
|
199
|
+
log_success "NPM global directory is writable"
|
|
200
|
+
else
|
|
201
|
+
log_warn "NPM global directory is not writable: $npm_prefix"
|
|
202
|
+
((warnings++))
|
|
203
|
+
fix_commands+=("mkdir -p \"\$HOME/.npm-global\" && npm config set prefix \"\$HOME/.npm-global\"")
|
|
204
|
+
fix_descriptions+=("Fix NPM global directory permissions")
|
|
205
|
+
fix_callbacks+=("_fix_npm_prefix")
|
|
206
|
+
fi
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
# Check for npm cache bloat
|
|
210
|
+
local npm_cache_size
|
|
211
|
+
npm_cache_size=$(du -sh "$(npm config get cache 2>/dev/null)" 2>/dev/null | awk '{print $1}')
|
|
212
|
+
if [[ -n "$npm_cache_size" ]]; then
|
|
213
|
+
log_info "NPM cache size: $npm_cache_size"
|
|
214
|
+
fi
|
|
215
|
+
else
|
|
216
|
+
log_warn "NPM is not installed"
|
|
217
|
+
((warnings++))
|
|
218
|
+
fix_commands+=("pkg install -y nodejs-lts")
|
|
219
|
+
fix_descriptions+=("Install Node.js with NPM")
|
|
220
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
221
|
+
fi
|
|
222
|
+
else
|
|
223
|
+
log_warn "Node.js is not installed"
|
|
224
|
+
((warnings++))
|
|
225
|
+
fix_commands+=("pkg install -y nodejs-lts")
|
|
226
|
+
fix_descriptions+=("Install Node.js LTS")
|
|
227
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
228
|
+
fi
|
|
229
|
+
|
|
230
|
+
# ===== 7. PYTHON =====
|
|
231
|
+
echo
|
|
232
|
+
separator_section "Python Environment"
|
|
233
|
+
echo
|
|
234
|
+
|
|
235
|
+
local py_cmd=""
|
|
236
|
+
for py in python3.12 python3.11 python3.10 python3.9 python3 python; do
|
|
237
|
+
if command -v "$py" &>/dev/null; then
|
|
238
|
+
py_cmd="$py"
|
|
239
|
+
break
|
|
240
|
+
fi
|
|
241
|
+
done
|
|
242
|
+
|
|
243
|
+
if [[ -n "$py_cmd" ]]; then
|
|
244
|
+
local py_ver
|
|
245
|
+
py_ver=$("$py_cmd" --version 2>&1 | awk '{print $2}')
|
|
246
|
+
log_success "Python: $py_cmd ($py_ver)"
|
|
247
|
+
|
|
248
|
+
# Check pip
|
|
249
|
+
if "$py_cmd" -m pip --version &>/dev/null; then
|
|
250
|
+
local pip_ver
|
|
251
|
+
pip_ver=$("$py_cmd" -m pip --version | awk '{print $2}')
|
|
252
|
+
log_success "Pip: $pip_ver"
|
|
253
|
+
else
|
|
254
|
+
log_warn "Pip is not installed for $py_cmd"
|
|
255
|
+
((warnings++))
|
|
256
|
+
fix_commands+=("$py_cmd -m ensurepip && $py_cmd -m pip install --upgrade pip")
|
|
257
|
+
fix_descriptions+=("Install/upgrade pip for $py_cmd")
|
|
258
|
+
fix_callbacks+=("_fix_pip")
|
|
259
|
+
fi
|
|
260
|
+
|
|
261
|
+
# Check venv module
|
|
262
|
+
if "$py_cmd" -m venv --help &>/dev/null; then
|
|
263
|
+
log_success "Python venv module available"
|
|
264
|
+
else
|
|
265
|
+
log_warn "Python venv module not available"
|
|
266
|
+
((warnings++))
|
|
267
|
+
local venv_pkg="python-venv"
|
|
268
|
+
[[ "$py_cmd" == "python3.11" ]] && venv_pkg="python3.11-venv"
|
|
269
|
+
[[ "$py_cmd" == "python3.10" ]] && venv_pkg="python3.10-venv"
|
|
270
|
+
fix_commands+=("pkg install -y $venv_pkg")
|
|
271
|
+
fix_descriptions+=("Install venv module for $py_cmd")
|
|
272
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
273
|
+
fi
|
|
274
|
+
else
|
|
275
|
+
log_warn "Python is not installed"
|
|
276
|
+
((warnings++))
|
|
277
|
+
fix_commands+=("pkg install -y python")
|
|
278
|
+
fix_descriptions+=("Install Python")
|
|
279
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
280
|
+
fi
|
|
281
|
+
|
|
282
|
+
# ===== 8. POSTGRESQL =====
|
|
283
|
+
echo
|
|
284
|
+
separator_section "PostgreSQL Database"
|
|
285
|
+
echo
|
|
286
|
+
|
|
287
|
+
local pg_installed=false
|
|
288
|
+
if command -v pg_ctl &>/dev/null; then
|
|
289
|
+
pg_installed=true
|
|
290
|
+
local pg_ver
|
|
291
|
+
pg_ver=$(postgres --version 2>/dev/null | awk '{print $3}')
|
|
292
|
+
log_success "PostgreSQL installed: $pg_ver"
|
|
293
|
+
|
|
294
|
+
# Check if data directory exists
|
|
295
|
+
local pg_data_found=false
|
|
296
|
+
local pg_data_dirs=(
|
|
297
|
+
"$PREFIX/var/lib/postgresql/data"
|
|
298
|
+
"$PREFIX/var/lib/postgresql"
|
|
299
|
+
"$HOME/.termux/postgresql/data"
|
|
300
|
+
"$HOME/.termux/postgresql"
|
|
301
|
+
)
|
|
302
|
+
for dir in "${pg_data_dirs[@]}"; do
|
|
303
|
+
if [[ -d "$dir" ]] && [[ -f "$dir/PG_VERSION" ]]; then
|
|
304
|
+
pg_data_found=true
|
|
305
|
+
log_success "Data directory found: $dir"
|
|
306
|
+
break
|
|
307
|
+
fi
|
|
308
|
+
done
|
|
309
|
+
|
|
310
|
+
if [[ "$pg_data_found" == "false" ]]; then
|
|
311
|
+
log_warn "PostgreSQL not initialized (no data directory)"
|
|
312
|
+
((warnings++))
|
|
313
|
+
fix_commands+=("omni pg init && omni pg start")
|
|
314
|
+
fix_descriptions+=("Initialize and start PostgreSQL")
|
|
315
|
+
fix_callbacks+=("_fix_pg_init")
|
|
316
|
+
else
|
|
317
|
+
# Check if running
|
|
318
|
+
if pg_ctl -D "$dir" status &>/dev/null; then
|
|
319
|
+
log_success "PostgreSQL: RUNNING"
|
|
320
|
+
else
|
|
321
|
+
log_warn "PostgreSQL: STOPPED"
|
|
322
|
+
((warnings++))
|
|
323
|
+
fix_commands+=("omni pg start")
|
|
324
|
+
fix_descriptions+=("Start PostgreSQL server")
|
|
325
|
+
fix_callbacks+=("_fix_pg_start")
|
|
326
|
+
fi
|
|
327
|
+
fi
|
|
328
|
+
else
|
|
329
|
+
log_warn "PostgreSQL is not installed"
|
|
330
|
+
((warnings++))
|
|
331
|
+
fix_commands+=("omni install db --postgresql")
|
|
332
|
+
fix_descriptions+=("Install PostgreSQL")
|
|
333
|
+
fix_callbacks+=("_fix_pg_install")
|
|
334
|
+
fi
|
|
335
|
+
|
|
336
|
+
# ===== 9. OMNI FRAMEWORK =====
|
|
337
|
+
echo
|
|
338
|
+
separator_section "Omni Framework"
|
|
339
|
+
echo
|
|
340
|
+
|
|
341
|
+
# Check Omni version
|
|
342
|
+
local omni_ver="unknown"
|
|
343
|
+
if [[ -n "${OMNI_VERSION:-}" ]]; then
|
|
344
|
+
omni_ver="$OMNI_VERSION"
|
|
345
|
+
fi
|
|
346
|
+
log_success "Omni version: $omni_ver"
|
|
347
|
+
|
|
348
|
+
# Check symlinks
|
|
349
|
+
if [[ -L "$PREFIX/bin/core" ]] && [[ -L "$PREFIX/bin/omni" ]]; then
|
|
350
|
+
log_success "CLI symlinks: core, omni"
|
|
351
|
+
else
|
|
352
|
+
log_warn "CLI symlinks missing"
|
|
353
|
+
((warnings++))
|
|
354
|
+
fix_commands+=("ln -sf \"$OMNI_PATH/bin/core\" \"$PREFIX/bin/core\" && ln -sf \"$OMNI_PATH/bin/omni\" \"$PREFIX/bin/omni\"")
|
|
355
|
+
fix_descriptions+=("Recreate CLI symlinks")
|
|
356
|
+
fix_callbacks+=("_fix_symlinks")
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
# Check if banner is installed in shell config
|
|
360
|
+
local shell_config=""
|
|
361
|
+
[[ -f "$HOME/.zshrc" ]] && shell_config="$HOME/.zshrc"
|
|
362
|
+
[[ -f "$HOME/.bashrc" ]] && shell_config="$HOME/.bashrc"
|
|
363
|
+
|
|
364
|
+
if [[ -n "$shell_config" ]]; then
|
|
365
|
+
if grep -qF "# ===== Omni Banner =====" "$shell_config" 2>/dev/null; then
|
|
366
|
+
log_success "Banner installed in $(basename "$shell_config")"
|
|
367
|
+
else
|
|
368
|
+
log_warn "Banner not installed in $(basename "$shell_config")"
|
|
369
|
+
((warnings++))
|
|
370
|
+
fix_commands+=("omni install ui --banner")
|
|
371
|
+
fix_descriptions+=("Install Omni banner in shell")
|
|
372
|
+
fix_callbacks+=("_fix_banner")
|
|
373
|
+
fi
|
|
374
|
+
fi
|
|
375
|
+
|
|
376
|
+
# ===== 10. AI TOOLS STATUS =====
|
|
377
|
+
echo
|
|
378
|
+
separator_section "AI Tools Installed"
|
|
379
|
+
echo
|
|
380
|
+
|
|
381
|
+
local -a ai_cmds=("opencode" "claude" "gemini" "codex" "qwen" "vibe" "mimo" "hermes" "kimi" "ollama" "freebuff" "pi" "agy" "mmx" "gentle-ai" "gga" "engram" "codegraph" "kiro" "kilo" "heygen" "seedance" "veo3" "odysseus" "openclaude" "openclaw" "command-code" "kimchi")
|
|
382
|
+
local ai_count=0
|
|
383
|
+
|
|
384
|
+
for cmd in "${ai_cmds[@]}"; do
|
|
385
|
+
if command -v "$cmd" &>/dev/null; then
|
|
386
|
+
log_success "$cmd: installed"
|
|
387
|
+
((ai_count++))
|
|
388
|
+
fi
|
|
389
|
+
done
|
|
390
|
+
|
|
391
|
+
if (( ai_count == 0 )); then
|
|
392
|
+
log_warn "No AI tools installed"
|
|
393
|
+
((warnings++))
|
|
394
|
+
fix_commands+=("omni install ai")
|
|
395
|
+
fix_descriptions+=("Install all AI tools")
|
|
396
|
+
fix_callbacks+=("_fix_ai_install")
|
|
397
|
+
else
|
|
398
|
+
log_info "$ai_count AI tool(s) installed"
|
|
399
|
+
fi
|
|
400
|
+
|
|
401
|
+
# ===== 11. SHELL CONFIGURATION =====
|
|
402
|
+
echo
|
|
403
|
+
separator_section "Shell Configuration"
|
|
404
|
+
echo
|
|
405
|
+
|
|
406
|
+
if [[ -f "$HOME/.zshrc" ]]; then
|
|
407
|
+
log_success "ZSH config: .zshrc exists"
|
|
408
|
+
|
|
409
|
+
# Check for syntax errors
|
|
410
|
+
if zsh -n "$HOME/.zshrc" 2>/dev/null; then
|
|
411
|
+
log_success ".zshrc syntax: OK"
|
|
412
|
+
else
|
|
413
|
+
log_error ".zshrc has syntax errors!"
|
|
414
|
+
((errors++))
|
|
415
|
+
fix_commands+=("cp \"$HOME/.zshrc\" \"$HOME/.zshrc.bak\" && omni install shell")
|
|
416
|
+
fix_descriptions+=("Backup and reinstall shell config")
|
|
417
|
+
fix_callbacks+=("_fix_shell_syntax")
|
|
418
|
+
fi
|
|
419
|
+
elif [[ -f "$HOME/.bashrc" ]]; then
|
|
420
|
+
log_success "Bash config: .bashrc exists"
|
|
421
|
+
else
|
|
422
|
+
log_warn "No shell config found"
|
|
423
|
+
((warnings++))
|
|
424
|
+
fi
|
|
425
|
+
|
|
426
|
+
# ===== 12. PHANTOM PROCESS KILLER =====
|
|
427
|
+
echo
|
|
428
|
+
separator_section "Android Compatibility"
|
|
429
|
+
echo
|
|
430
|
+
|
|
431
|
+
if [[ "$android_ver" =~ ^(12|13|14|15|16) ]]; then
|
|
432
|
+
log_warn "Android $android_ver: Phantom Process Killer may kill Termux processes"
|
|
433
|
+
log_info "Fix: Run via ADB:"
|
|
434
|
+
list_item "adb shell device_config put activity_manager max_phantom_processes 2147483647"
|
|
435
|
+
((warnings++))
|
|
436
|
+
else
|
|
437
|
+
log_success "No phantom killer warnings apply"
|
|
438
|
+
fi
|
|
439
|
+
|
|
440
|
+
# ===== 13. TERMUX:API =====
|
|
441
|
+
echo
|
|
442
|
+
separator_section "Termux:API"
|
|
443
|
+
echo
|
|
444
|
+
|
|
445
|
+
if command -v termux-info &>/dev/null; then
|
|
446
|
+
log_success "Termux:API is installed"
|
|
447
|
+
else
|
|
448
|
+
log_warn "Termux:API not installed (needed for voice commands)"
|
|
449
|
+
((warnings++))
|
|
450
|
+
fix_commands+=("pkg install -y termux-api")
|
|
451
|
+
fix_descriptions+=("Install Termux:API for voice features")
|
|
452
|
+
fix_callbacks+=("_fix_pkg_install")
|
|
453
|
+
fi
|
|
454
|
+
|
|
455
|
+
# ===== 14. GIT CONFIGURATION =====
|
|
456
|
+
echo
|
|
457
|
+
separator_section "Git Configuration"
|
|
458
|
+
echo
|
|
459
|
+
|
|
460
|
+
if command -v git &>/dev/null; then
|
|
461
|
+
local git_user git_email
|
|
462
|
+
git_user=$(git config --global user.name 2>/dev/null)
|
|
463
|
+
git_email=$(git config --global user.email 2>/dev/null)
|
|
464
|
+
if [[ -n "$git_user" ]] && [[ -n "$git_email" ]]; then
|
|
465
|
+
log_success "Git user: $git_user <$git_email>"
|
|
466
|
+
else
|
|
467
|
+
log_warn "Git user.name or user.email not configured"
|
|
468
|
+
((warnings++))
|
|
469
|
+
fi
|
|
470
|
+
fi
|
|
471
|
+
|
|
472
|
+
# ===== 15. SSH KEYS =====
|
|
473
|
+
echo
|
|
474
|
+
separator_section "SSH Keys"
|
|
475
|
+
echo
|
|
476
|
+
|
|
477
|
+
if [[ -f "$HOME/.ssh/id_ed25519" ]] || [[ -f "$HOME/.ssh/id_rsa" ]]; then
|
|
478
|
+
log_success "SSH key found"
|
|
479
|
+
else
|
|
480
|
+
log_warn "No SSH key found (needed for GitHub)"
|
|
481
|
+
((warnings++))
|
|
482
|
+
fix_commands+=("ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ''")
|
|
483
|
+
fix_descriptions+=("Generate SSH key for GitHub")
|
|
484
|
+
fix_callbacks+=("_fix_ssh_key")
|
|
485
|
+
fi
|
|
486
|
+
|
|
487
|
+
# ===== 16. NETWORK CONNECTIVITY =====
|
|
488
|
+
echo
|
|
489
|
+
separator_section "Network"
|
|
490
|
+
echo
|
|
491
|
+
|
|
492
|
+
if curl -fsSL --max-time 5 https://github.com &>/dev/null; then
|
|
493
|
+
log_success "Network connectivity: OK"
|
|
494
|
+
else
|
|
495
|
+
log_warn "Network connectivity issue detected"
|
|
496
|
+
((warnings++))
|
|
497
|
+
fi
|
|
498
|
+
|
|
499
|
+
# ===== 17. OPENSSH =====
|
|
500
|
+
if command -v sshd &>/dev/null; then
|
|
501
|
+
log_success "OpenSSH server available"
|
|
502
|
+
else
|
|
503
|
+
log_info "OpenSSH server not installed (optional)"
|
|
504
|
+
fi
|
|
505
|
+
|
|
506
|
+
# ===== 18. DISK SPACE CHECK =====
|
|
507
|
+
echo
|
|
508
|
+
separator_section "Disk Health"
|
|
509
|
+
echo
|
|
510
|
+
|
|
511
|
+
local free_space_kb
|
|
512
|
+
free_space_kb=$(df "$HOME" | awk 'NR==2 {print $4}')
|
|
513
|
+
if [[ -n "$free_space_kb" ]]; then
|
|
514
|
+
local free_mb=$((free_space_kb / 1024))
|
|
515
|
+
if (( free_mb < 500 )); then
|
|
516
|
+
log_warn "Low disk space: ${free_mb}MB free. Consider cleaning cache."
|
|
517
|
+
((warnings++))
|
|
518
|
+
fix_commands+=("rm -rf ~/.cache/omni/install_*.log 2>/dev/null; pkg clean -y 2>/dev/null")
|
|
519
|
+
fix_descriptions+=("Clean cache and unused packages")
|
|
520
|
+
fix_callbacks+=("_fix_disk_cleanup")
|
|
521
|
+
else
|
|
522
|
+
log_success "Disk space: OK (${free_mb}MB free)"
|
|
523
|
+
fi
|
|
524
|
+
fi
|
|
525
|
+
|
|
526
|
+
# ===== 19. OMNI DATA DIRS =====
|
|
527
|
+
echo
|
|
528
|
+
separator_section "Omni Data Integrity"
|
|
529
|
+
echo
|
|
530
|
+
|
|
531
|
+
local omni_dirs=("$OMNI_CONFIG" "$OMNI_CACHE" "$OMNI_DATA" "$HOME/.local/share/omni-data")
|
|
532
|
+
for dir in "${omni_dirs[@]}"; do
|
|
533
|
+
if [[ -d "$dir" ]]; then
|
|
534
|
+
local size
|
|
535
|
+
size=$(du -sh "$dir" 2>/dev/null | awk '{print $1}')
|
|
536
|
+
log_success "$(basename "$dir"): ${size:-0}"
|
|
537
|
+
else
|
|
538
|
+
log_warn "Missing: $(basename "$dir")"
|
|
539
|
+
((warnings++))
|
|
540
|
+
fix_commands+=("mkdir -p \"$dir\"")
|
|
541
|
+
fix_descriptions+=("Create missing dir: $(basename "$dir")")
|
|
542
|
+
fix_callbacks+=("_fix_mkdir_single")
|
|
543
|
+
fi
|
|
544
|
+
done
|
|
545
|
+
|
|
546
|
+
# ===== 20. GENERATE REPORT =====
|
|
547
|
+
local report_dir="$OMNI_DATA/doctor_reports"
|
|
548
|
+
mkdir -p "$report_dir"
|
|
549
|
+
local report_file="$report_dir/doctor_report_latest.md"
|
|
550
|
+
|
|
551
|
+
cat >"$report_file" <<EOF
|
|
552
|
+
# Omni Doctor Diagnostic Report
|
|
553
|
+
Generated: $(date)
|
|
554
|
+
|
|
555
|
+
## System Info
|
|
556
|
+
- **Android**: $android_ver
|
|
557
|
+
- **Termux**: $termux_ver
|
|
558
|
+
- **Architecture**: $arch
|
|
559
|
+
- **Omni Version**: $omni_ver
|
|
560
|
+
|
|
561
|
+
## Resources
|
|
562
|
+
- **Disk Free**: $free_space
|
|
563
|
+
- **RAM Total**: $ram_total
|
|
564
|
+
- **RAM Free**: $ram_free
|
|
565
|
+
|
|
566
|
+
## Storage & Permissions
|
|
567
|
+
- **Shared Storage**: $storage_status
|
|
568
|
+
- **Omni Write Access**: $([ -w "$OMNI_PATH" ] && echo "Yes" || echo "No")
|
|
569
|
+
|
|
570
|
+
## PostgreSQL
|
|
571
|
+
- **Installed**: $pg_installed
|
|
572
|
+
- **Data Found**: ${pg_data_found:-unknown}
|
|
573
|
+
|
|
574
|
+
## AI Tools
|
|
575
|
+
- **Count**: $ai_count
|
|
576
|
+
|
|
577
|
+
## Summary
|
|
578
|
+
- **Errors**: $errors
|
|
579
|
+
- **Warnings**: $warnings
|
|
580
|
+
- **Fixed**: $fixed
|
|
581
|
+
EOF
|
|
582
|
+
|
|
583
|
+
# ===== RESULTS =====
|
|
584
|
+
echo
|
|
585
|
+
separator
|
|
586
|
+
log_success "Diagnostics completed!"
|
|
587
|
+
list_item "Report saved: ${D_CYAN}$report_file${D_NC}"
|
|
588
|
+
|
|
589
|
+
if [[ $errors -gt 0 ]]; then
|
|
590
|
+
log_error "Found $errors error(s) and $warnings warning(s)."
|
|
591
|
+
elif [[ $warnings -gt 0 ]]; then
|
|
592
|
+
log_warn "Found $warnings warning(s). System is functional but can be optimized."
|
|
593
|
+
else
|
|
594
|
+
log_success "All systems healthy!"
|
|
595
|
+
fi
|
|
596
|
+
|
|
597
|
+
# ===== AUTO-FIX =====
|
|
598
|
+
if [[ ${#fix_commands[@]} -gt 0 ]]; then
|
|
599
|
+
echo
|
|
600
|
+
separator_section "Auto-Fix Options"
|
|
601
|
+
echo
|
|
602
|
+
log_info "Detected $(( ${#fix_commands[@]} )) issue(s) that can be automatically fixed:"
|
|
603
|
+
echo
|
|
604
|
+
for ((i=0; i<${#fix_commands[@]}; i++)); do
|
|
605
|
+
printf " ${D_YELLOW}%2d.${D_NC} %s\n" $((i + 1)) "${fix_descriptions[$i]}"
|
|
606
|
+
done
|
|
607
|
+
echo
|
|
608
|
+
|
|
609
|
+
local confirm
|
|
610
|
+
read_confirm "Apply all auto-corrections?" confirm
|
|
611
|
+
if [[ "$confirm" == "y" ]]; then
|
|
612
|
+
echo
|
|
613
|
+
for ((i=0; i<${#fix_commands[@]}; i++)); do
|
|
614
|
+
log_info "Fixing: ${fix_descriptions[$i]}..."
|
|
615
|
+
local callback="${fix_callbacks[$i]:-}"
|
|
616
|
+
local success=false
|
|
617
|
+
|
|
618
|
+
if [[ -n "$callback" ]] && type "$callback" &>/dev/null 2>&1; then
|
|
619
|
+
"$callback" && success=true
|
|
620
|
+
elif [[ -n "${fix_commands[$i]}" ]]; then
|
|
621
|
+
eval "${fix_commands[$i]}" 2>/dev/null && success=true
|
|
622
|
+
fi
|
|
623
|
+
|
|
624
|
+
if [[ "$success" == "true" ]]; then
|
|
625
|
+
((fixed++))
|
|
626
|
+
log_success "Fixed: ${fix_descriptions[$i]}"
|
|
627
|
+
else
|
|
628
|
+
log_warn "Could not fix: ${fix_descriptions[$i]}"
|
|
629
|
+
fi
|
|
630
|
+
done
|
|
631
|
+
echo
|
|
632
|
+
if (( fixed > 0 )); then
|
|
633
|
+
log_success "Fixed $fixed issue(s)! Run 'omni doctor' again to verify."
|
|
634
|
+
else
|
|
635
|
+
log_warn "Some fixes could not be applied. Check errors above."
|
|
636
|
+
fi
|
|
637
|
+
fi
|
|
638
|
+
fi
|
|
639
|
+
echo
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
# ===== FIX CALLBACK FUNCTIONS =====
|
|
643
|
+
|
|
644
|
+
_fix_storage() {
|
|
645
|
+
termux-setup-storage 2>/dev/null
|
|
646
|
+
return $?
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
_fix_mkdir() {
|
|
650
|
+
for dir in "${dirs[@]}"; do
|
|
651
|
+
mkdir -p "$dir" 2>/dev/null
|
|
652
|
+
chmod 755 "$dir" 2>/dev/null
|
|
653
|
+
done
|
|
654
|
+
return 0
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
_fix_pkg_install() {
|
|
658
|
+
local pkg_to_install=""
|
|
659
|
+
case "$1" in
|
|
660
|
+
pkg) pkg_to_install="$2" ;;
|
|
661
|
+
*) pkg_to_install="${fix_commands[$i]}" ;;
|
|
662
|
+
esac
|
|
663
|
+
local pkg_name=""
|
|
664
|
+
if [[ "$pkg_to_install" =~ pkg\ install\ -y\ (.+) ]]; then
|
|
665
|
+
pkg_name="${BASH_REMATCH[1]}"
|
|
666
|
+
fi
|
|
667
|
+
if [[ -n "$pkg_name" ]]; then
|
|
668
|
+
pkg install -y "$pkg_name" 2>/dev/null
|
|
669
|
+
return $?
|
|
670
|
+
fi
|
|
671
|
+
return 1
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
_fix_dpkg() {
|
|
675
|
+
dpkg --configure -a 2>/dev/null
|
|
676
|
+
apt-get -f install -y 2>/dev/null
|
|
677
|
+
return $?
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
_fix_apt_update() {
|
|
681
|
+
pkg update -y 2>/dev/null
|
|
682
|
+
return $?
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
_fix_npm_prefix() {
|
|
686
|
+
mkdir -p "$HOME/.npm-global"
|
|
687
|
+
npm config set prefix "$HOME/.npm-global" 2>/dev/null
|
|
688
|
+
return $?
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
_fix_pip() {
|
|
692
|
+
local py_cmd=""
|
|
693
|
+
for py in python3.12 python3.11 python3.10 python3.9 python3 python; do
|
|
694
|
+
if command -v "$py" &>/dev/null; then py_cmd="$py"; break; fi
|
|
695
|
+
done
|
|
696
|
+
if [[ -n "$py_cmd" ]]; then
|
|
697
|
+
"$py_cmd" -m ensurepip 2>/dev/null
|
|
698
|
+
"$py_cmd" -m pip install --upgrade pip 2>/dev/null
|
|
699
|
+
return $?
|
|
700
|
+
fi
|
|
701
|
+
return 1
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
_fix_pg_init() {
|
|
705
|
+
source "$OMNI_PATH/utils/env.sh" 2>/dev/null
|
|
706
|
+
import "@/modules/db" 2>/dev/null
|
|
707
|
+
if type pg_init &>/dev/null; then
|
|
708
|
+
pg_init 2>/dev/null
|
|
709
|
+
pg_start 2>/dev/null
|
|
710
|
+
return $?
|
|
711
|
+
fi
|
|
712
|
+
local pg_data="$HOME/.local/share/postgresql/data"
|
|
713
|
+
mkdir -p "$pg_data" 2>/dev/null
|
|
714
|
+
if command -v initdb &>/dev/null; then
|
|
715
|
+
initdb -D "$pg_data" 2>/dev/null
|
|
716
|
+
pg_ctl -D "$pg_data" -l "$HOME/.cache/omni/postgresql.log" start 2>/dev/null
|
|
717
|
+
return $?
|
|
718
|
+
fi
|
|
719
|
+
return 1
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
_fix_pg_start() {
|
|
723
|
+
local pg_data=""
|
|
724
|
+
for dir in "$PREFIX/var/lib/postgresql/data" "$PREFIX/var/lib/postgresql" "$HOME/.termux/postgresql/data" "$HOME/.termux/postgresql" "$HOME/.local/share/postgresql/data"; do
|
|
725
|
+
if [[ -d "$dir" ]] && [[ -f "$dir/PG_VERSION" ]]; then
|
|
726
|
+
pg_data="$dir"
|
|
727
|
+
break
|
|
728
|
+
fi
|
|
729
|
+
done
|
|
730
|
+
if [[ -n "$pg_data" ]] && command -v pg_ctl &>/dev/null; then
|
|
731
|
+
pg_ctl -D "$pg_data" -l "$HOME/.cache/omni/postgresql.log" start 2>/dev/null
|
|
732
|
+
return $?
|
|
733
|
+
fi
|
|
734
|
+
return 1
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
_fix_pg_install() {
|
|
738
|
+
source "$OMNI_PATH/utils/env.sh" 2>/dev/null
|
|
739
|
+
import "@/modules/db" 2>/dev/null
|
|
740
|
+
if type install_db &>/dev/null; then
|
|
741
|
+
install_db 2>/dev/null
|
|
742
|
+
return $?
|
|
743
|
+
fi
|
|
744
|
+
pkg install -y postgresql 2>/dev/null
|
|
745
|
+
return $?
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
_fix_symlinks() {
|
|
749
|
+
ln -sf "$OMNI_PATH/bin/core" "$PREFIX/bin/core" 2>/dev/null
|
|
750
|
+
ln -sf "$OMNI_PATH/bin/omni" "$PREFIX/bin/omni" 2>/dev/null
|
|
751
|
+
[[ -L "$PREFIX/bin/core" ]] && [[ -L "$PREFIX/bin/omni" ]]
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
_fix_banner() {
|
|
755
|
+
local shell_config=""
|
|
756
|
+
[[ -f "$HOME/.zshrc" ]] && shell_config="$HOME/.zshrc"
|
|
757
|
+
[[ -f "$HOME/.bashrc" ]] && shell_config="$HOME/.bashrc"
|
|
758
|
+
if [[ -z "$shell_config" ]]; then
|
|
759
|
+
shell_config="$HOME/.zshrc"
|
|
760
|
+
touch "$shell_config"
|
|
761
|
+
fi
|
|
762
|
+
local marker="# ===== Omni Banner ====="
|
|
763
|
+
if ! grep -qF "$marker" "$shell_config" 2>/dev/null; then
|
|
764
|
+
cat >>"$shell_config" <<EOF
|
|
765
|
+
|
|
766
|
+
$marker
|
|
767
|
+
source "$OMNI_UTILS/banner.sh"
|
|
768
|
+
EOF
|
|
769
|
+
return 0
|
|
770
|
+
fi
|
|
771
|
+
return 0
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
_fix_ai_install() {
|
|
775
|
+
log_info "Installing AI tools (this may take a while)..."
|
|
776
|
+
source "$OMNI_PATH/utils/env.sh" 2>/dev/null
|
|
777
|
+
import "@/modules/ai" 2>/dev/null
|
|
778
|
+
if type install_ai &>/dev/null; then
|
|
779
|
+
install_ai 2>/dev/null
|
|
780
|
+
return $?
|
|
781
|
+
fi
|
|
782
|
+
return 1
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
_fix_shell_syntax() {
|
|
786
|
+
local config=""
|
|
787
|
+
[[ -f "$HOME/.zshrc" ]] && config="$HOME/.zshrc"
|
|
788
|
+
[[ -f "$HOME/.bashrc" ]] && config="$HOME/.bashrc"
|
|
789
|
+
if [[ -n "$config" ]]; then
|
|
790
|
+
cp "$config" "${config}.bak" 2>/dev/null
|
|
791
|
+
local marker="# ===== Omni Banner ====="
|
|
792
|
+
local banner_block=""
|
|
793
|
+
if grep -qF "$marker" "$config" 2>/dev/null; then
|
|
794
|
+
local marker_line
|
|
795
|
+
marker_line=$(grep -nF "$marker" "$config" | head -1 | cut -d: -f1)
|
|
796
|
+
if [[ -n "$marker_line" ]]; then
|
|
797
|
+
banner_block=$(sed -n "$((marker_line - 1)),\$p" "$config" 2>/dev/null)
|
|
798
|
+
fi
|
|
799
|
+
fi
|
|
800
|
+
local tmpconfig
|
|
801
|
+
tmpconfig=$(mktemp)
|
|
802
|
+
sed '/^source.*\/dev\/null$/d; /^#.*syntax error/d' "$config" > "$tmpconfig" 2>/dev/null
|
|
803
|
+
if [[ -n "$banner_block" ]]; then
|
|
804
|
+
echo "" >> "$tmpconfig"
|
|
805
|
+
echo "$banner_block" >> "$tmpconfig"
|
|
806
|
+
fi
|
|
807
|
+
cp "$tmpconfig" "$config" 2>/dev/null
|
|
808
|
+
rm -f "$tmpconfig"
|
|
809
|
+
return 0
|
|
810
|
+
fi
|
|
811
|
+
return 1
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
_fix_ssh_key() {
|
|
815
|
+
mkdir -p "$HOME/.ssh"
|
|
816
|
+
chmod 700 "$HOME/.ssh"
|
|
817
|
+
ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -N '' 2>/dev/null
|
|
818
|
+
return $?
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
_fix_disk_cleanup() {
|
|
822
|
+
rm -rf ~/.cache/omni/install_*.log 2>/dev/null
|
|
823
|
+
if command -v pkg &>/dev/null; then
|
|
824
|
+
pkg clean -y 2>/dev/null
|
|
825
|
+
fi
|
|
826
|
+
return $?
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
_fix_mkdir_single() {
|
|
830
|
+
for dir in "${omni_dirs[@]}"; do
|
|
831
|
+
[[ -d "$dir" ]] || mkdir -p "$dir" 2>/dev/null
|
|
832
|
+
done
|
|
833
|
+
return 0
|
|
834
|
+
}
|