@ikyyofc/gemini-cli 2.0.6 → 2.0.7

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 CHANGED
@@ -3,17 +3,28 @@
3
3
  > AI Agent CLI — native function calling · GEMINI.md context · extension system
4
4
 
5
5
  ```
6
- ██████╗ ███████╗███╗ ███╗██╗███╗ ██╗██╗
7
- ██╔════╝ ██╔════╝████╗ ████║██║████╗ ██║██║
8
- ██║ ███╗█████╗ ██╔████╔██║██║██╔██╗ ██║██║
9
- ██║ ██║██╔══╝ ██║╚██╔╝██║██║██║╚██╗██║██║
10
- ╚██████╔╝███████╗██║ ╚═╝ ██║██║██║ ╚████║██║
11
- ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝
6
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
7
+ Gemini CLI ─ AI Agent ─ native function calling
8
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
12
9
  ```
13
10
 
11
+ Gemini CLI adalah asisten terminal bertenaga AI yang menggunakan model Gemini dari Google. CLI ini bukan sekadar antarmuka chat biasa, melainkan sebuah **AI Agent** yang dapat berinteraksi langsung dengan sistem file dan environment lokal Anda menggunakan *native function calling*.
12
+
14
13
  ---
15
14
 
16
- ## Instalasi
15
+ ## 📚 Dokumentasi Lengkap
16
+
17
+ Untuk detail lebih lanjut mengenai arsitektur dan fitur spesifik, silakan baca dokumentasi berikut:
18
+
19
+ - [**Architecture Overview**](./docs/ARCHITECTURE.md) - Penjelasan tentang ReAct loop dan cara kerja agent.
20
+ - [**API Reference**](./docs/API.md) - Referensi fungsi utama (`callGemini`, `chat`).
21
+ - [**Tools (Function Calling)**](./docs/TOOLS.md) - Daftar lengkap tool yang tersedia untuk agent (baca file, jalankan shell, dll).
22
+ - [**Extensions System**](./docs/EXTENSIONS.md) - Cara membuat dan mengelola ekstensi serta custom commands.
23
+ - [**Memory & Context**](./docs/MEMORY.md) - Panduan menggunakan `GEMINI.md` untuk memberikan konteks pada agent.
24
+
25
+ ---
26
+
27
+ ## 🚀 Instalasi
17
28
 
18
29
  ```bash
19
30
  npm install
@@ -23,118 +34,73 @@ npm link # optional: pakai sebagai `gemini` di terminal
23
34
 
24
35
  ---
25
36
 
26
- ## Penggunaan
37
+ ## 💻 Penggunaan
38
+
39
+ Anda dapat menggunakan Gemini CLI dalam mode interaktif (REPL) atau mode *one-shot* langsung dari terminal.
27
40
 
28
41
  ```bash
29
- gemini # interactive agent
30
- gemini "buatkan REST API di ./api" # one-shot
31
- gemini --system "Kamu senior backend engineer"
32
- gemini --file ./app.js "jelaskan kode ini"
33
- gemini --yolo "refactor semua file di src/"
34
- gemini --chat # plain chat tanpa tools
42
+ gemini # Masuk ke mode interactive agent
43
+ gemini "buatkan REST API di ./api" # One-shot task
44
+ gemini --system "Kamu senior backend engineer" # Set system prompt
45
+ gemini --file ./app.js "jelaskan kode ini" # Lampirkan file
46
+ gemini --yolo "refactor semua file di src/" # Skip semua konfirmasi tool (HATI-HATI)
47
+ gemini --chat # Plain chat tanpa tools (bukan agent)
35
48
  ```
36
49
 
37
- ---
38
-
39
- ## GEMINI.md — Context Files
50
+ ### Interactive Commands
40
51
 
41
- Buat `GEMINI.md` di lokasi berikut (dimuat hierarki, seperti Gemini CLI asli):
52
+ Saat berada di dalam mode interaktif, Anda dapat menggunakan perintah berikut:
42
53
 
43
- | Lokasi | Scope |
44
- |--------|-------|
45
- | `~/.gemini/GEMINI.md` | Global semua project |
46
- | `./GEMINI.md` | Project root (sampai `.git`) |
47
-
48
- Support import antar file:
49
- ```md
50
- @./components/style.md
51
- @../shared/conventions.md
52
- ```
53
-
54
- **Commands:**
55
54
  ```
