karnel-termux 0.0.4 → 4.7.6

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.
Files changed (46) hide show
  1. package/README.md +7 -9
  2. package/install.sh +9 -0
  3. package/karnel/bin/karnel +1 -1
  4. package/karnel/cli/commands/backup.sh +100 -0
  5. package/karnel/cli/commands/doctor/fixes.sh +310 -0
  6. package/karnel/cli/commands/doctor/system.sh +87 -0
  7. package/karnel/cli/commands/doctor.sh +7 -308
  8. package/karnel/cli/commands/install.sh +21 -2
  9. package/karnel/cli/commands/list.sh +5 -0
  10. package/karnel/cli/commands/reinstall.sh +5 -1
  11. package/karnel/cli/commands/restore.sh +83 -0
  12. package/karnel/cli/commands/search.sh +62 -0
  13. package/karnel/cli/commands/show.sh +102 -38
  14. package/karnel/cli/commands/uninstall.sh +3 -551
  15. package/karnel/cli/commands/update.sh +3 -551
  16. package/karnel/cli/karnel.sh +5 -0
  17. package/karnel/modules/db.sh +2 -0
  18. package/karnel/modules/dev.sh +9 -3
  19. package/karnel/tools/ai/antigravity-cli/bin/agy +1 -1
  20. package/karnel/tools/ai/claude-code/bin/claude +1 -1
  21. package/karnel/tools/ai/codegraph/bin/codegraph +1 -1
  22. package/karnel/tools/ai/freebuff/bin/freebuff +1 -1
  23. package/karnel/tools/ai/kilocode-cli/bin/kilocode +1 -1
  24. package/karnel/tools/ai/kilocode-cli/install.sh +1 -1
  25. package/karnel/tools/ai/kimchi-code/bin/kimchi +1 -1
  26. package/karnel/tools/ai/mimocode/bin/mimo +1 -1
  27. package/karnel/tools/ai/omni-route/README.md +17 -15
  28. package/karnel/tools/ai/opencode/bin/opencode +1 -1
  29. package/karnel/tools/db/redis/install.sh +1 -1
  30. package/karnel/tools/dev/all.sh +3 -0
  31. package/karnel/tools/dev/httptmux/install.sh +75 -0
  32. package/karnel/tools/dev/openssh/install.sh +1 -1
  33. package/karnel/tools/dev/snyk/install.sh +75 -0
  34. package/karnel/tools/dev/tmux/install.sh +1 -1
  35. package/karnel/tools/dev/zork/install.sh +133 -0
  36. package/karnel/tools/editor/neovim/install.sh +1 -1
  37. package/karnel/tools/editor/nvchad/install.sh +1 -1
  38. package/karnel/tools/npm/turbopack/bin/next-turbopack +1 -1
  39. package/karnel/tools/npm/turbopack/bin/node-glibc.sh +1 -1
  40. package/karnel/utils/env.sh +1 -1
  41. package/karnel/utils/log.sh +70 -0
  42. package/karnel/utils/tools.sh +34 -0
  43. package/karnel/utils/version.sh +1 -1
  44. package/package.json +1 -1
  45. package/scripts/completion.bash +28 -0
  46. package/scripts/completion.zsh +90 -0
@@ -1,8 +1,8 @@
1
- # karnelRoute
1
+ # omniRoute (karnelroute wrapper)
2
2
 
3
3
  **AI Gateway CLI** — 236+ AI providers via a single endpoint.
4
4
 
5
- **Package:** karnel-route
5
+ **Package:** omni-route (npm: karnelroute)
6
6
  **Author:** israel marques
7
7
  **Repository:** https://github.com/israelmarques1024-dotcom/karnel-termux
8
8
  **Official:** https://karnelroute.online
@@ -12,25 +12,27 @@
12
12
 
13
13
  ## Description
14
14
 
15
- karnelRoute is the Karnel Termux wrapper for the official `karnelroute` npm package — an AI Gateway that provides 236+ AI providers via a single endpoint, with auto-fallback to free providers and smart routing with compression (15-95% token savings).
15
+ omniRoute is the Karnel Termux wrapper for the official `karnelroute` npm package — an AI Gateway that provides 236+ AI providers via a single endpoint, with auto-fallback to free providers and smart routing with compression (15-95% token savings).
16
16
 
17
17
  ## Installation
18
18
 
19
19
  ```bash
20
- karnel install ai --karnel-route
20
+ karnel install ai --omni-route
21
21
  ```
22
22
 
23
23
  ## Usage
