๐ŸŽฏ Fitur OpsTerm โ€” Lengkap

Dokumen ini menjelaskan semua fitur yang tersedia di OpsTerm, lengkap dengan contoh penggunaan dan penjelasan.


๐Ÿ“‹ Daftar Semua Fitur

# Fitur CLI Command Kategori
1 ๐Ÿค– AI Chat ai <prompt> Core
2 ๐Ÿ”‘ Smart SSH ai ssh <server> Core
3 ๐Ÿ”— Multi-hop SSH ai ssh <srv> --via <proxy> Core
4 ๐Ÿ“ SCP File Transfer ai scp <src> <dst> Core
5 โšก Workflow ai run <name> Core
6 ๐Ÿ” Vault ai vault Core
7 ๐Ÿ”— Pipe Mode cmd \| ai <prompt> Core
8 ๐Ÿ’ป Shell Integration ai explain-last Shell
9 โŒจ๏ธ Tab Completion ai completion bash\|zsh Utility
10 ๐Ÿ› ๏ธ Server Manager ai servers Management
11 ๐Ÿ“‹ Workflow Manager ai workflows Management
12 โš™๏ธ Config Manager ai config Management
13 ๐Ÿ“– History ai history Management
14 ๐Ÿš€ Init ai init Setup

1๏ธโƒฃ ๐Ÿค– AI Chat

Bertanya apa pun ke AI langsung dari terminal.

# Minta command shell
ai cari file log lebih dari 1GB
# Output: $ find /var/log -type f -size +1G

# Minta penjelasan
ai explain apa itu reverse proxy

# Generate docker compose
ai buat docker compose untuk nginx + postgres

# Tanya general
ai how to check disk usage in linux

Cara kerja:
1. Load config (API key, model, URL dari config.yaml)
2. Build prompt + system message
3. HTTP POST ke AI provider (OpenAI-compatible API)
4. Parse response JSON
5. Print ke terminal
6. Simpan ke history (SQLite)
7. Deteksi $ prefix โ†’ offer auto-exec

Provider support: DeepSeek, OpenAI, OpenRouter, Ollama, vLLM, atau apapun yang OpenAI-compatible.


2๏ธโƒฃ ๐Ÿ”‘ Smart SSH

SSH ke server tanpa perlu hafal IP address.

# Langsung connect
ai ssh vps-utama

# Fuzzy match โ€” cukup sebagian nama
ai ssh vps

# Lihat daftar server dulu
ai servers list

Konfigurasi server di ~/.ai-workflows/servers.yaml:

servers:
  vps-utama:
    host: "43.157.204.199"
    user: "ubuntu"
    port: 22
    key: "~/.ssh/id_ed25519"
    desc: "Tencent Cloud VPS utama"

Yang bisa di-configure:
- host โ€” IP atau domain
- user โ€” SSH username
- port โ€” port SSH (default: 22)
- key โ€” path ke private key
- proxy โ€” jump host (lihat fitur multi-hop)
- desc โ€” deskripsi


3๏ธโƒฃ ๐Ÿ”— Multi-hop SSH

SSH ke server internal yang cuma bisa diakses lewat jump host/bastion.

# Via CLI (per-call)
ai ssh internal-server --via bastion

# Via config (permanen)
ai ssh internal-server  # otomatis lewat bastion

Config permanen di servers.yaml:

servers:
  bastion:
    host: "123.123.123.123"
    user: "ubuntu"
    key: "~/.ssh/id_ed25519"

  internal-server:
    host: "10.0.0.5"
    user: "ubuntu"
    key: "~/.ssh/internal-key"
    proxy: "bastion"           # <-- otomatis lewat bastion

Cara kerja:
- Pake SSH -J (ProxyJump) flag
- Chain bisa panjang: ssh -J jump1,jump2 server
- Proxy server di-resolve dari servers.yaml juga


4๏ธโƒฃ ๐Ÿ“ SCP File Transfer

Upload/download file antara lokal dan server โ€” pakai syntax server:path.

# Upload dari lokal ke server
ai scp ./config.yaml vps-utama:/home/ubuntu/

# Download dari server ke lokal
ai scp vps-utama:logs/app.log .

# Lewat jump host
ai scp file.txt internal-server:/tmp/ --via bastion

