cilok.js
Version:
AI-powered location toolkit CLI agent with intelligent search and free map alternatives
384 lines (302 loc) ⢠11.2 kB
Markdown
# š” Cilok - AI Location Toolkit
> **Smart CLI Agent for Intelligent Location Discovery**
Cilok adalah AI agent berbasis CLI yang menggunakan kecerdasan buatan untuk membantu pencarian lokasi, navigasi, dan eksplorasi tempat dengan dukungan multiple map services.
  
## ⨠Features
### š¤ AI-Powered Intelligence
- **Natural Language Processing** - Berbicara dengan AI dalam bahasa natural
- **Intelligent Retry System** - AI akan mencoba 3x dengan strategi berbeda jika lokasi tidak ditemukan
- **Creative Search** - AI akan mencari variasi nama, singkatan, dan alternatif lokasi
- **Contextual Responses** - Jawaban yang relevan dan informatif
### šŗļø Multi-Platform Map Integration
- **Free Services** (No API Key Required)
- ā
OpenStreetMap
- ā
Nominatim Geocoding
- ā
Overpass API
- ā
Open-Elevation
- **Premium Services** (Optional)
- š Google Maps API
- š Mapbox API
### š Location Capabilities
- **Location Search** - Cari detail lokasi dengan nama
- **Geocoding/Reverse Geocoding** - Convert alamat ā koordinat
- **Travel Time Calculation** - Hitung jarak dan estimasi waktu tempuh
- **Nearby Places** - Temukan tempat terdekat (hotel, restoran, dll)
- **QR Code Generation** - Generate QR code untuk navigasi
- **Multi-Map Links** - Link ke berbagai map services
## š Installation
### Global Installation
```bash
npm install -g cilok.js
```
### Local Development
```bash
git clone https://github.com/Cloud-Dark/cilok
cd cilok
npm install
npm link
```
## šÆ Quick Start
```bash
cilok
```
### First Run Setup
Pada penggunaan pertama, Cilok akan meminta konfigurasi:
**Required:**
- ā
**OpenRouter API Key** - Untuk AI engine
**Optional (akan menggunakan free alternatives jika kosong):**
- š Google Maps API Key
- š Mapbox API Key
### Example Interaction
```
š” Cilok > tampilkan detail lokasi mall ambasador indonesia
š¤ AI sedang berpikir keras mencari lokasi...
š Attempt 1/3: Searching with AI intelligence...
š¤ AI suggests searching for: mall ambasador Indonesia, PT mall ambasador Indonesia, mall ambasador Jakarta
ā
Found location: PT mall ambasador Indonesia
š Berhasil ditemukan setelah 2 percobaan!
š DETAIL LOKASI
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š¢ PT mall ambasador Indonesia
š® Jl. TB Simatupang No.26, Jakarta Selatan, DKI Jakarta
šÆ Koordinat: -6.2608, 106.7884
š·ļø Kategori: office, corporate
```
## š¬ Usage Examples
### Location Search
```bash
š” Cilok > tampilkan detail lokasi Monas
š” Cilok > dimana lokasi mall ambasador Indonesia?
š” Cilok > alamat lengkap Grand Indonesia
```
### Travel Planning
```bash
š” Cilok > dari Jakarta ke Bandung berapa jam?
š” Cilok > jarak dari Surabaya ke Malang?
š” Cilok > rute tercepat Johor Bahru ke Kuala Lumpur?
```
### Nearby Search
```bash
š” Cilok > hotel terdekat dari KLCC
š” Cilok > restoran halal di sekitar Orchard Road
š” Cilok > rumah sakit terdekat dari Thamrin
š” Cilok > bank di daerah Sudirman
```
### Coordinates
```bash
š” Cilok > koordinat dari Borobudur
š” Cilok > lokasi dari koordinat -6.2088, 106.8456
š” Cilok > convert alamat Plaza Indonesia ke koordinat
```
## š§ Commands
### System Commands
- `help` - Tampilkan bantuan
- `status` - Status layanan yang tersedia
- `debug` - Toggle debug mode
- `clear` - Bersihkan layar
- `exit` / `quit` - Keluar dari aplikasi
### Query Examples
**Berbagai cara bertanya yang didukung:**
- "Detail lokasi [nama tempat]"
- "Koordinat [alamat]"
- "Dari [asal] ke [tujuan] berapa jam?"
- "[jenis tempat] terdekat dari [lokasi]"
- "Hotel di daerah [area]"
- "Alamat lengkap [nama tempat]"
## š Configuration
### Environment Variables
```env
# Required - AI Engine
OPENROUTER_API_KEY=your_openrouter_api_key
# Optional - Premium Map Services
GOOGLE_MAPS_API_KEY=your_google_maps_key
MAPBOX_API_KEY=your_mapbox_key
# AI Model Selection
AI_MODEL=google/gemini-2.0-flash-exp:free
# Location Settings
DEFAULT_COUNTRY=ID
DEFAULT_LANGUAGE=id
USE_FREE_MAPS=true
```
### Supported AI Models
Via OpenRouter:
- `google/gemini-2.0-flash-exp:free` (default, gratis)
- `openai/gpt-4-turbo`
- `anthropic/claude-3-sonnet`
- `meta-llama/llama-3.1-8b-instruct:free`
- `mistral/mistral-7b-instruct:free`
## š§ How It Works
### Intelligent Search Flow
```
User Query ā AI Analysis ā Location Search
ā ā ā
Retry 1 Extract Names Not Found?
ā ā ā
Retry 2 Try Variations Still Not Found?
ā ā ā
Retry 3 Creative Search Suggest Alternatives
```
### AI Intelligence Features
1. **Query Understanding** - Memahami intent dari pertanyaan natural
2. **Name Variations** - Mencoba singkatan, nama lengkap, alternatif
3. **Context Learning** - Belajar dari kesalahan pencarian sebelumnya
4. **Fallback Suggestions** - Memberikan alternatif jika tidak ditemukan
## š± Output Features
### Rich Information Display
- š **Location Details** - Nama, alamat, koordinat
- šŗļø **Multiple Map Links** - OSM, Google, Bing, WikiMapia
- š± **QR Code** - Quick access ke maps
- šŖ **Nearby Places** - POI terdekat dengan jarak
- š **Travel Information** - Rute dan estimasi waktu
### Map Services Integration
```
Premium APIs Available:
ā Google Maps (detailed info, places, reviews)
ā Mapbox (custom styling, advanced routing)
Free Alternatives (always available):
ā OpenStreetMap (community-driven map data)
ā Nominatim (OSM geocoding service)
ā Overpass API (POI and nearby search)
ā Open-Elevation (elevation data)
```
## š ļø Development
### Project Structure
```
cilok/
āāā bin/
ā āāā cilok.js # CLI entry point
āāā src/
ā āāā cilok-agent.js # Main application logic
ā āāā services/
ā ā āāā ai-service.js # AI integration & retry logic
ā ā āāā location-service.js # Map services integration
ā ā āāā map-service.js # Map links & QR generation
ā āāā utils/
ā āāā free-maps.js # Free map services utilities
āāā package.json
āāā README.md
```
### Development Setup
```bash
# Clone repository
git clone https://github.com/Cloud-Dark/cilok
cd cilok
# Install dependencies
npm install
# Link for development
npm link
# Run
cilok
# Enable debug mode
export CILOK_DEBUG=true
cilok
```
### Testing
```bash
# Test specific functions
š” Cilok > debug # Enable debug mode
š” Cilok > test mall ambasador # Test location search
š” Cilok > status # Check service status
```
## š Advanced Features
### Intelligent Retry System
Cilok menggunakan AI untuk retry dengan strategi berbeda:
- **Attempt 1**: Pencarian normal dengan query asli
- **Attempt 2**: AI mencoba variasi nama dan singkatan
- **Attempt 3**: Pencarian kreatif dengan konteks dan alternatif
### Free Map Alternatives
Jika tidak ada premium API key:
- Otomatis menggunakan OpenStreetMap ecosystem
- Nominatim untuk geocoding
- Overpass API untuk nearby search
- Tetap mendapat informasi lengkap
### Natural Language Processing
- Memahami bahasa Indonesia natural
- Support berbagai format pertanyaan
- Contextual responses
- Conversational interaction
## š Performance
### Response Times
- **AI Processing**: ~2-3 detik
- **Location Search**: ~1-2 detik
- **Retry Attempts**: ~5-10 detik total
- **Map Generation**: <1 detik
### API Rate Limits
- **OpenRouter**: Tergantung plan
- **Google Maps**: 25,000 requests/day (free tier)
- **Nominatim**: 1 request/second
- **Overpass**: No strict limits
## š¤ Contributing
Kontribusi sangat diterima! Silakan:
1. Fork repository
2. Buat feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push ke branch (`git push origin feature/amazing-feature`)
5. Buat Pull Request
### Development Guidelines
- Gunakan ES6+ syntax
- Tambahkan error handling
- Update dokumentasi
- Test pada berbagai skenario
## š Troubleshooting
### Common Issues
**ā "OpenRouter API key not found"**
```bash
# Set API key in .env file
echo "OPENROUTER_API_KEY=your_key_here" >> .env
```
**ā "Location not found after 3 attempts"**
- Coba query dengan nama yang lebih spesifik
- Gunakan nama alternatif atau singkatan
- Periksa ejaan nama tempat
**ā "Service timeout"**
- Periksa koneksi internet
- Coba lagi beberapa saat
- Enable debug mode untuk detail error
### Debug Mode
```bash
š” Cilok > debug # Toggle debug mode
š” Cilok > status # Check service status
export CILOK_DEBUG=true # Enable via environment
```
## š Roadmap
### Version 2.0 (Coming Soon)
- [ ] **Route Planning** - Multi-point routing
- [ ] **Weather Integration** - Cuaca lokasi real-time
- [ ] **Traffic Information** - Data lalu lintas
- [ ] **Photo Integration** - Street View images
- [ ] **Business Hours** - Jam operasional tempat
- [ ] **Reviews & Ratings** - User reviews
- [ ] **Export Functions** - JSON/CSV export
- [ ] **History & Favorites** - Bookmark & riwayat
- [ ] **Multi-language** - English support
- [ ] **Voice Commands** - Speech-to-text
- [ ] **Offline Mode** - Cached data support
### Version 3.0 (Future)
- [ ] **Machine Learning** - Personalized recommendations
- [ ] **Real-time Collaboration** - Share locations
- [ ] **Augmented Reality** - AR navigation
- [ ] **IoT Integration** - Smart city data
- [ ] **API Endpoints** - REST API for developers
## š License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## šØāš» Author
**Cloud-Dark**
- GitHub: [@Cloud-Dark](https://github.com/Cloud-Dark)
- Repository: [cilok](https://github.com/Cloud-Dark/cilok)
## š Acknowledgments
- **OpenRouter** - AI model access
- **OpenStreetMap** - Free map data
- **Nominatim** - Geocoding services
- **Google Maps** - Premium location services
- **Mapbox** - Advanced mapping features
## š Support
Butuh bantuan?
- š [Report Issues](https://github.com/Cloud-Dark/cilok/issues)
- š¬ [Discussions](https://github.com/Cloud-Dark/cilok/discussions)
- š§ Contact: [Your Email]
---
<div align="center">
**Made with ā¤ļø in Indonesia**
[ā Star this project](https://github.com/Cloud-Dark/cilok) | [š“ Fork](https://github.com/Cloud-Dark/cilok/fork) | [š Issues](https://github.com/Cloud-Dark/cilok/issues)
</div>