24
24
 
25
25
  ```bash
26
- karnel-route # Start AI gateway on localhost:20128
27
- karnel-route serve --daemon # Start as background daemon
28
- karnel-route serve --daemon --no-open # Daemon without browser
29
- karnel-route stop # Stop the server
30
- karnel-route --help # Show all commands
31
- karnel-route --version # Show version
26
+ omni-route # Start AI gateway on localhost:20128
27
+ omni-route serve --daemon # Start as background daemon
28
+ omni-route serve --daemon --no-open # Daemon without browser
29
+ omni-route stop # Stop the server
30
+ omni-route --help # Show all commands
31
+ omni-route --version # Show version
32
32
  ```
33
33
 
34
+ > Note: `karnel-route` and `karnelroute` also work as aliases.
35
+
34
36
  ## Dashboard
35
37
 
36
38
  Access the web dashboard at:
@@ -85,10 +87,10 @@ karnel-route serve --daemon
85
87
 
86
88
  | Command | Description |
87
89
  |---------|-------------|
88
- | `karnel-route` | Shortcut to karnelroute |
89
- | `karnel-route serve` | Start the server |
90
- | `karnel-route serve --daemon` | Run in background |
91
- | `karnel-route stop` | Stop the daemon |
90
+ | `omni-route` | AI Gateway (alias: karnel-route) |
91
+ | `omni-route serve` | Start the server |
92
+ | `omni-route serve --daemon` | Run in background |
93
+ | `omni-route stop` | Stop the daemon |
92
94
 
93
95
  ## Notes
94
96
 
@@ -108,4 +110,4 @@ karnel-route serve --daemon
108
110
 
109
111
  - `karnel ia routes` — List installed AI CLI tools
110
112
  - `karnel ia sessions` — View active AI sessions
111
- - `karnel install ai --karnel-route` — Install
113
+ - `karnel install ai --omni-route` — Install
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  UBUNTU_ROOTFS="__UBUNTU_ROOTFS__"
4
4
 
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/version"
@@ -26,6 +26,9 @@ TOOLS_PACKAGES=(
26
26
  "shfmt"
27
27
  "make"
28
28
  "udocker"
29
+ "snyk"
30
+ "httptmux"
31
+ "zork"
29
32
  )
30
33
 