56
- /memory show tampilkan semua context yang dimuat
57
- /memory reload reload dari disk
58
- /memory add <text> append ke ~/.gemini/GEMINI.md
55
+ /agent Toggle agent mode (tools on/off)
56
+ /yolo Skip all tool confirmations
57
+ /file <path> Attach file to next message
58
+ /system <text> → Set system instruction
59
+ /history → Show conversation turns
60
+ /export <file> → Export history to JSON
61
+ /cd <path> → Change working directory
62
+ /cwd → Show current working directory
63
+ /new /clear → Reset conversation
64
+ /model → Show model & config
65
+ /help → Show help
66
+ /exit /quit → Exit
59
67
  ```
60
68
 
61
69
  ---
62
70
 
63
- ## Extensions
64
-
65
- Manifest: `~/.gemini/extensions/<name>/gemini-extension.json`
66
-
67
- ```json
68
- {
69
- "name": "my-ext",
70
- "version": "1.0.0",
71
- "description": "...",
72
- "contextFileName": "GEMINI.md",
73
- "enabled": true,
74
- "commands": {
75
- "do-thing": {
76
- "description": "Does a thing",
77
- "prompt": "Do this: {{args}}"
78
- }
79
- }
80
- }
81
- ```
71
+ ## 🧠 Fitur Utama
82
72
 
83
- **Commands:**
84
- ```
85
- /ext list
86
- /ext install /path/to/ext
87
- /ext install https://github.com/user/repo
88
- /ext uninstall <name>
89
- /ext enable / disable <name>
90
- /ext update <name>
91
- ```
92
-
93
- Custom commands dipanggil: `/code-reviewer:review ./src/app.js`
73
+ ### 1. Native Function Calling (Tools)
74
+ Agent dapat membaca file, menulis file, menjalankan perintah shell, dan mencari file secara mandiri untuk menyelesaikan tugas yang Anda berikan. [Baca selengkapnya](./docs/TOOLS.md).
94
75
 
95
- ---
76
+ ### 2. Hierarchical Context (`GEMINI.md`)
77
+ Anda dapat memberikan instruksi spesifik proyek atau global menggunakan file `GEMINI.md`. Agent akan memuat konteks ini secara otomatis. [Baca selengkapnya](./docs/MEMORY.md).
96
78
 
97
- ## Tools (Native Function Calling)
98
-
99
- | Tool | Aksi |
100
- |------|------|
101
- | `read_file` | Baca file |
102
- | `write_file` | Tulis/overwrite file |
103
- | `patch_file` | Edit bagian spesifik |
104
- | `append_file` | Append ke file |
105
- | `list_dir` | List direktori |
106
- | `find_files` | Cari file (glob) |
107
- | `search_in_files` | Grep dalam file |
108
- | `run_shell` | Jalankan shell command |
109
- | `create_dir` | Buat direktori |
110
- | `delete_file` | Hapus file |
111
- | `move_file` | Pindah/rename |
112
- | `get_env` | Info environment |
113
- | `read_url` | Fetch URL / API |
79
+ ### 3. Extension System
80
+ Perluas kemampuan CLI dengan membuat ekstensi yang berisi custom commands dan konteks tambahan. [Baca selengkapnya](./docs/EXTENSIONS.md).
114
81
 
115
82
  ---
116
83
 
117
- ## Struktur
84
+ ## 📂 Struktur Direktori
118
85
 
119
86
  ```
120
87
  gemini-cli/
121
88
  ├── index.js ← CLI entry + REPL + commands
122
- ├── GEMINI.md ← Project context (auto-loaded)
123
89
  ├── package.json
90
+ ├── docs/ ← Dokumentasi lengkap
124
91
  ├── src/
125
92
  │ ├── gemini.js ← API client (native function calling)
126
93
  │ ├── tools.js ← functionDeclarations + executor
127
94
  │ ├── agent.js ← ReAct loop
128
95
  │ ├── memory.js ← GEMINI.md hierarchy loader
129
96
  │ ├── extensions.js ← Extension manager
