codelantern-agent-cli 0.0.0-stage โ†’ 1.0.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/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,315 @@
1
- # Temporary Holding Version
1
+ # ๐Ÿฎ Code Lantern CLI (`codelantern-agent-cli`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **Personal AI coding assistant for the terminal with multi-provider intelligence, portable skills, and ironclad safety.**
4
+ > Terminal command: **`lantern`**
5
+ > Published version: **`1.0.1`**
6
+ > Default model: **`gemini-3.8-flash`** (Google Gemini)
7
+
8
+ 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, OpenAI, Anthropic Claude, OpenRouter, or custom OpenAI-compatible endpointsโ€”with zero third-party agent dependencies.
9
+
10
+ ---
11
+
12
+ ## โšก What's New in v1.0.1
13
+
14
+ - ๐Ÿš€ **Fix "Step 1: thinking" Hang & Slowness**:
15
+ - **Bounded Request & First-Token Timeouts (`TTFT`)**: Strict timeouts prevent indefinite network hangs with configurable `--timeout` (default: 60s) and `--first-token-timeout` (default: 30s).
16
+ - **Immediate Unbuffered Streaming**: Response tokens stream directly to stdout as they arrive.
17
+ - **Real-Time Spinner Stages**: Spinner transitions transparently across `Connecting...`, `Waiting for first token...`, `Receiving response...`, and `Executing tool [name]...`. Stale thinking states are completely eliminated.
18
+ - **Instant Cancellation (Ctrl+C)**: Pressing Ctrl+C aborts in-flight fetch and streaming requests instantly via linked `AbortController`, safely returning control to the prompt.
19
+ - **Safe Backoff Retries**: Transient HTTP failures (429/503) retry with small, capped backoff. Non-idempotent mutating tools (file edits, bash execution) are never duplicated.
20
+ - **Context Efficiency & Pruning**: Tool outputs exceeding 15KB are capped in session context, preventing memory bloat and preserving fast response times.
21
+ - **Timing Diagnostics**: Pass `--timing` or use `/timing` to display live latency benchmarks for connection, first-token arrival, tool steps, and total turn duration.
22
+ - ๐ŸŒ **Multi-Provider & Dynamic Model Architecture**:
23
+ - **Google Gemini**: Native official `@google/genai` SDK with `gemini-3.8-flash` as default.
24
+ - **OpenAI**: Native SSE streaming adapter supporting `gpt-4o`, `gpt-4o-mini`, `o1`, `o3-mini`, with function/tool calling.
25
+ - **Anthropic Claude**: Native SSE streaming adapter supporting `claude-3-7-sonnet`, `claude-3-5-sonnet`, and `claude-3-5-haiku`.
26
+ - **OpenRouter**: Access over 400 models dynamically via `https://openrouter.ai/api/v1` with dynamic catalog discovery.
27
+ - **Custom OpenAI-Compatible Providers**: Configure custom endpoints (Ollama, vLLM, DeepSeek, LocalAI) via base URL, API key, and model ID.
28
+ - **Secure AES-256-GCM Credential Vault**: Store provider API keys locally encrypted in `~/.codelantern/credentials.json` with machine-derived keys, or supply via standard environment variables (`GEMINI_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`).
29
+ - **Management Commands**: `lantern providers`, `lantern models`, `lantern keys`, and `/provider`, `/model` slash commands.
30
+ - ๐Ÿงฉ **Portable Skills System (`SKILL.md`)**:
31
+ - Import, enable, and use skills defined in portable `SKILL.md` format (YAML frontmatter + markdown instructions + references).
32
+ - Discovered automatically from user directory (`~/.codelantern/skills/`) and project workspaces (`.codelantern/skills/`).
33
+ - Install skills easily via local path or Git: `lantern skills add <path-or-git-url>`.
34
+ - Transparent, non-intrusive keyword/intent matching automatically injects relevant domain instructions into system prompts without arbitrary script execution.
35
+
36
+ ---
37
+
38
+ ## ๐Ÿ’ป System Prerequisites
39
+
40
+ | Requirement | Supported Version / Details |
41
+ | :--- | :--- |
42
+ | **Node.js** | `>= 18.0.0` (Node 20 or Node 22 LTS recommended) |
43
+ | **npm** | `>= 9.0.0` |
44
+ | **Operating Systems** | macOS 12+ (Apple Silicon `arm64` & Intel `x64`), Windows 10/11 (PowerShell & CMD), Linux |
45
+ | **API Keys** | Any of: `GEMINI_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`, or custom endpoint |
46
+
47
+ ---
48
+
49
+ ## ๐Ÿ“ฆ Installation
50
+
51
+ ### Option A: Local Development Installation
52
+
53
+ ```bash
54
+ cd "my own cli"
55
+
56
+ # 1. Install dependencies
57
+ npm install
58
+
59
+ # 2. Build the distribution bundle
60
+ npm run build
61
+
62
+ # 3. Link globally for immediate use
63
+ npm link
64
+ ```
65
+
66
+ Verify your installation:
67
+ ```bash
68
+ lantern --version
69
+ # Output: 1.0.1
70
+ ```
71
+
72
+ ### Option B: Global Installation from npm
73
+
74
+ Once published under `codelantern-agent-cli`:
75
+
76
+ #### macOS & Linux:
77
+ ```bash
78
+ npm install -g codelantern-agent-cli
79
+ lantern --version
80
+ ```
81
+
82
+ #### Windows (PowerShell or Command Prompt):
83
+ ```powershell
84
+ npm install -g codelantern-agent-cli
85
+ lantern --version
86
+ ```
87
+ *npm automatically generates `lantern.cmd` and `lantern.ps1` executables on Windows.*
88
+
89
+ ---
90
+
91
+ ## ๐Ÿ”‘ Credential & Key Management
92
+
93
+ Code Lantern supports two secure methods for supplying API keys:
94
+
95
+ ### 1. Secure Local Vault (AES-256-GCM)
96
+ Store encrypted keys on your local machine using `lantern keys set`:
97
+ ```bash
98
+ lantern keys set gemini
99
+ lantern keys set openai
100
+ lantern keys set anthropic
101
+ lantern keys set openrouter
102
+ ```
103
+ Keys are encrypted using AES-256-GCM with a machine-unique key derived from your host identity. Keys are never logged, committed, or transmitted except directly to the provider endpoint.
104
+
105
+ ### 2. Environment Variables
106
+ Standard environment variables take precedence when present:
107
+ ```bash
108
+ export GEMINI_API_KEY="AIzaSy..."
109
+ export OPENAI_API_KEY="sk-proj-..."
110
+ export ANTHROPIC_API_KEY="sk-ant-..."
111
+ export OPENROUTER_API_KEY="sk-or-v1-..."
112
+ ```
113
+
114
+ Inspect configured keys safely (masked):
115
+ ```bash
116
+ lantern keys list
117
+ ```
118
+
119
+ ---
120
+
121
+ ## ๐ŸŒ Multi-Provider Management
122
+
123
+ ### Switch Active Provider and Models
124
+ ```bash
125
+ # List all configured providers
126
+ lantern providers list
127
+
128
+ # Set default provider
129
+ lantern providers set-default openrouter
130
+
131
+ # Test provider connectivity and latency
132
+ lantern providers test openrouter
133
+ lantern providers test gemini
134
+
135
+ # Add a custom local Ollama or vLLM provider
136
+ lantern providers add ollama --base-url http://localhost:11434/v1 --model llama3.2:latest
137
+
138
+ # List available models for active provider
139
+ lantern models list
140
+
141
+ # Query models for a specific provider
142
+ lantern models list -p anthropic
143
+ lantern models list -p openrouter
144
+
145
+ # Set active default model
146
+ lantern models set gemini-3.8-flash
147
+ ```
148
+
149
+ ---
150
+
151
+ ## ๐Ÿงฉ Portable Skills System (`SKILL.md`)
152
+
153
+ Code Lantern supports domain-specific skills using the standard `SKILL.md` format:
154
+
155
+ ```markdown
156
+ ---
157
+ name: build-your-own-x
158
+ description: Step-by-step architectural patterns for recreating technologies from scratch
159
+ ---
160
+ # Build Your Own X Instructions
161
+ When designing and implementing systems from scratch, follow these patterns...
162
+ ```
163
+
164
+ ### Managing Skills
165
+ ```bash
166
+ # List installed skills
167
+ lantern skills list
168
+
169
+ # Add a skill from a local folder or markdown file
170
+ lantern skills add ./my-skill
171
+
172
+ # Add a skill directly from a Git repository
173
+ lantern skills add https://github.com/example/coding-skills.git
174
+
175
+ # Inspect skill instructions and reference documents
176
+ lantern skills show build-your-own-x
177
+
178
+ # Enable or disable skills
179
+ lantern skills enable build-your-own-x
180
+ lantern skills disable build-your-own-x
181
+
182
+ # Remove a skill
183
+ lantern skills remove build-your-own-x
184
+ ```
185
+
186
+ ---
187
+
188
+ ## ๐Ÿฉบ Diagnostics (`lantern doctor`)
189
+
190
+ Run `lantern doctor` at any time to verify system health, network connectivity, latency, and keys:
191
+
192
+ ```bash
193
+ lantern doctor
194
+ ```
195
+
196
+ Example output:
197
+ ```text
198
+ ๐Ÿฎ Code Lantern Doctor โ€” Diagnostics
199
+ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
200
+ โœ“ Platform / OS: macOS (Apple Silicon)
201
+ โœ“ Node.js Runtime: v26.12.1 (compatible)
202
+ โœ“ Active Provider: Google Gemini (gemini)
203
+ โœ“ Active Model: gemini-3.8-flash
204
+ โœ“ API Key (gemini): Configured [env] (AIza...W9q0)
205
+ โœ“ Gemini API Auth: Verified (latency: 340ms)
206
+ โœ“ Additional Providers: Configured (openrouter, openai)
207
+ โœ“ Git CLI: Available (git version 2.54.0)
208
+ โœ“ Config File: ~/.codelantern/config.json (Timeout: 60000ms, TTFT: 30000ms)
209
+ โœ“ Session Storage: ~/.codelantern/sessions (1 stored session(s))
210
+ โœ“ Skills: 1 installed (build-your-own-x)
211
+ โ„น MCP Servers: No external MCP servers configured (optional)
212
+ โœ“ Project Instructions: Found (LANTERN.md) in /workspace
213
+ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
214
+ โœจ All systems healthy! Code Lantern CLI is ready to assist.
215
+ ```
216
+
217
+ ---
218
+
219
+ ## ๐Ÿ“– Command Reference
220
+
221
+ | Command | Action |
222
+ | :--- | :--- |
223
+ | **`lantern`** | Launch the interactive conversational REPL |
224
+ | **`lantern ask "<question>"`** | One-shot prompt execution with streaming response |
225
+ | **`lantern plan "<task>"`** | Read-only inspection and implementation plan |
226
+ | **`lantern resume [sessionId]`** | Resume the most recent or specified session |
227
+ | **`lantern sessions`** | List saved local sessions (`--export <id>`, `--delete <id>`) |
228
+ | **`lantern providers`** | Manage AI providers (`list`, `set-default`, `test`, `add`, `remove`) |
229
+ | **`lantern models`** | List and select models (`list`, `set`, `-p <provider>`, `-r`, `--json`) |
230
+ | **`lantern keys`** | Manage encrypted API keys (`list`, `set`, `remove`) |
231
+ | **`lantern skills`** | Manage portable skills (`list`, `show`, `add`, `enable`, `disable`, `remove`) |
232
+ | **`lantern config`** | View or update configuration (`list`, `get`, `set`) |
233
+ | **`lantern doctor`** | Diagnose environment, credentials, latency, and MCP health |
234
+ | **`lantern mcp`** | Manage MCP servers (`list`, `add`, `remove`, `test`, `enable`, `disable`) |
235
+ | **`lantern --help`** | View all CLI flags and options |
236
+ | **`lantern --version`** | Output version string (`1.0.1`) |
237
+
238
+ ### Global Flags
239
+
240
+ - **`-p, --provider <provider>`**: Select provider (`gemini`, `openai`, `anthropic`, `openrouter`, or custom).
241
+ - **`-m, --model <id>`**: Override model ID (default: `gemini-3.8-flash`).
242
+ - **`-C, --cwd <path>`**: Set workspace directory for agent operations.
243
+ - **`-s, --session <id>`**: Use or resume a specific session ID.
244
+ - **`-a, --attach <files...>`**: Attach text files, images (`.png`, `.jpg`, `.webp`), or PDFs.
245
+ - **`--yolo`**: Skip interactive confirmation prompts for file edits and shell commands.
246
+ - **`--json`**: Output results formatted as JSON.
247
+ - **`--timeout <ms>`**: Maximum total request duration (default: `60000`).
248
+ - **`--first-token-timeout <ms>`**: Maximum wait time for initial response token (default: `30000`).
249
+ - **`--timing`**: Display detailed execution and latency timing diagnostics.
250
+ - **`--fast`**: Enable low-latency mode where supported.
251
+ - **`--skill <skills...>`**: Explicitly activate one or more skills for the run.
252
+
253
+ ---
254
+
255
+ ## ๐Ÿ›ก๏ธ Safe Mode & Invariants
256
+
257
+ Code Lantern runs in **Safe Mode** by default:
258
+ 1. **Interactive Unified Diffs**: Displays colored unified diffs showing exact deletions in red and additions in green before touching any file.
259
+ 2. **Command Approvals**: Shows command line and working directory before running shell commands.
260
+ 3. **Workspace Boundary**: Strict containment prevents path traversal (`../../`) or symlink escapes outside the workspace.
261
+ 4. **Secret Firewall**: Blocks reading `.env`, `.env.*`, `*.pem`, `*.key`, `id_rsa`, or credential stores.
262
+ 5. **Destructive Command Guard**: Rejects destructive system commands (e.g., `rm -rf /`, Windows `format c:`, `del /s /q c:\*`).
263
+
264
+ ---
265
+
266
+ ## ๐Ÿงช Automated Testing
267
+
268
+ Code Lantern includes a comprehensive test suite covering security sandboxing, CRLF line endings, tool execution, session persistence, timeout handling, first-token limits, cancellation, AES-256 encryption, skills parsing, and provider registries:
269
+
270
+ ```bash
271
+ # Run test suite (32 automated checks)
272
+ npm test
273
+
274
+ # Run TypeScript typecheck
275
+ npm run lint
276
+
277
+ # Build production bundle
278
+ npm run build
279
+ ```
280
+
281
+ ---
282
+
283
+ ## ๐Ÿš€ npm Publishing Guide (v1.0.1)
284
+
285
+ To publish `codelantern-agent-cli@1.0.1` to npm:
286
+
287
+ 1. **Verify All Checks Pass**:
288
+ ```bash
289
+ npm test
290
+ npm run lint
291
+ npm run build
292
+ ```
293
+ 2. **Inspect Tarball Contents**:
294
+ ```bash
295
+ npm pack --dry-run
296
+ ```
297
+ *Verify that only `dist/`, `README.md`, and `LICENSE` are included.*
298
+ 3. **Authenticate & Publish**:
299
+ ```bash
300
+ npm login
301
+ npm publish --access public
302
+ ```
303
+
304
+ ---
305
+
306
+ ## โš ๏ธ Platform Verification Notes
307
+
308
+ - **macOS (Directly Verified)**: Developed, built, and verified on macOS (Apple Silicon arm64, Node v26) with all 32 automated tests passing and live provider connectivity verified.
309
+ - **Windows (Architecturally Supported)**: Built with portable Node.js APIs (`path.normalize`, `path.sep`, `windowsHide: true`, CRLF handling, and Windows command guards). Direct testing on native Windows hardware or Windows CI is recommended upon deployment.
310
+
311
+ ---
312
+
313
+ ## ๐Ÿ“„ License
314
+
315
+ MIT ยฉ Code Lantern CLI Contributors