nex-code 0.3.5 โ†’ 0.3.9

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
@@ -18,7 +18,7 @@
18
18
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
19
19
  <img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node >= 18">
20
20
  <img src="https://img.shields.io/badge/dependencies-2-green.svg" alt="Dependencies: 2">
21
- <img src="https://img.shields.io/badge/tests-1783-blue.svg" alt="Tests: 1783">
21
+ <img src="https://img.shields.io/badge/tests-1752-blue.svg" alt="Tests: 1752">
22
22
  </p>
23
23
 
24
24
  ---
@@ -47,6 +47,21 @@ That's it. You'll see the banner, your project context, and the `>` prompt. Star
47
47
 
48
48
  ---
49
49
 
50
+ ## Automatic Updates
51
+
52
+ Nex Code automatically checks for new versions when you start it. If a newer version is available, you'll see a notification with instructions on how to update:
53
+
54
+ ```
55
+ ๐Ÿ’ก New version available! Run npm update -g nex-code to upgrade from x.x.x to x.x.x
56
+ ```
57
+
58
+ To update to the latest version:
59
+ ```bash
60
+ npm update -g nex-code
61
+ ```
62
+
63
+ ---
64
+
50
65
  ## Why nex-code?
51
66
 
52
67
  | | nex-code | aider | Cursor |
@@ -55,7 +70,7 @@ That's it. You'll see the banner, your project context, and the `>` prompt. Star
55
70
  | **Multi-provider** | 5 providers, swap at runtime | Multi-provider | Multi-provider |
56
71
  | **Free local models** | Ollama (no API key) | Ollama | โ€” |
57
72
  | **Runtime dependencies** | 2 (axios, dotenv) | Heavy | Electron |
58
- | **Test coverage** | 1783 tests, 90% coverage | โ€” | โ€” |
73
+ | **Test coverage** | 1752 tests, 85% coverage | โ€” | โ€” |
59
74
  | **Tool tiers** | Auto-adapts tools per model | Fixed | Fixed |
60
75
  | **No lock-in** | `/model openai:gpt-4o` โ†” `/model local:llama3` | Config change | Config change |
61
76
 
@@ -85,6 +100,7 @@ npx nex-code
85
100
  git clone https://github.com/hybridpicker/nex-code.git
86
101
  cd nex-code
87
102
  npm install
103
+ npm run build # Build the high-performance bundle
88
104
  cp .env.example .env
89
105
  npm link
90
106
  npm run install-hooks
@@ -96,7 +112,7 @@ Create a `.env` file in your project directory (or set environment variables):
96
112
 
