- LocalEngineServer: add a streaming AI endpoint (newline-delimited JSON frames)
over a no-Content-Length chunked response, plus an AIStreamHandler.
- AppState.handleServerAIStream: gate + iterate AIEngine.runStreaming, emitting
each token — gives the runStreaming infrastructure its first real consumer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wave 1 (correctness/trust):
- Fix paid large-model dead path: engine reads the persisted selected repo via a
thread-safe ModelManager.activeRepo(), so download/load/isReady now agree.
- Lemon Squeezy store/product check fails closed in release builds — the
placeholder-ID 'any key unlocks paid' bypass can no longer ship.
- Replace force-unwrapped Hugging Face URLs with safe URLComponents construction.
- Never read/replace/scan secure (password) fields via AX.isSecureTextField.
Wave 2 (compounding seam):
- Extract AIPromptKit (prompts/temperature/maxTokens/cleanup) out of MLXEngine so
every backend produces identical prompts and output.
- AIEngine gains protectedTerms (personal dictionary now actually injected into the
LLM), warmup(), and runStreaming(); add makeAIEngine() factory.
- Honor WritingMode.lengthCap for maxTokens; warm the model on launch/after download.
- Guard custom modes against empty prompts and duplicate names.
Wave 3: OllamaEngine — a URLSession-only AIEngine backend (cross-platform, opt-in
via GRAMMARGEM_AI_BACKEND=ollama).
Wave 4: LocalEngineServer — loopback-only, token-authed HTTP bridge (Network.framework,
no new deps), off by default, exposing Harper + the LLM + the entitlement gate to a
browser extension.
Tests: 6 new unit tests for the AIPrompts seam and custom-mode guard (19 pass).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>