nexus-agent-ai 2.2.1__tar.gz

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.
Files changed (58) hide show
  1. nexus_agent_ai-2.2.1/CHANGELOG.md +60 -0
  2. nexus_agent_ai-2.2.1/MANIFEST.in +10 -0
  3. nexus_agent_ai-2.2.1/PKG-INFO +292 -0
  4. nexus_agent_ai-2.2.1/README.md +272 -0
  5. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/PKG-INFO +292 -0
  6. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/SOURCES.txt +56 -0
  7. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/dependency_links.txt +1 -0
  8. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/entry_points.txt +3 -0
  9. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/requires.txt +8 -0
  10. nexus_agent_ai-2.2.1/nexus_agent_ai.egg-info/top_level.txt +4 -0
  11. nexus_agent_ai-2.2.1/pyproject.toml +41 -0
  12. nexus_agent_ai-2.2.1/requirements.txt +9 -0
  13. nexus_agent_ai-2.2.1/setup.cfg +4 -0
  14. nexus_agent_ai-2.2.1/src/__init__.py +1 -0
  15. nexus_agent_ai-2.2.1/src/__pycache__/__init__.cpython-313.pyc +0 -0
  16. nexus_agent_ai-2.2.1/src/agent/__init__.py +1 -0
  17. nexus_agent_ai-2.2.1/src/agent/__pycache__/__init__.cpython-313.pyc +0 -0
  18. nexus_agent_ai-2.2.1/src/agent/__pycache__/core.cpython-313.pyc +0 -0
  19. nexus_agent_ai-2.2.1/src/agent/__pycache__/memory.cpython-313.pyc +0 -0
  20. nexus_agent_ai-2.2.1/src/agent/__pycache__/persistence.cpython-313.pyc +0 -0
  21. nexus_agent_ai-2.2.1/src/agent/__pycache__/tools.cpython-313.pyc +0 -0
  22. nexus_agent_ai-2.2.1/src/agent/core.py +198 -0
  23. nexus_agent_ai-2.2.1/src/agent/memory.py +32 -0
  24. nexus_agent_ai-2.2.1/src/agent/persistence.py +72 -0
  25. nexus_agent_ai-2.2.1/src/agent/tools.py +489 -0
  26. nexus_agent_ai-2.2.1/src/cli/__init__.py +1 -0
  27. nexus_agent_ai-2.2.1/src/cli/__pycache__/__init__.cpython-313.pyc +0 -0
  28. nexus_agent_ai-2.2.1/src/cli/__pycache__/app.cpython-313.pyc +0 -0
  29. nexus_agent_ai-2.2.1/src/cli/__pycache__/display.cpython-313.pyc +0 -0
  30. nexus_agent_ai-2.2.1/src/cli/__pycache__/onboarding.cpython-313.pyc +0 -0
  31. nexus_agent_ai-2.2.1/src/cli/__pycache__/web.cpython-313.pyc +0 -0
  32. nexus_agent_ai-2.2.1/src/cli/app.py +420 -0
  33. nexus_agent_ai-2.2.1/src/cli/display.py +121 -0
  34. nexus_agent_ai-2.2.1/src/cli/onboarding.py +317 -0
  35. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/PKG-INFO +12 -0
  36. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/SOURCES.txt +21 -0
  37. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/dependency_links.txt +1 -0
  38. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/entry_points.txt +2 -0
  39. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/requires.txt +7 -0
  40. nexus_agent_ai-2.2.1/src/programmer_assistant.egg-info/top_level.txt +5 -0
  41. nexus_agent_ai-2.2.1/src/providers/__init__.py +8 -0
  42. nexus_agent_ai-2.2.1/src/providers/__pycache__/__init__.cpython-313.pyc +0 -0
  43. nexus_agent_ai-2.2.1/src/providers/__pycache__/anthropic_provider.cpython-313.pyc +0 -0
  44. nexus_agent_ai-2.2.1/src/providers/__pycache__/base.cpython-313.pyc +0 -0
  45. nexus_agent_ai-2.2.1/src/providers/__pycache__/fallback_provider.cpython-313.pyc +0 -0
  46. nexus_agent_ai-2.2.1/src/providers/__pycache__/gemini_provider.cpython-313.pyc +0 -0
  47. nexus_agent_ai-2.2.1/src/providers/__pycache__/mock_provider.cpython-313.pyc +0 -0
  48. nexus_agent_ai-2.2.1/src/providers/__pycache__/openai_provider.cpython-313.pyc +0 -0
  49. nexus_agent_ai-2.2.1/src/providers/anthropic_provider.py +103 -0
  50. nexus_agent_ai-2.2.1/src/providers/base.py +61 -0
  51. nexus_agent_ai-2.2.1/src/providers/fallback_provider.py +122 -0
  52. nexus_agent_ai-2.2.1/src/providers/gemini_provider.py +150 -0
  53. nexus_agent_ai-2.2.1/src/providers/mock_provider.py +331 -0
  54. nexus_agent_ai-2.2.1/src/providers/openai_provider.py +190 -0
  55. nexus_agent_ai-2.2.1/src/utils/__init__.py +1 -0
  56. nexus_agent_ai-2.2.1/src/utils/__pycache__/__init__.cpython-313.pyc +0 -0
  57. nexus_agent_ai-2.2.1/src/utils/__pycache__/config.cpython-313.pyc +0 -0
  58. nexus_agent_ai-2.2.1/src/utils/config.py +35 -0
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Nexus-Agent project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [2.2.1] - 2026-06-29
8
+
9
+ ### Added
10
+ - **`--max-iterations` / `-m` flag**: All 5 commands (`chat`, `repl`, `review`, `debug`, `generate`) now accept a `--max-iterations` option to override the default 10-step ReAct loop cap.
11
+ - **`run_file` tool**: New tool that runs an existing `.py` file directly via subprocess โ€” the safe escape hatch when `run_code` sandbox blocks a user's existing script.
12
+ - **psutil dependency**: Added `psutil>=5.9.0` to `pyproject.toml` and `requirements.txt` so system spec detection in onboarding works out of the box.
13
+
14
+ ### Fixed
15
+ - **Version sync**: `pyproject.toml` version bumped from `1.0.0` to `2.2.1` to match CLI output.
16
+ - **Dead code removed**: Cleaned up two `if False else` ternary blocks in `commit` command that were development leftovers.
17
+ - **SQLite Windows race condition**: `test_sqlite_memory` now explicitly calls `del mem` + closes connection before temp dir cleanup, preventing `PermissionError` on Windows.
18
+ - **`run_code` AST sandbox**: Added `_sandbox_check()` with `ast.walk()` analysis blocking `import os/subprocess/shutil/socket/...`, `open()`, `exec()`, and `eval()` calls before any execution occurs.
19
+
20
+ ## [2.2.0] - 2026-06-29
21
+
22
+ ### Added
23
+ - **Auto-Provider Fallback** (`src/providers/fallback_provider.py`): `FallbackProvider` chains `gemini โ†’ anthropic โ†’ openai` and silently switches on `RateLimitError` or missing API key, printing `[WARN]` instead of crashing.
24
+ - **First-Run Onboarding Wizard** (`src/cli/onboarding.py`): Detects first launch via `~/.nexus_agent_initialized`. Three-step setup: API key configuration, system spec detection (RAM/CPU via `psutil`, GPU via `nvidia-smi`), and default provider selection. Runs exactly once.
25
+ - **`agent commit` command**: Reads `git diff`, generates a conventional commit message via LLM, prompts for confirmation, and commits. Supports `--yes` flag for CI/automation.
26
+ - **`git_diff` and `git_commit` tools**: New tools powering the commit workflow.
27
+ - **Verbose ReAct Trace**: `--verbose` now shows `[THINKING]` / `[ACTION]` / `[OBSERVE]` labels. `run_code` shows full syntax-highlighted code (Monokai, line numbers) and up to 15 lines of output.
28
+ - **`--provider auto` flag**: Activates `FallbackProvider` for automatic multi-provider resilience.
29
+ - **`RateLimitError`**: Custom exception in `base.py` raised by all three providers on 429 responses.
30
+
31
+ ### Fixed
32
+ - **Provider header inconsistency**: `get_provider_instance()` returns `(provider, resolved_name)` โ€” `print_header()` always shows the actual active provider, not a stale/invalid input string.
33
+ - **429 raw crash**: All providers (`gemini`, `anthropic`, `openai`) now catch SDK-specific rate-limit exceptions and re-raise as `RateLimitError` for clean `[WARN]` output.
34
+ - **`run_code` verbose truncation**: Removed 40-char `args_str` truncation. `print_tool_result()` shows multi-line preview instead of 60-char single line.
35
+ - **README inconsistencies**: `claude-sonnet-4-6`, `gemini-2.5-flash`, correct LinkedIn URL (`yash-bajpai-b5a86332a`), removed broken `assets/demo.png`, added `agent debug`/`generate`/`commit` usage.
36
+
37
+ ## [2.1.2] - 2026-06-28
38
+
39
+
40
+ ### Added
41
+ - **GitHub Actions CI/CD Pipeline**: Automated matrix testing across Python 3.11, 3.12, and 3.13 (`.github/workflows/ci.yml`).
42
+ - **Architecture Decision Records (ADRs)**: Documented foundational engineering decisions in `docs/adr-001-react-loop.md`.
43
+ - **Competitive Comparison Matrix**: Highlighted key differentiators against GitHub Copilot CLI, Cursor, and Aider in `README.md`.
44
+ - **Mocked Provider Test Fixtures**: Isolated unit tests from real API keys and live network calls in `tests/test_providers.py`.
45
+
46
+ ### Fixed
47
+ - **Eager Provider Import Crash**: Decoupled package imports in `src/providers/__init__.py` and `src/cli/app.py` so missing SDKs don't crash fallback providers.
48
+ - **Streaming Cost Doubling Bug**: Resolved duplicate `provider.stream()` billing calls when full completions are already cached in memory during streaming execution.
49
+ - **Robust `@mention` Path Resolution**: Upgraded file mention parser to support multi-file mentions, space-delimited paths, and absolute/relative path resolution against the working directory.
50
+
51
+ ## [2.1.1] - 2026-06-27
52
+
53
+ ### Added
54
+ - **Smart Startup Project Detection**: Automatically senses `.git`, `pyproject.toml`, or `package.json` to inject project directory context into LLM prompts.
55
+ - **`@filename` Context Injection**: Allows users to reference local files directly inside terminal chat queries.
56
+ - **Live Terminal Spinner**: Claude-like ASCII animation during thinking and execution stages.
57
+
58
+ ### Changed
59
+ - Updated default model endpoints to `gemini-2.5-flash` and `claude-3-5-sonnet-20241022`.
60
+ - Standardized CLI syntax for `review`, `debug`, and `generate` subcommands.
@@ -0,0 +1,10 @@
1
+ include README.md
2
+ include CHANGELOG.md
3
+ include pyproject.toml
4
+ include requirements.txt
5
+ recursive-include src *
6
+ prune venv
7
+ prune tests
8
+ prune docs
9
+ prune .git
10
+ prune .github
@@ -0,0 +1,292 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexus-agent-ai
3
+ Version: 2.2.1
4
+ Summary: Autonomous terminal-first AI software engineering assistant with ReAct tool loops and multi-provider fallback
5
+ Author: Yash Bajpai
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Yash1bajpai/nexus-agent
8
+ Project-URL: Repository, https://github.com/Yash1bajpai/nexus-agent
9
+ Project-URL: Issues, https://github.com/Yash1bajpai/nexus-agent/issues
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: typer>=0.12.0
13
+ Requires-Dist: rich>=13.0.0
14
+ Requires-Dist: anthropic>=0.30.0
15
+ Requires-Dist: openai>=1.35.0
16
+ Requires-Dist: google-genai>=0.1.0
17
+ Requires-Dist: duckduckgo-search>=6.0.0
18
+ Requires-Dist: python-dotenv>=1.0.0
19
+ Requires-Dist: psutil>=5.9.0
20
+
21
+ # โšก Nexus-Agent: Autonomous Agentic AI Coding Assistant
22
+
23
+ <div align="center">
24
+ <p><strong>A production-grade, terminal-first AI Software Engineering Companion powered by autonomous ReAct tool loops and multi-provider backend switching.</strong></p>
25
+
26
+ ![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)
27
+ ![CLI Framework](https://img.shields.io/badge/CLI-Typer%20%7C%20Rich-purple.svg)
28
+ ![OpenAI Support](https://img.shields.io/badge/Model-OpenAI%20GPT--4o-green.svg)
29
+ ![Anthropic Support](https://img.shields.io/badge/Model-claude--sonnet--4--6-orange.svg)
30
+ ![Gemini Support](https://img.shields.io/badge/Model-Gemini%202.5%20Flash-blue.svg)
31
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2.svg?logo=linkedin&logoColor=white)](https://www.linkedin.com/in/yash-bajpai-b5a86332a/)
32
+ ![License](https://img.shields.io/badge/License-MIT-teal.svg)
33
+ </div>
34
+
35
+ ---
36
+
37
+ ## ๐ŸŽฌ Live Demo Recording
38
+
39
+ https://github.com/user-attachments/assets/73e78850-8669-40e9-aec3-3a355e975c1f
40
+
41
+ ---
42
+
43
+ ## ๐ŸŒŸ Overview
44
+
45
+ **Nexus-Agent** is an autonomous command-line coding agent designed to pair-program with developers directly inside their local workspace. Built from the ground up to showcase modern **Agentic AI Engineering** principles, Nexus-Agent doesn't just generate textโ€”it autonomously inspects files, modifies codebases, executes scripts inside secure local sandboxes, searches live web documentation, and inspects Git repositories.
46
+
47
+ Built with a clean **ReAct (Reasoning + Acting)** cognitive architecture, Nexus-Agent reasons step-by-step after every tool execution before deciding its next move.
48
+
49
+ ---
50
+
51
+ ## โ“ Why Nexus-Agent?
52
+
53
+ Unlike cloud-dependent tools like GitHub Copilot CLI, **Nexus-Agent** is built for offline-capable, cost-zero local execution. V2 will integrate a custom-trained 124M parameter LLM as the local backend โ€” enabling completely private, zero-latency execution with no external API key required.
54
+
55
+ ### ๐Ÿ“Š How Nexus-Agent Compares
56
+
57
+ | Feature | Nexus-Agent | Copilot CLI | Cursor | Aider |
58
+ | :--- | :---: | :---: | :---: | :---: |
59
+ | **Multi-Provider Support** (Claude, Gemini, OpenAI) | โœ… | โŒ | โŒ | โœ… |
60
+ | **Auto-Provider Fallback** (rate limit resilient) | โœ… | โŒ | โŒ | โŒ |
61
+ | **Autonomous Local Tool Execution** | โœ… | โŒ | โœ… | โœ… |
62
+ | **Real-Time Token & Cost Tracking** | โœ… | โŒ | โŒ | โŒ |
63
+ | **`@mention` File Context Injection** | โœ… | โŒ | โŒ | โŒ |
64
+ | **Smart Project vs. Global Detection** | โœ… | โŒ | โŒ | โŒ |
65
+ | **AI-Powered `agent commit`** | โœ… | โŒ | โŒ | โŒ |
66
+
67
+ ---
68
+
69
+ ## ๐Ÿ”ฅ Key Architectural Highlights
70
+
71
+ - ๐Ÿง  **Autonomous ReAct Loop**: Implements multi-step cognitive reasoning (`Thought โ†’ Action โ†’ Observation โ†’ Repeat`), allowing the agent to solve complex multi-file engineering tasks independently (up to 10 autonomous tool iterations per query).
72
+ - ๐Ÿ”Œ **Universal Multi-Provider Backend**: Abstracted provider layer supporting seamless switching between industry-leading LLMs (`OpenAI GPT-4o`, `Anthropic claude-sonnet-4-6`, and `Google gemini-2.5-flash`).
73
+ - ๐Ÿ”„ **Auto-Provider Fallback**: `--provider auto` chains `gemini โ†’ anthropic โ†’ openai` and switches silently on rate limit or auth failure, with a clean `[WARN]` message.
74
+ - ๐Ÿ’ฐ **Real-Time Dynamic Cost Tracker**: Live token computation engine that calculates exact input/output token expenditure and monetary cost in real time per session.
75
+ - ๐Ÿš€ **First-Run Onboarding Wizard**: Auto-detects first launch, guides through API key setup, detects RAM/CPU/GPU specs, and suggests optimal local model for V2.
76
+ - ๐Ÿ› ๏ธ **Comprehensive Developer Toolset**:
77
+ - `read_file`: Safely parses local file contents to prevent hallucinations.
78
+ - `write_file`: Actively writes or overwrites code files with automatic directory creation.
79
+ - `list_directory`: Recursively maps workspace architecture.
80
+ - `run_code`: Executes arbitrary Python code inside isolated subprocesses with strict execution timeout enforcement (`CODE_EXECUTION_TIMEOUT = 10s`).
81
+ - `search_web`: Queries live DuckDuckGo indexes for real-time API docs and error debugging.
82
+ - `git_status`: Monitors uncommitted workspace changes and diff statistics.
83
+ - `git_diff` + `git_commit`: Reads full staged diff and commits โ€” powering `nexus-agent commit`.
84
+ - ๐ŸŽจ **Rich Syntax-Highlighted UI**: Beautiful terminal display powered by `Rich`, featuring markdown rendering and ReAct trace badges (`[THINKING]`, `[ACTION]`, `[OBSERVE]`).
85
+ - โšก **Streaming CLI Response**: Interactive streaming text output with `--no-stream` toggle support.
86
+
87
+ ---
88
+
89
+ ## ๐Ÿ—๏ธ System Architecture
90
+
91
+ ```
92
+ nexus-agent/
93
+ โ”œโ”€โ”€ pyproject.toml โ† Package metadata & Typer binary entry point (`nexus-agent` / `agent`)
94
+ โ”œโ”€โ”€ requirements.txt โ† Core dependencies (Typer, Rich, OpenAI, Anthropic, Gemini, DDGS)
95
+ โ”œโ”€โ”€ .env.example โ† Environment variable configuration template
96
+ โ””โ”€โ”€ src/
97
+ โ”œโ”€โ”€ agent/
98
+ โ”‚ โ”œโ”€โ”€ core.py โ† Autonomous ReAct agent loop & system instructions
99
+ โ”‚ โ”œโ”€โ”€ memory.py โ† Sliding-window conversation buffer (max 20 turns)
100
+ โ”‚ โ””โ”€โ”€ tools.py โ† Universal tool schema & execution handlers
101
+ โ”œโ”€โ”€ cli/
102
+ โ”‚ โ”œโ”€โ”€ app.py โ† Typer CLI command definitions (chat, repl, review, debug, generate, commit)
103
+ โ”‚ โ”œโ”€โ”€ display.py โ† Rich terminal UI components & live cost tracking
104
+ โ”‚ โ””โ”€โ”€ onboarding.py โ† First-run wizard (API keys, system spec detection, provider setup)
105
+ โ”œโ”€โ”€ providers/
106
+ โ”‚ โ”œโ”€โ”€ base.py โ† Abstract BaseProvider interface & RateLimitError
107
+ โ”‚ โ”œโ”€โ”€ fallback_provider.py โ† Auto-fallback chain (gemini โ†’ anthropic โ†’ openai)
108
+ โ”‚ โ”œโ”€โ”€ openai_provider.py โ† OpenAI backend implementation
109
+ โ”‚ โ”œโ”€โ”€ anthropic_provider.py โ† Anthropic claude-sonnet-4-6 backend implementation
110
+ โ”‚ โ””โ”€โ”€ gemini_provider.py โ† Google gemini-2.5-flash backend implementation
111
+ โ””โ”€โ”€ utils/
112
+ โ””โ”€โ”€ config.py โ† Environment loader & dynamic token cost calculator
113
+ ```
114
+
115
+ ### Cognitive ReAct Workflow
116
+
117
+ ```mermaid
118
+ graph TD
119
+ User["Developer Query"] --> Core["Agent ReAct Loop"]
120
+ Core --> Provider["LLM Provider (OpenAI / Claude / Gemini)"]
121
+ Provider -->|Tool Call Requested| Dispatcher["Tool Execution Dispatcher"]
122
+ Provider -->|Rate Limit| Fallback["FallbackProvider (auto-switch)"]
123
+ Fallback --> Provider
124
+
125
+ subgraph Sandbox Tools
126
+ Dispatcher --> RF["read_file / list_directory"]
127
+ Dispatcher --> WF["write_file"]
128
+ Dispatcher --> RC["run_code (Subprocess Timeout)"]
129
+ Dispatcher --> WEB["search_web (DuckDuckGo)"]
130
+ Dispatcher --> GIT["git_status / git_diff / git_commit"]
131
+ end
132
+
133
+ RF --> Obs["Observation Buffer"]
134
+ WF --> Obs
135
+ RC --> Obs
136
+ WEB --> Obs
137
+ GIT --> Obs
138
+
139
+ Obs -->|Append Tool Result| Core
140
+ Provider -->|Final Markdown Text| UI["Rich Terminal UI Panel"]
141
+ ```
142
+
143
+ ---
144
+
145
+ ## ๐Ÿš€ Getting Started
146
+
147
+ ### 1. Installation
148
+
149
+ Install officially via PyPI:
150
+ ```bash
151
+ pip install nexus-agent-ai
152
+ ```
153
+
154
+ Or clone for local development:
155
+ ```bash
156
+ git clone https://github.com/Yash1bajpai/nexus-agent.git
157
+ cd nexus-agent
158
+ pip install -e .
159
+ ```
160
+
161
+ ### 2. API Key Configuration
162
+
163
+ Copy the example environment template and add your preferred API keys:
164
+
165
+ ```bash
166
+ cp .env.example .env
167
+ ```
168
+
169
+ Open `.env` and configure your keys:
170
+ ```ini
171
+ DEFAULT_PROVIDER=gemini
172
+ GEMINI_API_KEY=AIzaSy...
173
+ ANTHROPIC_API_KEY=sk-ant-...
174
+ OPENAI_API_KEY=sk-proj-...
175
+ ```
176
+
177
+ > **First run auto-wizard**: On the very first `nexus-agent` launch, an interactive onboarding wizard will guide you through key setup automatically.
178
+
179
+ ### 3. Usage
180
+
181
+ #### Interactive Multi-Turn REPL Mode (Default)
182
+ Start a continuous pair-programming session directly by invoking `nexus-agent` (or `agent`) without any subcommands:
183
+
184
+ ```bash
185
+ nexus-agent
186
+ # Or with flags: nexus-agent --provider anthropic
187
+ # Auto-fallback mode: nexus-agent --provider auto
188
+ ```
189
+
190
+ #### Single-Turn Coding (`chat`)
191
+ Execute an instant autonomous coding task directly from your terminal:
192
+
193
+ ```bash
194
+ nexus-agent chat "Create a python script fib.py that prints the first 10 Fibonacci numbers and run it to verify." --provider openai
195
+ ```
196
+
197
+ #### Automated Code Review (`review`)
198
+ Inspect local code files for bugs, security vulnerabilities, and clean coding practices:
199
+
200
+ ```bash
201
+ nexus-agent review src/utils/config.py --provider gemini
202
+ ```
203
+
204
+ #### Autonomous Error Debugging (`debug`)
205
+ Feed error tracebacks directly into Nexus-Agent to diagnose root causes and write fixes:
206
+
207
+ ```bash
208
+ nexus-agent debug src/app.py --error "AttributeError: 'NoneType' object has no attribute 'stream'"
209
+ # With verbose ReAct trace:
210
+ nexus-agent debug src/app.py --error "KeyError: 'model'" --verbose
211
+ ```
212
+
213
+ #### Direct File Generation (`generate`)
214
+ Generate complete code files autonomously and save them to your workspace:
215
+
216
+ ```bash
217
+ nexus-agent generate "Create an async web scraper using aiohttp and BeautifulSoup" --output scraper.py
218
+ ```
219
+
220
+ #### AI Commit Message (`commit`)
221
+ Reads your git diff, generates a meaningful conventional commit message, asks for confirmation, then commits:
222
+
223
+ ```bash
224
+ nexus-agent commit
225
+ # Skip confirmation prompt:
226
+ nexus-agent commit --yes
227
+ ```
228
+
229
+ #### Verbose ReAct Trace
230
+ See the agent's full reasoning process โ€” thinking, actions, and observations:
231
+
232
+ ```bash
233
+ nexus-agent chat "Refactor utils.py to use dataclasses" --verbose
234
+ ```
235
+
236
+ Output looks like:
237
+ ```
238
+ [THINKING] I need to read the file first to understand the current structure
239
+ [ACTION] read_file(path="utils.py")
240
+ [OBSERVE] Done (0.1s) โ†’ class Config: | def load(): | ...
241
+ [THINKING] Now I'll rewrite using dataclasses and write_file
242
+ [ACTION] write_file(path="utils.py", content="...")
243
+ [OBSERVE] Done (0.0s) โ†’ Successfully wrote 847 characters to utils.py
244
+ ```
245
+
246
+ ---
247
+
248
+ ## ๐Ÿงช Testing & Verification
249
+
250
+ Nexus-Agent maintains a **100% passing unit test suite** covering all tool dispatchers, filesystem handlers, UX features, and subprocess safety boundaries:
251
+
252
+ ```bash
253
+ pytest tests/ -v
254
+ ```
255
+
256
+ ```text
257
+ ============================= test session starts =============================
258
+ collecting ... collected 19 items
259
+
260
+ tests/test_providers.py::test_anthropic_provider_schema PASSED [ 5%]
261
+ tests/test_providers.py::test_openai_provider_schema PASSED [ 10%]
262
+ tests/test_providers.py::test_gemini_provider_schema PASSED [ 15%]
263
+ tests/test_providers.py::test_provider_tool_result_format PASSED [ 21%]
264
+ tests/test_tools.py::test_read_file_success PASSED [ 26%]
265
+ tests/test_tools.py::test_read_file_not_found PASSED [ 31%]
266
+ tests/test_tools.py::test_list_directory_success PASSED [ 36%]
267
+ tests/test_tools.py::test_list_directory_not_found PASSED [ 42%]
268
+ tests/test_tools.py::test_search_web PASSED [ 47%]
269
+ tests/test_tools.py::test_write_file_success PASSED [ 52%]
270
+ tests/test_tools.py::test_run_code_success PASSED [ 57%]
271
+ tests/test_tools.py::test_git_status_tool PASSED [ 63%]
272
+ tests/test_tools.py::test_execute_tool_dispatcher PASSED [ 68%]
273
+ tests/test_ux_features.py::test_parse_at_mentions PASSED [ 73%]
274
+ tests/test_ux_features.py::test_smart_startup_project_mode PASSED [ 78%]
275
+ tests/test_ux_features.py::test_status_spinner_helpers PASSED [ 84%]
276
+ tests/test_ux_features.py::test_sqlite_memory PASSED [ 89%]
277
+
278
+ ============================= 19 passed in 4.28s ==============================
279
+ ```
280
+
281
+ ---
282
+
283
+ ## ๐Ÿ›ก๏ธ Security & Sandbox Best Practices
284
+
285
+ - **Strict Secret Exclusion**: Verified `.gitignore` blocks `.env`, `.env.local`, and `.env.*.local`.
286
+ - **Subprocess Isolation**: Code execution (`run_code`) runs in dedicated subprocess threads with mandatory timeouts to prevent infinite loops.
287
+
288
+ ---
289
+
290
+ <div align="center">
291
+ <p>Engineered by <a href="https://github.com/Yash1bajpai">Yash Bajpai</a> ยท <a href="https://www.linkedin.com/in/yash-bajpai-b5a86332a/">LinkedIn</a></p>
292
+ </div>
@@ -0,0 +1,272 @@
1
+ # โšก Nexus-Agent: Autonomous Agentic AI Coding Assistant
2
+
3
+ <div align="center">
4
+ <p><strong>A production-grade, terminal-first AI Software Engineering Companion powered by autonomous ReAct tool loops and multi-provider backend switching.</strong></p>
5
+
6
+ ![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)
7
+ ![CLI Framework](https://img.shields.io/badge/CLI-Typer%20%7C%20Rich-purple.svg)
8
+ ![OpenAI Support](https://img.shields.io/badge/Model-OpenAI%20GPT--4o-green.svg)
9
+ ![Anthropic Support](https://img.shields.io/badge/Model-claude--sonnet--4--6-orange.svg)
10
+ ![Gemini Support](https://img.shields.io/badge/Model-Gemini%202.5%20Flash-blue.svg)
11
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2.svg?logo=linkedin&logoColor=white)](https://www.linkedin.com/in/yash-bajpai-b5a86332a/)
12
+ ![License](https://img.shields.io/badge/License-MIT-teal.svg)
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## ๐ŸŽฌ Live Demo Recording
18
+
19
+ https://github.com/user-attachments/assets/73e78850-8669-40e9-aec3-3a355e975c1f
20
+
21
+ ---
22
+
23
+ ## ๐ŸŒŸ Overview
24
+
25
+ **Nexus-Agent** is an autonomous command-line coding agent designed to pair-program with developers directly inside their local workspace. Built from the ground up to showcase modern **Agentic AI Engineering** principles, Nexus-Agent doesn't just generate textโ€”it autonomously inspects files, modifies codebases, executes scripts inside secure local sandboxes, searches live web documentation, and inspects Git repositories.
26
+
27
+ Built with a clean **ReAct (Reasoning + Acting)** cognitive architecture, Nexus-Agent reasons step-by-step after every tool execution before deciding its next move.
28
+
29
+ ---
30
+
31
+ ## โ“ Why Nexus-Agent?
32
+
33
+ Unlike cloud-dependent tools like GitHub Copilot CLI, **Nexus-Agent** is built for offline-capable, cost-zero local execution. V2 will integrate a custom-trained 124M parameter LLM as the local backend โ€” enabling completely private, zero-latency execution with no external API key required.
34
+
35
+ ### ๐Ÿ“Š How Nexus-Agent Compares
36
+
37
+ | Feature | Nexus-Agent | Copilot CLI | Cursor | Aider |
38
+ | :--- | :---: | :---: | :---: | :---: |
39
+ | **Multi-Provider Support** (Claude, Gemini, OpenAI) | โœ… | โŒ | โŒ | โœ… |
40
+ | **Auto-Provider Fallback** (rate limit resilient) | โœ… | โŒ | โŒ | โŒ |
41
+ | **Autonomous Local Tool Execution** | โœ… | โŒ | โœ… | โœ… |
42
+ | **Real-Time Token & Cost Tracking** | โœ… | โŒ | โŒ | โŒ |
43
+ | **`@mention` File Context Injection** | โœ… | โŒ | โŒ | โŒ |
44
+ | **Smart Project vs. Global Detection** | โœ… | โŒ | โŒ | โŒ |
45
+ | **AI-Powered `agent commit`** | โœ… | โŒ | โŒ | โŒ |
46
+
47
+ ---
48
+
49
+ ## ๐Ÿ”ฅ Key Architectural Highlights
50
+
51
+ - ๐Ÿง  **Autonomous ReAct Loop**: Implements multi-step cognitive reasoning (`Thought โ†’ Action โ†’ Observation โ†’ Repeat`), allowing the agent to solve complex multi-file engineering tasks independently (up to 10 autonomous tool iterations per query).
52
+ - ๐Ÿ”Œ **Universal Multi-Provider Backend**: Abstracted provider layer supporting seamless switching between industry-leading LLMs (`OpenAI GPT-4o`, `Anthropic claude-sonnet-4-6`, and `Google gemini-2.5-flash`).
53
+ - ๐Ÿ”„ **Auto-Provider Fallback**: `--provider auto` chains `gemini โ†’ anthropic โ†’ openai` and switches silently on rate limit or auth failure, with a clean `[WARN]` message.
54
+ - ๐Ÿ’ฐ **Real-Time Dynamic Cost Tracker**: Live token computation engine that calculates exact input/output token expenditure and monetary cost in real time per session.
55
+ - ๐Ÿš€ **First-Run Onboarding Wizard**: Auto-detects first launch, guides through API key setup, detects RAM/CPU/GPU specs, and suggests optimal local model for V2.
56
+ - ๐Ÿ› ๏ธ **Comprehensive Developer Toolset**:
57
+ - `read_file`: Safely parses local file contents to prevent hallucinations.
58
+ - `write_file`: Actively writes or overwrites code files with automatic directory creation.
59
+ - `list_directory`: Recursively maps workspace architecture.
60
+ - `run_code`: Executes arbitrary Python code inside isolated subprocesses with strict execution timeout enforcement (`CODE_EXECUTION_TIMEOUT = 10s`).
61
+ - `search_web`: Queries live DuckDuckGo indexes for real-time API docs and error debugging.
62
+ - `git_status`: Monitors uncommitted workspace changes and diff statistics.
63
+ - `git_diff` + `git_commit`: Reads full staged diff and commits โ€” powering `nexus-agent commit`.
64
+ - ๐ŸŽจ **Rich Syntax-Highlighted UI**: Beautiful terminal display powered by `Rich`, featuring markdown rendering and ReAct trace badges (`[THINKING]`, `[ACTION]`, `[OBSERVE]`).
65
+ - โšก **Streaming CLI Response**: Interactive streaming text output with `--no-stream` toggle support.
66
+
67
+ ---
68
+
69
+ ## ๐Ÿ—๏ธ System Architecture
70
+
71
+ ```
72
+ nexus-agent/
73
+ โ”œโ”€โ”€ pyproject.toml โ† Package metadata & Typer binary entry point (`nexus-agent` / `agent`)
74
+ โ”œโ”€โ”€ requirements.txt โ† Core dependencies (Typer, Rich, OpenAI, Anthropic, Gemini, DDGS)
75
+ โ”œโ”€โ”€ .env.example โ† Environment variable configuration template
76
+ โ””โ”€โ”€ src/
77
+ โ”œโ”€โ”€ agent/
78
+ โ”‚ โ”œโ”€โ”€ core.py โ† Autonomous ReAct agent loop & system instructions
79
+ โ”‚ โ”œโ”€โ”€ memory.py โ† Sliding-window conversation buffer (max 20 turns)
80
+ โ”‚ โ””โ”€โ”€ tools.py โ† Universal tool schema & execution handlers
81
+ โ”œโ”€โ”€ cli/
82
+ โ”‚ โ”œโ”€โ”€ app.py โ† Typer CLI command definitions (chat, repl, review, debug, generate, commit)
83
+ โ”‚ โ”œโ”€โ”€ display.py โ† Rich terminal UI components & live cost tracking
84
+ โ”‚ โ””โ”€โ”€ onboarding.py โ† First-run wizard (API keys, system spec detection, provider setup)
85
+ โ”œโ”€โ”€ providers/
86
+ โ”‚ โ”œโ”€โ”€ base.py โ† Abstract BaseProvider interface & RateLimitError
87
+ โ”‚ โ”œโ”€โ”€ fallback_provider.py โ† Auto-fallback chain (gemini โ†’ anthropic โ†’ openai)
88
+ โ”‚ โ”œโ”€โ”€ openai_provider.py โ† OpenAI backend implementation
89
+ โ”‚ โ”œโ”€โ”€ anthropic_provider.py โ† Anthropic claude-sonnet-4-6 backend implementation
90
+ โ”‚ โ””โ”€โ”€ gemini_provider.py โ† Google gemini-2.5-flash backend implementation
91
+ โ””โ”€โ”€ utils/
92
+ โ””โ”€โ”€ config.py โ† Environment loader & dynamic token cost calculator
93
+ ```
94
+
95
+ ### Cognitive ReAct Workflow
96
+
97
+ ```mermaid
98
+ graph TD
99
+ User["Developer Query"] --> Core["Agent ReAct Loop"]
100
+ Core --> Provider["LLM Provider (OpenAI / Claude / Gemini)"]
101
+ Provider -->|Tool Call Requested| Dispatcher["Tool Execution Dispatcher"]
102
+ Provider -->|Rate Limit| Fallback["FallbackProvider (auto-switch)"]
103
+ Fallback --> Provider
104
+
105
+ subgraph Sandbox Tools
106
+ Dispatcher --> RF["read_file / list_directory"]
107
+ Dispatcher --> WF["write_file"]
108
+ Dispatcher --> RC["run_code (Subprocess Timeout)"]
109
+ Dispatcher --> WEB["search_web (DuckDuckGo)"]
110
+ Dispatcher --> GIT["git_status / git_diff / git_commit"]
111
+ end
112
+
113
+ RF --> Obs["Observation Buffer"]
114
+ WF --> Obs
115
+ RC --> Obs
116
+ WEB --> Obs
117
+ GIT --> Obs
118
+
119
+ Obs -->|Append Tool Result| Core
120
+ Provider -->|Final Markdown Text| UI["Rich Terminal UI Panel"]
121
+ ```
122
+
123
+ ---
124
+
125
+ ## ๐Ÿš€ Getting Started
126
+
127
+ ### 1. Installation
128
+
129
+ Install officially via PyPI:
130
+ ```bash
131
+ pip install nexus-agent-ai
132
+ ```
133
+
134
+ Or clone for local development:
135
+ ```bash
136
+ git clone https://github.com/Yash1bajpai/nexus-agent.git
137
+ cd nexus-agent
138
+ pip install -e .
139
+ ```
140
+
141
+ ### 2. API Key Configuration
142
+
143
+ Copy the example environment template and add your preferred API keys:
144
+
145
+ ```bash
146
+ cp .env.example .env
147
+ ```
148
+
149
+ Open `.env` and configure your keys:
150
+ ```ini
151
+ DEFAULT_PROVIDER=gemini
152
+ GEMINI_API_KEY=AIzaSy...
153
+ ANTHROPIC_API_KEY=sk-ant-...
154
+ OPENAI_API_KEY=sk-proj-...
155
+ ```
156
+
157
+ > **First run auto-wizard**: On the very first `nexus-agent` launch, an interactive onboarding wizard will guide you through key setup automatically.
158
+
159
+ ### 3. Usage
160
+
161
+ #### Interactive Multi-Turn REPL Mode (Default)
162
+ Start a continuous pair-programming session directly by invoking `nexus-agent` (or `agent`) without any subcommands:
163
+
164
+ ```bash
165
+ nexus-agent
166
+ # Or with flags: nexus-agent --provider anthropic
167
+ # Auto-fallback mode: nexus-agent --provider auto
168
+ ```
169
+
170
+ #### Single-Turn Coding (`chat`)
171
+ Execute an instant autonomous coding task directly from your terminal:
172
+
173
+ ```bash
174
+ nexus-agent chat "Create a python script fib.py that prints the first 10 Fibonacci numbers and run it to verify." --provider openai
175
+ ```
176
+
177
+ #### Automated Code Review (`review`)
178
+ Inspect local code files for bugs, security vulnerabilities, and clean coding practices:
179
+
180
+ ```bash
181
+ nexus-agent review src/utils/config.py --provider gemini
182
+ ```
183
+
184
+ #### Autonomous Error Debugging (`debug`)
185
+ Feed error tracebacks directly into Nexus-Agent to diagnose root causes and write fixes:
186
+
187
+ ```bash
188
+ nexus-agent debug src/app.py --error "AttributeError: 'NoneType' object has no attribute 'stream'"
189
+ # With verbose ReAct trace:
190
+ nexus-agent debug src/app.py --error "KeyError: 'model'" --verbose
191
+ ```
192
+
193
+ #### Direct File Generation (`generate`)
194
+ Generate complete code files autonomously and save them to your workspace:
195
+
196
+ ```bash
197
+ nexus-agent generate "Create an async web scraper using aiohttp and BeautifulSoup" --output scraper.py
198
+ ```
199
+
200
+ #### AI Commit Message (`commit`)
201
+ Reads your git diff, generates a meaningful conventional commit message, asks for confirmation, then commits:
202
+
203
+ ```bash
204
+ nexus-agent commit
205
+ # Skip confirmation prompt:
206
+ nexus-agent commit --yes
207
+ ```
208
+
209
+ #### Verbose ReAct Trace
210
+ See the agent's full reasoning process โ€” thinking, actions, and observations:
211
+
212
+ ```bash
213
+ nexus-agent chat "Refactor utils.py to use dataclasses" --verbose
214
+ ```
215
+
216
+ Output looks like:
217
+ ```
218
+ [THINKING] I need to read the file first to understand the current structure
219
+ [ACTION] read_file(path="utils.py")
220
+ [OBSERVE] Done (0.1s) โ†’ class Config: | def load(): | ...
221
+ [THINKING] Now I'll rewrite using dataclasses and write_file
222
+ [ACTION] write_file(path="utils.py", content="...")
223
+ [OBSERVE] Done (0.0s) โ†’ Successfully wrote 847 characters to utils.py
224
+ ```
225
+
226
+ ---
227
+
228
+ ## ๐Ÿงช Testing & Verification
229
+
230
+ Nexus-Agent maintains a **100% passing unit test suite** covering all tool dispatchers, filesystem handlers, UX features, and subprocess safety boundaries:
231
+
232
+ ```bash
233
+ pytest tests/ -v
234
+ ```
235
+
236
+ ```text
237
+ ============================= test session starts =============================
238
+ collecting ... collected 19 items
239
+
240
+ tests/test_providers.py::test_anthropic_provider_schema PASSED [ 5%]
241
+ tests/test_providers.py::test_openai_provider_schema PASSED [ 10%]
242
+ tests/test_providers.py::test_gemini_provider_schema PASSED [ 15%]
243
+ tests/test_providers.py::test_provider_tool_result_format PASSED [ 21%]
244
+ tests/test_tools.py::test_read_file_success PASSED [ 26%]
245
+ tests/test_tools.py::test_read_file_not_found PASSED [ 31%]
246
+ tests/test_tools.py::test_list_directory_success PASSED [ 36%]
247
+ tests/test_tools.py::test_list_directory_not_found PASSED [ 42%]
248
+ tests/test_tools.py::test_search_web PASSED [ 47%]
249
+ tests/test_tools.py::test_write_file_success PASSED [ 52%]
250
+ tests/test_tools.py::test_run_code_success PASSED [ 57%]
251
+ tests/test_tools.py::test_git_status_tool PASSED [ 63%]
252
+ tests/test_tools.py::test_execute_tool_dispatcher PASSED [ 68%]
253
+ tests/test_ux_features.py::test_parse_at_mentions PASSED [ 73%]
254
+ tests/test_ux_features.py::test_smart_startup_project_mode PASSED [ 78%]
255
+ tests/test_ux_features.py::test_status_spinner_helpers PASSED [ 84%]
256
+ tests/test_ux_features.py::test_sqlite_memory PASSED [ 89%]
257
+
258
+ ============================= 19 passed in 4.28s ==============================
259
+ ```
260
+
261
+ ---
262
+
263
+ ## ๐Ÿ›ก๏ธ Security & Sandbox Best Practices
264
+
265
+ - **Strict Secret Exclusion**: Verified `.gitignore` blocks `.env`, `.env.local`, and `.env.*.local`.
266
+ - **Subprocess Isolation**: Code execution (`run_code`) runs in dedicated subprocess threads with mandatory timeouts to prevent infinite loops.
267
+
268
+ ---
269
+
270
+ <div align="center">
271
+ <p>Engineered by <a href="https://github.com/Yash1bajpai">Yash Bajpai</a> ยท <a href="https://www.linkedin.com/in/yash-bajpai-b5a86332a/">LinkedIn</a></p>
272
+ </div>