karnel-termux 0.0.1
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 +454 -0
- package/install.sh +272 -0
- package/karnel/bin/karnel +77 -0
- package/karnel/cli/commands/brain.sh +1553 -0
- package/karnel/cli/commands/cleanup.sh +66 -0
- package/karnel/cli/commands/doctor.sh +1528 -0
- package/karnel/cli/commands/env.sh +233 -0
- package/karnel/cli/commands/help.sh +8 -0
- package/karnel/cli/commands/ia.sh +502 -0
- package/karnel/cli/commands/init.sh +1274 -0
- package/karnel/cli/commands/install.sh +718 -0
- package/karnel/cli/commands/list.sh +399 -0
- package/karnel/cli/commands/open.sh +106 -0
- package/karnel/cli/commands/pg.sh +719 -0
- package/karnel/cli/commands/reinstall.sh +663 -0
- package/karnel/cli/commands/show.sh +90 -0
- package/karnel/cli/commands/start.sh +54 -0
- package/karnel/cli/commands/status.sh +96 -0
- package/karnel/cli/commands/uninstall.sh +668 -0
- package/karnel/cli/commands/update.sh +723 -0
- package/karnel/cli/commands/upgrade.sh +40 -0
- package/karnel/cli/commands/version.sh +3 -0
- package/karnel/cli/commands/voice.sh +230 -0
- package/karnel/cli/karnel.sh +706 -0
- package/karnel/modules/ai.sh +135 -0
- package/karnel/modules/auto.sh +114 -0
- package/karnel/modules/db.sh +132 -0
- package/karnel/modules/deploy.sh +74 -0
- package/karnel/modules/dev.sh +148 -0
- package/karnel/modules/editor.sh +115 -0
- package/karnel/modules/lang.sh +124 -0
- package/karnel/modules/npm.sh +146 -0
- package/karnel/modules/shell.sh +338 -0
- package/karnel/modules/ui.sh +139 -0
- package/karnel/modules/voice.sh +118 -0
- package/karnel/tools/ai/all.sh +209 -0
- package/karnel/tools/ai/antigravity-cli/README.md +45 -0
- package/karnel/tools/ai/antigravity-cli/bin/agy +28 -0
- package/karnel/tools/ai/antigravity-cli/helper/agy_helper.c +39 -0
- package/karnel/tools/ai/antigravity-cli/install.sh +469 -0
- package/karnel/tools/ai/claude-code/README.md +45 -0
- package/karnel/tools/ai/claude-code/bin/claude +29 -0
- package/karnel/tools/ai/claude-code/helper/claude_helper.c +42 -0
- package/karnel/tools/ai/claude-code/install.sh +278 -0
- package/karnel/tools/ai/cline/install.sh +160 -0
- package/karnel/tools/ai/codegraph/README.md +43 -0
- package/karnel/tools/ai/codegraph/bin/codegraph +5 -0
- package/karnel/tools/ai/codegraph/install.sh +160 -0
- package/karnel/tools/ai/codex/README.md +44 -0
- package/karnel/tools/ai/codex/install.sh +104 -0
- package/karnel/tools/ai/command-code/README.md +62 -0
- package/karnel/tools/ai/command-code/install.sh +136 -0
- package/karnel/tools/ai/crush/README.md +17 -0
- package/karnel/tools/ai/crush/install.sh +89 -0
- package/karnel/tools/ai/ctx7/README.md +26 -0
- package/karnel/tools/ai/ctx7/install.sh +61 -0
- package/karnel/tools/ai/engram/README.md +44 -0
- package/karnel/tools/ai/engram/install.sh +127 -0
- package/karnel/tools/ai/freebuff/README.md +52 -0
- package/karnel/tools/ai/freebuff/bin/freebuff +28 -0
- package/karnel/tools/ai/freebuff/helper/freebuff_helper.c +47 -0
- package/karnel/tools/ai/freebuff/install.sh +303 -0
- package/karnel/tools/ai/gemini-cli/README.md +46 -0
- package/karnel/tools/ai/gemini-cli/install.sh +111 -0
- package/karnel/tools/ai/gentle-ai/README.md +42 -0
- package/karnel/tools/ai/gentle-ai/install.sh +253 -0
- package/karnel/tools/ai/gentle-ai/termux-patches.go +256 -0
- package/karnel/tools/ai/gga/README.md +49 -0
- package/karnel/tools/ai/gga/install.sh +134 -0
- package/karnel/tools/ai/hermes-agent/README.md +50 -0
- package/karnel/tools/ai/hermes-agent/install.sh +120 -0
- package/karnel/tools/ai/kilocode-cli/README.md +45 -0
- package/karnel/tools/ai/kilocode-cli/bin/kilocode +21 -0
- package/karnel/tools/ai/kilocode-cli/helper/kilocode_helper.c +47 -0
- package/karnel/tools/ai/kilocode-cli/install.sh +179 -0
- package/karnel/tools/ai/kimchi-code/README.md +53 -0
- package/karnel/tools/ai/kimchi-code/install.sh +221 -0
- package/karnel/tools/ai/kimi-code/README.md +45 -0
- package/karnel/tools/ai/kimi-code/install.sh +111 -0
- package/karnel/tools/ai/kiro/README.md +17 -0
- package/karnel/tools/ai/kiro/install.sh +134 -0
- package/karnel/tools/ai/mimocode/README.md +43 -0
- package/karnel/tools/ai/mimocode/bin/mimo +28 -0
- package/karnel/tools/ai/mimocode/helper/mimocode_helper.c +47 -0
- package/karnel/tools/ai/mimocode/install.sh +287 -0
- package/karnel/tools/ai/minimax-cli/README.md +45 -0
- package/karnel/tools/ai/minimax-cli/install.sh +111 -0
- package/karnel/tools/ai/mistral-vibe/README.md +46 -0
- package/karnel/tools/ai/mistral-vibe/install.sh +119 -0
- package/karnel/tools/ai/odysseus/README.md +35 -0
- package/karnel/tools/ai/odysseus/install.sh +198 -0
- package/karnel/tools/ai/ollama/README.md +44 -0
- package/karnel/tools/ai/ollama/install.sh +78 -0
- package/karnel/tools/ai/omni-route/README.md +111 -0
- package/karnel/tools/ai/omni-route/install.sh +165 -0
- package/karnel/tools/ai/openclaude/README.md +46 -0
- package/karnel/tools/ai/openclaude/install.sh +110 -0
- package/karnel/tools/ai/openclaw/README.md +47 -0
- package/karnel/tools/ai/openclaw/install.sh +112 -0
- package/karnel/tools/ai/opencode/README.md +51 -0
- package/karnel/tools/ai/opencode/bin/opencode +28 -0
- package/karnel/tools/ai/opencode/helper/opencode_helper.c +57 -0
- package/karnel/tools/ai/opencode/install.sh +290 -0
- package/karnel/tools/ai/openspec/README.md +34 -0
- package/karnel/tools/ai/openspec/install.sh +61 -0
- package/karnel/tools/ai/pi/README.md +46 -0
- package/karnel/tools/ai/pi/install.sh +104 -0
- package/karnel/tools/ai/qwen-code/README.md +45 -0
- package/karnel/tools/ai/qwen-code/install.sh +111 -0
- package/karnel/tools/auto/all.sh +57 -0
- package/karnel/tools/auto/n8n/README.md +47 -0
- package/karnel/tools/auto/n8n/install.sh +102 -0
- package/karnel/tools/db/all.sh +61 -0
- package/karnel/tools/db/mariadb/README.md +43 -0
- package/karnel/tools/db/mariadb/install.sh +65 -0
- package/karnel/tools/db/mongodb/README.md +42 -0
- package/karnel/tools/db/mongodb/install.sh +73 -0
- package/karnel/tools/db/postgresql/README.md +45 -0
- package/karnel/tools/db/postgresql/install.sh +65 -0
- package/karnel/tools/db/redis/README.md +46 -0
- package/karnel/tools/db/redis/install.sh +64 -0
- package/karnel/tools/db/sqlite/README.md +44 -0
- package/karnel/tools/db/sqlite/install.sh +65 -0
- package/karnel/tools/deploy/all.sh +43 -0
- package/karnel/tools/deploy/netlify/install.sh +41 -0
- package/karnel/tools/deploy/railway/install.sh +109 -0
- package/karnel/tools/deploy/vercel/install.sh +43 -0
- package/karnel/tools/dev/all.sh +77 -0
- package/karnel/tools/dev/bat/README.md +44 -0
- package/karnel/tools/dev/bat/install.sh +82 -0
- package/karnel/tools/dev/bc/README.md +44 -0
- package/karnel/tools/dev/bc/install.sh +82 -0
- package/karnel/tools/dev/cloudflared/README.md +43 -0
- package/karnel/tools/dev/cloudflared/install.sh +82 -0
- package/karnel/tools/dev/curl/README.md +43 -0
- package/karnel/tools/dev/curl/install.sh +82 -0
- package/karnel/tools/dev/fzf/README.md +44 -0
- package/karnel/tools/dev/fzf/install.sh +82 -0
- package/karnel/tools/dev/gh/README.md +43 -0
- package/karnel/tools/dev/gh/install.sh +82 -0
- package/karnel/tools/dev/html2text/README.md +44 -0
- package/karnel/tools/dev/html2text/install.sh +82 -0
- package/karnel/tools/dev/imagemagick/README.md +44 -0
- package/karnel/tools/dev/imagemagick/install.sh +82 -0
- package/karnel/tools/dev/jq/README.md +44 -0
- package/karnel/tools/dev/jq/install.sh +82 -0
- package/karnel/tools/dev/lsd/README.md +44 -0
- package/karnel/tools/dev/lsd/install.sh +82 -0
- package/karnel/tools/dev/make/README.md +44 -0
- package/karnel/tools/dev/make/install.sh +82 -0
- package/karnel/tools/dev/ncurses/README.md +42 -0
- package/karnel/tools/dev/ncurses/install.sh +82 -0
- package/karnel/tools/dev/openssh/README.md +43 -0
- package/karnel/tools/dev/openssh/install.sh +75 -0
- package/karnel/tools/dev/proot/README.md +43 -0
- package/karnel/tools/dev/proot/install.sh +82 -0
- package/karnel/tools/dev/shfmt/README.md +44 -0
- package/karnel/tools/dev/shfmt/install.sh +82 -0
- package/karnel/tools/dev/tmate/README.md +44 -0
- package/karnel/tools/dev/tmate/install.sh +82 -0
- package/karnel/tools/dev/tmux/README.md +43 -0
- package/karnel/tools/dev/tmux/install.sh +75 -0
- package/karnel/tools/dev/translate/README.md +44 -0
- package/karnel/tools/dev/translate/install.sh +82 -0
- package/karnel/tools/dev/tree/README.md +44 -0
- package/karnel/tools/dev/tree/install.sh +82 -0
- package/karnel/tools/dev/udocker/README.md +44 -0
- package/karnel/tools/dev/udocker/install.sh +82 -0
- package/karnel/tools/dev/wget/README.md +44 -0
- package/karnel/tools/dev/wget/install.sh +82 -0
- package/karnel/tools/editor/all.sh +59 -0
- package/karnel/tools/editor/code-server/README.md +42 -0
- package/karnel/tools/editor/code-server/install.sh +74 -0
- package/karnel/tools/editor/neovim/README.md +43 -0
- package/karnel/tools/editor/neovim/install.sh +64 -0
- package/karnel/tools/editor/nvchad/README.md +45 -0
- package/karnel/tools/editor/nvchad/install.sh +105 -0
- package/karnel/tools/lang/all.sh +63 -0
- package/karnel/tools/lang/clang/README.md +43 -0
- package/karnel/tools/lang/clang/install.sh +79 -0
- package/karnel/tools/lang/golang/README.md +43 -0
- package/karnel/tools/lang/golang/install.sh +79 -0
- package/karnel/tools/lang/nodejs/README.md +43 -0
- package/karnel/tools/lang/nodejs/install.sh +79 -0
- package/karnel/tools/lang/perl/README.md +43 -0
- package/karnel/tools/lang/perl/install.sh +79 -0
- package/karnel/tools/lang/php/README.md +43 -0
- package/karnel/tools/lang/php/install.sh +79 -0
- package/karnel/tools/lang/python/README.md +43 -0
- package/karnel/tools/lang/python/install.sh +79 -0
- package/karnel/tools/lang/rust/README.md +43 -0
- package/karnel/tools/lang/rust/install.sh +79 -0
- package/karnel/tools/npm/all.sh +90 -0
- package/karnel/tools/npm/live-server/README.md +43 -0
- package/karnel/tools/npm/live-server/install.sh +96 -0
- package/karnel/tools/npm/localtunnel/README.md +43 -0
- package/karnel/tools/npm/localtunnel/install.sh +112 -0
- package/karnel/tools/npm/markserv/README.md +43 -0
- package/karnel/tools/npm/markserv/install.sh +95 -0
- package/karnel/tools/npm/ncu/README.md +43 -0
- package/karnel/tools/npm/ncu/install.sh +95 -0
- package/karnel/tools/npm/nestjs/README.md +43 -0
- package/karnel/tools/npm/nestjs/install.sh +95 -0
- package/karnel/tools/npm/ngrok/README.md +44 -0
- package/karnel/tools/npm/ngrok/install.sh +95 -0
- package/karnel/tools/npm/prettier/README.md +43 -0
- package/karnel/tools/npm/prettier/install.sh +95 -0
- package/karnel/tools/npm/psqlformat/README.md +43 -0
- package/karnel/tools/npm/psqlformat/install.sh +95 -0
- package/karnel/tools/npm/turbopack/README.md +8 -0
- package/karnel/tools/npm/turbopack/install.sh +42 -0
- package/karnel/tools/npm/typescript/README.md +43 -0
- package/karnel/tools/npm/typescript/install.sh +95 -0
- package/karnel/tools/npm/vercel/README.md +43 -0
- package/karnel/tools/npm/vercel/install.sh +95 -0
- package/karnel/tools/shell/all.sh +67 -0
- package/karnel/tools/shell/better-npm/README.md +43 -0
- package/karnel/tools/shell/better-npm/install.sh +85 -0
- package/karnel/tools/shell/fzf-tab/README.md +44 -0
- package/karnel/tools/shell/fzf-tab/install.sh +85 -0
- package/karnel/tools/shell/history-substring/README.md +43 -0
- package/karnel/tools/shell/history-substring/install.sh +85 -0
- package/karnel/tools/shell/powerlevel10k/README.md +43 -0
- package/karnel/tools/shell/powerlevel10k/install.sh +85 -0
- package/karnel/tools/shell/you-should-use/README.md +43 -0
- package/karnel/tools/shell/you-should-use/install.sh +85 -0
- package/karnel/tools/shell/zsh-autopair/README.md +44 -0
- package/karnel/tools/shell/zsh-autopair/install.sh +85 -0
- package/karnel/tools/shell/zsh-autosuggestions/README.md +43 -0
- package/karnel/tools/shell/zsh-autosuggestions/install.sh +85 -0
- package/karnel/tools/shell/zsh-completions/README.md +43 -0
- package/karnel/tools/shell/zsh-completions/install.sh +85 -0
- package/karnel/tools/shell/zsh-defer/README.md +43 -0
- package/karnel/tools/shell/zsh-defer/install.sh +85 -0
- package/karnel/tools/shell/zsh-syntax-highlighting/README.md +43 -0
- package/karnel/tools/shell/zsh-syntax-highlighting/install.sh +72 -0
- package/karnel/tools/ui/all.sh +61 -0
- package/karnel/tools/ui/banner/README.md +42 -0
- package/karnel/tools/ui/banner/install.sh +160 -0
- package/karnel/tools/ui/cursor/README.md +42 -0
- package/karnel/tools/ui/cursor/install.sh +58 -0
- package/karnel/tools/ui/extra-keys/README.md +43 -0
- package/karnel/tools/ui/extra-keys/install.sh +62 -0
- package/karnel/tools/ui/font/README.md +43 -0
- package/karnel/tools/ui/font/install.sh +63 -0
- package/karnel/tools/voice/all.sh +27 -0
- package/karnel/tools/voice/install.sh +10 -0
- package/karnel/tools/voice/uninstall.sh +8 -0
- package/karnel/utils/banner.sh +492 -0
- package/karnel/utils/bootstrap.sh +25 -0
- package/karnel/utils/colors.sh +33 -0
- package/karnel/utils/dialogrc +30 -0
- package/karnel/utils/env.sh +53 -0
- package/karnel/utils/log.sh +567 -0
- package/karnel/utils/version.sh +205 -0
- package/package.json +42 -0
- package/scripts/npm-install.js +60 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
|
|
5
|
+
LOG_FILE="$KARNEL_CACHE/install_ai.log"
|
|
6
|
+
|
|
7
|
+
_openclaude_dependencies() {
|
|
8
|
+
loading "Installing dependencies" _openclaude_dependencies_impl
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_openclaude_dependencies_impl() {
|
|
12
|
+
declare -A DEPS=(
|
|
13
|
+
["nodejs-lts"]="node"
|
|
14
|
+
["git"]="git"
|
|
15
|
+
["ripgrep"]="rg"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
local pkg_name bin_name
|
|
19
|
+
for pkg_name in "${!DEPS[@]}"; do
|
|
20
|
+
bin_name="${DEPS[$pkg_name]}"
|
|
21
|
+
if ! command -v "$bin_name" &>/dev/null; then
|
|
22
|
+
if ! pkg install "$pkg_name" -y &>>"$LOG_FILE"; then
|
|
23
|
+
log_error "Failed to install $pkg_name"
|
|
24
|
+
return 1
|
|
25
|
+
fi
|
|
26
|
+
fi
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
return 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_install_openclaude_npm() {
|
|
33
|
+
loading "Installing OpenClaude" _install_openclaude_npm_impl
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_install_openclaude_npm_impl() {
|
|
37
|
+
export GYP_DEFINES="android_ndk_path=''"
|
|
38
|
+
export ANDROID_API_LEVEL=24
|
|
39
|
+
|
|
40
|
+
if ! npm install -g @gitlawb/openclaude &>>"$LOG_FILE"; then
|
|
41
|
+
log_error "Failed to install OpenClaude"
|
|
42
|
+
return 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
return 0
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
install_openclaude() {
|
|
49
|
+
if command -v openclaude &>/dev/null; then
|
|
50
|
+
log_info "OpenClaude is already installed"
|
|
51
|
+
return 2
|
|
52
|
+
fi
|
|
53
|
+
log_info "Installing OpenClaude..."
|
|
54
|
+
|
|
55
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
56
|
+
|
|
57
|
+
_openclaude_dependencies || return 1
|
|
58
|
+
_install_openclaude_npm || return 1
|
|
59
|
+
|
|
60
|
+
log_success "OpenClaude installed"
|
|
61
|
+
return 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
uninstall_openclaude() {
|
|
65
|
+
if ! command -v openclaude &>/dev/null; then
|
|
66
|
+
log_info "OpenClaude is not installed"
|
|
67
|
+
return 2
|
|
68
|
+
fi
|
|
69
|
+
log_info "Uninstalling OpenClaude..."
|
|
70
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
71
|
+
|
|
72
|
+
loading "Removing OpenClaude" _uninstall_openclaude_impl
|
|
73
|
+
|
|
74
|
+
log_success "OpenClaude uninstalled"
|
|
75
|
+
return 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_uninstall_openclaude_impl() {
|
|
79
|
+
if ! npm uninstall -g @gitlawb/openclaude &>>"$LOG_FILE"; then
|
|
80
|
+
log_error "Failed to uninstall OpenClaude"
|
|
81
|
+
return 1
|
|
82
|
+
fi
|
|
83
|
+
return 0
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
update_openclaude() {
|
|
87
|
+
log_info "Updating OpenClaude..."
|
|
88
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
89
|
+
|
|
90
|
+
loading "Updating OpenClaude" _update_openclaude_impl
|
|
91
|
+
|
|
92
|
+
log_success "OpenClaude updated"
|
|
93
|
+
return 0
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_update_openclaude_impl() {
|
|
97
|
+
export GYP_DEFINES="android_ndk_path=''"
|
|
98
|
+
export ANDROID_API_LEVEL=24
|
|
99
|
+
|
|
100
|
+
if ! npm update -g @gitlawb/openclaude &>>"$LOG_FILE"; then
|
|
101
|
+
log_error "Failed to update OpenClaude"
|
|
102
|
+
return 1
|
|
103
|
+
fi
|
|
104
|
+
return 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
reinstall_openclaude() {
|
|
108
|
+
uninstall_openclaude
|
|
109
|
+
install_openclaude
|
|
110
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# OpenClaw
|
|
2
|
+
|
|
3
|
+
Personal AI Assistant
|
|
4
|
+
|
|
5
|
+
**Package:** openclaw
|
|
6
|
+
**Author:** israel marques
|
|
7
|
+
**Repository:** https://github.com/israelmarques1024-dotcom/karnel-termux
|
|
8
|
+
**Official:** https://github.com/openclaw/openclaw
|
|
9
|
+
**Type:** AI assistant aggregator (npm global package)
|
|
10
|
+
**License:** MIT
|
|
11
|
+
|
|
12
|
+
## Description
|
|
13
|
+
|
|
14
|
+
OpenClaw is a Personal AI Assistant. It provides a unified interface for interacting with AI services from your terminal.
|
|
15
|
+
|
|
16
|
+
## Dependencies
|
|
17
|
+
|
|
18
|
+
- Node.js LTS (nodejs-lts)
|
|
19
|
+
- npm
|
|
20
|
+
- git, ripgrep
|
|
21
|
+
- Additional npm packages: @larksuiteoapi/node-sdk, nostr-tools, @slack/web-api, @whiskeysockets/baileys
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
karnel install ai --openclaw
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Uninstall
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
karnel uninstall ai --openclaw
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Update
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
karnel update ai --openclaw
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Notes
|
|
42
|
+
|
|
43
|
+
- Installed as a global npm package: `openclaw`
|
|
44
|
+
- Command: `openclaw`
|
|
45
|
+
- Installs companion SDK packages for multi-platform support
|
|
46
|
+
- Requires configuration for each platform
|
|
47
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
|
|
5
|
+
LOG_FILE="$KARNEL_CACHE/install_ai.log"
|
|
6
|
+
|
|
7
|
+
_openclaw_dependencies() {
|
|
8
|
+
loading "Installing dependencies" _openclaw_dependencies_impl
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_openclaw_dependencies_impl() {
|
|
12
|
+
declare -A DEPS=(
|
|
13
|
+
["nodejs-lts"]="node"
|
|
14
|
+
["git"]="git"
|
|
15
|
+
["ripgrep"]="rg"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
local pkg_name bin_name
|
|
19
|
+
for pkg_name in "${!DEPS[@]}"; do
|
|
20
|
+
bin_name="${DEPS[$pkg_name]}"
|
|
21
|
+
if ! command -v "$bin_name" &>/dev/null; then
|
|
22
|
+
if ! pkg install "$pkg_name" -y &>>"$LOG_FILE"; then
|
|
23
|
+
log_error "Failed to install $pkg_name"
|
|
24
|
+
return 1
|
|
25
|
+
fi
|
|
26
|
+
fi
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
return 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_install_openclaw_npm() {
|
|
33
|
+
loading "Installing OpenClaw and dependencies" _install_openclaw_npm_impl
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_install_openclaw_npm_impl() {
|
|
37
|
+
export GYP_DEFINES="android_ndk_path=''"
|
|
38
|
+
export ANDROID_API_LEVEL=24
|
|
39
|
+
|
|
40
|
+
npm install -g @larksuiteoapi/node-sdk nostr-tools @slack/web-api @whiskeysockets/baileys &>>"$LOG_FILE"
|
|
41
|
+
|
|
42
|
+
if ! npm install -g openclaw@latest &>>"$LOG_FILE"; then
|
|
43
|
+
log_error "Failed to install OpenClaw"
|
|
44
|
+
return 1
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
return 0
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
install_openclaw() {
|
|
51
|
+
if command -v openclaw &>/dev/null; then
|
|
52
|
+
log_info "OpenClaw is already installed"
|
|
53
|
+
return 2
|
|
54
|
+
fi
|
|
55
|
+
log_info "Installing OpenClaw..."
|
|
56
|
+
|
|
57
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
58
|
+
|
|
59
|
+
_openclaw_dependencies || return 1
|
|
60
|
+
_install_openclaw_npm || return 1
|
|
61
|
+
|
|
62
|
+
log_success "OpenClaw installed"
|
|
63
|
+
return 0
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
uninstall_openclaw() {
|
|
67
|
+
if ! command -v openclaw &>/dev/null; then
|
|
68
|
+
log_info "OpenClaw is not installed"
|
|
69
|
+
return 2
|
|
70
|
+
fi
|
|
71
|
+
log_info "Uninstalling OpenClaw..."
|
|
72
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
73
|
+
|
|
74
|
+
loading "Removing OpenClaw" _uninstall_openclaw_impl
|
|
75
|
+
|
|
76
|
+
log_success "OpenClaw uninstalled"
|
|
77
|
+
return 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_uninstall_openclaw_impl() {
|
|
81
|
+
if ! npm uninstall -g openclaw @larksuiteoapi/node-sdk nostr-tools @slack/web-api @whiskeysockets/baileys &>>"$LOG_FILE"; then
|
|
82
|
+
log_error "Failed to uninstall OpenClaw"
|
|
83
|
+
return 1
|
|
84
|
+
fi
|
|
85
|
+
return 0
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
update_openclaw() {
|
|
89
|
+
log_info "Updating OpenClaw..."
|
|
90
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
91
|
+
|
|
92
|
+
loading "Updating OpenClaw" _update_openclaw_impl
|
|
93
|
+
|
|
94
|
+
log_success "OpenClaw updated"
|
|
95
|
+
return 0
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_update_openclaw_impl() {
|
|
99
|
+
export GYP_DEFINES="android_ndk_path=''"
|
|
100
|
+
export ANDROID_API_LEVEL=24
|
|
101
|
+
|
|
102
|
+
if ! npm update -g openclaw @larksuiteoapi/node-sdk nostr-tools @slack/web-api @whiskeysockets/baileys &>>"$LOG_FILE"; then
|
|
103
|
+
log_error "Failed to update OpenClaw"
|
|
104
|
+
return 1
|
|
105
|
+
fi
|
|
106
|
+
return 0
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
reinstall_openclaw() {
|
|
110
|
+
uninstall_openclaw
|
|
111
|
+
install_openclaw
|
|
112
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# OpenCode
|
|
2
|
+
|
|
3
|
+
Open-source agent that helps you write code in your terminal
|
|
4
|
+
|
|
5
|
+
**Package:** opencode
|
|
6
|
+
**Author:** israel marques
|
|
7
|
+
**Repository:** https://github.com/israelmarques1024-dotcom/karnel-termux
|
|
8
|
+
**Official:** https://github.com/anomalyco/opencode
|
|
9
|
+
**Type:** AI coding agent (Binary + glibc bootstrapper)
|
|
10
|
+
**License:** MIT
|
|
11
|
+
|
|
12
|
+
## Description
|
|
13
|
+
|
|
14
|
+
OpenCode is an AI-powered coding agent developed by anomalyco that operates directly in your terminal. It provides intelligent code completion, refactoring suggestions, and natural language code generation. Karnel Termux offers two installation methods: native with glibc support for best performance, or via proot-distro Ubuntu container for maximum compatibility.
|
|
15
|
+
|
|
16
|
+
## Dependencies
|
|
17
|
+
|
|
18
|
+
- **Native mode:** glibc-repo, glibc, clang, git, ripgrep, python, jq, nodejs-lts, curl, tar
|
|
19
|
+
- **Proot mode:** proot-distro, curl, ca-certificates
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
karnel install ai --opencode
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You will be prompted to choose:
|
|
28
|
+
|
|
29
|
+
1. **Native (recommended)** — Compiles a glibc bootstrapper and downloads the latest OpenCode binary from GitHub releases
|
|
30
|
+
2. **Proot-distro (alternative)** — Runs OpenCode inside an Ubuntu proot-distro container
|
|
31
|
+
|
|
32
|
+
## Uninstall
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
karnel uninstall ai --opencode
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Update
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
karnel update ai --opencode
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Notes
|
|
45
|
+
|
|
46
|
+
- **Native mode** requires `glibc-repo`, `glibc`, `clang`, and other dependencies (installed automatically)
|
|
47
|
+
- The native binary is stored in `~/.local/share/karnel-data/opencode/`
|
|
48
|
+
- A small C bootstrapper (`opencode_helper.c`) handles ELF loading via the glibc dynamic linker
|
|
49
|
+
- **Proot mode** uses `proot-distro ubuntu` and installs via the official opencode.ai installer
|
|
50
|
+
- Data directory: `~/.local/share/karnel-data/opencode/`
|
|
51
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/data/data/com.termux/files/usr/bin/bash
|
|
2
|
+
|
|
3
|
+
UBUNTU_ROOTFS="__UBUNTU_ROOTFS__"
|
|
4
|
+
|
|
5
|
+
EXCLUDE_REGEX="^(PATH|LD_PRELOAD|LD_LIBRARY_PATH|PREFIX|HOME|PWD|OLDPWD|SHELL|IFS|_|SHLVL|PROMPT_COMMAND|TERMCAP|LS_COLORS|TERM)="
|
|
6
|
+
|
|
7
|
+
ENV_ARGS=()
|
|
8
|
+
while IFS= read -r line; do
|
|
9
|
+
if [[ -n "$line" && ! "$line" =~ $EXCLUDE_REGEX ]]; then
|
|
10
|
+
ENV_ARGS+=("--env" "$line")
|
|
11
|
+
fi
|
|
12
|
+
done < <(env)
|
|
13
|
+
|
|
14
|
+
ENV_ARGS+=(
|
|
15
|
+
"--env" "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt"
|
|
16
|
+
"--env" "TERM=$TERM"
|
|
17
|
+
"--env" "HOME=/root"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
unset LD_PRELOAD
|
|
21
|
+
proot-distro login \
|
|
22
|
+
"${ENV_ARGS[@]}" \
|
|
23
|
+
--termux-home \
|
|
24
|
+
--shared-tmp \
|
|
25
|
+
--bind "$UBUNTU_ROOTFS/root/.opencode:/root/.opencode" \
|
|
26
|
+
--work-dir $PWD \
|
|
27
|
+
ubuntu \
|
|
28
|
+
-- /root/.opencode/bin/opencode "$@"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#include <stdlib.h>
|
|
2
|
+
#include <unistd.h>
|
|
3
|
+
#include <string.h>
|
|
4
|
+
#include <libgen.h>
|
|
5
|
+
#include <limits.h>
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
|
|
8
|
+
int main(int argc, char** argv) {
|
|
9
|
+
// 1. Clear conflicting Android Bionic preloads and search paths
|
|
10
|
+
unsetenv("LD_PRELOAD");
|
|
11
|
+
unsetenv("LD_LIBRARY_PATH");
|
|
12
|
+
|
|
13
|
+
// 2. Set dynamic Go resolver and SSL configurations for Termux environment
|
|
14
|
+
setenv("GODEBUG", "netdns=cgo", 1);
|
|
15
|
+
setenv("SSL_CERT_FILE", "/data/data/com.termux/files/usr/etc/tls/cert.pem", 1);
|
|
16
|
+
|
|
17
|
+
// 3. Resolve current executable directory
|
|
18
|
+
char exec_path[PATH_MAX];
|
|
19
|
+
ssize_t len = readlink("/proc/self/exe", exec_path, sizeof(exec_path) - 1);
|
|
20
|
+
if (len == -1) {
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
exec_path[len] = '\0';
|
|
24
|
+
char* dir = dirname(exec_path);
|
|
25
|
+
|
|
26
|
+
// 4. Construct paths for the glibc loader and the real binary
|
|
27
|
+
// In our deb structure, opencode.real is in /usr/share/opencode/
|
|
28
|
+
// This bootstrapper is usually in /usr/bin/
|
|
29
|
+
char* loader = "/data/data/com.termux/files/usr/glibc/lib/ld-linux-aarch64.so.1";
|
|
30
|
+
char real_bin[] = "/data/data/com.termux/files/home/.local/share/karnel-data/opencode/opencode";
|
|
31
|
+
char lib_path[] = "/data/data/com.termux/files/usr/glibc/lib";
|
|
32
|
+
|
|
33
|
+
// 5. Construct argument array for execv
|
|
34
|
+
// Format: [loader, --library-path, lib_path, real_bin, ...original_args]
|
|
35
|
+
char** new_argv = malloc((argc + 4) * sizeof(char*));
|
|
36
|
+
if (!new_argv) {
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
new_argv[0] = loader;
|
|
41
|
+
new_argv[1] = "--library-path";
|
|
42
|
+
new_argv[2] = lib_path;
|
|
43
|
+
new_argv[3] = real_bin;
|
|
44
|
+
|
|
45
|
+
for (int i = 1; i < argc; i++) {
|
|
46
|
+
new_argv[i + 3] = argv[i];
|
|
47
|
+
}
|
|
48
|
+
new_argv[argc + 3] = NULL;
|
|
49
|
+
|
|
50
|
+
// 6. Execute the glibc loader to run the real binary
|
|
51
|
+
execv(loader, new_argv);
|
|
52
|
+
|
|
53
|
+
// If execv returns, an error occurred
|
|
54
|
+
perror("execv");
|
|
55
|
+
free(new_argv);
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
import "@/utils/colors"
|
|
5
|
+
|
|
6
|
+
LOG_FILE="$KARNEL_CACHE/install_ai.log"
|
|
7
|
+
OPENCODE_DATA_DIR="$HOME/.local/share/karnel-data/opencode"
|
|
8
|
+
|
|
9
|
+
_opencode_detect_ubuntu_root() {
|
|
10
|
+
local root
|
|
11
|
+
root="$(find /data/data/com.termux -maxdepth 10 -type d \
|
|
12
|
+
-name "rootfs" -path "*/containers/ubuntu/*" 2>/dev/null | head -1)"
|
|
13
|
+
|
|
14
|
+
if [ -z "$root" ]; then
|
|
15
|
+
root="$(find /data/data/com.termux -maxdepth 10 -type d \
|
|
16
|
+
-name "ubuntu" -path "*/installed-rootfs/*" 2>/dev/null | head -1)"
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
echo "$root"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_opencode_proot_ubuntu() {
|
|
23
|
+
proot-distro login \
|
|
24
|
+
--shared-tmp \
|
|
25
|
+
ubuntu \
|
|
26
|
+
-- "$@"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_get_latest_opencode_version() {
|
|
30
|
+
curl -fsSL https://api.github.com/repos/anomalyco/opencode/releases/latest |
|
|
31
|
+
grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_opencode_install_deps_native() {
|
|
35
|
+
loading "Installing glibc and dependencies" _opencode_install_deps_native_impl
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
_opencode_install_deps_native_impl() {
|
|
39
|
+
if [[ ! -f $PREFIX/etc/apt/sources.list.d/glibc.list ]]; then
|
|
40
|
+
if ! pkg install glibc-repo -y &>>"$LOG_FILE"; then
|
|
41
|
+
log_error "Failed to install glibc-repo"
|
|
42
|
+
return 1
|
|
43
|
+
fi
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
if [[ ! -f $PREFIX/glibc/lib/libc.so.6 ]]; then
|
|
47
|
+
if ! pkg install glibc -y &>>"$LOG_FILE"; then
|
|
48
|
+
log_error "Failed to install glibc"
|
|
49
|
+
return 1
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
declare -A DEPS=(
|
|
54
|
+
["git"]="git"
|
|
55
|
+
["ripgrep"]="rg"
|
|
56
|
+
["python"]="python"
|
|
57
|
+
["clang"]="clang"
|
|
58
|
+
["jq"]="jq"
|
|
59
|
+
["nodejs-lts"]="node"
|
|
60
|
+
["curl"]="curl"
|
|
61
|
+
["tar"]="tar"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
local pkg_name bin_name
|
|
65
|
+
for pkg_name in "${!DEPS[@]}"; do
|
|
66
|
+
bin_name="${DEPS[$pkg_name]}"
|
|
67
|
+
if ! command -v "$bin_name" &>/dev/null; then
|
|
68
|
+
if ! pkg install "$pkg_name" -y &>>"$LOG_FILE"; then
|
|
69
|
+
log_error "Failed to install $pkg_name"
|
|
70
|
+
return 1
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
73
|
+
done
|
|
74
|
+
|
|
75
|
+
return 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_download_opencode_binary() {
|
|
79
|
+
loading "Downloading OpenCode" _download_opencode_binary_impl
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_download_opencode_binary_impl() {
|
|
83
|
+
local latest_version
|
|
84
|
+
latest_version=$(_get_latest_opencode_version)
|
|
85
|
+
if [ -z "$latest_version" ]; then
|
|
86
|
+
log_error "Failed to fetch latest OpenCode version"
|
|
87
|
+
return 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
mkdir -p "$OPENCODE_DATA_DIR"
|
|
91
|
+
|
|
92
|
+
local tarball="opencode-linux-arm64.tar.gz"
|
|
93
|
+
local download_url="https://github.com/anomalyco/opencode/releases/download/$latest_version/$tarball"
|
|
94
|
+
|
|
95
|
+
if ! curl -fsSL "$download_url" -o "$OPENCODE_DATA_DIR/$tarball" &>>"$LOG_FILE"; then
|
|
96
|
+
log_error "Failed to download OpenCode binary"
|
|
97
|
+
return 1
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
if ! tar -zxf "$OPENCODE_DATA_DIR/$tarball" -C "$OPENCODE_DATA_DIR" &>>"$LOG_FILE"; then
|
|
101
|
+
log_error "Failed to extract OpenCode binary"
|
|
102
|
+
return 1
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
rm -f "$OPENCODE_DATA_DIR/$tarball"
|
|
106
|
+
|
|
107
|
+
if [ ! -f "$OPENCODE_DATA_DIR/opencode" ]; then
|
|
108
|
+
log_error "OpenCode binary not found after extraction"
|
|
109
|
+
return 1
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
chmod +x "$OPENCODE_DATA_DIR/opencode"
|
|
113
|
+
return 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
_compile_opencode_helper() {
|
|
117
|
+
loading "Compiling helper" _compile_opencode_helper_impl
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_compile_opencode_helper_impl() {
|
|
121
|
+
local HELPER_SRC="$KARNEL_PATH/tools/ai/opencode/helper/opencode_helper.c"
|
|
122
|
+
if [ ! -f "$HELPER_SRC" ]; then
|
|
123
|
+
log_error "Helper source not found at $HELPER_SRC"
|
|
124
|
+
return 1
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
if ! clang -O2 -o "$PREFIX/bin/opencode" "$HELPER_SRC" &>>"$LOG_FILE"; then
|
|
128
|
+
log_error "Failed to compile opencode helper"
|
|
129
|
+
return 1
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
chmod +x "$PREFIX/bin/opencode"
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
_install_opencode_native() {
|
|
137
|
+
_opencode_install_deps_native || return 1
|
|
138
|
+
_download_opencode_binary || return 1
|
|
139
|
+
_compile_opencode_helper || return 1
|
|
140
|
+
log_success "OpenCode installed natively"
|
|
141
|
+
return 0
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_install_opencode_proot() {
|
|
145
|
+
loading "Installing OpenCode (proot-distro)" _install_opencode_proot_impl
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_install_opencode_proot_impl() {
|
|
149
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
150
|
+
|
|
151
|
+
if ! command -v proot-distro &>/dev/null; then
|
|
152
|
+
pkg install proot-distro -y &>>"$LOG_FILE"
|
|
153
|
+
fi
|
|
154
|
+
|
|
155
|
+
if [ ! -d "$(_opencode_detect_ubuntu_root)" ]; then
|
|
156
|
+
proot-distro install ubuntu:24.04 &>>"$LOG_FILE"
|
|
157
|
+
fi
|
|
158
|
+
|
|
159
|
+
_opencode_proot_ubuntu /bin/bash -c \
|
|
160
|
+
'apt-get update && apt-get upgrade -y && apt-get install -y curl ca-certificates' \
|
|
161
|
+
&>>"$LOG_FILE"
|
|
162
|
+
|
|
163
|
+
_opencode_proot_ubuntu /bin/bash -c '
|
|
164
|
+
export SHELL=/bin/bash
|
|
165
|
+
export TMPDIR=/tmp
|
|
166
|
+
export HOME=/root
|
|
167
|
+
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path
|
|
168
|
+
' &>>"$LOG_FILE"
|
|
169
|
+
|
|
170
|
+
local ubuntu_root
|
|
171
|
+
ubuntu_root="$(_opencode_detect_ubuntu_root)"
|
|
172
|
+
|
|
173
|
+
if [ -z "$ubuntu_root" ]; then
|
|
174
|
+
log_error "Ubuntu rootfs not found"
|
|
175
|
+
return 1
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
local opencode_bin="$ubuntu_root/root/.opencode/bin/opencode"
|
|
179
|
+
|
|
180
|
+
if [ ! -f "$opencode_bin" ]; then
|
|
181
|
+
log_error "OpenCode binary not found after install"
|
|
182
|
+
return 1
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
local wrapper_src="$KARNEL_PATH/tools/ai/opencode/bin/opencode"
|
|
186
|
+
if [ ! -f "$wrapper_src" ]; then
|
|
187
|
+
log_error "Wrapper template not found at $wrapper_src"
|
|
188
|
+
return 1
|
|
189
|
+
fi
|
|
190
|
+
sed "s|__UBUNTU_ROOTFS__|$ubuntu_root|g" "$wrapper_src" >"$PREFIX/bin/opencode"
|
|
191
|
+
chmod +x "$PREFIX/bin/opencode"
|
|
192
|
+
|
|
193
|
+
if ! grep -q '.opencode/bin' "$ubuntu_root/root/.bashrc" 2>/dev/null; then
|
|
194
|
+
printf '\n# opencode\nexport PATH=/root/.opencode/bin:$PATH\n' >>"$ubuntu_root/root/.bashrc"
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
return 0
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
install_opencode() {
|
|
201
|
+
if command -v opencode &>/dev/null; then
|
|
202
|
+
log_info "OpenCode is already installed"
|
|
203
|
+
return 2
|
|
204
|
+
fi
|
|
205
|
+
|
|
206
|
+
log_info "Select installation method for OpenCode:"
|
|
207
|
+
|
|
208
|
+
read_select "Installation method" SELECTED_METHOD \
|
|
209
|
+
"Native (recommended) - Compile with glibc support" \
|
|
210
|
+
"Proot-distro (alternative) - Ubuntu container"
|
|
211
|
+
|
|
212
|
+
case "$SELECTED_METHOD" in
|
|
213
|
+
*Native*)
|
|
214
|
+
_install_opencode_native
|
|
215
|
+
;;
|
|
216
|
+
*Proot-distro*)
|
|
217
|
+
_install_opencode_proot
|
|
218
|
+
;;
|
|
219
|
+
esac
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
uninstall_opencode() {
|
|
223
|
+
log_info "Uninstalling OpenCode..."
|
|
224
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
225
|
+
|
|
226
|
+
if [ ! -f "$PREFIX/bin/opencode" ]; then
|
|
227
|
+
log_warn "OpenCode is not installed"
|
|
228
|
+
return 1
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
if [ -f "$OPENCODE_DATA_DIR/opencode" ]; then
|
|
232
|
+
rm -f "$PREFIX/bin/opencode"
|
|
233
|
+
rm -rf "$OPENCODE_DATA_DIR"
|
|
234
|
+
log_success "OpenCode (native) uninstalled"
|
|
235
|
+
return 0
|
|
236
|
+
fi
|
|
237
|
+
|
|
238
|
+
_opencode_proot_ubuntu /bin/bash -c 'rm -rf /root/.opencode' &>>"$LOG_FILE"
|
|
239
|
+
|
|
240
|
+
local ubuntu_bashrc
|
|
241
|
+
ubuntu_bashrc="$(_opencode_detect_ubuntu_root)/root/.bashrc"
|
|
242
|
+
|
|
243
|
+
if [ -f "$ubuntu_bashrc" ]; then
|
|
244
|
+
sed -i '/# opencode/d; /export PATH=\/root\/.opencode\/bin/d' "$ubuntu_bashrc"
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
if rm -f "$PREFIX/bin/opencode" &>>"$LOG_FILE"; then
|
|
248
|
+
log_success "OpenCode (proot-distro) uninstalled"
|
|
249
|
+
return 0
|
|
250
|
+
else
|
|
251
|
+
log_error "Failed to uninstall OpenCode"
|
|
252
|
+
return 1
|
|
253
|
+
fi
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
update_opencode() {
|
|
257
|
+
log_info "Updating OpenCode..."
|
|
258
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
259
|
+
|
|
260
|
+
if [ -f "$OPENCODE_DATA_DIR/opencode" ]; then
|
|
261
|
+
_install_opencode_native
|
|
262
|
+
return $?
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
_opencode_proot_ubuntu /bin/bash -c 'rm -rf /root/.opencode' &>>"$LOG_FILE"
|
|
266
|
+
|
|
267
|
+
_opencode_proot_ubuntu /bin/bash -c '
|
|
268
|
+
export SHELL=/bin/bash
|
|
269
|
+
export TMPDIR=/tmp
|
|
270
|
+
export HOME=/root
|
|
271
|
+
curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path
|
|
272
|
+
' &>>"$LOG_FILE"
|
|
273
|
+
|
|
274
|
+
local ubuntu_root
|
|
275
|
+
ubuntu_root="$(_opencode_detect_ubuntu_root)"
|
|
276
|
+
local opencode_bin="$ubuntu_root/root/.opencode/bin/opencode"
|
|
277
|
+
|
|
278
|
+
if [ ! -f "$opencode_bin" ]; then
|
|
279
|
+
log_error "OpenCode binary not found after update"
|
|
280
|
+
return 1
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
log_success "OpenCode (proot-distro) updated"
|
|
284
|
+
return 0
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
reinstall_opencode() {
|
|
288
|
+
uninstall_opencode
|
|
289
|
+
install_opencode
|
|
290
|
+
}
|