97
113
  ```bash
98
114
  # Pick any โ€” only one is required
99
- OLLAMA_API_KEY=your-key # Ollama Cloud (Qwen3 Coder, DeepSeek R1, Devstral, Kimi K2.5, Llama 4, MiniMax M2.5, GLM 4.7)
115
+ OLLAMA_API_KEY=your-key # Ollama Cloud (Qwen3 Coder, Qwen3.5, DeepSeek R1, Devstral, Kimi K2.5, Llama 4, MiniMax M2.5, GLM 4.7)
100
116
  OPENAI_API_KEY=your-key # OpenAI (GPT-4o, GPT-4.1, o1, o3, o4-mini)
101
117
  ANTHROPIC_API_KEY=your-key # Anthropic (Claude Sonnet 4.6, Opus 4.6, Haiku 4.5)
102
118
  GEMINI_API_KEY=your-key # Google Gemini (3.1 Pro Preview, 2.5 Pro/Flash, 2.0 Flash)
@@ -193,10 +209,10 @@ Switch providers and models at runtime:
193
209
 
194
210
  | Provider | Models | Env Variable |
195
211
  |----------|--------|-------------|
196
- | **ollama** | Qwen3 Coder, DeepSeek R1, Devstral, Kimi K2.5, MiniMax M2.5, GLM 4.7, Llama 4 | `OLLAMA_API_KEY` |
212
+ | **ollama** | Qwen3 Coder, Qwen3.5 (397B, 122B-A10B, 35B-A3B, 27B, 9B, 4B, 2B, 0.8B), DeepSeek R1, Devstral, Kimi K2.5, MiniMax M2.5, GLM 4.7, Llama 4 | `OLLAMA_API_KEY` |
197
213
  | **openai** | GPT-4o, GPT-4.1, o1, o3, o4-mini | `OPENAI_API_KEY` |
198
214
  | **anthropic** | Claude Sonnet 4.6, Opus 4.6, Haiku 4.5, Sonnet 4.5, Sonnet 4 | `ANTHROPIC_API_KEY` |
199
- | **gemini** | Gemini 3.1 Pro Preview, 2.5 Pro/Flash/Lite, 2.0 Flash/Lite | `GEMINI_API_KEY` |
215
+ | **gemini** | Gemini 3.1 Pro Preview, 2.5 Pro/Flash, 1.5 Pro/Flash | `GEMINI_API_KEY` |
200
216
  | **local** | Any model on your local Ollama server | (none) |
201
217
 
202
218
  Fallback chains let you auto-switch when a provider fails:
@@ -299,6 +315,11 @@ When the model runs tools but produces no visible text, an automatic nudge force
299
315
  ### Response Quality
300
316
  The system prompt enforces substantive responses: the model always presents findings as formatted text after using tools (users only see 1-line tool summaries). Responses use markdown with headers, bullet lists, and code blocks. The model states its approach before non-trivial tasks and summarizes results after completing work.
301
317
 
318
+ ### Performance
319
+ - **Asynchronous I/O**: The entire CLI is built on non-blocking I/O. File reads, writes, and git operations never block the main thread, keeping the UI responsive even during heavy tasks.
320
+ - **Fast Startup**: Pre-bundled with `esbuild` to minimize module loading overhead, achieving sub-100ms startup times.
321
+ - **In-Memory Indexing**: A background indexing engine (using `ripgrep` or a fast fallback) keeps project file paths in RAM for instant file discovery, path auto-fixing, and glob searches.
322
+
302
323
  ### Streaming Output
303
324
  Tokens appear live as the model generates them. Braille spinner during connection, then real-time line-by-line rendering via `StreamRenderer` with markdown formatting and syntax highlighting (JS, TS, Python, Go, Rust, CSS, HTML, and more).
304
325
 
@@ -310,7 +331,8 @@ Pressing Ctrl+C during a running request immediately cancels the active HTTP str
310
331
  - An `AbortController` signal flows from the SIGINT handler through the agent loop to the provider's HTTP request
311
332
  - All providers (Ollama, OpenAI, Anthropic, Gemini, local) destroy the response stream on abort
312
333
  - No EPIPE errors after cancellation (stdout writes are EPIPE-guarded)
313
- - 3x rapid Ctrl+C force-exits the process
334
+ - 2x Ctrl+C during processing force-exits the process
335
+ - At the idle prompt: first Ctrl+C shows `(Press Ctrl+C again to exit)`, second Ctrl+C exits (hint resets after 2 s)
314
336
 
315
337
  ### Diff Preview
316
338
  Every file change is shown in a diff-style format before being applied:
@@ -475,6 +497,12 @@ Four features that make Nex Code significantly more reliable with open-source mo
475
497
  - **Edit auto-fix**: Close match (โ‰ค5% Levenshtein distance) in `edit_file`/`patch_file` is auto-applied instead of erroring. Stacks with fuzzy whitespace matching.
476
498
  - **Bash error hints**: Enriches error output with actionable hints โ€” "command not found" โ†’ install suggestion, `MODULE_NOT_FOUND` โ†’ `npm install <pkg>`, port in use, syntax errors, TypeScript errors, test failures, and more.
477
499
 
500
+ **Stale Stream Recovery** โ€” Progressive retry strategy when streams stall (common with large Ollama models after many agent steps):
501
+ - 1st retry: 3s backoff delay, resend same context (handles transient stalls)
502
+ - 2nd retry: force-compress conversation (~80k tokens freed), 5s delay, retry with smaller context
503
+ - Last resort: if retries exhausted, one final force-compress + reset for fresh attempts
504
+ - Broader context-too-long detection catches Ollama-specific error formats (`num_ctx`, `prompt`, `size`, `exceeds`)
505
+
478
506
  **Tool Tiers** โ€” Dynamically reduces the tool set based on model capability:
479
507
  - **essential** (5 tools): bash, read_file, write_file, edit_file, list_directory
480
508
  - **standard** (13 tools): + search_files, glob, grep, ask_user, git_status, git_diff, git_log, task_list
@@ -635,6 +663,7 @@ cli/
635
663
  โ”œโ”€โ”€ tool-validator.js # Tool argument validation + auto-correction
636
664
  โ”œโ”€โ”€ tool-tiers.js # Dynamic tool set selection per model + model tier lookup
637
665
  โ”œโ”€โ”€ ui.js # ANSI colors, banner + re-exports from format.js/spinner.js
666
+ โ”œโ”€โ”€ index-engine.js # In-memory file index (ripgrep/fallback)
638
667
  โ”œโ”€โ”€ auto-fix.js # Path resolution, edit matching, bash error hints
639
668
  โ”œโ”€โ”€ tool-retry.js # Malformed argument retry with schema hints
640
669
  โ””โ”€โ”€ ollama.js # Backward-compatible wrapper
@@ -682,6 +711,29 @@ Project-local configuration and state (gitignored):
682
711
 
683
712
  ---
684
713
 
714
+ ## Performance
715
+
716
+ Nex Code v0.3.7+ includes comprehensive performance optimizations:
717
+
718
+ | Optimization | Improvement | Impact |
719
+ |--------------|-------------|--------|
720
+ | **System Prompt Caching** | 4.3ร— faster | 77ยตs โ†’ 18ยตs |
721
+ | **Token Estimation Caching** | 3.5ร— faster | Cached after first call |
722
+ | **Context File Caching** | 10-20ร— faster | 50-200ms โ†’ 5-10ms |
723
+ | **Debounced Auto-Save** | 0ms in hot path | Saves after 5s inactivity |
724
+ | **Tool Filter Caching** | 1.7ร— faster | Cached per model |
725
+ | **Schema Cache** | 3.4ร— faster | 2.51ยตs โ†’ 0.73ยตs |
726
+
727
+ **Average speedup:** 2.7ร— (micro-benchmarks)
728
+ **Real-world improvement:** ~10ร— faster per turn
729
+
730
+ Run benchmarks yourself:
731
+ ```bash
732
+ node benchmark.js
733
+ ```
734
+
735
+ ---
736
+
685
737
  ## Testing
686
738
 
687
739
  ```bash
@@ -689,7 +741,7 @@ npm test # Run all tests with coverage
689
741
  npm run test:watch # Watch mode
690
742
  ```
691
743
 
692
- 43 test suites, 1783 tests, 90% statement / 83% branch coverage.
744
+ 44 test suites, 1752 tests, 85% statement / 79% branch coverage.
693
745
 
694
746
  CI runs on GitHub Actions (Node 18/20/22).
695
747