@nuvin/nuvin-cli 2.0.0-rc.14 → 2.0.0-rc.16

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
@@ -1,186 +1,244 @@
1
1
  # @nuvin/nuvin-cli
2
2
 
3
- Interactive AI coding assistant for the terminal.
4
- Your terminal, your choice of model, your rules—nothing hidden.
3
+ A full-featured terminal UI (TUI) coding assistant built with **React** and **Ink**. It provides an interactive, streaming chat interface in your terminal that connects to LLM providers (Anthropic, OpenAI-compatible) and gives the assistant a suite of workspace tools — file reading/writing, search, shell execution, and more — with a human-in-the-loop approval system for safety-critical operations.
5
4
 
6
- ## Features
7
-
8
- **Provider Freedom** — Use any LLM provider without lock-in. Supports OpenRouter, Anthropic, GitHub Models, DeepInfra, ZAI, Moonshot, Kimi, MiniMax out of the box. Switch models mid-conversation.
5
+ ---
9
6
 
10
- **Multi-Agent Delegation** — Spawn specialist agents for focused tasks like security audits or code investigation. Each agent runs in isolated context with session resumption support.
7
+ ## Features
11
8
 
12
- **Native Code Intelligence** — Built-in LSP integration for go-to-definition, find references, hover information, and real-time diagnostics. Understand your codebase, not just pattern match.
9
+ - **Interactive Terminal UI** — Full-screen TUI with virtualized message list, scrolling, keyboard navigation, and alt-screen buffer support.
10
+ - **Streaming Responses** — Real-time streaming of assistant text, reasoning, and tool output as they arrive.
11
+ - **Workspace Tools** — Built-in tools for file inspection (`FileRead`, `Ls`, `Glob`, `Grep`), file editing (`FileEdit`, `FileNew`), and shell execution (`Bash`).
12
+ - **Human-in-the-Loop Approvals** — Tool calls that modify state (e.g., `Bash`, `FileEdit`, `FileNew`) require explicit user approval before execution. Read-only tools (`FileRead`, `Ls`, `Glob`, `Grep`) are auto-approved.
13
+ - **Delegated Agents** — Pluggable agent delegation system (`AssignTask`) for spawning specialist sub-agents (code review, debugging, planning, etc.) with nested message rendering.
14
+ - **Rich Markdown Rendering** — Terminal-optimized markdown with syntax highlighting, table rendering, emoji support, and configurable text reflow.
15
+ - **Theming Engine** — Adaptive light/dark theme with automatic terminal color-depth detection, background fills, dim variants for modals, and full customization via config/env variables.
16
+ - **Diff View** — Inline file-diff rendering for `FileEdit` tool calls showing additions, removals, and context lines with color-coded highlighting.
17
+ - **Customizable Chat Model** — Configurable LLM provider with support for Anthropic Messages API, OpenAI-compatible endpoints, bearer/API-key auth schemes, and reasoning effort settings.
13
18
 
14
- **Modern TUI** — React/Ink-based terminal interface with vim mode, virtualized rendering for large outputs, and session statistics.
19
+ ---
15
20
 
16
- **Configuration Profiles** — Maintain separate configurations for different projects, teams, or workflows. Layer global, workspace, and CLI settings.
21
+ ## Architecture
17
22
 
18
- **MCP Extensibility** — Extend capabilities with Model Context Protocol servers. Add custom tools without modifying core code.
23
+ ```
24
+ src/
25
+ ├── index.ts # Entry point — boots the app
26
+ ├── root.tsx # Main bootstrap: config, model, agent, render
27
+ ├── app.tsx # Root React component — state, events, approvals
28
+ ├── components/
29
+ │ ├── Header.tsx # Top bar: brand, cwd, model name, approval mode
30
+ │ ├── Composer.tsx # User input field with busy/idle states
31
+ │ ├── MessageList.tsx # Virtualized scrollable message list
32
+ │ ├── MessageRow.tsx # Renders a single message (text or tool)
33
+ │ ├── ToolMessageRow.tsx # Tool-specific message rendering
34
+ │ ├── ApprovalModal.tsx # Modal for approving/denying tool calls
35
+ │ ├── StatusFooter.tsx # Footer with hints + live memory usage
36
+ │ ├── Modal.tsx # Generic modal overlay component
37
+ │ ├── ChildMessagesContext.tsx # Context for nested delegation messages
38
+ │ └── tool-renders/ # Per-tool renderers
39
+ │ ├── BashToolRender.tsx
40
+ │ ├── FileReadToolRender.tsx
41
+ │ ├── FileEditToolRender.tsx
42
+ │ ├── FileNewToolRender.tsx
43
+ │ ├── FileDiffView.tsx # Inline diff display
44
+ │ ├── GlobToolRender.tsx
45
+ │ ├── GrepToolRender.tsx
46
+ │ ├── LsToolRender.tsx
47
+ │ ├── AssignTaskToolRender.tsx
48
+ │ ├── UnknownToolRender.tsx
49
+ │ └── ...
50
+ └── lib/
51
+ ├── agent-channel.ts # Event bridge between Agent and React UI
52
+ ├── approvals/
53
+ │ └── queue.ts # Approval queue with FIFO processing
54
+ ├── chat/
55
+ │ └── model.ts # Chat model factory (provider config, auth)
56
+ ├── diagnostics/
57
+ │ └── memory.ts # Memory tracking & diagnostics
58
+ ├── markdown/ # Markdown → terminal rendering pipeline
59
+ │ ├── cache.ts
60
+ │ ├── provider.ts # Cached Marked instance management
61
+ │ ├── render.ts
62
+ │ └── renderers/
63
+ │ ├── terminal-renderer.ts
64
+ │ ├── code-highlighter.ts
65
+ │ ├── table-renderer.ts
66
+ │ ├── list-renderer.ts
67
+ │ ├── text-reflow.ts
68
+ │ ├── emoji-processor.ts
69
+ │ └── text-utils.ts
70
+ ├── messages/
71
+ │ └── state.ts # Immutable message state machine
72
+ ├── theme/
73
+ │ ├── runtime.ts # Theme resolution (light/dark, color depth)
74
+ │ └── store.ts # Zustand theme store with dim support
75
+ └── tools/
76
+ └── argsRenderer.ts # Tool argument formatting for approval UI
77
+ ```
19
78
 
