codelantern-agent-cli 0.0.0-stage โ 1.0.0
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/LICENSE +21 -0
- package/README.md +363 -2
- package/dist/chunk-Y3PEOLTZ.js +2513 -0
- package/dist/chunk-Y3PEOLTZ.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +914 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +284 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Code Lantern CLI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,364 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ฎ Code Lantern CLI (`codelantern-agent-cli`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Personal AI coding assistant for the terminal powered directly by the Google Gemini API.**
|
|
4
|
+
> Cross-platform terminal command: **`lantern`**
|
|
5
|
+
> Default model: **`gemini-3.8-flash`**
|
|
6
|
+
|
|
7
|
+
Code Lantern CLI is an autonomous terminal coding assistant designed to help you inspect, build, edit, and troubleshoot codebases directly from your shell. It calls Google's official Gemini API directly using `@google/genai`โit does not depend on Antigravity, Codex, or Gemini CLI being installed.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## โก Key Highlights
|
|
12
|
+
|
|
13
|
+
- **Direct Gemini Connection**: Native integration with Google's `@google/genai` TypeScript SDK using `gemini-3.8-flash` by default.
|
|
14
|
+
- **Cross-Platform Architecture**: Engineered to run consistently on **macOS** (both Apple Silicon M-series and Intel x86_64) and **Windows** (Command Prompt, PowerShell, Windows Terminal), as well as Linux.
|
|
15
|
+
- **Safe Mode with Diff Previews**: Inspects before modifying. Shows colored unified patch diffs (`+ added`, `- removed`) and command previews before requesting interactive approval.
|
|
16
|
+
- **Deliberate YOLO Mode (`--yolo`)**: Auto-approves operations when explicitly requested, while maintaining strict workspace containment and secret shielding boundaries.
|
|
17
|
+
- **Read-Only Plan Mode (`lantern plan`)**: Formulates comprehensive, step-by-step implementation plans without mutating files or running shell commands.
|
|
18
|
+
- **Piped Unix / PowerShell Workflows**: Pipe test failures, git diffs, or files into Lantern:
|
|
19
|
+
- macOS/Linux: `npm test 2>&1 | lantern "diagnose error"`
|
|
20
|
+
- Windows PowerShell: `Get-Content error.log | lantern "how do I fix this?"`
|
|
21
|
+
- **Context Awareness**: Respects `.gitignore`, ignores vendor and build trees (`node_modules`, `dist`, `.git`), detects `LANTERN.md` / `GEMINI.md` project rules, and renders ASCII file trees.
|
|
22
|
+
- **Security Sandbox**: Rejects path traversal (`../../`) and symlink escapes. Masks `.env` files, private keys, and scrubs API tokens from transcripts and logs.
|
|
23
|
+
- **Model Context Protocol (MCP)**: Native stdio client integration via `@modelcontextprotocol/sdk` to dynamically expose external database, API, and tool servers to Gemini.
|
|
24
|
+
- **Rich Terminal Experience**: Streaming responses, syntax-highlighted markdown, animated spinners, multiline prompt input (`\`), command history, and slash commands.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ๐ป System Prerequisites
|
|
29
|
+
|
|
30
|
+
| Requirement | Supported Version / Details |
|
|
31
|
+
| :--- | :--- |
|
|
32
|
+
| **Node.js** | `>= 18.0.0` (Node 20 or Node 22 LTS recommended) |
|
|
33
|
+
| **npm** | `>= 9.0.0` |
|
|
34
|
+
| **Operating Systems** | macOS 12+ (Apple Silicon `arm64` & Intel `x64`), Windows 10/11 (PowerShell & CMD), Linux |
|
|
35
|
+
| **API Key** | Google Gemini API Key ([Get one free at Google AI Studio](https://aistudio.google.com/app/apikey)) |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## ๐ฆ Installation
|
|
40
|
+
|
|
41
|
+
### Option A: Local Development Installation
|
|
42
|
+
|
|
43
|
+
Clone or open the project folder in your terminal:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cd "my own cli"
|
|
47
|
+
|
|
48
|
+
# 1. Install dependencies
|
|
49
|
+
npm install
|
|
50
|
+
|
|
51
|
+
# 2. Build the executable
|
|
52
|
+
npm run build
|
|
53
|
+
|
|
54
|
+
# 3. Link the 'lantern' command globally
|
|
55
|
+
npm link
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Verify your installation:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
lantern --version
|
|
62
|
+
# Output: 1.0.0
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Option B: Global Installation after Publishing to npm
|
|
66
|
+
|
|
67
|
+
Once published to npm under `codelantern-agent-cli`:
|
|
68
|
+
|
|
69
|
+
#### On macOS / Linux:
|
|
70
|
+
```bash
|
|
71
|
+
npm install -g codelantern-agent-cli
|
|
72
|
+
lantern --version
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### On Windows (PowerShell or Command Prompt):
|
|
76
|
+
```powershell
|
|
77
|
+
npm install -g codelantern-agent-cli
|
|
78
|
+
lantern --version
|
|
79
|
+
```
|
|
80
|
+
*npm automatically generates `lantern.cmd` and `lantern.ps1` wrappers on Windows, placing them in your npm global PATH.*
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## ๐ Gemini API Key Configuration
|
|
85
|
+
|
|
86
|
+
Code Lantern CLI reads your API key from the standard environment variable `GEMINI_API_KEY`.
|
|
87
|
+
|
|
88
|
+
### macOS / Linux (`zsh` or `bash`)
|
|
89
|
+
|
|
90
|
+
Add to `~/.zshrc` or `~/.bashrc`:
|
|
91
|
+
```bash
|
|
92
|
+
export GEMINI_API_KEY="AIzaSyYourActualGeminiApiKeyHere"
|
|
93
|
+
```
|
|
94
|
+
Or set it for the current session:
|
|
95
|
+
```bash
|
|
96
|
+
export GEMINI_API_KEY="AIzaSyYourActualGeminiApiKeyHere"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Windows (PowerShell)
|
|
100
|
+
|
|
101
|
+
For the current session:
|
|
102
|
+
```powershell
|
|
103
|
+
$env:GEMINI_API_KEY="AIzaSyYourActualGeminiApiKeyHere"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Persistently for user environment:
|
|
107
|
+
```powershell
|
|
108
|
+
[System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'AIzaSyYourActualGeminiApiKeyHere', 'User')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Windows (Command Prompt `cmd.exe`)
|
|
112
|
+
|
|
113
|
+
For current session:
|
|
114
|
+
```cmd
|
|
115
|
+
set GEMINI_API_KEY=AIzaSyYourActualGeminiApiKeyHere
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Persistently:
|
|
119
|
+
```cmd
|
|
120
|
+
setx GEMINI_API_KEY "AIzaSyYourActualGeminiApiKeyHere"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
> **Security Note:** Code Lantern never prints, commits, logs, or saves your raw API key in session transcripts.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## ๐ฉบ Diagnostics (`lantern doctor`)
|
|
128
|
+
|
|
129
|
+
Run `lantern doctor` at any time to verify your environment, API key validity, git availability, and MCP servers:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
lantern doctor
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Example output:
|
|
136
|
+
```text
|
|
137
|
+
๐ฎ Code Lantern Doctor โ Diagnostics
|
|
138
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
139
|
+
โ Platform / OS: macOS (Apple Silicon)
|
|
140
|
+
โ Node.js Runtime: v26.12.1 (compatible)
|
|
141
|
+
โ GEMINI_API_KEY: Found (AIza...W9q0)
|
|
142
|
+
โ Gemini API Auth: Verified (contacted 'gemini-3.8-flash')
|
|
143
|
+
โ Git CLI: Available (git version 2.54.0)
|
|
144
|
+
โ Config File: ~/.codelantern/config.json (Model: gemini-3.8-flash)
|
|
145
|
+
โ Session Storage: ~/.codelantern/sessions (0 stored session(s))
|
|
146
|
+
โน MCP Configuration: No external MCP servers configured (optional)
|
|
147
|
+
โ Project Instructions: Found (LANTERN.md) in /workspace
|
|
148
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
149
|
+
โจ All systems healthy! Code Lantern CLI is ready to assist.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## ๐ Command Reference
|
|
155
|
+
|
|
156
|
+
| Command | Action |
|
|
157
|
+
| :--- | :--- |
|
|
158
|
+
| **`lantern`** | Launch the interactive conversational REPL |
|
|
159
|
+
| **`lantern ask "<question>"`** | One-shot prompt execution with streaming answer |
|
|
160
|
+
| **`lantern plan "<task>"`** | Read-only inspection & implementation plan |
|
|
161
|
+
| **`lantern resume [sessionId]`** | Resume the most recent or specified session |
|
|
162
|
+
| **`lantern sessions`** | List saved local sessions |
|
|
163
|
+
| **`lantern sessions --export <id>`** | Export session transcript to Markdown or JSON |
|
|
164
|
+
| **`lantern sessions --delete <id>`** | Delete a saved session by ID |
|
|
165
|
+
| **`lantern config`** | View active configuration |
|
|
166
|
+
| **`lantern config set <key> <val>`** | Update a configuration setting |
|
|
167
|
+
| **`lantern doctor`** | Diagnose environment, credentials, and connectivity |
|
|
168
|
+
| **`lantern mcp`** | Manage configured MCP servers (`list`, `add`, `remove`, `test`) |
|
|
169
|
+
| **`lantern --help`** | View all CLI flags and options |
|
|
170
|
+
| **`lantern --version`** | Output version string |
|
|
171
|
+
|
|
172
|
+
### Global Options
|
|
173
|
+
|
|
174
|
+
- **`-m, --model <id>`**: Override model ID (default: `gemini-3.8-flash`).
|
|
175
|
+
- **`-C, --cwd <path>`**: Set workspace directory for agent operations.
|
|
176
|
+
- **`-s, --session <id>`**: Use or resume a specific session ID.
|
|
177
|
+
- **`-a, --attach <files...>`**: Attach text files, images (`.png`, `.jpg`, `.webp`), or PDFs.
|
|
178
|
+
- **`--yolo`**: Skip interactive confirmation prompts for file edits and shell commands.
|
|
179
|
+
- **`--json`**: Output results formatted as JSON.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## ๐ก Usage Examples
|
|
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
|
+
```
|
|
213
|
+
|
|
214
|
+
### 3. Read-Only Planning Mode
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
lantern plan "Design an authentication system using JWT tokens with refresh cookies"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 4. Piped Standard Input
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# macOS / Linux
|
|
224
|
+
cat build.log | lantern "Summarize the root cause of these compiler errors"
|
|
225
|
+
|
|
226
|
+
# Windows PowerShell
|
|
227
|
+
Get-Content build.log | lantern "Summarize the root cause of these compiler errors"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## ๐ก๏ธ Approval & YOLO Modes
|
|
233
|
+
|
|
234
|
+
Code Lantern defaults to **Safe Mode**.
|
|
235
|
+
|
|
236
|
+
### Safe Mode (Default)
|
|
237
|
+
|
|
238
|
+
1. **Before Editing Files**: Displays an ANSI color-coded patch diff showing exact removals in red and additions in green:
|
|
239
|
+
```text
|
|
240
|
+
Approve this action? [y/N / (a)ll-yolo]:
|
|
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.
|
|
244
|
+
|
|
245
|
+
### YOLO Mode (`--yolo`)
|
|
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"
|
|
250
|
+
```
|
|
251
|
+
|
|
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
|
+
---
|
|
260
|
+
|
|
261
|
+
## ๐ Model Context Protocol (MCP)
|
|
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
|
|
278
|
+
|
|
279
|
+
# Remove a server
|
|
280
|
+
lantern mcp remove sqlite
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## โ๏ธ Configuration & Project Instructions
|
|
286
|
+
|
|
287
|
+
Configurations are persisted in `~/.codelantern/config.json` (or `%USERPROFILE%\.codelantern\config.json` on Windows):
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# View configuration
|
|
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
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Project Instructions (`LANTERN.md`)
|
|
300
|
+
|
|
301
|
+
Place a `LANTERN.md` (or `GEMINI.md`) file in your project root to provide persistent instructions to Code Lantern:
|
|
302
|
+
|
|
303
|
+
```markdown
|
|
304
|
+
# Project Instructions
|
|
305
|
+
- Codebase language: TypeScript (NodeNext modules)
|
|
306
|
+
- Run `npm test` before concluding file edits
|
|
307
|
+
- Keep imports organized alphabetically
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## ๐ npm Release Checklist
|
|
313
|
+
|
|
314
|
+
To publish `codelantern-agent-cli` to npm:
|
|
315
|
+
|
|
316
|
+
1. **Ensure Tests Pass**:
|
|
317
|
+
```bash
|
|
318
|
+
npm test
|
|
319
|
+
npm run lint
|
|
320
|
+
npm run build
|
|
321
|
+
```
|
|
322
|
+
2. **Verify Pack Contents**:
|
|
323
|
+
```bash
|
|
324
|
+
npm pack --dry-run
|
|
325
|
+
```
|
|
326
|
+
*Verify that only `dist/`, `README.md`, and `LICENSE` are included. Ensure no `.env`, `.codelantern/`, or test files are listed.*
|
|
327
|
+
3. **Log in to npm**:
|
|
328
|
+
```bash
|
|
329
|
+
npm login
|
|
330
|
+
```
|
|
331
|
+
4. **Publish**:
|
|
332
|
+
```bash
|
|
333
|
+
npm publish --access public
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## ๐งช Testing
|
|
339
|
+
|
|
340
|
+
Run the automated cross-platform test suite:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
npm test
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Run TypeScript compilation check:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
npm run lint
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## โ ๏ธ Known Limitations & Platform Notes
|
|
355
|
+
|
|
356
|
+
- **Directly Tested Platform**: Built and fully tested on **macOS (Apple Silicon arm64, Node v26)** with all 23 automated unit and integration tests passing.
|
|
357
|
+
- **Windows Platform**: Designed with standard Node.js APIs (`path.normalize`, `path.sep`, `windowsHide`, CRLF normalization, command guard patterns). Physical hardware testing on Windows 10/11 is recommended upon clone or CI run.
|
|
358
|
+
- **Terminal Colors**: A modern terminal emulator with ANSI color support (macOS Terminal, iTerm2, Windows Terminal, VS Code Integrated Terminal) is recommended.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## ๐ License
|
|
363
|
+
|
|
364
|
+
MIT ยฉ Code Lantern CLI Contributors
|