130
- └── renderer.js ← Terminal UI + markdown
131
- └── extensions/
132
- └── code-reviewer/
133
- ├── gemini-extension.json
134
- └── GEMINI.md
135
-
136
- ~/.gemini/ ← Global config dir
137
- ├── GEMINI.md
138
- ├── extensions/
139
- └── commands/
140
- ```
97
+ ├── renderer.js ← Terminal UI + markdown
98
+ └── input.js ← Bracketed paste via Transform stream
99
+ └── utils/
100
+ └── proxy-manager.js ← Global proxy manager
101
+
102
+ ~/.gemini/ ← Global config dir (dibuat otomatis)
103
+ ├── GEMINI.md ← Global context
104
+ ├── extensions/ ← Folder instalasi ekstensi
105
+ └── commands/ ← Global custom commands
106
+ ```
package/docs/API.md ADDED
@@ -0,0 +1,37 @@
1
+ # API Reference
2
+
3
+ The Gemini CLI exposes its core functionality through `src/gemini.js`.
4
+
5
+ ## `callGemini(options)`
6
+
7
+ The primary function for interacting with the Gemini API, supporting native function calling and multimodal inputs.
8
+
9
+ ### Parameters
10
+
11
+ An object containing the following properties:
12
+
13
+ - `messages` (Array): The conversation history. Each message should have a `role` (`user` or `model`) and `parts` (an array of text or function call/response objects).
14
+ - `fileBuffer` (Buffer, optional): A buffer containing a file to be sent as an inline attachment (e.g., an image or document).
15
+ - `tools` (Array, optional): An array of tool declarations. Typically `GEMINI_TOOLS` from `src/tools.js`.
16
+ - `systemInstruction` (String, optional): The system prompt to guide the model's behavior.
17
+
18
+ ### Returns
19
+
20
+ A Promise that resolves to an object containing:
21
+
22
+ - `parts`: The response parts from the model (text or function calls).
23
+ - `raw`: The raw response object from the API.
24
+ - `full`: The complete API response data.
25
+
26
+ ## `chat(messages, systemInstruction)`
27
+
28
+ A simplified wrapper around `callGemini` for plain text chat without tools.
29
+
30
+ ### Parameters
31
+
32
+ - `messages` (Array): The conversation history.
33
+ - `systemInstruction` (String, optional): The system prompt.
34
+
35
+ ### Returns
36
+
37
+ A Promise that resolves to the concatenated text response from the model.
@@ -0,0 +1,40 @@
1
+ # Architecture Overview
2
+
3
+ Gemini CLI is built around a ReAct (Reasoning and Acting) agent loop that leverages Gemini's native function calling capabilities.
4
+
5
+ ## Core Components
6
+
7
+ 1. **Agent Loop (`src/agent.js`)**
8
+ - Implements the ReAct loop.
9
+ - Sends the conversation history and available tools to the Gemini API.
10
+ - If the model responds with a `functionCall`, the agent executes the corresponding tool locally.
11
+ - The result of the tool execution is appended to the conversation history as a `functionResponse`.
12
+ - This loop continues until the model provides a final text response without any tool calls.
13
+
14
+ 2. **Native Function Calling (`src/gemini.js` & `src/tools.js`)**
15
+ - The CLI uses Gemini's native `tools` parameter to pass `functionDeclarations`.
16
+ - `src/tools.js` defines the schema for all available tools (e.g., `read_file`, `run_shell`) using an OpenAPI-subset format.
17
+ - The `executeTool` function handles the actual execution of these tools on the local system, including prompting the user for confirmation on destructive actions.
18
+
19
+ 3. **Memory & Context (`src/memory.js`)**
20
+ - Implements a hierarchical context loading system based on `GEMINI.md` files.
21
+ - Context is loaded globally (`~/.gemini/GEMINI.md`), from extensions, and from the project root up to the current working directory.
22
+ - Supports recursive imports using `@./path/to/file.md`.
23
+
24
+ 4. **Extension System (`src/extensions.js`)**
25
+ - Allows extending the CLI's capabilities with custom commands and context.
26
+ - Extensions are stored in `~/.gemini/extensions/` and defined via a `gemini-extension.json` manifest.
27
+ - Custom commands can be defined in extensions or globally in `~/.gemini/commands/`.
28
+
29
+ 5. **Terminal UI (`src/renderer.js` & `src/input.js`)**
30
+ - Handles rendering markdown, syntax highlighting, and tool execution status in the terminal.
31
+ - `src/input.js` manages user input, including support for bracketed paste to handle multi-line inputs gracefully.
32
+
33
+ ## Data Flow
34
+
35
+ 1. User enters a prompt in the CLI.
36
+ 2. The CLI loads context from `GEMINI.md` files and extensions.
37
+ 3. The prompt, context, and tool declarations are sent to the Gemini API via `callGemini`.
38
+ 4. The model decides whether to respond with text or call a tool.
39
+ 5. If a tool is called, `agent.js` executes it via `tools.js` and sends the result back to the model.
40
+ 6. Once the model finishes reasoning and acting, the final text response is rendered to the user.
@@ -0,0 +1,65 @@
1
+ # Extensions System
2
+
3
+ Gemini CLI supports an extension system that allows you to add custom commands and context to the agent. Extensions are managed in `~/.gemini/extensions/`.
4
+
5
+ ## Extension Structure
6
+
7
+ An extension is a directory containing at least a `gemini-extension.json` manifest file. It can optionally include a `GEMINI.md` file for context.
8
+
9
+ ```
10
+ ~/.gemini/extensions/my-extension/
11
+ ├── gemini-extension.json
12
+ └── GEMINI.md
13
+ ```
14
+
15
+ ## Manifest (`gemini-extension.json`)
16
+
17
+ The manifest defines the extension's metadata and custom commands.
18
+
19
+ ```json
20
+ {
21
+ "name": "my-extension",
22
+ "version": "1.0.0",
23
+ "description": "A sample extension",
24
+ "contextFileName": "GEMINI.md",
25
+ "enabled": true,
26
+ "commands": {
27
+ "review": {
28
+ "description": "Review the provided code",
29
+ "prompt": "Please review the following code and suggest improvements: {{args}}"
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Custom Commands
36
+
37
+ Custom commands defined in the manifest can be invoked in the CLI using the syntax `/extension-name:command-name [args]`.
38
+
39
+ For example, using the manifest above:
40
+ ```bash
41
+ /my-extension:review ./src/app.js
42
+ ```
43
+ This will expand to the prompt defined in the manifest, replacing `{{args}}` with `./src/app.js`.
44
+
45
+ ## Managing Extensions
46
+
47
+ You can manage extensions using the `/ext` command in the interactive CLI:
48
+
49
+ - `/ext list`: List all installed extensions.
50
+ - `/ext install <path-or-url>`: Install an extension from a local path or a Git repository.
51
+ - `/ext uninstall <name>`: Uninstall an extension.
52
+ - `/ext enable <name>`: Enable an extension.
53
+ - `/ext disable <name>`: Disable an extension.
54
+ - `/ext update <name>`: Update an extension (if installed via Git).
55
+
56
+ ## Global Commands
57
+
58
+ In addition to extensions, you can define global custom commands in `~/.gemini/commands/<namespace>/<name>.toml`.
59
+
60
+ Example `~/.gemini/commands/git/commit.toml`:
61
+ ```toml
62
+ description = "Generate a commit message"
63
+ prompt = "Generate a concise conventional commit message for the following git diff: {{args}}"
64
+ ```
65
+ Usage: `/git:commit`
package/docs/MEMORY.md ADDED
@@ -0,0 +1,36 @@
1
+ # Memory & Context (`GEMINI.md`)
2
+
3
+ Gemini CLI uses a hierarchical context loading system based on `GEMINI.md` files. This allows you to provide persistent instructions, coding conventions, and project-specific knowledge to the AI agent.
4
+
5
+ ## Context Hierarchy
6
+
7
+ When you start a conversation, the CLI loads context from `GEMINI.md` files in the following order (lowest to highest priority):
8
+
9
+ 1. **Global Context**: `~/.gemini/GEMINI.md`
10
+ - Use this for global preferences, such as "Always use TypeScript" or "I prefer concise answers."
11
+ 2. **Extension Context**: `~/.gemini/extensions/<name>/GEMINI.md`
12
+ - Extensions can inject their own context when enabled.
13
+ 3. **Project Context**: Walk up from the Current Working Directory (CWD) to the project root (defined by the presence of a `.git` folder).
14
+ - E.g., if you are in `/project/src/components`, it will load `/project/GEMINI.md`, then `/project/src/GEMINI.md`, then `/project/src/components/GEMINI.md`.
15
+ - This allows you to define project-wide rules at the root, and specific rules for subdirectories.
16
+
17
+ ## Imports
18
+
19
+ You can modularize your context files using the `@./path/to/file.md` syntax. The CLI will recursively resolve and inline these imports.
20
+
21
+ Example `GEMINI.md`:
22
+ ```markdown
23
+ # Project Context
24
+ This is a React project.
25
+
26
+ @./docs/conventions.md
27
+ @./docs/architecture.md
28
+ ```
29
+
30
+ ## Managing Memory
31
+
32
+ You can interact with the memory system using the `/memory` command in the interactive CLI:
33
+
34
+ - `/memory show`: Display all currently loaded context files and their contents.
35
+ - `/memory reload`: Reload the context files from disk (useful if you edited them outside the CLI).
36
+ - `/memory add <text>`: Append text to your global `~/.gemini/GEMINI.md` file.
package/docs/TOOLS.md ADDED
@@ -0,0 +1,44 @@
1
+ # Tools (Native Function Calling)
2
+
3
+ Gemini CLI provides a set of built-in tools that the AI agent can use to interact with your local system. These tools are defined in `src/tools.js` and are passed to the Gemini API as native `functionDeclarations`.
4
+
5
+ ## Available Tools
6
+
7
+ ### File System Operations
8
+
9
+ - **`read_file`**: Reads the full contents of a file. Returns numbered lines to help the AI reference specific parts of the code.
10
+ - Parameters: `path` (String)
11
+ - **`write_file`**: Creates or overwrites a file with the provided content. Automatically creates parent directories. *(Requires confirmation)*
12
+ - Parameters: `path` (String), `content` (String)
13
+ - **`patch_file`**: Replaces a specific unique string in a file with a new string. Safer than rewriting whole files. *(Requires confirmation)*
14
+ - Parameters: `path` (String), `old_str` (String), `new_str` (String)
15
+ - **`append_file`**: Appends text to the end of an existing file. *(Requires confirmation)*
16
+ - Parameters: `path` (String), `content` (String)
17
+ - **`delete_file`**: Permanently deletes a file or empty directory. *(Requires confirmation)*
18
+ - Parameters: `path` (String)
19
+ - **`move_file`**: Moves or renames a file or directory. *(Requires confirmation)*
20
+ - Parameters: `from` (String), `to` (String)
21
+
22
+ ### Directory & Search Operations
23
+
24
+ - **`list_dir`**: Lists files and subdirectories in a directory. Excludes `node_modules` and `.git` by default.
25
+ - Parameters: `path` (String, optional), `show_hidden` (Boolean, optional)
26
+ - **`create_dir`**: Creates a directory and all necessary parent directories (`mkdir -p`). *(Requires confirmation)*
27
+ - Parameters: `path` (String)
28
+ - **`find_files`**: Finds files matching a name pattern (glob) recursively.
29
+ - Parameters: `pattern` (String), `dir` (String, optional)
30
+ - **`search_in_files`**: Searches for a text pattern (grep) inside files recursively.
31
+ - Parameters: `pattern` (String), `dir` (String, optional), `extension` (String, optional), `case_insensitive` (Boolean, optional)
32
+
33
+ ### Execution & Environment
34
+
35
+ - **`run_shell`**: Executes any shell command (e.g., `npm install`, `git status`, running tests). Returns stdout and stderr. *(Requires confirmation)*
36
+ - Parameters: `command` (String), `cwd` (String, optional), `timeout` (Number, optional)
37
+ - **`get_env`**: Retrieves information about the current environment (CWD, platform, Node version, Git branch, etc.).
38
+ - Parameters: None
39
+ - **`read_url`**: Fetches the raw content of a URL (web page, REST API, raw file).
40
+ - Parameters: `url` (String), `headers` (String, optional)
41
+
42
+ ## Security & Confirmation
43
+
44
+ Tools marked with *(Requires confirmation)* are considered destructive. When the AI attempts to use one of these tools, the CLI will pause and prompt the user for approval before executing the action. This can be bypassed using the `/yolo` command or the `--yolo` flag.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikyyofc/gemini-cli",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "AI CLI Agent powered by Gemini — your own terminal assistant",
5
5
  "type": "module",
6
6
  "main": "index.js",