20
- **Session Persistence** Resume previous conversations with full context. Export, browse, and manage conversation history.
79
+ ### Key Design Patterns
21
80
 
22
- **Controlled Execution** Optional sudo mode for manual tool approval. Review and approve file edits, bash commands, and web requests before execution.
81
+ | Pattern | Description |
82
+ |---------|-------------|
83
+ | **Agent Channel** | Decouples the imperative `Agent` (constructed before React mounts) from the UI via an `EventEmitter`-based channel. The agent publishes events and requests tool decisions; `<App />` subscribes and resolves approvals. |
84
+ | **Immutable State** | All message and approval state transitions use pure functions that return new state objects, composed inside React's `setState`. |
85
+ | **Virtualized List** | Only visible messages are rendered (with overscan), using `@nuvin/ink-virtualized-list` for efficient scrolling through long conversations. |
86
+ | **Singleton Theme Store** | A Zustand store (not React Context) holds the resolved theme, enabling both React hook access (`useTheme()`) and vanilla JS snapshots (`getTheme()`). |
87
+ | **Cached Markdown Provider** | `Marked` instances are cached by config key (width, tokens, reflow) to avoid re-creating the parser pipeline on every render frame. |
23
88
 
24
- ## Installation
89
+ ---
25
90
 
26
- ```bash
27
- # Install globally
28
- npm install --global @nuvin/nuvin-cli
91
+ ## Getting Started
29
92
 
30
- # Use with npx (no installation required)
31
- npx @nuvin/nuvin-cli
93
+ ### Prerequisites
32
94
 
33
- # Install in project as dependency
34
- npm install @nuvin/nuvin-cli
95
+ - **Node.js** 22
96
+ - **npm**, **pnpm**, or **yarn** (monorepo workspace setup with `pnpm` recommended)
35
97
 
36
- # Or with pnpm
37
- pnpm add @nuvin/nuvin-cli
98
+ ### Install Dependencies
38
99
 
39
- # Or with yarn
40
- yarn add @nuvin/nuvin-cli
100
+ ```bash
101
+ pnpm install
41
102
  ```
42
103
 
43
- ## Quick Start
104
+ ### Development
44
105
 
45
106
  ```bash
46
- # Start with default provider
47
- nuvin
107
+ # Run in dev mode with hot reload
108
+ pnpm dev
48
109
 
49
- # Use OpenRouter with a free model
50
- nuvin --provider openrouter --model minimax/minimax-m2:free
110
+ # Run with file watcher
111
+ pnpm dev:watch
112
+ ```
51
113
 
52
- # Use Anthropic Claude (requires API key)
53
- nuvin --provider anthropic --model claude-sonnet-4-5
114
+ ### Build
54
115
 
55
- # Use GitHub Models (requires GitHub token)
56
- nuvin --provider github --model claude-sonnet-4.5
116
+ ```bash
117
+ pnpm build
118
+ ```
57
119
 
58
- # Use configuration file for persistent settings
59
- nuvin --config ./my-config.yaml
120
+ Output is written to `dist/`. The CLI entry point is `dist/index.js`.
60
121
 
61
- # List available commands
62
- nuvin --help
122
+ ### Run Tests
63
123
 
64
- # Check version
65
- nuvin --version
66
- ```
124
+ ```bash
125
+ # Run all tests once
126
+ pnpm test
67
127
 
68
- ## CLI Usage
128
+ # Run tests in watch mode
129
+ pnpm test:watch
130
+ ```
69
131
 
