sarangai-cli 1.0.9 → 1.0.11
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.
- package/README.md +34 -70
- package/dist/index.js +39 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,104 +1,68 @@
|
|
|
1
1
|
# SarangAI CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Gateway AI Coding Workspace interaktif langsung dari terminal Anda, didukung oleh model-model reasoning & coding terbaik dunia (Anthropic, OpenAI, DeepSeek, Alibaba, Google, Meta).
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Fitur Utama
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
- **Interactive Terminal Workspace (TUI)**: Antarmuka terminal interaktif modern berbasis full-screen alternate buffer tanpa flicker.
|
|
10
|
+
- **Top Coding Models (1 Brand = 1 Flagship)**: Dikurasi khusus untuk programming, arsitektur sistem, dan debugging mendalam:
|
|
11
|
+
- Claude 3.7 Sonnet (Anthropic) - Architecture & Agentic coding
|
|
12
|
+
- GPT-4o (OpenAI) - Fast full-stack & complex logic
|
|
13
|
+
- DeepSeek-R1 (DeepSeek) - Deep reasoning & hard algorithms
|
|
14
|
+
- Qwen 2.5 Coder 32B (Alibaba) - Multi-language syntax specialist
|
|
15
|
+
- Gemini 2.5 Flash (Google) - 1M context & full repo analysis
|
|
16
|
+
- Llama 3.3 70B (Meta) - Robust open-source coding engine
|
|
17
|
+
- **Real-Time Streaming**: Output kode dan respons AI mengalir seketika (zero-latency stream).
|
|
18
|
+
- **Auto-Auth via Browser**: Login cepat dan aman tanpa perlu input API Key manual.
|
|
19
|
+
- **Credit & Tier Monitoring**: Pantau sisa saldo credit secara live langsung di dalam terminal.
|
|
14
20
|
|
|
15
21
|
---
|
|
16
22
|
|
|
17
23
|
## Instalasi
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
Pastikan Node.js (>= 18) telah terpasang, lalu instal paket secara global:
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
npm install -g sarangai-cli
|
|
23
|
-
```
|
|
27
|
+
npm install -g sarangai-cli@latest
|
|
24
28
|
|
|
25
29
|
---
|
|
26
30
|
|
|
27
|
-
##
|
|
31
|
+
## Memulai Workspace Interaktif
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
Dapatkan API Key dari dashboard akun SarangAI Anda, lalu hubungkan ke CLI:
|
|
33
|
+
Cukup jalankan satu perintah:
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
sarang login
|
|
34
|
-
```
|
|
35
|
+
sarang
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
Terminal akan otomatis menampilkan modal seleksi model coding, ringkasan saldo akun, dan opsi masuk ke ruang kerja (Workspace).
|
|
37
38
|
|
|
38
|
-
###
|
|
39
|
-
|
|
39
|
+
### Navigasi Keyboard:
|
|
40
|
+
- [↑/↓] (Panah) : Navigasi antar opsi dan pilihan model.
|
|
41
|
+
- [Enter / Space] : Konfirmasi pilihan / Masuk ke Workspace.
|
|
42
|
+
- [c] : Salin tautan dashboard referal ke clipboard.
|
|
43
|
+
- [Esc] : Mengakhiri sesi aktif di Workspace dan kembali ke menu seleksi.
|
|
44
|
+
- [q] : Keluar dari SarangAI CLI.
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
sarang balance
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### 3. Jelajahi dan Filter Model
|
|
46
|
-
Melihat seluruh model yang tersedia:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
sarang models
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Menyaring model berdasarkan kata kunci:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
sarang models -s deepseek
|
|
56
|
-
sarang models -s claude
|
|
57
|
-
sarang models -s free
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 4. Ganti Default Model
|
|
61
|
-
Tentukan model yang selalu digunakan secara otomatis:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
sarang set-model minimax/minimax-m2.7
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 5. Chat & Streaming
|
|
68
|
-
Mengirim prompt langsung:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
sarang chat "Jelaskan konsep index di database PostgreSQL."
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Menggunakan model tertentu tanpa mengubah default:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
sarang chat -m anthropic/claude-sonnet-4 "Buatkan regex validasi nomor telepon Indonesia."
|
|
78
|
-
```
|
|
46
|
+
---
|
|
79
47
|
|
|
80
|
-
|
|
81
|
-
Membaca input langsung dari terminal atau berkas kode:
|
|
48
|
+
## Autentikasi Otomatis
|
|
82
49
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
Jika pertama kali menggunakan CLI:
|
|
51
|
+
1. Jalankan `sarang`.
|
|
52
|
+
2. CLI akan mengenerate tautan otorisasi unik dan otomatis menyalinnya ke clipboard.
|
|
53
|
+
3. Buka tautan tersebut di browser untuk mengizinkan sesi.
|
|
54
|
+
4. Terminal akan otomatis mendeteksi sesi dan menyimpan token ke `~/.sarangairc`.
|
|
87
55
|
|
|
88
56
|
---
|
|
89
57
|
|
|
90
58
|
## Konfigurasi Gateway
|
|
91
59
|
|
|
92
|
-
Secara default, CLI
|
|
93
|
-
|
|
94
|
-
Untuk gateway self-hosted atau pengujian lokal:
|
|
60
|
+
Secara default, CLI terhubung ke `[https://idshop.or.id](https://idshop.or.id)`. Jika Anda menggunakan custom gateway atau development server lokal:
|
|
95
61
|
|
|
96
|
-
|
|
97
|
-
export SARANGAI_BASE_URL="http://localhost:3001"
|
|
98
|
-
```
|
|
62
|
+
export SARANGAI_BASE_URL="http://localhost:3001"
|
|
99
63
|
|
|
100
64
|
---
|
|
101
65
|
|
|
102
66
|
## Lisensi
|
|
103
67
|
|
|
104
|
-
MIT
|
|
68
|
+
MIT License (c) SarangAI
|
package/dist/index.js
CHANGED
|
@@ -35,12 +35,12 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "sarangai-cli",
|
|
38
|
-
version: "1.0.
|
|
38
|
+
version: "1.0.11",
|
|
39
39
|
description: "CLI resmi SarangAI \u2014 Gateway multi-model AI langsung dari terminal Anda",
|
|
40
40
|
main: "dist/index.js",
|
|
41
41
|
bin: {
|
|
42
42
|
sarang: "dist/index.js",
|
|
43
|
-
sarangai: "dist/index.
|
|
43
|
+
sarangai: "dist/index.js"
|
|
44
44
|
},
|
|
45
45
|
files: [
|
|
46
46
|
"dist"
|
|
@@ -131,8 +131,8 @@ var greenDot = import_chalk.default.hex("#4ade80");
|
|
|
131
131
|
var grayMuted = import_chalk.default.hex("#94a3b8");
|
|
132
132
|
var CODING_MODELS = [
|
|
133
133
|
{
|
|
134
|
-
id: "anthropic/claude-
|
|
135
|
-
name: "Claude
|
|
134
|
+
id: "anthropic/claude-sonnet-4.6",
|
|
135
|
+
name: "Claude Sonnet 4.6",
|
|
136
136
|
desc: "Anthropic \u2022 Best coding & agentic workflow",
|
|
137
137
|
rate: "12,000 Credits/hr"
|
|
138
138
|
},
|
|
@@ -183,20 +183,20 @@ function copyToClipboard(text) {
|
|
|
183
183
|
}
|
|
184
184
|
async function fetchUserMeta(baseUrl2, apiKey) {
|
|
185
185
|
try {
|
|
186
|
-
const res = await fetch(`${baseUrl2}/api/
|
|
186
|
+
const res = await fetch(`${baseUrl2}/api/gateway/v1/balance`, {
|
|
187
187
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
188
188
|
});
|
|
189
189
|
if (res.ok) {
|
|
190
190
|
const d = await res.json();
|
|
191
191
|
return {
|
|
192
|
-
balance: d.balance ??
|
|
192
|
+
balance: d.balance ?? 0,
|
|
193
193
|
tier: d.tier || "DEVELOPER",
|
|
194
|
-
accountId: d.accountId
|
|
194
|
+
accountId: d.accountId ? `SA-${d.accountId}` : "SA-\u2014"
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
} catch {
|
|
198
198
|
}
|
|
199
|
-
return { balance:
|
|
199
|
+
return { balance: 0, tier: "DEVELOPER", accountId: "SA-\u2014" };
|
|
200
200
|
}
|
|
201
201
|
function getDisplayDir() {
|
|
202
202
|
const cwd = process.cwd();
|
|
@@ -378,7 +378,7 @@ function enterWorkspace() {
|
|
|
378
378
|
}
|
|
379
379
|
}, 1e3);
|
|
380
380
|
}
|
|
381
|
-
async function runPromptStream(query) {
|
|
381
|
+
async function runPromptStream(query, isRetry = false) {
|
|
382
382
|
isExecuting = true;
|
|
383
383
|
process.stdout.write("\x1B[?25l");
|
|
384
384
|
const pad = getCenterPad(72);
|
|
@@ -399,9 +399,31 @@ async function runPromptStream(query) {
|
|
|
399
399
|
})
|
|
400
400
|
});
|
|
401
401
|
if (!res.ok) {
|
|
402
|
+
let detail = res.statusText || `HTTP ${res.status}`;
|
|
403
|
+
try {
|
|
404
|
+
const errBody = await res.json();
|
|
405
|
+
const msg = errBody?.error?.message || errBody?.error || errBody?.message;
|
|
406
|
+
if (msg) detail = typeof msg === "string" ? msg : JSON.stringify(msg);
|
|
407
|
+
} catch {
|
|
408
|
+
}
|
|
402
409
|
console.log(pad + import_chalk.default.red(`
|
|
403
|
-
Error
|
|
410
|
+
Error (${res.status}): ${detail}
|
|
404
411
|
`));
|
|
412
|
+
if (res.status === 401 && !isRetry) {
|
|
413
|
+
console.log(pad + import_chalk.default.yellow("API key tidak valid atau sudah di-revoke. Memulai ulang otorisasi...\n"));
|
|
414
|
+
try {
|
|
415
|
+
saveConfig({ apiKey: void 0 });
|
|
416
|
+
} catch {
|
|
417
|
+
}
|
|
418
|
+
cfg = getConfig();
|
|
419
|
+
const newKey = await handleAutoAuth(baseUrl);
|
|
420
|
+
if (newKey) {
|
|
421
|
+
cfg = getConfig();
|
|
422
|
+
userMeta = await fetchUserMeta(baseUrl, cfg.apiKey || "");
|
|
423
|
+
return runPromptStream(query, true);
|
|
424
|
+
}
|
|
425
|
+
console.log(pad + import_chalk.default.red("Otorisasi ulang dibatalkan.\n"));
|
|
426
|
+
}
|
|
405
427
|
} else {
|
|
406
428
|
const reader = res.body?.getReader();
|
|
407
429
|
const decoder = new TextDecoder();
|
|
@@ -468,6 +490,13 @@ async function handleAutoAuth(baseUrl2) {
|
|
|
468
490
|
async function startInteractiveSession() {
|
|
469
491
|
cfg = getConfig();
|
|
470
492
|
baseUrl = resolveBaseUrl();
|
|
493
|
+
const MODEL_MIGRATIONS = {
|
|
494
|
+
"anthropic/claude-3.7-sonnet": "anthropic/claude-sonnet-4.6"
|
|
495
|
+
};
|
|
496
|
+
if (cfg.defaultModel && MODEL_MIGRATIONS[cfg.defaultModel]) {
|
|
497
|
+
cfg.defaultModel = MODEL_MIGRATIONS[cfg.defaultModel];
|
|
498
|
+
saveConfig({ defaultModel: cfg.defaultModel });
|
|
499
|
+
}
|
|
471
500
|
if (!cfg.apiKey) {
|
|
472
501
|
const key = await handleAutoAuth(baseUrl);
|
|
473
502
|
if (!key) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sarangai-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "CLI resmi SarangAI — Gateway multi-model AI langsung dari terminal Anda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sarang": "dist/index.js",
|
|
8
|
-
"sarangai": "dist/index.
|
|
8
|
+
"sarangai": "dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|