Cara kerja:
- Parse server:path โ†’ resolve ke user@host:path
- Sama kaya SSH: support proxy jump, key file, custom port
- Pake scp system command via subprocess


5๏ธโƒฃ โšก Workflow

Multi-step automation yang jalanin beberapa command secara berurutan.

# Jalanin workflow
ai run deploy-app

# Lihat daftar workflow
ai workflows list

Contoh workflow:

workflows:
  deploy-full:
    desc: "Full deployment dengan file transfer"
    steps:
      - scp: "./docker-compose.yml"
        to: "/home/ubuntu/app/docker-compose.yml"
        ssh: vps-utama
        desc: "Upload compose file"
      - ssh: vps-utama
        command: "cd /home/ubuntu/app && docker compose pull && docker compose up -d"
        desc: "Pull images & restart"
      - command: "echo 'โœ… Deploy selesai!'"
        desc: "Notifikasi"

Step types:
| Type | Format | Fungsi |
|------|--------|--------|
| ssh | ssh: <server> + command: | Jalanin command di server remote |
| scp | scp: <src> + to: <dst> + ssh: <server> | Transfer file ke server |
| command | command: | Jalanin command lokal |
| confirm | confirm: true | Minta konfirmasi user sebelum lanjut |
| wait | wait: <detik> | Tunggu beberapa detik |


6๏ธโƒฃ ๐Ÿ” Vault โ€” Encrypted Credentials

Nyimpen credentials (API key, password, token) secara terenkripsi.

# Init vault (set master password)
ai vault init

# Simpan credential
ai vault set db_password "supersecret"
ai vault set github_token "ghp_..."

# Ambil credential
ai vault get db_password    # Output: supersecret

# List keys
ai vault list

# Hapus key
ai vault rm db_password

# Kunci vault (clear password dari memory)
ai vault lock

Teknis:
- Encryption: AES-128-CBC via cryptography.fernet.Fernet
- Key derivation: PBKDF2-HMAC-SHA256, 600.000 iterasi
- Master password: dari OPSTERM_VAULT_PASSWORD env atau prompt
- Fallback: kalo cryptography gak terinstall โ†’ HMAC + XOR (kurang aman)
- Data: encrypted JSON di ~/.ai-workflows/vault.json


7๏ธโƒฃ ๐Ÿ”— Pipe Mode

Kirim output command ke AI untuk dianalisa.

# Explain output
kubectl get pods | ai "ada yang error?"
docker logs webapp --tail 100 | ai "analisa error ini"
free -h | ai "apakah memory cukup?"
netstat -tlnp | ai "port apa aja yang terbuka?"

# Pipe tanpa prompt spesifik
df -h | ai
# AI otomatis: "Jelaskan output ini"

Cara kerja:
1. Deteksi stdin (sys.stdin.isatty() == False)
2. Baca stdin โ†’ simpen sebagai stdin_data
3. Build prompt: "Output dari command:\n\n{stdin_data}\n\nPertanyaan: {prompt}"
4. Kirim ke AI โ†’ print response


8๏ธโƒฃ ๐Ÿ’ป Shell Integration (Zsh Plugin)

Integrasi dengan Zsh shell untuk ngeliat & explain output command terakhir.

# Load di .zshrc
source ~/opsterm/zsh/opsterm.plugin.zsh

# Lihat output command terakhir
ai last

# Explain output command terakhir pake AI
ai explain-last

Fitur:
- ai-last โ€” alias ke ai last
- ai-explain โ€” alias ke ai explain-last
- ai-ti โ€” AI + Terminal Integration: tanya AI, extract command, auto-execute

Cara kerja:
- Zsh preexec hook โ†’ simpen command sebelum jalan
- Output command terakhir disimpan di ~/.ai-workflows/last_output.txt
- ai explain-last โ†’ baca file โ†’ kirim ke AI


9๏ธโƒฃ โŒจ๏ธ Tab Completion

Auto-complete buat bash dan zsh โ€” ga perlu hafal nama server/workflow.

# Bash
source <(ai completion bash)

# Zsh
source <(ai completion zsh)

# Atau permanen:
echo 'source <(ai completion bash)' >> ~/.bashrc
echo 'source <(ai completion zsh)' >> ~/.zshrc

