Referensi Commands#
Semua perintah Lokio beserta opsi dan contoh penggunaannya.
lokio init#
Inisialisasi Lokio di project kamu. Jalankan sekali di awal.
lokio init
lokio init --enterprise <kode> # aktifkan Enterprise sekaligusYang dibuat:
lokio.yaml— metadata projectlokio.local.yaml— placeholder API key (auto-ditambahkan ke.gitignore)lokio/configs.yaml— template, check config, dan AI config (sudah terisi default)lokio/templates/— folder untuk file.lokiobeserta contoh template.gitignore—lokio.local.yamlotomatis ditambahkan
Enterprise flag (
--enterprise <kode>): Membuatlokio.yaml+lokio/configs.yamlminimal tanpa template. Jalankanlokio pullsetelah ini untuk menarik template dari Hub.
lokio doctor#
Diagnosa seluruh setup Lokio dan tampilkan status tiap komponen.
lokio doctorYang dicek:
| Section | Cek |
|---|---|
| Project Config | lokio.yaml ada dan valid |
| Templates & Config | lokio/configs.yaml ada, setiap file .lokio template tersedia, tidak ada parameter yang menimpa built-in helper |
| AI Integration | ai: section dikonfigurasi, API key tersedia (env/local), standards: terdefinisi |
| Security | lokio.local.yaml ada di .gitignore |
| Lock File | File di lokio.lock masih ada di disk, tidak ada output yang diklaim dua template |
Contoh output:
Project Config
✓ lokio.yaml project: my-app v2.0.14
Templates & Config
✓ lokio/configs.yaml 2 template(s)
✓ template: service lokio/templates/service.lokio
✗ template: screen file missing: lokio/templates/screen.lokio
⚠ check config not configured
AI Integration
✓ AI config provider: gemini, model: gemini-2.0-flash
✗ AI api_key not set — add api_key to lokio.local.yaml
Security
✓ .gitignore lokio.local.yaml is listed
Lock File
✓ lokio.lock 3 generation(s) tracked, all files present
Status:
✓OK⚠Warning — bisa jalan tapi perlu perhatian✗Error — perlu diperbaiki–Skip — komponen belum dikonfigurasi
lokio add / lokio a#
Membuat template baru secara interaktif.
lokio add
lokio add service # langsung isi nama template
lokio add screen --multi # langsung multi-file mode
lokio a api -m # alias + flag pendekAlur:
- Nama template
- Deskripsi template
- Single-file atau multi-file?
- Output path (di mana file hasil generate disimpan)
- Blueprint filename (nama file
.lokio) - Parameter tambahan (opsional)
lokio edit / lokio e#
Edit konfigurasi template yang sudah ada (bukan isi .lokio-nya, tapi metadata di configs.yaml).
lokio edit service
lokio e screenPilihan edit:
- Description
- Path & Output (single-file) atau Files (multi-file)
- Parameters — tambah, edit, atau hapus parameter
- Convert single ↔ multi-file
Untuk mengedit isi template (
.lokiofile), buka file-nya langsung di editor.
lokio remove / lokio rm#
Hapus template dari configs.yaml.
lokio remove service
lokio rm screenKonfirmasi akan ditanya apakah file
.lokioikut dihapus.
lokio gen / lokio g#
Generate kode dari template.
# Interaktif — pilih template, isi semua parameter satu per satu
lokio gen
lokio g
# Tentukan template
lokio gen service
lokio g screen
# Tentukan template + parameter pertama (name) sekaligus
lokio gen service UserProfile
lokio g screen Home
# Re-generate satu file (perbarui file dari template terbaru)
lokio gen --update src/services/UserService.ts
# Batch generate dari file JSON
lokio gen service --batch entities.jsonParameter collision: Jika nama parameter kamu sama dengan built-in helper (
camelCase,plural, dll.), Lokio akan menampilkan warning karena helper tersebut akan ditimpa.
--update <file>#
Re-generate satu file yang sudah pernah di-generate sebelumnya. Menggunakan 3-way merge sehingga perubahan manual kamu tidak hilang.
lokio gen --update src/services/UserService.ts--batch <file>#
Generate banyak file sekaligus dari satu file JSON. File JSON harus berupa array objek parameter.
lokio gen service --batch entities.jsonContoh entities.json:
[
{ "name": "User" },
{ "name": "Order", "type": "repository" },
{ "name": "Product" }
]lokio diff#
Preview apa yang akan berubah kalau lokio sync dijalankan — tanpa menulis apapun.
lokio diffContoh output:
✓ src/services/UserService.ts — no changes
~ src/services/OrderService.ts — +3 -1 (your edits preserved)
✗ src/services/TokenService.ts — conflict (resolve markers manually)
2 changed, 1 up to date — run lokio sync to apply
lokio sync#
Terapkan perubahan template ke file yang sudah di-generate. Menggunakan 3-way merge untuk mempertahankan perubahan manual.
lokio syncAlur:
- Scan semua file di
lokio.lock - Re-render setiap file dari template terbaru
- Bandingkan dengan versi git (HEAD) sebagai base merge
- Tampilkan ringkasan perubahan
- Tanya: Apply all / Review each / Cancel
Jenis status:
| Ikon | Status | Artinya |
|---|---|---|
✓ | up to date | Tidak ada perubahan |
~ | changed | Ada perubahan, bisa di-apply |
~ | your edits preserved | Perubahan template diterapkan, edit manualmu aman |
✗ | conflict | Kamu dan template keduanya mengubah baris yang sama |
lokio check#
Validasi file-file di repo apakah sudah sesuai dengan aturan struktural yang didefinisikan di template.
lokio checkBerbeda dengan
lokio diff/lokio sync:checktidak peduli apakah file pernah di-generate dengan Lokio atau tidak. Ia scan seluruh repo dan cocokkan file berdasarkan pola output path dari template.
Aturan bisa didefinisikan dengan anotasi di file .lokio:
<%# @lokio required danger "Harus ada @Injectable()" @Injectable %>
<%# @lokio forbidden warning "Jangan pakai any" : any %>Konfigurasi di lokio/configs.yaml:
check:
danger_mode: block # "block" = exit code 1 (cocok pre-commit hook)
# "warn" = hanya tampilkan, tidak exit 1
# templates: # opsional — omit untuk check semua template
# - service
# - controllerSebagai pre-commit hook:
# .git/hooks/pre-commit
#!/bin/sh
lokio checklokio ai#
Validasi standar tim menggunakan AI. AI menganalisis file di repo dan membandingkan dengan standards yang kamu definisikan.
lokio aiSetup pertama kali (jika belum dikonfigurasi), wizard interaktif akan muncul:
⚠ AI config not found in lokio/configs.yaml.
? Set up AI config now? › Yes
◇ Select AI provider:
│ Gemini ← free tier
◇ Model name:
│ gemini-2.0-flash
◇ Add sample standards (unit-test, no-console-log)?
│ Yes
✓ AI config written to lokio/configs.yaml
✓ Created lokio.local.yaml (gitignored)
╭─ Next step ───────────────────────────────────╮
│ Fill in your API key in lokio.local.yaml: │
│ │
│ ai: │
│ api_key: YOUR_KEY_HERE │
│ │
│ Then run 'lokio ai' again. │
╰───────────────────────────────────────────────╯
Konfigurasi di lokio/configs.yaml (aman di-commit — tidak mengandung secret):
ai:
provider: gemini # openai | anthropic | gemini | ollama | openrouter
model: gemini-2.0-flash
standards:
- id: unit-test
description: "Setiap service harus punya file unit test"
severity: danger # danger | warning
- id: no-console-log
description: "Tidak ada console.log di kode produksi"
severity: warningAPI key di lokio.local.yaml (gitignored — jangan commit):
# lokio.local.yaml
ai:
api_key: YOUR_API_KEY_HEREAtau gunakan environment variable:
export LOKIO_AI_API_KEY=your-keyProvider yang didukung:
| Provider | Model rekomendasi | Catatan |
|---|---|---|
gemini | gemini-2.0-flash | Free tier tersedia |
openai | gpt-4o-mini | Terjangkau |
anthropic | claude-haiku-4-5-20251001 | — |
openrouter | meta-llama/llama-3.3-70b-instruct:free | Model gratis tersedia |
ollama | llama3.2 | Lokal / VPS, tidak butuh API key |
Contoh output:
✓ unit-test PASS All services have corresponding test files
✗ no-console-log FAIL Found console.log in production code
└─ src/services/UserService.ts
──────────────────────────────────────────────────────────
Summary: 1 pass / 1 fail — 2 standard(s) checked
✗ Danger standards failed. Fix before merging.
lokio run#
Jalankan serangkaian perintah shell (steps) yang sudah didefinisikan di lokio/configs.yaml.
lokio run --id <id>
# Contoh
lokio run --id install-docker
lokio run --id setup-vmKonfigurasi di lokio/configs.yaml:
runs:
- id: install-docker
description: Install Docker & Docker Compose (Ubuntu/Debian)
steps:
- name: Update apt
run: sudo apt update -y
- name: Install Docker Engine
run: sudo apt install -y docker-ce docker-ce-cli containerd.io
- name: Verify Docker
run: docker --versionField step:
| Field | Wajib | Keterangan |
|---|---|---|
name | ya | Label yang ditampilkan saat step berjalan |
run | ya | Perintah shell yang dieksekusi |
continue_on_error | tidak | Jika true, lanjut ke step berikutnya meski step ini gagal |
Perintah multi-baris menggunakan YAML block scalar (|):
- name: Add Docker GPG key
run: |
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgcontinue_on_error — berguna saat sebuah step boleh gagal tanpa menghentikan proses (misalnya container sudah berjalan):
- name: Run Redis container
run: docker run -d --name redis -p 6379:6379 redis:7-alpine
continue_on_error: trueContoh output:
Running: install-docker
● Update apt
✓ Update apt
● Install Docker Engine
✓ Install Docker Engine
● Verify Docker
✓ Verify Docker
✓ Done — 3 step(s) completed
lokio pull#
Tarik template dari Enterprise Hub (butuh aktivasi Enterprise).
lokio pulllokio --help#
Tampilkan daftar semua perintah.
lokio --help
lokio gen --help # help untuk command tertentulokio --version / lokio -V#
Tampilkan versi Lokio yang terinstall.
lokio -V