Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit cad298a

Browse files
committed
Reloading source
1 parent 02dae53 commit cad298a

25 files changed

Lines changed: 5235 additions & 0 deletions

File tree

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# DeepShell C Version Makefile
2+
# Supports both Linux and Windows (MSYS2/Mingw64)
3+
4+
CC = gcc
5+
CFLAGS = -Wall -Wextra -std=c99 -O2
6+
LDFLAGS =
7+
LIBS = -lcurl -ljson-c -lpthread
8+
9+
# Platform detection
10+
ifeq ($(OS),Windows_NT)
11+
# Windows with MSYS2/Mingw64
12+
EXECUTABLE = deepshell.exe
13+
CFLAGS += -D_WIN32
14+
LDFLAGS += -static-libgcc
15+
else
16+
# Linux
17+
EXECUTABLE = deepshell
18+
CFLAGS += -D_POSIX_C_SOURCE=200809L
19+
endif
20+
21+
# Source files
22+
SOURCES = main.c settings.c gemini.c ollama.c openrouter.c utils.c config.c interactive.c
23+
OBJECTS = $(SOURCES:.c=.o)
24+
25+
# Default target
26+
all: $(EXECUTABLE)
27+
28+
# Build the executable
29+
$(EXECUTABLE): $(OBJECTS)
30+
$(CC) $(OBJECTS) -o $(EXECUTABLE) $(LDFLAGS) $(LIBS)
31+
32+
# Compile source files
33+
%.o: %.c
34+
$(CC) $(CFLAGS) -c $< -o $@
35+
36+
# Clean build artifacts
37+
clean:
38+
rm -f $(OBJECTS) $(EXECUTABLE)
39+
40+
# Install dependencies (Linux)
41+
install-deps-linux:
42+
sudo apt-get update
43+
sudo apt-get install -y libcurl4-openssl-dev libjson-c-dev
44+
45+
# Install dependencies (Windows/MSYS2)
46+
install-deps-windows:
47+
pacman -S mingw-w64-x86_64-curl mingw-w64-x86_64-json-c
48+
49+
# Development build with debug info
50+
debug: CFLAGS += -g -DDEBUG
51+
debug: $(EXECUTABLE)
52+
53+
# Release build
54+
release: CFLAGS += -DNDEBUG
55+
release: $(EXECUTABLE)
56+
57+
.PHONY: all clean install-deps-linux install-deps-windows debug release