Yang bisa di-complete:
| Context | Completion |
|---------|-----------|
| ai [Tab] | Semua subcommand |
| ai ssh [Tab] | Nama server |
| ai run [Tab] | Nama workflow |
| ai scp [Tab] | server: prefix |
| ai servers [Tab] | add, edit, rm, list |
| ai vault [Tab] | init, set, get, list, rm, lock |
| ai --via [Tab] | Nama proxy server |


๐Ÿ”Ÿ ๐Ÿ› ๏ธ Server Manager

CRUD untuk server โ€” simpan, edit, hapus konfigurasi server.

# Lihat semua server (dengan kolom PROXY)
ai servers list
# Output:
# NAMA       HOST            USER    PORT  PROXY  DESKRIPSI
# vps-utama  43.157.204.199  ubuntu  22    โ€”      Tencent Cloud VPS

# Tambah server baru (interaktif)
ai servers add

# Edit server
ai servers edit vps-utama

# Hapus server
ai servers rm vps-utama

Data disimpan di ~/.ai-workflows/servers.yaml.


1๏ธโƒฃ1๏ธโƒฃ ๐Ÿ“‹ Workflow Manager

CRUD untuk workflow โ€” simpan, edit, hapus workflow.

# Lihat semua workflow
ai workflows list

# Tambah workflow baru (interaktif)
ai workflows add

# Edit workflow (buka editor)
ai workflows edit deploy-app

# Hapus workflow
ai workflows rm deploy-app

Data disimpan di ~/.ai-workflows/workflows.yaml.


1๏ธโƒฃ2๏ธโƒฃ โš™๏ธ Config Manager

Lihat dan set konfigurasi OpsTerm.

# Lihat semua config
ai config list

# Set nilai
ai config set ai.model deepseek-chat
ai config set ai.api_url https://api.deepseek.com/v1/chat/completions
ai config set ai.temperature 0.3
ai config set shell.confirm_before_exec true

# Get nilai spesifik
ai config get ai.model

Data disimpan di ~/.ai-workflows/config.yaml.


1๏ธโƒฃ3๏ธโƒฃ ๐Ÿ“– History

Riwayat semua command yang pernah dijalanin.

# Lihat 20 riwayat terakhir
ai history

# Lihat 50 riwayat terakhir
ai history 50

Output:

  [1] ๐Ÿค– 2026-05-24 15:30 [ai] how to check disk usage
  [2] ๐Ÿ”‘ 2026-05-24 15:35 [ssh] vps-utama
  [3] โšก 2026-05-24 15:40 [workflow] deploy-app
  [4] ๐Ÿ”— 2026-05-24 15:45 [pipe] docker ps | ai error

Ikon mode:
| Ikon | Mode |
|------|------|
| ๐Ÿค– | AI chat |
| ๐Ÿ”‘ | SSH |
| โšก | Workflow |
| ๐Ÿ”— | Pipe mode |
| ๐Ÿ’ป | Shell command |
| ๐Ÿ“ | SCP transfer |
| ๐Ÿ” | Vault |

Data disimpan di SQLite: ~/.ai-workflows/history.db.


1๏ธโƒฃ4๏ธโƒฃ ๐Ÿš€ Init

Setup awal โ€” bikin file konfigurasi default.

ai init

Yang dibuat:
- ~/.ai-workflows/config.yaml โ€” template AI provider
- ~/.ai-workflows/servers.yaml โ€” contoh server
- ~/.ai-workflows/workflows.yaml โ€” contoh workflow


๐ŸŽฏ Use Case Matrix

Yang Mau Dilakuin Command
SSH ke server ai ssh vps-utama
SSH lewat bastion ai ssh internal --via bastion
Upload file ai scp file.txt server:/path/
Download file ai scp server:log.txt .
Deploy app ai run deploy-app
Cek server health ai run cek-server
Tanya command ai how to check disk
Explain error docker logs -n50 \| ai "error?"
Explain last command ai explain-last
Simpan password ai vault set db_pass
Ambil password ai vault get db_pass
Auto-complete ai [Tab]
Lihat riwayat ai history
Setup dari awal ai init

๐Ÿ”œ Fitur Mendatang (Roadmap)