31
34
  for _tool in "${TOOLS_PACKAGES[@]}"; do
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env bash
2
+
3
+ import "@/utils/log"
4
+ import "@/utils/version"
5
+
6
+ LOG_FILE="$KARNEL_CACHE/install_dev.log"
7
+
8
+ _install_httptmux_npm() {
9
+ loading "Installing httptmux via npm" _install_httptmux_npm_impl
10
+ }
11
+
12
+ _install_httptmux_npm_impl() {
13
+ if ! npm install -g httptmux &>>"$LOG_FILE"; then
14
+ log_error "Failed to install httptmux"
15
+ return 1
16
+ fi
17
+ return 0
18
+ }
19
+
20
+ _uninstall_httptmux_npm() {
21
+ loading "Uninstalling httptmux" _uninstall_httptmux_npm_impl
22
+ }
23
+
24
+ _uninstall_httptmux_npm_impl() {
25
+ if ! npm uninstall -g httptmux &>>"$LOG_FILE"; then
26
+ log_error "Failed to uninstall httptmux"
27
+ return 1
28
+ fi
29
+ return 0
30
+ }
31
+
32
+ install_httptmux() {
33
+ if command -v httptmux &>/dev/null; then
34
+ log_info "httptmux is already installed"
35
+ return 2
36
+ fi
37
+ log_info "Installing httptmux..."
38
+
39
+ mkdir -p "$(dirname "$LOG_FILE")"
40
+
41
+ if ! command -v npm &>/dev/null; then
42
+ pkg install nodejs-lts -y &>>"$LOG_FILE"
43
+ fi
44
+
45
+ _install_httptmux_npm || return 1
46
+ log_success "httptmux installed"
47
+ return 0
48
+ }
49
+
50
+ uninstall_httptmux() {
51
+ if ! command -v httptmux &>/dev/null; then
52
+ log_info "httptmux is not installed"
53
+ return 2
54
+ fi
55
+ log_info "Uninstalling httptmux..."
56
+ mkdir -p "$(dirname "$LOG_FILE")"
57
+
58
+ _uninstall_httptmux_npm || return 1
59
+ log_success "httptmux uninstalled"
60
+ return 0
61
+ }
62
+
63
+ update_httptmux() {
64
+ _check_update_needed "httptmux" "$(_get_installed_npm_version httptmux)" "$(_get_remote_npm_version httptmux)" _do_update_httptmux
65
+ }
66
+
67
+ _do_update_httptmux() {
68
+ npm update -g httptmux &>>"$LOG_FILE" || return 1
69
+ return 0
70
+ }
71
+
72
+ reinstall_httptmux() {
73
+ uninstall_httptmux
74
+ install_httptmux
75
+ }
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/version"
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env bash
2
+
3
+ import "@/utils/log"
4
+ import "@/utils/version"
5
+
6
+ LOG_FILE="$KARNEL_CACHE/install_dev.log"
7
+
8
+ _install_snyk_npm() {
9
+ loading "Installing Snyk via npm" _install_snyk_npm_impl
10
+ }
11
+
12
+ _install_snyk_npm_impl() {
13
+ if ! npm install -g snyk &>>"$LOG_FILE"; then
14
+ log_error "Failed to install Snyk"
15
+ return 1
16
+ fi
17
+ return 0
18
+ }
19
+
20
+ _uninstall_snyk_npm() {
21
+ loading "Uninstalling Snyk" _uninstall_snyk_npm_impl
22
+ }
23
+
24
+ _uninstall_snyk_npm_impl() {
25
+ if ! npm uninstall -g snyk &>>"$LOG_FILE"; then
26
+ log_error "Failed to uninstall Snyk"
27
+ return 1
28
+ fi
29
+ return 0
30
+ }
31
+
32
+ install_snyk() {
33
+ if command -v snyk &>/dev/null; then
34
+ log_info "Snyk is already installed"
35
+ return 2
36
+ fi
37
+ log_info "Installing Snyk..."
38
+
39
+ mkdir -p "$(dirname "$LOG_FILE")"
40
+
41
+ if ! command -v npm &>/dev/null; then
42
+ pkg install nodejs-lts -y &>>"$LOG_FILE"
43
+ fi
44
+
45
+ _install_snyk_npm || return 1
46
+ log_success "Snyk installed"
47
+ return 0
48
+ }
49
+
50
+ uninstall_snyk() {
51
+ if ! command -v snyk &>/dev/null; then
52
+ log_info "Snyk is not installed"
53
+ return 2
54
+ fi
55
+ log_info "Uninstalling Snyk..."
56
+ mkdir -p "$(dirname "$LOG_FILE")"
57
+
58
+ _uninstall_snyk_npm || return 1
59
+ log_success "Snyk uninstalled"
60
+ return 0
61
+ }
62
+
63
+ update_snyk() {
64
+ _check_update_needed "Snyk" "$(_get_installed_npm_version snyk)" "$(_get_remote_npm_version snyk)" _do_update_snyk
65
+ }
66
+
67
+ _do_update_snyk() {
68
+ npm update -g snyk &>>"$LOG_FILE" || return 1
69
+ return 0
70
+ }
71
+
72
+ reinstall_snyk() {
73
+ uninstall_snyk
74
+ install_snyk
75
+ }
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/version"
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env bash
2
+
3
+ import "@/utils/log"
4
+ import "@/utils/version"
5
+
6
+ LOG_FILE="$KARNEL_CACHE/install_dev.log"
7
+ ZORK_DATA_DIR="$HOME/.local/share/karnel-data/zork"
8
+
9
+ ZORK_URLS=(
10
+ "1:http://www.infocom-if.org/downloads/zork1.zip"
11
+ "2:http://www.infocom-if.org/downloads/zork2.zip"
12
+ "3:http://www.infocom-if.org/downloads/zork3.zip"
13
+ )
14
+
15
+ _install_zork_deps() {
16
+ loading "Installing dependencies" _install_zork_deps_impl
17
+ }
18
+
19
+ _install_zork_deps_impl() {
20
+ if ! command -v frotz &>/dev/null; then
21
+ if ! pkg install frotz -y &>>"$LOG_FILE"; then
22
+ log_error "Failed to install frotz"
23
+ return 1
24
+ fi
25
+ fi
26
+ if ! command -v unzip &>/dev/null; then
27
+ if ! pkg install unzip -y &>>"$LOG_FILE"; then
28
+ log_error "Failed to install unzip"
29
+ return 1
30
+ fi
31
+ fi
32
+ return 0
33
+ }
34
+
35
+ _download_zork_data() {
36
+ loading "Downloading Zork games" _download_zork_data_impl
37
+ }
38
+
39
+ _download_zork_data_impl() {
40
+ mkdir -p "$ZORK_DATA_DIR"
41
+
42
+ for entry in "${ZORK_URLS[@]}"; do
43
+ local num="${entry%%:*}"
44
+ local url="${entry#*:}"
45
+ local zip_file="$ZORK_DATA_DIR/zork${num}.zip"
46
+
47
+ if [ -f "$ZORK_DATA_DIR/DATA/ZORK${num}.DAT" ]; then
48
+ continue
49
+ fi
50
+
51
+ if ! curl -sSfL "$url" -o "$zip_file" 2>>"$LOG_FILE"; then
52
+ log_error "Failed to download Zork ${num}"
53
+ return 1
54
+ fi
55
+
56
+ if ! unzip -o "$zip_file" -d "$ZORK_DATA_DIR" 2>>"$LOG_FILE"; then
57
+ log_error "Failed to extract Zork ${num}"
58
+ return 1
59
+ fi
60
+
61
+ rm -f "$zip_file"
62
+ done
63
+
64
+ return 0
65
+ }
66
+
67
+ _create_zork_wrapper() {
68
+ local wrapper="$PREFIX/bin/zork"
69
+ cat > "$wrapper" << 'WRAPPER'
70
+ #!/usr/bin/env bash
71
+ ZORK_DIR="$HOME/.local/share/karnel-data/zork"
72
+ ROM_DIR="$ZORK_DIR/DATA"
73
+
74
+ if [ ! -d "$ROM_DIR" ]; then
75
+ echo "Zork data not found. Run: karnel install zork"
76
+ exit 1
77
+ fi
78
+
79
+ case "${1:-1}" in
80
+ 1|I|i) game="ZORK1.DAT" ;;
81
+ 2|II|ii) game="ZORK2.DAT" ;;
82
+ 3|III|iii) game="ZORK3.DAT" ;;
83
+ *) echo "Usage: zork [1|2|3] (default: 1)"; exit 1 ;;
84
+ esac
85
+
86
+ shift 2>/dev/null || true
87
+ exec frotz "$ROM_DIR/$game" "$@"
88
+ WRAPPER
89
+ chmod +x "$wrapper"
90
+ }
91
+
92
+ install_zork() {
93
+ if command -v zork &>/dev/null; then
94
+ log_info "Zork is already installed"
95
+ return 2
96
+ fi
97
+ log_info "Installing Zork..."
98
+
99
+ mkdir -p "$(dirname "$LOG_FILE")"
100
+
101
+ _install_zork_deps || return 1
102
+ _download_zork_data || return 1
103
+ _create_zork_wrapper || return 1
104
+ log_success "Zork installed"
105
+ return 0
106
+ }
107
+
108
+ uninstall_zork() {
109
+ if ! command -v zork &>/dev/null; then
110
+ log_info "Zork is not installed"
111
+ return 2
112
+ fi
113
+ log_info "Uninstalling Zork..."
114
+
115
+ rm -f "$PREFIX/bin/zork"
116
+ rm -rf "$ZORK_DATA_DIR"
117
+
118
+ log_success "Zork uninstalled"
119
+ return 0
120
+ }
121
+
122
+ update_zork() {
123
+ log_info "Updating Zork..."
124
+ rm -rf "$ZORK_DATA_DIR"
125
+ _download_zork_data || return 1
126
+ log_success "Zork updated"
127
+ return 0
128
+ }
129
+
130
+ reinstall_zork() {
131
+ uninstall_zork
132
+ install_zork
133
+ }
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/version"
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/version"
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
  unset LD_LIBRARY_PATH
