{"slug": "show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant", "title": "Show HN: Nanocode-CLI – A lightweight terminal-based AI coding assistant", "summary": "A developer released Nanocode-CLI, a lightweight terminal-based AI coding assistant written in Python that operates entirely within a command-line interface. The tool features live turn control, file-state tracking, stale-edit protection, and project-aware navigation to help developers edit code and run shell commands without leaving the terminal.", "body_md": "A small terminal coding agent written in Python.\n\nnanocode is pre-1.0 software. Commands, configuration, and tool behavior may change before a stable release.\n\n**Live turn control**: Add follow-up input while the agent is still working, without losing the current tool flow.** File-state brain**: Reads and edits build a current, line-numbered view of the files that matter now.** Stale-edit protection**:`line:hash`\n\nanchors reject edits when the target code has drifted.**Project-aware navigation**: Use the symbol index to jump through outlines, references, and changed files quickly.** Recoverable context**: Tool output stays bounded in the prompt, while raw`tr.N`\n\nresults remain recallable.**Cache-aware context**: Stable sections stay early and noisy working state stays late to improve prompt-cache reuse.** Focused working memory**:`Note`\n\nseparates goal, plan, and known facts from noisy execution logs.**Terminal-first workflow**: Model selection, history search, confirmations, live command output, appended input, and status all stay in one CLI.\n\n```\nuv tool install nanocode-cli\n```\n\nUpgrade:\n\n```\nuv tool upgrade nanocode-cli\n```\n\nFor local development:\n\n```\nuv sync --extra dev\nuv run nanocode\n```\n\nStart the CLI:\n\n```\nnanocode\n```\n\nUseful arguments:\n\n`--config <path>`\n\n: use a TOML config file.`--init-config`\n\n: create a default config file.`--yolo`\n\n: skip confirmations for mutating tools.`-v`\n\n,`--version`\n\n: show the version.\n\nDuring a running turn, the `+>`\n\nprompt accepts follow-up input for the next model request.\n\n`/help`\n\n: show commands and tools.`/status`\n\n: show runtime status.`/config`\n\n: show active config.`/api [auto|chat|anthropic]`\n\n: show or set provider API format.`/debug [on|off]`\n\n: toggle model I/O debug traces.`/compact`\n\n: compact context now.`/index [force]`\n\n: sync or rebuild the code symbol index.`/provider [NAME]`\n\n: show or set provider.`/model [MODEL]`\n\n: show or set model.`/reason`\n\n: choose reasoning effort.`/set KEY VALUE`\n\n: set provider/runtime values.`/yolo`\n\n: toggle tool confirmations.`/exit`\n\n,`/quit`\n\n: exit.\n\nInteractive selectors support `j`\n\n/`k`\n\n, arrows, `/`\n\nsearch, Enter, and Esc. Input supports history, completion, and `Ctrl-R`\n\nhistory search.\n\n- File:\n`Read`\n\n,`LineCount`\n\n,`List`\n\n,`Find`\n\n,`Search`\n\n. - Code index:\n`InspectCode`\n\n. - Edit:\n`Edit`\n\ncreates or patches file content. - Shell:\n`Bash`\n\n,`Git`\n\n. - Tool results:\n`Recall`\n\n. - Working notes:\n`Note`\n\n.\n\n`Read`\n\n, `Search`\n\n, and `InspectCode`\n\nreturn line anchors where useful. `Edit`\n\nuses current `line:hash`\n\nanchors to reject stale edits.\n\nRun:\n\n```\nnanocode --init-config\n```\n\nDefault config location is `~/.nanocode/config.toml`\n\n.\n\nMain fields:\n\n`[provider] active = \"name\"`\n\n`[provider.<name>]`\n\n:`url`\n\n,`key`\n\n,`model`\n\n,`api`\n\n,`prompt_cache_key`\n\n,`available_models`\n\n,`reasoning`\n\n,`chat_reasoning`\n\n,`temperature`\n\n,`timeout`\n\n`[paths] data_dir`\n\n`[runtime] shell_timeout`\n\n,`max_agent_steps`\n\n,`max_context_tokens`\n\n,`yolo`\n\n`api = \"auto\"`\n\nchooses between Chat Completions and Anthropic Messages using provider/model profiles. `prompt_cache_key = \"auto\"`\n\nderives a stable key from provider, model, workspace, and tool schema names.\n\nThe following providers have been tested with nanocode:\n\n**deepseek**: DeepSeek API** opencode**: OpenCode API** aliyun**: Alibaba Cloud (Tongyi Qianwen) API via Chat Completions** llama.cpp**: Local inference via llama.cpp server\n\nEach model request is built manually from explicit messages. Stable context comes first, conversation stays as messages, working memory follows, and the latest file state is appended at the end.\n\n```\nmodel request\n+--------------------------------------------------+\n| system                                           |\n|   concise agent contract and tool rules          |\n+--------------------------------------------------+\n| user                                             |\n|   Environment                                   |\n+--------------------------------------------------+\n| user/assistant                                  |\n|   conversation, compacted summaries, tools      |\n+--------------------------------------------------+\n| user                                             |\n|   Memory: goal, plan, known, date               |\n+--------------------------------------------------+\n| user                                             |\n|   FILE STATE: latest Read/Edit file view        |\n+--------------------------------------------------+\n```\n\nCore rules:\n\n- Mid-turn assistant text and appended user input are kept as conversation.\n- Earlier conversation is compacted into an explicit summary when the context grows too large.\n- FILE STATE is updated by successful\n`Read`\n\nand`Edit`\n\ntools and shows current listed file ranges, with recent files first. - Newer file lines overwrite older lines; edit invalidations clear stale ranges.\n- File lines are checked against current file stat or line hash before being shown.\n- Successful\n`Read`\n\nand`Edit`\n\ntool messages point to FILE STATE instead of repeating file bodies. - Other tool outputs are bounded in conversation messages and can be recalled by\n`tr.N`\n\n.\n\nnanocode can edit files and run shell commands in the environment where it is started. It does not provide sandbox protection. Run it inside your own sandbox, container, VM, or other isolated environment when needed.", "url": "https://wpnews.pro/news/show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant", "canonical_source": "https://github.com/hit9/nanocode", "published_at": "2026-06-06 04:54:05+00:00", "updated_at": "2026-06-06 05:16:12.273597+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "artificial-intelligence", "large-language-models", "ai-products"], "entities": ["Nanocode", "Nanocode-CLI", "Python", "TOML"], "alternates": {"html": "https://wpnews.pro/news/show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant", "markdown": "https://wpnews.pro/news/show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant.md", "text": "https://wpnews.pro/news/show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant.txt", "jsonld": "https://wpnews.pro/news/show-hn-nanocode-cli-a-lightweight-terminal-based-ai-coding-assistant.jsonld"}}