70
- ### Basic Commands
132
+ Test files are co-located alongside source files using the `.test.ts` / `.test.tsx` convention, run via [Vitest](https://vitest.dev/).
71
133
 
72
- ```bash
73
- # Start interactive mode with default provider
74
- nuvin
134
+ ---
75
135
 
76
- # Use specific provider and model
77
- nuvin --provider openrouter --model openai/gpt-4o
136
+ ## Configuration
78
137
 
79
- # Use Anthropic Claude
80
- nuvin --provider anthropic --model claude-sonnet-4-5
138
+ ### Config File
81
139
 
82
- # Use GitHub Models
83
- nuvin --provider github --model claude-sonnet-4.5
140
+ The CLI loads configuration from a `config.yaml` (or the path resolved by `@nuvin/config`). Example:
84
141
 
85
- # Use Echo mode for testing
86
- nuvin --provider echo --model echo
142
+ ```yaml
143
+ database:
144
+ host: localhost
145
+ port: 5432
146
+ name: myapp_db
87
147
 
88
- # Load configuration from file
89
- nuvin --config ./my-config.yaml
148
+ server:
149
+ port: 9000
150
+ timeout: 60
151
+ debug: true
152
+ ssl_enabled: true
90
153
 
91
- # Show help and all options
92
- nuvin --help
154
+ features:
155
+ - login
156
+ - signup
157
+ - profile
158
+ - dashboard
159
+ - api_integration
93
160
  ```
94
161
 
95
- ### Advanced Usage
162
+ ### Environment Variables
96
163
 
97
- ```bash
98
- # Combine multiple options
99
- nuvin --provider openrouter --model openai/gpt-4o --config ./config.yaml
164
+ | Variable | Description |
165
+ |----------|-------------|
166
+ | `API_KEY` | LLM provider API key (fallback if not in config) |
167
+ | `NUVIN_THEME_MODE` | Force `"dark"` or `"light"` theme |
168
+ | `NUVIN_THEME_BACKGROUNDS` | Background fills: `"on"`, `"off"`, or `"auto"` |
169
+ | `NUVIN_MESSAGE_STYLE` | Message styling: `"plain"` or `"tinted"` |
170
+ | `FORCE_COLOR` | Force color level (`0`=none, `1`=16-color, `2`=256-color, `3`=truecolor) |
171
+ | `NO_COLOR` | Disable all colors |
172
+ | `COLORFGBG` | Auto-detect light/dark terminal background |
100
173
 
101
- # Use ZAI provider
102
- nuvin --provider zai --model glm-4.7
103
- ```
174
+ ---
104
175
 
105
- ### ACP Server Mode
176
+ ## Approval System
106
177
 
107
- Run Nuvin as an ACP server over stdio:
178
+ Tool calls fall into two categories:
108
179
 
109
- ```bash
110
- nuvin --acp
111
- ```
180
+ | Category | Tools | Behavior |
181
+ |----------|-------|----------|
182
+ | **Auto-approved** | `FileRead`, `Ls`, `Glob`, `Grep` | Execute immediately without prompting |
183
+ | **Requires approval** | `Bash`, `FileEdit`, `FileNew`, `AssignTask` | Pauses for user decision |
112
184
 
113
- Notes: Uses the same config resolution as the CLI. File system and terminal actions use local Nuvin tools (no ACP fs/terminal proxy in the initial implementation).
185
+ When a tool requires approval, the **Approval Modal** appears with:
114
186
 
115
- ## Environment Variables
187
+ - **Tool name & parameters** — scrollable argument display
188
+ - **Yes** (1) — approve this call
189
+ - **No** (2) — deny this call
190
+ - **Yes, for this session** (3) — auto-approve this tool for the rest of the session
191
+ - **Comment input** (4) — submit a change request / denial reason
116
192
 
117
- Set up authentication via environment variables:
193
+ Navigate with `Tab`, confirm with `Enter`, dismiss with `Escape`.
118
194
 
119
- ```bash
120
- # AI Provider Authentication
121
- export OPENROUTER_API_KEY=sk-or-xxxxxxxx
122
- export ANTHROPIC_API_KEY=sk-ant-xxxxxxxx
123
- export GITHUB_ACCESS_TOKEN=ghp_xxxxxxxxxxxx
124
-
125
- # Optional Tool Configuration
126
- export GOOGLE_CSE_KEY=your_google_cse_key
127
- export GOOGLE_CSE_CX=your_search_engine_id
128
- ```
195
+ ---
196
+
197
+ ## Theming
129
198
 
130
- ## What You Can Do
199
+ The theme system automatically adapts to your terminal:
131
200
 
132
- ### Development & Code Analysis
133
- - "Analyze my project structure and provide optimization recommendations"
134
- - "Review the recent git commits and summarize changes"
135
- - "Find all TODO comments in my codebase"
136
- - "Set up automated testing for my codebase"
137
- - "Refactor this function to follow SOLID principles"
201
+ 1. **Mode** Detects light vs. dark background via `COLORFGBG` or `NUVIN_THEME_MODE`
202
+ 2. **Color Level** Reads `FORCE_COLOR` / `NO_COLOR` or probes `stdout.getColorDepth()`
203
+ 3. **Backgrounds** — Enables colored surface fills only when truecolor/256-color is available (off by default in light mode)
204
+ 4. **Dim Variant** — When a modal opens, all background colors blend toward a neutral target so the overlay stands out
138
205
 
139
- ### Multi-Agent Delegation
140
- - "Delegate code review to the specialist agent"
141
- - "Create a comprehensive test suite for this module"
142
- - "Research documentation for this API and create usage examples"
143
- - "Organize my git changes into conventional commits"
144
- - "Have the architect review this design and suggest improvements"
206
+ The theme is accessible via `useTheme()` in React components or `getTheme()` in vanilla code.
145
207
 
146
- ## Documentation
208
+ ---
147
209
 
148
- - **[Configuration Guide](docs/configuration.md)** - Detailed configuration system documentation
149
- - **[Commands Reference](docs/commands.md)** - Built-in commands and usage examples
150
- - **[MCP Integration](docs/mcp-integration.md)** - Model Context Protocol setup and usage
151
- - **[Specialist Agents](docs/agents.md)** - Multi-agent system and delegation guide
152
- - **[Development Guide](docs/development.md)** - Contributing and development workflow
153
- - **[Tool Approval Renderers](docs/tool-approval-renderers.md)** - Tool approval system and custom renderers
210
+ ## Delegated Agents
154
211
 
155
- ## Troubleshooting
212
+ The CLI supports a pluggable agent delegation system. Agent definitions are discovered from configured directories and can be enabled/disabled per profile. When enabled, the coordinator agent can delegate subtasks to specialists:
156
213
 
157
- ### Common Issues
214
+ - **Code Reviewer** — Reviews code for quality, bugs, and best practices
215
+ - **React Senior Dev** — Expert React/TypeScript/CSS implementation
216
+ - **News Collector** — Gathers current news and updates
217
+ - **GSD Agents** — Planning, execution, verification, debugging workflows
158
218
 
159
- **Installation problems**
160
- - Ensure Node.js 18+ is installed: `node --version`
161
- - Clear npm cache: `npm cache clean --force`
162
- - Use specific version: `npm install -g @nuvin/nuvin-cli@latest`
219
+ Delegated agents run with their own tool set and publish events back through the `AgentChannel`, rendered as nested messages under the parent `AssignTask` tool call.
163
220
 
164
- **Provider authentication issues**
165
- - Check API keys are set correctly as environment variables
166
- - Verify keys have proper permissions for the provider
167
- - Test with free models first before upgrading
221
+ ---
168
222
 
169
- **Configuration file issues**
170
- - Validate YAML syntax (use online validator)
171
- - Check file paths are correct
172
- - Use absolute paths if relative paths fail
223
+ ## Key Dependencies
173
224
 
174
- **Performance issues**
175
- - Close other memory-intensive applications
176
- - Increase Node.js memory limit: `node --max-old-space-size=4096`
177
- - Use lighter models for faster responses
225
+ | Package | Purpose |
226
+ |---------|---------|
227
+ | `@nuvin/nuvin-core` | Agent runtime, tool definitions, chat model abstractions |
228
+ | `@nuvin/config` | Configuration management, profiles, env loading |
229
+ | `@nuvin/ink` | React-based terminal rendering (fork of Ink) |
230
+ | `@nuvin/ink-input` | Keyboard input handling |
231
+ | `@nuvin/ink-text-input` | Text input component |
232
+ | `@nuvin/ink-virtualized-list` | Virtualized scrolling list |
233
+ | `react` / `react-dom` | UI framework |
234
+ | `zustand` | Lightweight state management (theme store) |
235
+ | `marked` | Markdown parsing |
236
+ | `chalk` | Terminal color utilities |
237
+ | `cli-highlight` | Syntax highlighting |
238
+ | `vitest` | Test framework |
178
239
 
179
- **Getting help**
180
- - Run `nuvin --help` for command options
181
- - Check [GitHub Issues](https://github.com/marschhuynh/nuvin-cli/issues) for known problems
182
- - Enable debug mode (if available) for detailed logs
240
+ ---
183
241
 
184
242
  ## License
185
243
 
186
- Apache-2.0 © Marsch Huynh
244
+ Private All rights reserved.