3
3
  unset LD_PRELOAD
4
4
  NODE_GLIBC="$HOME/.local/share/karnel-data/node-glibc/bin/node"
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
  unset LD_LIBRARY_PATH
3
3
  unset LD_PRELOAD
4
4
  NODE_GLIBC="$HOME/.local/share/karnel-data/node-glibc/bin/node"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- KARNEL_VERSION="4.7.4"
3
+ KARNEL_VERSION="4.7.6"
4
4
 
5
5
  # -------------------------
6
6
  # Directorios del usuario
@@ -333,6 +333,76 @@ read_confirm() {
333
333
  done
334
334
  }
335
335
 
336
+ # --- Confirmación con default ---
337
+ # default="y" -> [Y/n] | default="n" -> [y/N]
338
+ # Retorna 0 si sí, 1 si no. VAR_NAME recibe "y" o "n"
339
+ read_confirm_default() {
340
+ local prompt="$1"
341
+ local default="$2"
342
+ local var="$3"
343
+ local _val
344
+
345
+ local show_default
346
+ if [[ "$default" == "y" ]]; then
347
+ show_default="${D_GREEN}Y${GRAY}/${D_RED}n${GRAY}"
348
+ else
349
+ show_default="${D_GREEN}y${GRAY}/${D_RED}N${GRAY}"
350
+ fi
351
+
352
+ while true; do
353
+ echo -e -n " ${GRAY}┌─${D_YELLOW} ${prompt} ${GRAY}[${show_default}${GRAY}]${D_NC}\n" >&2
354
+ echo -e -n " ${GRAY}└─${D_YELLOW}▶ ${D_NC}" >&2
355
+ read -rn1 _val
356
+ echo >&2
357
+ if [[ -z "$_val" ]]; then
358
+ _val="$default"
359
+ fi
360
+ case "${_val,,}" in
361
+ y)
362
+ read -r "$var" <<<"y"
363
+ return 0
364
+ ;;
365
+ n)
366
+ read -r "$var" <<<"n"
367
+ return 1
368
+ ;;
369
+ *) echo -e " ${RED}✖${D_NC} Reply ${D_GREEN}y${D_NC} o ${D_RED}n${D_NC}" >&2 ;;
370
+ esac
371
+ done
372
+ }
373
+
374
+ # --- Entrada multi-línea ---
375
+ read_multiline() {
376
+ local initial="$1"
377
+ local tmpfile
378
+ tmpfile=$(mktemp)
379
+
380
+ echo "$initial" >"$tmpfile"
381
+ echo >>"$tmpfile"
382
+
383
+ local cols
384
+ cols=$(tput cols 2>/dev/null || echo 80)
385
+ local w=$((cols - 6))
386
+ local bar
387
+ printf -v bar '%*s' "$w" ''
388
+
389
+ echo -e " ${GRAY}╭${bar// /─}╮${NC}" >&2
390
+ printf " ${GRAY}│${NC} ${D_CYAN}✎ Write your content${D_NC}%*s ${GRAY}│${NC}\n" $((w - 26)) "" >&2
391
+ printf " ${GRAY}│${NC} ${D_DIM}(Ctrl+D to finish, Ctrl+C to cancel)${D_NC}%*s ${GRAY}│${NC}\n" $((w - 40)) "" >&2
392
+ echo -e " ${GRAY}├${bar// /─}┤${NC}" >&2
393
+
394
+ local line
395
+ while IFS= read -r line; do
396
+ echo "$line" >>"$tmpfile"
397
+ done
398
+
399
+ echo >&2
400
+ echo -e " ${GRAY}╰${bar// /─}╯${NC}" >&2
401
+ echo -e " ${GRAY}${D_GREEN}✔ Content captured${D_NC}" >&2
402
+
403
+ echo "$tmpfile"
404
+ }
405
+
336
406
  # --- Selección de opciones ---