README.md

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
<div align="center">
2+
<h1>DeepShell C Version</h1>
3+
<p><strong>Your Universal LLM Command-Line Interface</strong></p>
4+
</div>
5+
6+
[![C Version](https://img.shields.io/badge/C-Native-green.svg)](https://gcc.gnu.org/)
7+
<!-- Add other badges as appropriate, e.g., license, build status, etc. -->
8+
9+
**DeepShell** is a powerful and versatile command-line program written in C that seamlessly blends the familiar environment of your local shell with the immense knowledge and capabilities of Large Language Models (LLMs). Imagine having direct access to the world's most advanced AI models—from local Ollama instances to cloud-based services like Google's Gemini—all unified within a single, efficient native binary.
10+
11+
Designed for developers, researchers, and power users, DeepShell abstracts away the complexity of API integrations. It offers a streamlined pathway to query both open-source and proprietary LLMs, transforming your command prompt into a conduit for deep AI intelligence with native performance.
12+
13+
## ✨ Features
14+
15+
* **Multi-LLM Support:**
16+
* Seamlessly connect to **Ollama** servers (local or remote).
17+
* Integrate with the **Google Gemini API**.
18+
* Connect to **OpenRouter.ai** for access to 200+ LLM models from various providers.
19+
* Advanced model selection with pagination and sorting (free models first).
20+
* Multi-key management with nicknames for different OpenRouter accounts.
21+
* **Conversational Memory & Customization:**
22+
* Engage in multi-turn conversations using the **interactive mode** (`-i`).
23+
* Set the conversation history limit (defaults to 25 turns).
24+
* Toggle response streaming for immediate (plain-text) or complete (Markdown-rendered) output. Streaming is disabled by default to preserve formatting.
25+
* Enable or disable Markdown rendering for each LLM service individually.
26+
* **Unified & Interactive Configuration:**
27+
* A central, user-friendly settings menu (`-s`) guides you through all configuration tasks.
28+
* Manages LLM service details, including server addresses (Ollama) and API keys (Gemini).
29+
* Stores configuration securely in `~/.deepshell/deepshell.conf`.
30+
* **Flexible Service & Model Management:**
31+
* Easily switch between configured LLM services (`-l`).
32+
* Quickly jump back to the previously used LLM service (`-j`).
33+
* List available models from your connected LLM service and change the default model per service (`-m`).
34+
* **Advanced API Key Management:**
35+
* Store and manage multiple API keys with user-defined nicknames for both Gemini and OpenRouter.
36+
* Unified key management interface (`-set-key`) supporting both services.
37+
* Display the currently active API key for any LLM service (`-show-key`).
38+
* Quick active configuration summary showing current LLM, model, and API key (`-a`).
39+
* Gemini-specific quota checking and usage dashboard access (`-gq`).
40+
* **Configuration Backup & Migration:**
41+
* Export complete configuration to encrypted files (`-b`) with password protection.
42+
* Import configuration from backup files (`-c`) with confirmation prompts.
43+
* Files saved to Downloads folder in secure binary format (unreadable as text).
44+
* Future-proof design with version metadata for cross-version compatibility.
45+
* Perfect for backing up settings, sharing configurations, or migrating between systems.
46+
* **Intuitive User Experience:**
47+
* Send queries directly from your command line (`-q`).
48+
* Beautiful Markdown rendering for LLM responses in the terminal with native C implementation.
49+
* Engaging progress animation while waiting for the LLM.
50+
* Clear, colored console output for enhanced readability.
51+
* Well-formatted and alphabetized help messages (`-h`).
52+
53+
## 🛠️ Installation
54+
55+
1. **Prerequisites:**
56+
* GCC compiler and build tools
57+
* libcurl4-openssl-dev
58+
* libjson-c-dev
59+
60+
2. **Install Dependencies (Linux):**
61+
```bash
62+
sudo apt-get update
63+
sudo apt-get install -y build-essential libcurl4-openssl-dev libjson-c-dev
64+
```
65+
66+
3. **Clone the Repository:**
67+
```bash
68+
git clone https://github.com/ashes00/deepshell.git
69+
cd deepshell
70+
```
71+
72+
4. **Build DeepShell:**
73+
```bash
74+
make
75+
```
76+
77+
5. **Run DeepShell:**
78+
```bash
79+
./deepshell [OPTIONS]
80+
```
81+
82+
## 🏁 Getting Started: Initial Setup
83+
84+
The first time you run DeepShell, or anytime you want to manage settings, use the `-s` or `--setup` flag:
85+
86+
```bash
87+
./deepshell -s
88+
```
89+
90+
This launches a comprehensive, interactive menu that allows you to:
91+
1. **Add or Reconfigure LLM Services:**
92+
* **For Ollama:** Enter your server address (e.g., `http://localhost:11434`) and select a default model from those available on your server.
93+
* **For Gemini:** Manage your API keys (add, remove, set active) and select a default model from the Gemini API.
94+
2. **Switch** the active LLM service.
95+
3. **Change** the default model for the currently active service.
96+
4. **Manage** Gemini API keys specifically.
97+
5. **View** your current configuration or **delete** it entirely.
98+
6. **Toggle Markdown Rendering:** Enable or disable Markdown formatting for the active service's responses.
99+
7. **Set Interactive History Limit:** Change the number of conversation turns remembered in interactive mode.
100+
8. **Toggle Response Streaming:** Enable or disable streaming responses. (Note: Markdown is not supported in streaming mode).
101+
102+
103+
Your settings will be saved to `~/.deepshell/deepshell.conf`.
104+
105+
## 💻 Usage & Command-Line Options
106+
107+
### Primary Usage
108+
109+
**Query the active LLM**
110+
```bash
111+
./deepshell -q "What are the benefits of using a CLI for LLM interaction?"
112+
./deepshell --query "Write a python function to calculate a factorial"
113+
```
114+
115+
### LLM & Model Management
116+
117+
**Enter the main settings menu**
118+
```bash
119+
./deepshell -s (or --setup)
120+
```
121+
122+
**Switch active service or configure services** (shortcut to a settings sub-menu)
123+
```bash
124+
./deepshell -l (or --llm)
125+
```
126+
127+
**Quickly jump to the previously used LLM service**
128+
```bash
129+
./deepshell -j (or --jump-llm)
130+
```
131+
132+
**Change the default model for the active service** (shortcut)
133+
```bash
134+
./deepshell -m (or --model-change)
135+
```
136+
137+
### API Key Management
138+
139+
**Interactively manage API keys for LLM services** (Gemini or OpenRouter)
140+
```bash
141+
./deepshell -set-key (or --set-api-key)
142+
```
143+
144+
**Show the active API key for current LLM service**
145+
```bash
146+
./deepshell -show-key (or --show-api-key)
147+
```
148+
149+
**Quick summary of active LLM, model, and API key**
150+
```bash
151+
./deepshell -a (or --active-config)
152+
```
153+
154+
**Check Gemini API key status and get quota info**
155+
```bash
156+
./deepshell -gq (or --gemini-quota)
157+
```
158+
159+
### Configuration Backup & Migration
160+
161+
**Export configuration to encrypted backup file**
162+
```bash
163+
./deepshell -b mybackup.config (or --export mybackup.config)
164+
```
165+
166+
**Import configuration from encrypted backup file**
167+
```bash
168+
./deepshell -c mybackup.config (or --import mybackup.config)
169+
```
170+
171+
### Configuration & Info
172+
173+
**Display the currently active configuration details**
174+
```bash
175+
./deepshell -show-config (or --show-full-conf)
176+
```
177+
178+
**Delete the entire configuration file** (use with caution!)
179+
```bash
180+
./deepshell -d (or --delete-config)
181+
```
182+
183+
**Show the help message**
184+
```bash
185+
./deepshell -h (or --help)
186+
```
187+
188+
**Show the program's version**
189+
```bash
190+
./deepshell -v (or --version)
191+
```
192+
193+
**Start an interactive chat session**
194+
```bash
195+
./deepshell -i (or --interactive)
196+
```
197+
198+
## ⚙️ Configuration File
199+
200+
DeepShell stores its configuration in a JSON file located at `~/.deepshell/deepshell.conf`. While you can view this file, it's recommended to manage settings through DeepShell's command-line options for safety and ease of use.
201+
202+
An example configuration might look like this:
203+
```json
204+
{
205+
"active_llm_service": "openrouter",
206+
"previous_active_llm_service": "gemini",
207+
"interactive_history_limit": 25,
208+
"enable_streaming": false,
209+
"show_progress_animation": true,
210+
"ollama": {
211+
"server_address": "http://localhost:11434",
212+
"model": "llama3:latest",
213+
"render_markdown": true
214+
},
215+
"gemini": {
216+
"api_keys": [
217+
{
218+
"nickname": "personal-key",
219+
"key": "AIza..."
220+
}
221+
],
222+
"active_api_key_nickname": "personal-key",
223+
"model": "models/gemini-1.5-flash",
224+
"render_markdown": true
225+
},
226+
"openrouter": {
227+
"api_keys": [
228+
{
229+
"nickname": "work-account",
230+
"key": "sk-or-v1-..."
231+
}
232+
],
233+
"active_api_key_nickname": "work-account",
234+
"model": "openai/gpt-4o",
235+
"site_url": "https://myproject.com",
236+
"site_name": "My Project",
237+
"render_markdown": true
238+
}
239+
}
240+
```
241+
242+
## 🚀 Performance Benefits
243+
244+
The C version offers several advantages over interpreted languages:
245+
- **Faster startup time**: No interpreter overhead
246+
- **Smaller executable**: Single binary with minimal dependencies
247+
- **Lower memory usage**: More efficient memory management
248+
- **Better system integration**: Native system calls
249+
- **Extended timeouts**: 30-second request timeout for better compatibility with slower models
250+
251+
## 🤖 Supported LLMs
252+
253+
----
254+
* **Ollama:** Connect to any Ollama instance serving models like Llama, Mistral, etc.
255+
* **Google Gemini:** Access Gemini models (e.g., `gemini-1.5-pro`, `gemini-1.5-flash`) via the Google AI Studio API.
256+
* **OpenRouter.ai:** Access 200+ models from providers like OpenAI, Anthropic, Meta, Google, and more:
257+
* GPT-4, GPT-3.5, Claude, Llama, Mixtral, Gemma, and many others
258+
* Free and paid models with transparent pricing
259+
* Advanced model browser with pagination and sorting (free models first)
260+
* Multi-account support with API key nicknames
261+
262+
---
263+
264+
## ⚙️ Pro Tip
265+
266+
1. Copy deepshell to your Environment path:
267+
```bash
268+
sudo cp deepshell /usr/local/bin/
269+
```
270+
271+
2. Create aliases for ds & dsq for quick keyboard actions:
272+
```bash
273+
nano .bashrc
274+
alias dsq="deepshell -q"
275+
alias ds="deepshell"
276+
alias dsi="deepshell -i"
277+
```
278+
279+
3. Save .bashrc file:
280+
```bash
281+
Ctrl+s & Ctrl+x
282+
```
283+
284+
4. Update your .bashrc file to use commands:
285+
```bash
286+
source .bashrc
287+
```
288+
289+
5. Use the alias `dsq` to quickly query the LLM:
290+
```bash
291+
dsq What is the best LLM?
292+
```
293+
294+
6. Use the alias `ds` to quickly access features with options:
295+
```bash
296+
ds -v
297+
```
298+
299+
7. Use the alias `dsi` to enter interactive mode:
300+
```bash
301+
dsi
302+
```
303+
304+
Happy Querying!!!

0 commit comments

Comments
 (0)