Animated Circular Progress Bar0
Font.Lokio
CLI

Commands

Dokumentasi lengkap semua commands yang tersedia di Lokio CLI


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 sekaligus

Yang dibuat:

  • lokio.yaml — metadata project
  • lokio.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 .lokio beserta contoh template
  • .gitignorelokio.local.yaml otomatis ditambahkan

Enterprise flag (--enterprise <kode>): Membuat lokio.yaml + lokio/configs.yaml minimal tanpa template. Jalankan lokio pull setelah ini untuk menarik template dari Hub.


lokio doctor#

Diagnosa seluruh setup Lokio dan tampilkan status tiap komponen.

lokio doctor

Yang dicek:

SectionCek
Project Configlokio.yaml ada dan valid
Templates & Configlokio/configs.yaml ada, setiap file .lokio template tersedia, tidak ada parameter yang menimpa built-in helper
AI Integrationai: section dikonfigurasi, API key tersedia (env/local), standards: terdefinisi
Securitylokio.local.yaml ada di .gitignore
Lock FileFile 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 pendek

Alur:

  1. Nama template
  2. Deskripsi template
  3. Single-file atau multi-file?
  4. Output path (di mana file hasil generate disimpan)
  5. Blueprint filename (nama file .lokio)
  6. 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 screen

Pilihan edit:

  • Description
  • Path & Output (single-file) atau Files (multi-file)
  • Parameters — tambah, edit, atau hapus parameter
  • Convert single ↔ multi-file

Untuk mengedit isi template (.lokio file), buka file-nya langsung di editor.


lokio remove / lokio rm#

Hapus template dari configs.yaml.

lokio remove service
lokio rm screen

Konfirmasi akan ditanya apakah file .lokio ikut 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.json

Parameter 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.json

Contoh 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 diff

Contoh 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 sync

Alur:

  1. Scan semua file di lokio.lock
  2. Re-render setiap file dari template terbaru
  3. Bandingkan dengan versi git (HEAD) sebagai base merge
  4. Tampilkan ringkasan perubahan
  5. Tanya: Apply all / Review each / Cancel

Jenis status:

IkonStatusArtinya
up to dateTidak ada perubahan
~changedAda perubahan, bisa di-apply
~your edits preservedPerubahan template diterapkan, edit manualmu aman
conflictKamu 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 check

Berbeda dengan lokio diff/lokio sync: check tidak 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
  #   - controller

Sebagai pre-commit hook:

# .git/hooks/pre-commit
#!/bin/sh
lokio check

lokio ai#

Validasi standar tim menggunakan AI. AI menganalisis file di repo dan membandingkan dengan standards yang kamu definisikan.

lokio ai

Setup 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: warning

API key di lokio.local.yaml (gitignored — jangan commit):

# lokio.local.yaml
ai:
  api_key: YOUR_API_KEY_HERE

Atau gunakan environment variable:

export LOKIO_AI_API_KEY=your-key

Provider yang didukung:

ProviderModel rekomendasiCatatan
geminigemini-2.0-flashFree tier tersedia
openaigpt-4o-miniTerjangkau
anthropicclaude-haiku-4-5-20251001
openroutermeta-llama/llama-3.3-70b-instruct:freeModel gratis tersedia
ollamallama3.2Lokal / 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-vm

Konfigurasi 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 --version

Field step:

FieldWajibKeterangan
nameyaLabel yang ditampilkan saat step berjalan
runyaPerintah shell yang dieksekusi
continue_on_errortidakJika 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.gpg

continue_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: true

Contoh 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 pull

lokio --help#

Tampilkan daftar semua perintah.

lokio --help
lokio gen --help   # help untuk command tertentu

lokio --version / lokio -V#

Tampilkan versi Lokio yang terinstall.

lokio -V