codelantern-agent-cli 1.0.0 โ 1.0.2
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 +294 -223
- package/dist/chunk-45FEFNMM.js +5030 -0
- package/dist/chunk-45FEFNMM.js.map +1 -0
- package/dist/cli.js +974 -89
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +371 -23
- package/dist/index.js +64 -7
- package/package.json +3 -2
- package/dist/chunk-Y3PEOLTZ.js +0 -2513
- package/dist/chunk-Y3PEOLTZ.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,27 +1,59 @@
|
|
|
1
1
|
# ๐ฎ Code Lantern CLI (`codelantern-agent-cli`)
|
|
2
2
|
|
|
3
|
-
> **Personal AI coding assistant for the terminal
|
|
4
|
-
>
|
|
5
|
-
>
|
|
3
|
+
> **Personal AI coding assistant for the terminal with native OS credential storage, automatic key reuse, multi-provider intelligence, and ironclad safety.**
|
|
4
|
+
> Terminal command: **`lantern`**
|
|
5
|
+
> Package: **`codelantern-agent-cli`**
|
|
6
|
+
> Release status: **`1.0.1` published on npm** | **`1.0.2` prepared locally**
|
|
7
|
+
> Default provider: **Google Gemini** (`gemini-3.8-flash`)
|
|
6
8
|
|
|
7
|
-
Code Lantern CLI is
|
|
9
|
+
Code Lantern CLI is a resilient, autonomous terminal coding assistant designed to help you inspect, build, edit, and troubleshoot codebases directly from your shell. It connects directly to your chosen AI providersโGoogle Gemini, OpenRouter, OpenAI, Anthropic Claude, or custom OpenAI-compatible endpointsโwith zero third-party agent dependencies.
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
11
|
-
## โก
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
13
|
+
## โก What's New in v1.0.2
|
|
14
|
+
|
|
15
|
+
- ๐ **Connection & Request Lifecycle Resilience (Google Gemini Hang Resolution)**:
|
|
16
|
+
- **Identified Root Cause**: In `@google/genai`, the client uses an internal Undici dispatcher configured with disabled header/body timeouts (`headersTimeout: 0, bodyTimeout: 0`). The previous implementation did not pass `abortSignal` or `httpOptions.timeout` to `client.models.generateContentStream`, nor did it bound the connection promise. Any stalled socket, proxy delay, or handshake freeze caused the application to await `generateContentStream` indefinitely while the spinner remained frozen at `Connecting to Google Gemini (gemini-3.8-flash)...`.
|
|
17
|
+
- **End-to-End Signal & Timeout Propagation**: Propagates a unified abort signal through credential resolution, provider initialization, network connection, streaming token consumption, and tool execution.
|
|
18
|
+
- **Bounded Connection Setup**: Introduces `connectTimeoutMs` (default: 15s or bounded by `timeoutMs`) using provider-level `withTimeoutRace` so that connection stalls or socket hangs abort promptly and cleanly.
|
|
19
|
+
- **Real Progress Stages**: Real-time spinner dynamically transitions through:
|
|
20
|
+
- `Resolving credentials for <provider>...`
|
|
21
|
+
- `Connecting to <provider> (<model>)...`
|
|
22
|
+
- `Waiting for first token from <provider> (<model>)...`
|
|
23
|
+
- `Receiving streaming response...`
|
|
24
|
+
- `Executing tool <name>...`
|
|
25
|
+
- **Zero Stuck Spinners**: Empty text chunks or function-call-only responses unconditionally stop the spinner immediately upon arrival.
|
|
26
|
+
- **Actionable Diagnostics**: Clear, specific error formatting for timeouts, cancellations, 401/403 authentication failures, 404 model access issues, and 429 rate limits without leaking API keys.
|
|
27
|
+
- **Safe Retries**: Only safe transient network errors (503, connection resets) retry with capped exponential backoff. Previously executed tool operations are never repeated.
|
|
28
|
+
- ๐ **Persistent Native OS Credential Storage & Automatic Reuse**:
|
|
29
|
+
- **Native OS Stores**: Keys are securely saved directly into your operating system's native credential vault:
|
|
30
|
+
- **macOS**: Apple Keychain via native Keychain Services.
|
|
31
|
+
- **Windows**: Windows Credential Manager.
|
|
32
|
+
- **One-Time Key Setup**: Enter an API key once per provider (`lantern keys set <provider>` or on prompt when first switching). Lantern securely remembers it and automatically reuses it across all future CLI sessions, requests, model queries, and provider switches. You never have to re-paste keys on every start.
|
|
33
|
+
- **Zero Plaintext Storage**: Keys are never stored in plaintext in `credentials.json`, config files, transcripts, logs, or command arguments.
|
|
34
|
+
- **Prebuilt Cross-Platform Engine**: Uses `@napi-rs/keyring` (prebuilt N-API binaries, no Python/node-gyp/C++ toolchain required during `npm install -g`) with native CLI fallbacks (`/usr/bin/security` on macOS, PowerShell Win32 API on Windows).
|
|
35
|
+
- **Explicit Environment Overrides**: Environment variables (`GEMINI_API_KEY`, `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`) continue to take explicit precedence over stored credentials.
|
|
36
|
+
- **Seamless Crash-Safe Migration**: Automatically inspects and migrates existing keys from legacy `~/.codelantern/credentials.json` into your native OS credential store, verifies retrieval, and cleans up legacy material safely without data loss.
|
|
37
|
+
- **Masked Input Prompts**: Interactive key entry is masked (`*`) so secrets are never echoed on your terminal screen.
|
|
38
|
+
- ๐ **In-Session Provider & Model Switching**:
|
|
39
|
+
- Switch providers and models **directly inside the running CLI** without restarting or exiting to the shell.
|
|
40
|
+
- `/provider` โ View configured providers and interactively select one.
|
|
41
|
+
- `/provider <name>` โ Switch the running session immediately (e.g. `/provider openrouter`, `/provider gemini`). Reuses the saved key automatically; asks only if no key is stored.
|
|
42
|
+
- `/provider default <name>` โ Set a provider as your persistent default and activate it immediately.
|
|
43
|
+
- `/model` โ Live discovery of usable models from the active provider with interactive selection.
|
|
44
|
+
- `/model <model-id>` โ Switch the active session to any valid model ID.
|
|
45
|
+
- `/model default <model-id>` โ Save a model as your persistent default.
|
|
46
|
+
- Real-time prompt indicator reflects the active provider (e.g. `lantern (openrouter) โฏ `).
|
|
47
|
+
- Preserves entire conversation history across provider and model switches.
|
|
48
|
+
- ๐ฏ **Capability Classification & Safety Guardrails**:
|
|
49
|
+
- Distinguishes **Interactive Coding Models** (tools + chat + streaming) from **Chat-Only Models** and **Specialized Models** (Embeddings, Image generation, Audio/Speech, Batch-only).
|
|
50
|
+
- Rejects attempts to select incompatible specialized models (such as `text-embedding-3-small` or `dall-e-3`) with clear explanations and offers compatible coding alternatives.
|
|
51
|
+
- ๐ **Performance & Hang Elimination**:
|
|
52
|
+
- **Bounded Request & First-Token Timeouts (`TTFT`)**: Configurable `--timeout` (default: 60s) and `--first-token-timeout` (default: 30s) eliminate indefinite network stalls.
|
|
53
|
+
- **Immediate Unbuffered Streaming**: Response tokens stream directly to stdout as they arrive.
|
|
54
|
+
- **Real-Time Spinner Stages**: Spinner transitions dynamically across `Connecting...`, `Waiting for first token...`, `Receiving response...`, and `Executing tool [name]...`.
|
|
55
|
+
- **Instant Cancellation (Ctrl+C)**: Pressing Ctrl+C aborts in-flight requests instantly via linked `AbortController`, cleanly returning to the prompt.
|
|
56
|
+
- **Safe Backoff Retries**: Transient HTTP failures (429/503) retry with small, capped backoff. Mutating tools (file edits, bash execution) are never duplicated.
|
|
25
57
|
|
|
26
58
|
---
|
|
27
59
|
|
|
@@ -32,330 +64,369 @@ Code Lantern CLI is an autonomous terminal coding assistant designed to help you
|
|
|
32
64
|
| **Node.js** | `>= 18.0.0` (Node 20 or Node 22 LTS recommended) |
|
|
33
65
|
| **npm** | `>= 9.0.0` |
|
|
34
66
|
| **Operating Systems** | macOS 12+ (Apple Silicon `arm64` & Intel `x64`), Windows 10/11 (PowerShell & CMD), Linux |
|
|
35
|
-
| **
|
|
67
|
+
| **Native Storage** | macOS Keychain (built-in) or Windows Credential Manager (built-in) |
|
|
68
|
+
| **API Keys** | Any of: `GEMINI_API_KEY`, `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or custom endpoint |
|
|
36
69
|
|
|
37
70
|
---
|
|
38
71
|
|
|
39
|
-
## ๐ฆ Installation
|
|
72
|
+
## ๐ฆ Installation & Startup
|
|
40
73
|
|
|
41
|
-
### Option A:
|
|
74
|
+
### Option A: Global Installation from npm
|
|
75
|
+
The current published version on the npm registry is **`1.0.1`**:
|
|
42
76
|
|
|
43
|
-
|
|
77
|
+
#### macOS & Linux:
|
|
78
|
+
```bash
|
|
79
|
+
npm install -g codelantern-agent-cli
|
|
80
|
+
lantern --version
|
|
81
|
+
# Output: 1.0.1
|
|
82
|
+
```
|
|
44
83
|
|
|
84
|
+
#### Windows (PowerShell or Command Prompt):
|
|
85
|
+
```powershell
|
|
86
|
+
npm install -g codelantern-agent-cli
|
|
87
|
+
lantern --version
|
|
88
|
+
# Output: 1.0.1
|
|
89
|
+
```
|
|
90
|
+
*npm automatically generates `lantern.cmd` and `lantern.ps1` wrappers on Windows, placing them in your npm global PATH.*
|
|
91
|
+
|
|
92
|
+
### Option B: Local Source Installation (v1.0.2)
|
|
45
93
|
```bash
|
|
46
94
|
cd "my own cli"
|
|
47
95
|
|
|
48
96
|
# 1. Install dependencies
|
|
49
97
|
npm install
|
|
50
98
|
|
|
51
|
-
# 2. Build
|
|
99
|
+
# 2. Build production bundle
|
|
52
100
|
npm run build
|
|
53
101
|
|
|
54
|
-
# 3. Link
|
|
102
|
+
# 3. Link globally for local testing
|
|
55
103
|
npm link
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Verify your installation:
|
|
59
104
|
|
|
60
|
-
```bash
|
|
61
105
|
lantern --version
|
|
62
|
-
# Output: 1.0.
|
|
106
|
+
# Output: 1.0.2
|
|
63
107
|
```
|
|
64
108
|
|
|
65
|
-
###
|
|
66
|
-
|
|
67
|
-
Once published to npm under `codelantern-agent-cli`:
|
|
68
|
-
|
|
69
|
-
#### On macOS / Linux:
|
|
109
|
+
### Starting Code Lantern
|
|
110
|
+
Start interactive mode:
|
|
70
111
|
```bash
|
|
71
|
-
|
|
72
|
-
lantern --version
|
|
112
|
+
lantern
|
|
73
113
|
```
|
|
114
|
+
You will be greeted with the banner showing your active provider, model, workspace, and security mode:
|
|
115
|
+
```text
|
|
116
|
+
๐ฎ Code Lantern CLI v1.0.2
|
|
117
|
+
Provider: Google Gemini (gemini) | Model: gemini-3.8-flash | Workspace: /path/to/project
|
|
118
|
+
Status: SAFE MODE (Approval Prompts) | Type /help for commands
|
|
74
119
|
|
|
75
|
-
|
|
76
|
-
```powershell
|
|
77
|
-
npm install -g codelantern-agent-cli
|
|
78
|
-
lantern --version
|
|
120
|
+
lantern (gemini) โฏ
|
|
79
121
|
```
|
|
80
|
-
*npm automatically generates `lantern.cmd` and `lantern.ps1` wrappers on Windows, placing them in your npm global PATH.*
|
|
81
122
|
|
|
82
123
|
---
|
|
83
124
|
|
|
84
|
-
## ๐
|
|
125
|
+
## ๐ Secure API Key Storage & Automatic Reuse
|
|
85
126
|
|
|
86
|
-
Code Lantern
|
|
127
|
+
Code Lantern uses a zero-plaintext credential model. You enter your API key once per provider, and Lantern securely stores it in your OS credential store and reuses it automatically across all future commands and sessions.
|
|
87
128
|
|
|
88
|
-
###
|
|
129
|
+
### One-Time Key Setup (Shell)
|
|
89
130
|
|
|
90
|
-
|
|
131
|
+
Run `lantern keys set <provider>`:
|
|
91
132
|
```bash
|
|
92
|
-
|
|
133
|
+
# Set Google Gemini API key
|
|
134
|
+
lantern keys set gemini
|
|
135
|
+
|
|
136
|
+
# Set OpenRouter API key
|
|
137
|
+
lantern keys set openrouter
|
|
138
|
+
|
|
139
|
+
# Set OpenAI or Anthropic keys
|
|
140
|
+
lantern keys set openai
|
|
141
|
+
lantern keys set anthropic
|
|
93
142
|
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
143
|
+
|
|
144
|
+
Lantern prompts for your key with a masked input prompt (`*`). As you type, nothing is displayed in plaintext.
|
|
145
|
+
Once entered, Lantern verifies that the key can be retrieved from your native OS store and saves it:
|
|
146
|
+
```text
|
|
147
|
+
Enter API key for 'gemini': ***************************************
|
|
148
|
+
โ Successfully saved API key for 'gemini' to macOS Keychain (AIza...W9q0)
|
|
149
|
+
Lantern will automatically reuse this key in future sessions and commands.
|
|
97
150
|
```
|
|
98
151
|
|
|
99
|
-
###
|
|
152
|
+
### In-Session Automatic Key Entry
|
|
153
|
+
If you launch Lantern or switch to a provider that does not yet have a stored key:
|
|
154
|
+
1. Lantern prompts you right inside the terminal:
|
|
155
|
+
```text
|
|
156
|
+
๐ฎ No API key configured for OpenRouter (openrouter).
|
|
157
|
+
Lantern will securely save this key to your macOS Keychain so you never have to re-enter it.
|
|
158
|
+
Enter API key for 'openrouter': *******************************************************
|
|
159
|
+
โ Saved key for 'OpenRouter' to macOS Keychain (sk-o...097d)
|
|
160
|
+
```
|
|
161
|
+
2. Lantern saves it to your OS credential store, tests connectivity, and proceeds immediately.
|
|
162
|
+
3. Every future run, model listing, or session switch reuses that key automatically without prompting again!
|
|
100
163
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
164
|
+
### Viewing Configured Keys Safely
|
|
165
|
+
Inspect configured providers and their storage source without exposing secrets:
|
|
166
|
+
```bash
|
|
167
|
+
lantern keys list
|
|
104
168
|
```
|
|
105
169
|
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
|
|
170
|
+
Example output:
|
|
171
|
+
```text
|
|
172
|
+
๐ฎ Configured Provider API Keys
|
|
173
|
+
Storage: macOS Keychain
|
|
174
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
175
|
+
Provider Source Masked Key
|
|
176
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
177
|
+
gemini [macOS Keychain] AIza...W9q0
|
|
178
|
+
openai none (not configured)
|
|
179
|
+
anthropic none (not configured)
|
|
180
|
+
openrouter [env: OPENROUTER_API_KEY] sk-o...097d
|
|
181
|
+
custom none (not configured)
|
|
109
182
|
```
|
|
110
183
|
|
|
111
|
-
###
|
|
184
|
+
### Environment Variable Overrides
|
|
185
|
+
Environment variables take explicit precedence over stored credentials when present:
|
|
112
186
|
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
|
|
187
|
+
#### macOS / Linux (`zsh` or `bash`):
|
|
188
|
+
```bash
|
|
189
|
+
export GEMINI_API_KEY="AIzaSyYourGeminiApiKeyHere"
|
|
190
|
+
export OPENROUTER_API_KEY="sk-or-v1-YourOpenRouterKeyHere"
|
|
191
|
+
export OPENAI_API_KEY="sk-proj-..."
|
|
192
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
116
193
|
```
|
|
117
194
|
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
|
|
195
|
+
#### Windows (PowerShell):
|
|
196
|
+
```powershell
|
|
197
|
+
$env:GEMINI_API_KEY="AIzaSyYourGeminiApiKeyHere"
|
|
198
|
+
$env:OPENROUTER_API_KEY="sk-or-v1-YourOpenRouterKeyHere"
|
|
121
199
|
```
|
|
122
200
|
|
|
123
|
-
|
|
201
|
+
### Replacing or Removing Keys
|
|
202
|
+
- **To replace an existing key**: Simply run `lantern keys set <provider>` again. The new key overwrites the old entry in your OS credential store.
|
|
203
|
+
- **To remove a stored key**:
|
|
204
|
+
```bash
|
|
205
|
+
lantern keys remove gemini
|
|
206
|
+
# Output: โ Removed stored key for 'gemini' from macOS Keychain
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Automatic Legacy Migration
|
|
210
|
+
If you previously had keys saved in the legacy `~/.codelantern/credentials.json` format:
|
|
211
|
+
1. Lantern automatically detects the file upon startup or credential lookup.
|
|
212
|
+
2. It decrypts the legacy payload in-memory without displaying or logging it.
|
|
213
|
+
3. It saves the key to your native OS credential store and verifies retrieval.
|
|
214
|
+
4. Only after successful verification, the provider entry is purged from the legacy file.
|
|
215
|
+
5. If Lantern is interrupted, remaining keys are preserved for safe retry on the next run.
|
|
216
|
+
6. Once all keys are migrated, the obsolete file is safely deleted.
|
|
124
217
|
|
|
125
218
|
---
|
|
126
219
|
|
|
127
|
-
##
|
|
220
|
+
## ๐ In-Session Provider & Model Switching
|
|
128
221
|
|
|
129
|
-
|
|
222
|
+
Code Lantern allows you to switch providers and models **from inside the running CLI** without exiting to your shell.
|
|
130
223
|
|
|
131
|
-
|
|
132
|
-
lantern
|
|
133
|
-
|
|
224
|
+
> **Important Distinction**:
|
|
225
|
+
> - **In-Session Slash Commands** (prefixed with `/`) are typed **inside Lantern** at the `lantern (...) โฏ` prompt.
|
|
226
|
+
> - **System Shell Commands** (prefixed with `lantern`) are typed in your standard terminal (`bash`, `zsh`, `cmd`, `pwsh`).
|
|
134
227
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
228
|
+
### In-Session Provider Commands (Inside Lantern)
|
|
229
|
+
|
|
230
|
+
| In-Session Command | What It Does |
|
|
231
|
+
| :--- | :--- |
|
|
232
|
+
| **`/provider`** | Lists configured providers with status and lets you select one interactively |
|
|
233
|
+
| **`/provider openrouter`** | Switches current session to OpenRouter immediately (reuses saved key automatically) |
|
|
234
|
+
| **`/provider gemini`** | Switches current session to Google Gemini immediately (reuses saved key automatically) |
|
|
235
|
+
| **`/provider openai`** | Switches current session to OpenAI immediately |
|
|
236
|
+
| **`/provider anthropic`** | Switches current session to Anthropic Claude immediately |
|
|
237
|
+
| **`/provider default openrouter`** | Saves OpenRouter as persistent default in config and activates it immediately |
|
|
238
|
+
|
|
239
|
+
### In-Session Model Commands (Inside Lantern)
|
|
240
|
+
|
|
241
|
+
| In-Session Command | What It Does |
|
|
242
|
+
| :--- | :--- |
|
|
243
|
+
| **`/model`** | Queries active provider API for available models and displays an interactive selection menu |
|
|
244
|
+
| **`/model gemini-2.5-pro`** | Switches current session to `gemini-2.5-pro` |
|
|
245
|
+
| **`/model anthropic/claude-3.7-sonnet`** | Switches current session to Claude 3.7 Sonnet (on OpenRouter) |
|
|
246
|
+
| **`/model default <model-id>`** | Saves model as persistent default in config and activates it immediately |
|
|
247
|
+
|
|
248
|
+
### Capability Classification & Discovery
|
|
249
|
+
When listing models via `/model`, Lantern separates models into clear categories:
|
|
250
|
+
|
|
251
|
+
1. **Interactive Coding Models**: Models that support text chat, streaming, and tool execution (function calling). Examples: `gemini-3.8-flash`, `gpt-4o`, `claude-3-7-sonnet`, `anthropic/claude-3.7-sonnet`.
|
|
252
|
+
2. **Chat-Only Models**: Models that support streaming conversation, but lack tool/function calling. Lantern warns you that file editing and command execution will be unavailable.
|
|
253
|
+
3. **Specialized Models**: Non-coding models such as Embeddings (`text-embedding-3-small`), Image Generation (`dall-e-3`), Speech/Audio (`whisper-1`), and Batch-only (`*:batch`). Lantern cleanly rejects attempts to use specialized models for interactive coding and offers compatible models.
|
|
151
254
|
|
|
152
255
|
---
|
|
153
256
|
|
|
154
|
-
##
|
|
257
|
+
## ๐ป System Shell Commands Reference
|
|
258
|
+
|
|
259
|
+
Use these commands from your operating system shell (`bash`, `zsh`, `cmd`, `PowerShell`):
|
|
155
260
|
|
|
156
261
|
| Command | Action |
|
|
157
262
|
| :--- | :--- |
|
|
158
263
|
| **`lantern`** | Launch the interactive conversational REPL |
|
|
159
|
-
| **`lantern ask "<question>"`** | One-shot prompt execution with streaming
|
|
160
|
-
| **`lantern plan "<task>"`** | Read-only inspection
|
|
264
|
+
| **`lantern ask "<question>"`** | One-shot prompt execution with streaming response |
|
|
265
|
+
| **`lantern plan "<task>"`** | Read-only inspection and implementation plan |
|
|
161
266
|
| **`lantern resume [sessionId]`** | Resume the most recent or specified session |
|
|
162
|
-
| **`lantern sessions`** | List saved local sessions |
|
|
163
|
-
| **`lantern
|
|
164
|
-
| **`lantern
|
|
165
|
-
| **`lantern
|
|
166
|
-
| **`lantern
|
|
167
|
-
| **`lantern
|
|
168
|
-
| **`lantern
|
|
267
|
+
| **`lantern sessions`** | List saved local sessions (`--export <id>`, `--delete <id>`) |
|
|
268
|
+
| **`lantern providers`** | Shell management for providers (`list`, `set-default`, `test`, `add`, `remove`) |
|
|
269
|
+
| **`lantern models`** | Shell management for models (`list`, `set`, `-p <provider>`, `-r`, `--json`) |
|
|
270
|
+
| **`lantern keys`** | Manage OS-stored API keys (`list`, `set`, `remove`) |
|
|
271
|
+
| **`lantern skills`** | Manage portable skills (`list`, `show`, `add`, `enable`, `disable`, `remove`) |
|
|
272
|
+
| **`lantern config`** | View or update configuration (`list`, `get`, `set`) |
|
|
273
|
+
| **`lantern doctor`** | Diagnose environment, credentials, latency, and MCP health |
|
|
274
|
+
| **`lantern mcp`** | Manage MCP servers (`list`, `add`, `remove`, `test`, `enable`, `disable`) |
|
|
169
275
|
| **`lantern --help`** | View all CLI flags and options |
|
|
170
|
-
| **`lantern --version`** | Output version string |
|
|
171
|
-
|
|
172
|
-
### Global Options
|
|
276
|
+
| **`lantern --version`** | Output version string (`1.0.2`) |
|
|
173
277
|
|
|
278
|
+
### Global CLI Flags
|
|
279
|
+
- **`-p, --provider <provider>`**: Select provider (`gemini`, `openai`, `anthropic`, `openrouter`, or custom).
|
|
174
280
|
- **`-m, --model <id>`**: Override model ID (default: `gemini-3.8-flash`).
|
|
175
281
|
- **`-C, --cwd <path>`**: Set workspace directory for agent operations.
|
|
176
282
|
- **`-s, --session <id>`**: Use or resume a specific session ID.
|
|
177
283
|
- **`-a, --attach <files...>`**: Attach text files, images (`.png`, `.jpg`, `.webp`), or PDFs.
|
|
178
284
|
- **`--yolo`**: Skip interactive confirmation prompts for file edits and shell commands.
|
|
179
285
|
- **`--json`**: Output results formatted as JSON.
|
|
286
|
+
- **`--timeout <ms>`**: Maximum total request duration (default: `60000`).
|
|
287
|
+
- **`--first-token-timeout <ms>`**: Maximum wait time for initial response token (default: `30000`).
|
|
288
|
+
- **`--timing`**: Display detailed execution and latency timing diagnostics.
|
|
289
|
+
- **`--fast`**: Enable low-latency mode where supported.
|
|
290
|
+
- **`--skill <skills...>`**: Explicitly activate one or more skills for the run.
|
|
180
291
|
|
|
181
292
|
---
|
|
182
293
|
|
|
183
|
-
##
|
|
184
|
-
|
|
185
|
-
### 1. Interactive Shell
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
lantern
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Inside the interactive REPL:
|
|
192
|
-
- Type your question or task naturally.
|
|
193
|
-
- Use `\` at the end of a line for multiline continuation.
|
|
194
|
-
- Enclose multiline code blocks inside `""" ... """`.
|
|
195
|
-
- Press `Up`/`Down` arrows to navigate previous prompt history.
|
|
196
|
-
- Available slash commands:
|
|
197
|
-
- `/help` โ List available commands and tools.
|
|
198
|
-
- `/clear` โ Clear terminal screen.
|
|
199
|
-
- `/status` โ View workspace, model, token count, and active session ID.
|
|
200
|
-
- `/model [id]` โ Switch model on the fly (e.g. `/model gemini-3.8-flash`).
|
|
201
|
-
- `/plan [on|off]` โ Toggle read-only plan mode.
|
|
202
|
-
- `/yolo [on|off]` โ Toggle YOLO mode for the session.
|
|
203
|
-
- `/sessions` โ List saved sessions.
|
|
204
|
-
- `/history` โ Print recent conversation turns.
|
|
205
|
-
- `/export [md|json]` โ Export current session transcript.
|
|
206
|
-
- `/exit` or `/quit` โ Save session and exit.
|
|
207
|
-
|
|
208
|
-
### 2. One-Shot Question with File Attachment
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
lantern ask "Refactor this component to use React hooks" --attach src/components/UserProfile.tsx
|
|
212
|
-
```
|
|
294
|
+
## ๐งฉ Portable Skills System (`SKILL.md`)
|
|
213
295
|
|
|
214
|
-
|
|
296
|
+
Code Lantern supports domain-specific skills using the portable `SKILL.md` format (YAML frontmatter + markdown instructions + references):
|
|
215
297
|
|
|
216
|
-
```
|
|
217
|
-
|
|
298
|
+
```markdown
|
|
299
|
+
---
|
|
300
|
+
name: build-your-own-x
|
|
301
|
+
description: Step-by-step architectural patterns for recreating technologies from scratch
|
|
302
|
+
---
|
|
303
|
+
# Build Your Own X Instructions
|
|
304
|
+
When designing and implementing systems from scratch, follow these patterns...
|
|
218
305
|
```
|
|
219
306
|
|
|
220
|
-
###
|
|
221
|
-
|
|
307
|
+
### Managing Skills (From Shell)
|
|
222
308
|
```bash
|
|
223
|
-
#
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
# Windows PowerShell
|
|
227
|
-
Get-Content build.log | lantern "Summarize the root cause of these compiler errors"
|
|
228
|
-
```
|
|
309
|
+
# List installed skills
|
|
310
|
+
lantern skills list
|
|
229
311
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
## ๐ก๏ธ Approval & YOLO Modes
|
|
312
|
+
# Add a skill from a local directory or markdown file
|
|
313
|
+
lantern skills add ./my-skill-folder
|
|
233
314
|
|
|
234
|
-
|
|
315
|
+
# Add a skill directly from a Git repository
|
|
316
|
+
lantern skills add https://github.com/example/skills-repo.git
|
|
235
317
|
|
|
236
|
-
|
|
318
|
+
# Inspect skill instructions and reference documents
|
|
319
|
+
lantern skills show build-your-own-x
|
|
237
320
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
2. **Before Creating Files**: Displays a line-numbered preview of the file.
|
|
243
|
-
3. **Before Executing Shell Commands**: Displays the exact command and working directory.
|
|
321
|
+
# Enable or disable skills
|
|
322
|
+
lantern skills enable build-your-own-x
|
|
323
|
+
lantern skills disable build-your-own-x
|
|
244
324
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
Run Lantern with `--yolo` or enter `yolo` / `a` at an approval prompt to auto-approve safe modifications for that execution:
|
|
248
|
-
```bash
|
|
249
|
-
lantern --yolo ask "Run npm test and fix failing assertions"
|
|
325
|
+
# Remove a skill
|
|
326
|
+
lantern skills remove build-your-own-x
|
|
250
327
|
```
|
|
251
328
|
|
|
252
|
-
### Unconditional Safety Invariants
|
|
253
|
-
|
|
254
|
-
- **Strict Workspace Containment**: Lantern cannot read, edit, or execute outside your workspace directory. Path traversal attempts (`../../`) and symlink escapes are rejected.
|
|
255
|
-
- **Secret Shielding**: `.env`, `.env.*`, `*.pem`, `*.key`, `id_rsa`, and credential JSON files are blocked from reading or being sent to Gemini.
|
|
256
|
-
- **Destructive Command Firewall**: Destructive system commands (e.g. `rm -rf /`, `mkfs`, Windows `format c:`, `del /s /q c:\*`) are strictly blocked across all platforms.
|
|
257
|
-
- **Token Redaction**: Any API keys detected in text are automatically masked before saving or displaying.
|
|
258
|
-
|
|
259
329
|
---
|
|
260
330
|
|
|
261
|
-
##
|
|
262
|
-
|
|
263
|
-
Connect external tool servers using the official Model Context Protocol stdio transport:
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
# Add SQLite database MCP server
|
|
267
|
-
lantern mcp add sqlite npx -y @modelcontextprotocol/server-sqlite ./data.db
|
|
268
|
-
|
|
269
|
-
# Test server connection and inspect exposed tools
|
|
270
|
-
lantern mcp test sqlite
|
|
271
|
-
|
|
272
|
-
# List configured MCP servers
|
|
273
|
-
lantern mcp list
|
|
274
|
-
|
|
275
|
-
# Disable or enable a server
|
|
276
|
-
lantern mcp disable sqlite
|
|
277
|
-
lantern mcp enable sqlite
|
|
331
|
+
## ๐ก๏ธ Safe Mode & Invariants
|
|
278
332
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
333
|
+
Code Lantern runs in **Safe Mode** by default:
|
|
334
|
+
1. **Interactive Unified Diffs**: Displays colored unified diffs showing exact deletions in red and additions in green before modifying any file.
|
|
335
|
+
2. **Command Approvals**: Shows exact command line and working directory before executing shell commands.
|
|
336
|
+
3. **Workspace Boundary**: Strict containment prevents path traversal (`../../`) or symlink escapes outside the workspace.
|
|
337
|
+
4. **Secret Firewall**: Blocks reading `.env`, `.env.*`, `*.pem`, `*.key`, `id_rsa`, or credential stores.
|
|
338
|
+
5. **Key Redaction**: Dynamic and pattern-based redaction ensures API keys are never leaked in error messages, logs, transcripts, or HTTP diagnostics.
|
|
339
|
+
6. **Destructive Command Guard**: Rejects destructive system commands (e.g., `rm -rf /`, Windows `format c:`, `del /s /q c:\*`).
|
|
282
340
|
|
|
283
341
|
---
|
|
284
342
|
|
|
285
|
-
##
|
|
343
|
+
## ๐ฉบ Diagnostics (`lantern doctor`)
|
|
286
344
|
|
|
287
|
-
|
|
345
|
+
Run `lantern doctor` at any time to verify system health, OS credential storage, network connectivity, latency, and keys:
|
|
288
346
|
|
|
289
347
|
```bash
|
|
290
|
-
|
|
291
|
-
lantern config
|
|
292
|
-
|
|
293
|
-
# Update settings
|
|
294
|
-
lantern config set defaultModel gemini-3.8-flash
|
|
295
|
-
lantern config set maxSteps 30
|
|
296
|
-
lantern config set temperature 0.2
|
|
348
|
+
lantern doctor
|
|
297
349
|
```
|
|
298
350
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
351
|
+
Example output:
|
|
352
|
+
```text
|
|
353
|
+
๐ฎ Code Lantern Doctor โ Diagnostics
|
|
354
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
355
|
+
โ Platform / OS: macOS (Apple Silicon)
|
|
356
|
+
โ Node.js Runtime: v26.12.1 (compatible)
|
|
357
|
+
โ Active Provider: Google Gemini (gemini)
|
|
358
|
+
โ Active Model: gemini-3.8-flash
|
|
359
|
+
โ Credential Storage: macOS Keychain
|
|
360
|
+
โ API Key (gemini): Configured [macOS Keychain] (AIza...W9q0)
|
|
361
|
+
โ Provider Auth & Ping: Verified (295ms latency)
|
|
362
|
+
โ Additional Providers: Configured (openrouter)
|
|
363
|
+
โ Git CLI: Available (git version 2.54.0)
|
|
364
|
+
โ Config File: ~/.codelantern/config.json (Timeout: 60000ms, TTFT: 30000ms)
|
|
365
|
+
โ Session Storage: ~/.codelantern/sessions (2 stored session(s))
|
|
366
|
+
โ Skills: Cleanly loaded
|
|
367
|
+
โ Project Instructions: Found (LANTERN.md)
|
|
368
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
369
|
+
โจ All systems healthy! Code Lantern CLI is ready to assist.
|
|
308
370
|
```
|
|
309
371
|
|
|
310
372
|
---
|
|
311
373
|
|
|
312
|
-
##
|
|
374
|
+
## ๐ง Troubleshooting Google Gemini Connectivity
|
|
313
375
|
|
|
314
|
-
|
|
376
|
+
If you ever encounter connection difficulties, follow these steps:
|
|
315
377
|
|
|
316
|
-
1. **
|
|
378
|
+
1. **Verify Configured API Key**:
|
|
379
|
+
Run `lantern keys list` to ensure `gemini` is configured via your native OS credential store or environment:
|
|
317
380
|
```bash
|
|
318
|
-
|
|
319
|
-
npm run lint
|
|
320
|
-
npm run build
|
|
381
|
+
lantern keys list
|
|
321
382
|
```
|
|
322
|
-
|
|
383
|
+
If unconfigured, store your key once:
|
|
323
384
|
```bash
|
|
324
|
-
|
|
385
|
+
lantern keys set gemini
|
|
325
386
|
```
|
|
326
|
-
|
|
327
|
-
|
|
387
|
+
2. **Test Provider Connection**:
|
|
388
|
+
Test direct connectivity, authorization, and token latency:
|
|
328
389
|
```bash
|
|
329
|
-
|
|
390
|
+
lantern keys test gemini
|
|
391
|
+
# or:
|
|
392
|
+
lantern providers test gemini
|
|
330
393
|
```
|
|
331
|
-
|
|
394
|
+
3. **Switch Model if Needed**:
|
|
395
|
+
If a particular model is unavailable or restricted on your account:
|
|
396
|
+
- Inside interactive session: type `/model` to browse models, or `/model gemini-2.5-flash` to switch immediately.
|
|
397
|
+
- From shell: `lantern models set gemini-2.5-flash`
|
|
398
|
+
4. **Adjust Timeout Limits**:
|
|
399
|
+
If your network has high latency or is behind a strict proxy, increase the timeout limits:
|
|
332
400
|
```bash
|
|
333
|
-
|
|
401
|
+
lantern config set timeoutMs 120000
|
|
402
|
+
lantern config set firstTokenTimeoutMs 45000
|
|
334
403
|
```
|
|
404
|
+
5. **Instant Cancellation**:
|
|
405
|
+
Pressing **Ctrl+C** at any time during credential resolution, connection setup, first-token waiting, streaming, or tool execution immediately stops the request and cleanly returns to your prompt.
|
|
335
406
|
|
|
336
407
|
---
|
|
337
408
|
|
|
338
|
-
## ๐งช Testing
|
|
409
|
+
## ๐งช Automated Testing
|
|
339
410
|
|
|
340
|
-
|
|
411
|
+
Code Lantern includes a comprehensive test suite covering security sandboxing, CRLF line endings, tool execution, session persistence, timeout handling, first-token limits, cancellation, OS credential storage, automatic key reuse, provider isolation, env var overrides, crash-safe migration, secret redaction, in-session switching, slash commands, and the Gemini request lifecycle:
|
|
341
412
|
|
|
342
413
|
```bash
|
|
414
|
+
# Run test suite (61 automated checks)
|
|
343
415
|
npm test
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
Run TypeScript compilation check:
|
|
347
416
|
|
|
348
|
-
|
|
417
|
+
# Run TypeScript type check
|
|
349
418
|
npm run lint
|
|
419
|
+
|
|
420
|
+
# Build production bundle
|
|
421
|
+
npm run build
|
|
350
422
|
```
|
|
351
423
|
|
|
352
424
|
---
|
|
353
425
|
|
|
354
|
-
## โ ๏ธ
|
|
426
|
+
## โ ๏ธ Platform Verification Notes
|
|
355
427
|
|
|
356
|
-
- **Directly
|
|
357
|
-
- **Windows
|
|
358
|
-
- **Terminal Colors**: A modern terminal emulator with ANSI color support (macOS Terminal, iTerm2, Windows Terminal, VS Code Integrated Terminal) is recommended.
|
|
428
|
+
- **macOS (Directly Verified)**: Developed, built, and verified on macOS (Apple Silicon arm64, Node v26) with all 61 automated tests passing, native macOS Keychain integration verified, and live provider connectivity verified.
|
|
429
|
+
- **Windows (Architecturally Supported)**: Built with portable Node.js APIs (`path.normalize`, `path.sep`, `windowsHide: true`, CRLF handling, Windows Credential Manager integration, and Windows command guards). Direct testing on native Windows hardware was not performed in this session; Windows verification relies on the automated Windows CI workflow (`.github/workflows/ci.yml`).
|
|
359
430
|
|
|
360
431
|
---
|
|
361
432
|
|