sarangai-cli 1.0.14 → 1.1.1
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 +127 -43
- package/dist/index.js +1254 -897
- package/package.json +20 -15
package/README.md
CHANGED
|
@@ -1,68 +1,152 @@
|
|
|
1
1
|
# SarangAI CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SarangAI CLI is an **autonomous terminal coding agent** that lives entirely inside your shell. It drives five locked, coding-tuned frontier models through a single gateway, executes file edits directly on disk, and renders everything inside a hand-rolled **Alternate Screen Buffer TUI** that never flickers, never scrolls your layout out of view, and never dumps raw code walls over your prompt.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```
|
|
6
|
+
███████╗ █████╗ ██████╗ █████╗ ███╗ ██╗ ██████╗ █████╗ ██╗
|
|
7
|
+
██╔════╝██╔══██╗██╔══██╗██╔══██╗████╗ ██║██╔════╝ ██╔══██╗██║
|
|
8
|
+
███████╗███████║██████╔╝███████║██╔██╗ ██║██║ ███╗███████║██║
|
|
9
|
+
╚════██║██╔══██║██╔══██╗██╔══██║██║╚██╗██║██║ ██║██╔══██║██║
|
|
10
|
+
███████║██║ ██║██║ ██║██║ ██║██║ ╚████║╚██████╔╝██║ ██║██║
|
|
11
|
+
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝
|
|
12
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
13
|
+
● Account: SA-8WWREVSJ | Tier: DEVELOPER | ⚡ Balance: 55,318
|
|
14
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
15
|
+
```
|
|
6
16
|
|
|
7
|
-
##
|
|
17
|
+
## Why SarangAI
|
|
8
18
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
|
|
12
|
-
|
|
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.
|
|
19
|
+
- **Zero-flicker, fixed-layout TUI** — the entire interface is repainted as one atomic ANSI frame per change; only dirty rows are rewritten while idle. No tearing, no runaway escape sequences, no autoscroll chaos.
|
|
20
|
+
- **Persistent layout** — the ASCII header, account line, and model line are locked to the top; the rounded prompt box is locked to the bottom; the content viewport sits between them, pinned to the bottom (sticky scroll). Modals (the model selector) paint *over* the viewport without shifting any other region.
|
|
21
|
+
- **Multi-turn FIFO context memory** — every completed task is distilled into a strict summary (touched files + core explanation) and kept in an in-memory session history. The last 6 turns (≤ 12,000 chars, trimmed at intact line boundaries) ride along with each request, so follow-up tasks understand previous instructions without blowing the token budget.
|
|
22
|
+
- **Silent file execution** — the agent emits structured file-operation tags; the CLI parses and applies them straight to disk and prints only a clean report. Reasoning monologue is captured internally and never printed.
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
## Locked Model Roster
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
Five models are permanently registered — the roster cannot drift. Pick by workload:
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
| Alias | Model ID | Role | Recommended for |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| `glm` | `z-ai/glm-5.3-flash` | Rapid Scaffolder | **Recommended default.** Instant execution for scaffolding new projects, boilerplate, and everyday scripting. |
|
|
31
|
+
| `sonnet` | `anthropic/claude-sonnet-4.6` | Deep Architect & Refactor | Architecture design, systematic refactoring, and complex multi-module codebase changes. |
|
|
32
|
+
| `luna` | `openai/gpt-5.6-luna` | Fast Precision & Fixer | Fast precision work: bug fixes, edge-case analysis, and strict verification. |
|
|
33
|
+
| `deepseek` | `deepseek/deepseek-v3.2` | Logic & Algorithm Engineer | Core logic, algorithms, and query/performance optimization. |
|
|
34
|
+
| `mimo` | `xiaomi/mimo-v2.5-pro` | Fullstack & Multimodal Agent | Fullstack development and multimodal workflows (logs, traces, build automation). |
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
## Core Architecture Highlights
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
- **Alternate Screen Buffer isolation** — the TUI enters with `\x1b[?1049h` and restores your shell exactly with `\x1b[?1049l`; your scrollback is never touched.
|
|
39
|
+
- **Fixed header with live balance** — ASCII branding plus `● Account | Tier | ⚡ Balance` fetched in real time from the gateway (`/api/gateway/v1/balance`) and refreshed after every task.
|
|
40
|
+
- **Floating in-place ticker** — a single status line directly above the prompt box updates in place (`Analyzing… → Reading context files… → Applying code changes… → Done`) with a spinner and elapsed seconds; it never reflows other rows.
|
|
41
|
+
- **Interactive startup selector** — the first thing you see. Navigate with `↑`/`↓` or `j`/`k`, quick-pick with `1`–`5`, confirm with `Enter`. `Ctrl+C`, `Esc`, or `q` aborts cleanly (terminal restored, exit code 0) — you are never forced to pick a model to leave.
|
|
42
|
+
- **Direct disk mutations, no code dumps** — `WRITE_FILE` (create/rewrite) and `REPLACE…WITH` (byte-exact `str_replace` edits) are parsed from the response and applied silently; the terminal only shows the file list and a concise summary.
|
|
43
|
+
- **Strict typo rejection** — an unknown `/model` argument is an error, never a silent fallback.
|
|
44
|
+
- **Ad-free & sponsor-free** — the agent prompt itself forbids promotional content; no sponsored tasks, no external advertising, ever.
|
|
30
45
|
|
|
31
|
-
##
|
|
46
|
+
## Installation
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
Requirements: **Node 18+** (tested on Node 20 LTS).
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
```bash
|
|
51
|
+
npm install -g sarangai-cli
|
|
52
|
+
```
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
Or run from a clone of this repository:
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- [q] : Keluar dari SarangAI CLI.
|
|
56
|
+
```bash
|
|
57
|
+
npm install
|
|
58
|
+
npm run build
|
|
59
|
+
node dist/index.js
|
|
60
|
+
```
|
|
45
61
|
|
|
46
|
-
|
|
62
|
+
### Authentication
|
|
47
63
|
|
|
48
|
-
|
|
64
|
+
SarangAI reads its gateway credentials from, in order:
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
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`.
|
|
66
|
+
1. `SARANGAI_TOKEN` / `SARANGAI_API_KEY` environment variables
|
|
67
|
+
2. `apiKey` in `~/.sarangairc`
|
|
55
68
|
|
|
56
|
-
|
|
69
|
+
`~/.sarangairc` also accepts `baseUrl` (default `https://sarangai.id`) and `defaultModel` (`glm | sonnet | luna | deepseek | mimo`).
|
|
57
70
|
|
|
58
|
-
##
|
|
71
|
+
## CLI Commands & Navigation
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
### Starting a session
|
|
61
74
|
|
|
62
|
-
|
|
75
|
+
```bash
|
|
76
|
+
sarang # header → interactive model selector → workspace
|
|
77
|
+
sarang run # same as above
|
|
78
|
+
sarang -m sonnet # skip the selector, start directly on a model
|
|
79
|
+
sarang run "build a REST API with express" # start with an initial task
|
|
80
|
+
```
|
|
63
81
|
|
|
64
|
-
|
|
82
|
+
On startup the selector is mandatory (you cannot cancel your way past it): highlight a model, press `Enter` (or hit its number), and the workspace activates with the prompt `sarang(<alias>)>`.
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
### REPL slash commands
|
|
67
85
|
|
|
68
|
-
|
|
86
|
+
| Command | Effect |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `/model` | Reopen the interactive model selector mid-session (`Esc`/`q` cancel is allowed here). |
|
|
89
|
+
| `/model <alias>` | Switch instantly, e.g. `/model sonnet`. Header and prompt box update in place. |
|
|
90
|
+
| `/clear` | Wipe the viewport **and** the multi-turn session memory (`Session memory cleared.`). |
|
|
91
|
+
| `exit` / `quit` | Leave the workspace (`Goodbye! Workspace closed.`). |
|
|
92
|
+
|
|
93
|
+
Anything that is not a slash command is treated as a coding task and executed autonomously.
|
|
94
|
+
|
|
95
|
+
### Strict model argument validation
|
|
96
|
+
|
|
97
|
+
Typos are rejected loudly instead of silently falling back:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
✖ Model 'sonneth' not found. Available: glm, sonnet, luna, deepseek, mimo.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The active model is left untouched; fix the alias and retry.
|
|
104
|
+
|
|
105
|
+
### Keyboard map (selector)
|
|
106
|
+
|
|
107
|
+
| Key | Action |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `↑` / `↓` or `j` / `k` | Move the highlight (wraps around) |
|
|
110
|
+
| `1` – `5` | Select that model directly |
|
|
111
|
+
| `Enter` | Confirm the highlighted model |
|
|
112
|
+
| `Ctrl+C` / `Esc` / `q` | Abort — startup mode exits the app; session mode just closes the menu |
|
|
113
|
+
|
|
114
|
+
## Prerequisites & Developer Workflows
|
|
115
|
+
|
|
116
|
+
- **Node 18+** (project is exercised on Node 20 LTS).
|
|
117
|
+
- A gateway API key in `~/.sarangairc` or `SARANGAI_API_KEY`.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm run build # bundle to dist/ with tsup
|
|
121
|
+
npx tsc --noEmit # typecheck
|
|
122
|
+
npm test # run the vitest suite (61 tests)
|
|
123
|
+
npm run test:watch
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The test suite covers the locked model roster, the pure model-selector logic, strict argument validation, the `WRITE_FILE`/`REPLACE` parsers, multi-turn memory budgets, the Codebuff-style prompt assembly, and TUI layout primitives.
|
|
127
|
+
|
|
128
|
+
## Project Layout
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
src/
|
|
132
|
+
├── index.ts # CLI entry, REPL session, startup flow, slash commands
|
|
133
|
+
├── constants.ts # Locked model roster + strict model lookup
|
|
134
|
+
├── config.ts # ~/.sarangairc persistence
|
|
135
|
+
├── core/
|
|
136
|
+
│ ├── workspace.ts # Autonomous agent loop, context assembly, file exec
|
|
137
|
+
│ ├── prompt-builder.ts# Codebuff-style task-first / rules-last prompt assembly
|
|
138
|
+
│ ├── memory.ts # Bounded multi-turn conversation memory
|
|
139
|
+
│ ├── gateway.ts # Streaming chat completions client
|
|
140
|
+
│ ├── auth.ts # Credential detection + real-time balance
|
|
141
|
+
│ ├── fs-agent.ts # Safe file read/write primitives
|
|
142
|
+
│ ├── scanner.ts # Project tree scanning
|
|
143
|
+
│ └── history.ts # Optional on-disk session records
|
|
144
|
+
└── ui/
|
|
145
|
+
├── tui.ts # Alternate Screen Buffer TUI (atomic frame renderer)
|
|
146
|
+
├── model-menu.ts # Pure model-selector state machine + rendering
|
|
147
|
+
└── banner.ts # ASCII banner + account line
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT © SarangAI
|