Skip to content

NeamCode v0.3.4 — Offline Auto-Recovery

Choose a tag to compare

@Praveengovianalytics Praveengovianalytics released this 06 Mar 23:47

NeamCode v0.3.4 — Offline Auto-Recovery with Ollama Fallback

Never lose your conversation. NeamCode now automatically detects internet loss and seamlessly switches to a local Ollama model — preserving your full conversation context. When connectivity returns, it switches back to cloud without missing a beat.


Highlights

Automatic Cloud ↔ Ollama Switching

  • TCP health probing — lightweight socket checks (no HTTP, no auth, no cost) detect connectivity changes in real time
  • Flap protection — 2 consecutive failures → offline, 3 consecutive successes + 60s dwell time → online (prevents rapid toggling)
  • Error classification — only network errors (ECONNREFUSED, ETIMEDOUT, ENOTFOUND) trigger fallback; auth (401/403) and rate-limit (429) errors are handled separately
  • 4-state machineCLOUD_ACTIVESWITCHING_OFFLINEOLLAMA_ACTIVESWITCHING_ONLINE

Context Memory Preservation

  • Persistent sessions — conversation state saved to ~/.neamcode/sessions/<id>/context.json with atomic writes and 0600 permissions
  • Sliding window compression — keeps last N message pairs verbatim, summarizes older messages to fit local model's context window
  • Cross-provider continuity — context transfers seamlessly between cloud and Ollama without data loss

Smart Model Selection

  • Ollama auto-discovery — probes /api/tags and /api/show to detect available models
  • 8-tier capability ranking — automatically selects the best local model (llama3.1:70b → gemma)
  • User preferencepreferredModel config option to override automatic selection

New Slash Commands

Command Description
/offline [switch|models] Force switch to Ollama or list available local models
/online Force switch back to cloud provider
/status Show connectivity state, provider info, context stats, switch history

StatusBar Enhancements

  • Connectivity dot — green (online), yellow (degraded), red (offline) indicator
  • Offline mode display — shows [offline] ollama/<model> when running locally

Doctor Check

  • Ollama availability/doctor now checks if Ollama is running and reports available model count

Configuration

Add to your neamcode.json:

{
  "offline": {
    "enabled": true,
    "autoSwitch": true,
    "autoRecover": true,
    "ollamaHost": "http://localhost:11434",
    "preferredModel": "",
    "health": {
      "interval": 30,
      "timeout": 3,
      "failuresToOffline": 2,
      "successesToOnline": 3,
      "minDwellTime": 60
    },
    "context": {
      "strategy": "sliding",
      "slidingWindow": 10,
      "maxLocalTokens": 0,
      "persist": true,
      "sessionTtl": 7
    }
  }
}

All settings have sensible defaults — offline mode works out of the box with zero configuration if Ollama is installed.


Architecture

┌─────────────────────────────────────────────────┐
│                ProviderManager                  │
│  ┌──────────┐  ┌──────────────┐  ┌───────────┐ │
│  │  Health   │  │   Context    │  │  Ollama   │ │
│  │  Monitor  │  │    Store     │  │ Discovery │ │
│  │ (TCP probe│  │ (persistent) │  │ (ranked)  │ │
│  └────┬─────┘  └──────┬───────┘  └─────┬─────┘ │
│       │offline/online  │save/load       │select  │
│  ┌────▼────────────────▼────────────────▼─────┐ │
│  │           State Machine (4 states)         │ │
│  │  CLOUD_ACTIVE ↔ SWITCHING ↔ OLLAMA_ACTIVE  │ │
│  └────────────────────┬───────────────────────┘ │
│                       │                         │
│  ┌────────────────────▼───────────────────────┐ │
│  │        Context Compressor                  │ │
│  │   full → sliding window → summarize        │ │
│  └────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘

Test Coverage

  • 77 new unit tests across 7 test files covering all offline modules
  • 109 total tests pass including updated banner and startup tests
  • Modules tested: token-counter, health-monitor, ollama-discovery, context-store, context-compressor, provider-manager, commands

Documentation


Stats

  • 26 files changed, 4,927 insertions
  • 9 new source modules in src/offline/
  • 7 new test files in tests/unit/offline/
  • Build size: 975.93 KB (dist/index.js)

Installation

npm:

npm install -g neamcode@0.3.4

From source:

git clone https://github.com/Praveengovianalytics/NeamCode.git
cd NeamCode && npm install && npm run build

Full Changelog: Praveengovianalytics/NeamCode@v0.3.3...v0.3.4