337
407
  # Uso: read_select "Prompt" VAR_NAME "Opción1" "Opción2" ...
338
408
  # VAR_NAME recibe el texto de la opción elegida
@@ -0,0 +1,34 @@
1
+ _batch_tool_action() {
2
+ local module="$1"
3
+ local action="$2"
4
+ shift 2
5
+ local -a tools=("$@")
6
+ local success_count=0
7
+ local failed_count=0
8
+
9
+ import "@/tools/$module/all"
10
+
11
+ for tool in "${tools[@]}"; do
12
+ local func_name="${action}_${tool//-/_}"
13
+ if declare -f "$func_name" &>/dev/null; then
14
+ "$func_name"
15
+ case $? in
16
+ 0) ((success_count++));;
17
+ 1) ((failed_count++));;
18
+ esac
19
+ else
20
+ log_warn "Unknown $module tool: $tool"
21
+ ((failed_count++))
22
+ fi
23
+ done
24
+
25
+ echo
26
+ if [[ $success_count -gt 0 ]]; then
27
+ log_success "$success_count tool(s) ${action}ed"
28
+ fi
29
+ if [[ $failed_count -gt 0 ]]; then
30
+ log_warn "$failed_count tool(s) failed to ${action}"
31
+ fi
32
+
33
+ return $failed_count
34
+ }
@@ -1,4 +1,4 @@
1
- #!/data/data/com.termux/files/usr/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  import "@/utils/log"
4
4
  import "@/utils/colors"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karnel-termux",
