$ show Doorman11991/smallcode
SmallCode is an open-source AI coding assistant CLI designed to run locally on consumer hardware with small language models (8B–35B parameters). It provides a full-screen terminal UI with streaming output, tool execution, and multi-turn agent loops. The system compensates for small-model limitations through a context budget engine, forgiving JSON parser, patch-first editing, early-stop detection, and TODO-driven planning. It supports multiple LLM providers (Ollama, LM Studio, llama.cpp, OpenAI, Anthropic, DeepSeek) with automatic escalation to stronger models on hard failure. The architecture is a monolith agent loop with modular subsystems: a plugin system for tools, commands, and hooks; a skill system for reusable prompt templates; a knowledge injection system for contextual notes; a memory store with SQLite/FTS5; a RAG index for code snippet retrieval; and an MCP client/server for tool interoperability. The codebase includes a compiled MarrowScript cognition layer with typed prompts, output validation, and budget tracking, though the dual implementation (hand-ported JS alongside MarrowScript sources) introduces drift risk. Key entry points include bin/smallcode.js (main CLI), src/tui/fullscreen.js (zero-dependency TUI), and src/compiled/cognition/ (prompts, routers, validation). The agent loop orchestrates user input, model calls, tool dispatch, and improvement loops. The repository also includes benchmark harnesses, trace recording, evaluation runners, and a provider wizard for configuration. Despite being marked as 'dead' in the README, the codebase exhibits high craftsmanship in several reusable components, though the large feature surface and experimental nature suggest maintenance challenges.
The LLM identified 5 files worth highlighting for reuse:
A zero-dependency full-screen terminal UI using raw ANSI escapes. Implements framebuffer diffing for efficient rendering, visual-width-aware text wrapping and cursor positioning, word-boundary editing, SGR mouse selection, clipboard integration via platform commands, and live tool-start/tool-end handles with a context meter. This is a self-contained, reusable TUI component that could be extracted into any Node.js CLI application needing a rich terminal interface.
Reassembles Server-Sent Events (SSE) chunks from streaming LLM responses into a single non-streaming response object. Handles multi-line content, error events, and partial chunks. This is a clean, self-contained utility that can be reused in any application that consumes SSE streams and needs to convert them to complete JSON responses.
Tracks token usage per call and per turn, providing a live context meter in the TUI. Maintains running totals, estimates remaining budget, and exposes event hooks for UI updates. This is a reusable token accounting component that can be integrated into any LLM application to monitor and cap token consumption.
Implements a hybrid code search using BM25 ranking combined with bag-of-words semantic similarity, without requiring external embedding models. Includes tokenization with identifier splitting, inverse document frequency computation, and result merging. This is a self-contained search algorithm that can be extracted and applied to any codebase for fast, context-aware retrieval.
Maps common model-hallucinated tool names (e.g., 'write_file' vs 'write', 'read' vs 'read_file') to the canonical built-in tool names. It also handles pluralization and common misspellings. This is a reusable pattern for any LLM application that needs to interpret and normalize tool call outputs from varying models.