3
- "version": "0.0.4",
3
+ "version": "4.7.6",
4
4
  "description": "Modular Dev Environment for Termux — install languages, databases, AI agents, editors, and more with one command",
5
5
  "bin": {
6
6
  "karnel": "karnel/bin/karnel"
@@ -0,0 +1,28 @@
1
+ _karnel_completions() {
2
+ local cur prev words cword
3
+ _init_completion || return
4
+
5
+ local commands="backup brain cleanup doctor env help ia init install list open pg reinstall restore search show start status uninstall update upgrade version voice"
6
+ local modules="ai auto db deploy dev editor lang npm shell ui"
7
+
8
+ if [[ $cword -eq 1 ]]; then
9
+ COMPREPLY=($(compgen -W "$commands" -- "$cur"))
10
+ return
11
+ fi
12
+
13
+ case "${words[1]}" in
14
+ install|uninstall|update|reinstall|list|show)
15
+ if [[ $cword -eq 2 ]]; then
16
+ COMPREPLY=($(compgen -W "$modules" -- "$cur"))
17
+ fi
18
+ ;;
19
+ doctor)
20
+ COMPREPLY=($(compgen -W "--quick --fix" -- "$cur"))
21
+ ;;
22
+ restore)
23
+ COMPREPLY=($(compgen -f -- "$cur"))
24
+ ;;
25
+ esac
26
+ }
27
+
28
+ complete -F _karnel_completions karnel
@@ -0,0 +1,90 @@
1
+ #compdef karnel
2
+
3
+ _karnel_commands() {
4
+ local -a commands=(
5
+ 'backup:Backup tool manifest and configs'
6
+ 'brain:Second brain — save and search memories'
7
+ 'cleanup:Clean caches, logs, and temp files'
8
+ 'doctor:Diagnose and fix environment'
9
+ 'env:Manage environment variables'
10
+ 'help:Show help'
11
+ 'ia:AI agent manager'
12
+ 'init:Configure existing projects'
13
+ 'install:Install modules and packages'
14
+ 'list:List available tools in modules'
15
+ 'open:Open documentation in browser'
16
+ 'pg:PostgreSQL database manager'
17
+ 'reinstall:Uninstall + install modules'
18
+ 'restore:Restore from a backup'
19
+ 'search:Search tools and memories'
20
+ 'show:Show tool documentation'
21
+ 'start:Start services'
22
+ 'status:Quick system overview'
23
+ 'uninstall:Remove installed modules'
24
+ 'update:Update modules or framework'
25
+ 'upgrade:Upgrade Karnel framework'
26
+ 'version:Show version'
27
+ 'voice:Speech-to-agent'
28
+ )
29
+ _describe 'command' commands
30
+ }
31
+
32
+ _karnel_modules() {
33
+ local -a modules=(
34
+ 'ai:AI tools'
35
+ 'auto:Automation tools'
36
+ 'db:Databases'
37
+ 'deploy:Deployment CLIs'
38
+ 'dev:Development tools'
39
+ 'editor:Code editors'
40
+ 'lang:Programming languages'
41
+ 'npm:Node.js packages'
42
+ 'shell:ZSH shell plugins'
43
+ 'ui:Termux UI components'
44
+ )
45
+ _describe 'module' modules
46
+ }
47
+
48
+ _karnel_ai_tools() {
49
+ local -a tools=(
50
+ '--qwen-code:Qwen Code'
51
+ '--gemini-cli:Gemini CLI'
52
+ '--claude-code:Claude Code'
53
+ '--ollama:Ollama'
54
+ '--opencode:OpenCode'
55
+ '--codex:Codex CLI'
56
+ )
57
+ _describe 'tool' tools
58
+ }
59
+
60
+ _karnel() {
61
+ local curcontext="$curcontext" state line
62
+ typeset -A opt_args
63
+
64
+ _arguments \
65
+ '1: :->command' \
66
+ '*: :->args'
67
+
68
+ case $state in
69
+ command)
70
+ _karnel_commands
71
+ ;;
72
+ args)
73
+ case $words[2] in
74
+ install|uninstall|update|reinstall|list|show)
75
+ if [[ ${#words[@]} -eq 3 ]]; then
76
+ _karnel_modules
77
+ fi
78
+ ;;
79
+ doctor)
80
+ _arguments '--quick[Quick mode]' '--fix[Auto-fix]'
81
+ ;;
82
+ *)
83
+ _default
84
+ ;;
85
+ esac
86
+ ;;
87
+ esac
88
+ }
89
+
90
+ compdef _karnel karnel