devpilot-agentic-cli 1.0.0__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 (47) hide show
  1. devpilot_agentic_cli-1.0.0/PKG-INFO +288 -0
  2. devpilot_agentic_cli-1.0.0/README.md +246 -0
  3. devpilot_agentic_cli-1.0.0/agent/__init__.py +1 -0
  4. devpilot_agentic_cli-1.0.0/agent/a2a_client.py +94 -0
  5. devpilot_agentic_cli-1.0.0/agent/a2a_server.py +148 -0
  6. devpilot_agentic_cli-1.0.0/agent/cli.py +233 -0
  7. devpilot_agentic_cli-1.0.0/agent/config.py +232 -0
  8. devpilot_agentic_cli-1.0.0/agent/context.py +182 -0
  9. devpilot_agentic_cli-1.0.0/agent/history.py +172 -0
  10. devpilot_agentic_cli-1.0.0/agent/loop.py +102 -0
  11. devpilot_agentic_cli-1.0.0/agent/mcp_client.py +104 -0
  12. devpilot_agentic_cli-1.0.0/agent/providers/__init__.py +4 -0
  13. devpilot_agentic_cli-1.0.0/agent/providers/anthropic_provider.py +169 -0
  14. devpilot_agentic_cli-1.0.0/agent/providers/base.py +148 -0
  15. devpilot_agentic_cli-1.0.0/agent/providers/factory.py +35 -0
  16. devpilot_agentic_cli-1.0.0/agent/providers/openai_provider.py +194 -0
  17. devpilot_agentic_cli-1.0.0/agent/providers/system_prompt.py +132 -0
  18. devpilot_agentic_cli-1.0.0/agent/setup_wizard.py +309 -0
  19. devpilot_agentic_cli-1.0.0/agent/tools/__init__.py +15 -0
  20. devpilot_agentic_cli-1.0.0/agent/tools/a2a.py +56 -0
  21. devpilot_agentic_cli-1.0.0/agent/tools/base.py +52 -0
  22. devpilot_agentic_cli-1.0.0/agent/tools/diagram.py +131 -0
  23. devpilot_agentic_cli-1.0.0/agent/tools/doc_gen.py +163 -0
  24. devpilot_agentic_cli-1.0.0/agent/tools/fs.py +411 -0
  25. devpilot_agentic_cli-1.0.0/agent/tools/git_ops.py +145 -0
  26. devpilot_agentic_cli-1.0.0/agent/tools/registry.py +219 -0
  27. devpilot_agentic_cli-1.0.0/agent/tools/search_code.py +120 -0
  28. devpilot_agentic_cli-1.0.0/agent/tools/shell.py +118 -0
  29. devpilot_agentic_cli-1.0.0/agent/tools/web_search.py +105 -0
  30. devpilot_agentic_cli-1.0.0/agent/tui/__init__.py +3 -0
  31. devpilot_agentic_cli-1.0.0/agent/tui/app.py +557 -0
  32. devpilot_agentic_cli-1.0.0/agent/ui.py +263 -0
  33. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/PKG-INFO +288 -0
  34. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/SOURCES.txt +45 -0
  35. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/dependency_links.txt +1 -0
  36. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/entry_points.txt +2 -0
  37. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/requires.txt +23 -0
  38. devpilot_agentic_cli-1.0.0/devpilot_agentic_cli.egg-info/top_level.txt +1 -0
  39. devpilot_agentic_cli-1.0.0/pyproject.toml +76 -0
  40. devpilot_agentic_cli-1.0.0/setup.cfg +4 -0
  41. devpilot_agentic_cli-1.0.0/tests/test_config.py +201 -0
  42. devpilot_agentic_cli-1.0.0/tests/test_e2e.py +248 -0
  43. devpilot_agentic_cli-1.0.0/tests/test_history.py +43 -0
  44. devpilot_agentic_cli-1.0.0/tests/test_loop.py +91 -0
  45. devpilot_agentic_cli-1.0.0/tests/test_providers.py +400 -0
  46. devpilot_agentic_cli-1.0.0/tests/test_setup_wizard.py +254 -0
  47. devpilot_agentic_cli-1.0.0/tests/test_tools.py +460 -0
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: devpilot-agentic-cli
3
+ Version: 1.0.0
4
+ Summary: Autonomous AI coding agent for your terminal β€” Claude, GPT-4o, Groq, Ollama, and more
5
+ Author: Thijesh Praveen V
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Thijeshpraveen-V/DevPilot
8
+ Project-URL: Repository, https://github.com/Thijeshpraveen-V/DevPilot
9
+ Project-URL: Issues, https://github.com/Thijeshpraveen-V/DevPilot/issues
10
+ Keywords: ai,coding-agent,cli,llm,anthropic,openai,groq,ollama,claude,gpt4,terminal,agent,mcp,textual,tui
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Topic :: Software Development
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: anthropic>=0.40.0
22
+ Requires-Dist: openai>=1.50.0
23
+ Requires-Dist: rich>=13.7.0
24
+ Requires-Dist: textual>=0.52.0
25
+ Requires-Dist: fastapi>=0.111.0
26
+ Requires-Dist: uvicorn[standard]>=0.30.0
27
+ Requires-Dist: sse-starlette>=2.1.0
28
+ Requires-Dist: httpx>=0.27.0
29
+ Requires-Dist: anyio>=4.4.0
30
+ Requires-Dist: mcp>=1.0.0
31
+ Requires-Dist: python-dotenv>=1.0.1
32
+ Requires-Dist: pydantic>=2.7.0
33
+ Requires-Dist: tavily-python>=0.3.0
34
+ Requires-Dist: GitPython>=3.1.40
35
+ Requires-Dist: markdown-it-py>=3.0.0
36
+ Requires-Dist: pypdf>=4.0.0
37
+ Provides-Extra: pdf
38
+ Requires-Dist: pdfkit>=1.0.0; extra == "pdf"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
41
+ Requires-Dist: pytest-asyncio>=0.23.7; extra == "dev"
42
+
43
+ # DevPilot πŸš€
44
+
45
+ [![PyPI](https://img.shields.io/pypi/v/devpilot-agentic-cli)](https://pypi.org/project/devpilot-agentic-cli/)
46
+ [![Python](https://img.shields.io/pypi/pyversions/devpilot-agentic-cli)](https://pypi.org/project/devpilot-agentic-cli/)
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
48
+
49
+ **An autonomous AI coding agent for your terminal.** DevPilot gives Claude, GPT-4o, Groq, Mistral, or any local model a full suite of tools β€” file read/write, bash execution, code search, git, MCP, and more β€” orchestrated into a self-healing agentic loop inside a rich Textual TUI.
50
+
51
+ ```
52
+ β”Œβ”€ DevPilot ──────────────────────────────────────────────────────┐
53
+ β”‚ ✦ claude-opus-4-5 β”‚ agent/tools/fs.py β”‚ iteration 2/50 β”‚
54
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
55
+ β”‚ You β€Ί Add input validation to the write_file tool β”‚
56
+ β”‚ β”‚
57
+ β”‚ ● Calling read_file agent/tools/fs.py β”‚
58
+ β”‚ ● Calling edit_file agent/tools/fs.py β”‚
59
+ β”‚ βœ“ Edited agent/tools/fs.py successfully. β”‚
60
+ β”‚ β”‚
61
+ β”‚ Done β€” added a size cap and path-escape guard. The diff is β”‚
62
+ β”‚ above. Want me to run the tests? β”‚
63
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Features
69
+
70
+ | Category | Capability |
71
+ |---|---|
72
+ | **File ops** | `read_file`, `write_file`, `edit_file` (surgical replace), `list_files` |
73
+ | **Shell** | `run_bash` with timeout, blocked-command guard, and auto-heal loop |
74
+ | **Code search** | Regex `search_code` |
75
+ | **Pre-flight linting** | Syntax-checks Python (`ast.parse`) and JS/TS (`node --check`) before writing |
76
+ | **Git** | `git_status`, `git_commit` with surgical file staging |
77
+ | **Documentation** | `doc_gen` (markdown), `diagram` (Mermaid) |
78
+ | **Web search** | `web_search` via Tavily (optional) |
79
+
80
+ | **MCP** | Connect any MCP server via `mcp_servers.json` |
81
+ | **A2A** | Agent-to-agent task delegation over HTTP |
82
+ | **Providers** | Anthropic, OpenAI, Groq, Together AI, Mistral, Ollama, any OpenAI-compatible endpoint |
83
+
84
+ ---
85
+
86
+ ## Quickstart
87
+
88
+ **Requires Python β‰₯ 3.11.**
89
+
90
+ ```bash
91
+ pip install devpilot-agentic-cli
92
+ devpilot
93
+ ```
94
+
95
+ That's it. On first run DevPilot launches a setup wizard β€” pick your provider, enter your API key, choose a model. It saves everything to a `.env` file and opens the TUI. Every subsequent run starts immediately.
96
+
97
+ ### Optional Features
98
+
99
+ **PDF Documentation Generation**
100
+ Enable the `generate_docs` tool to export PDFs:
101
+ ```bash
102
+ pip install devpilot-agentic-cli[pdf]
103
+ ```
104
+ *Note: You also need to install the [wkhtmltopdf](https://wkhtmltopdf.org/downloads.html) system binary.*
105
+
106
+ ---
107
+
108
+ ## Providers
109
+
110
+ DevPilot works with any of these out of the box β€” the setup wizard walks you through each one:
111
+
112
+ | Provider | Models | Get API key |
113
+ |---|---|---|
114
+ | **Anthropic** | claude-opus-4-5, claude-sonnet-4-5, claude-haiku-4-5 | [console.anthropic.com](https://console.anthropic.com/) |
115
+ | **OpenAI** | gpt-4o, gpt-4o-mini, o3, o4-mini | [platform.openai.com](https://platform.openai.com/api-keys) |
116
+ | **Groq** | llama-3.3-70b, mixtral-8x7b, gemma2-9b | [console.groq.com](https://console.groq.com/keys) |
117
+ | **Together AI** | Llama 3, Mixtral, and more | [api.together.xyz](https://api.together.xyz/settings/api-keys) |
118
+ | **Mistral AI** | mistral-large, codestral | [console.mistral.ai](https://console.mistral.ai/api-keys/) |
119
+ | **Ollama** | Any local model β€” no API key needed | [ollama.com](https://ollama.com/library) |
120
+ | **Other** | Any OpenAI-compatible endpoint | β€” |
121
+
122
+ ---
123
+
124
+ ## Configuration
125
+
126
+ All settings live in a `.env` file in your project directory. The setup wizard creates this on first run. You can edit it manually anytime β€” or re-run the wizard with `devpilot --setup`.
127
+
128
+ ### Full settings reference
129
+
130
+ | Variable | Default | Description |
131
+ |---|---|---|
132
+ | `ANTHROPIC_API_KEY` | β€” | API key for Anthropic provider |
133
+ | `OPENAI_API_KEY` | β€” | API key for OpenAI / Groq / Together / Mistral / Ollama |
134
+ | `DEVPILOT_PROVIDER` | `anthropic` | `anthropic` or `openai` |
135
+ | `DEVPILOT_MODEL` | `claude-opus-4-5` | Model name |
136
+ | `DEVPILOT_BASE_URL` | β€” | Custom endpoint, e.g. `http://localhost:11434/v1` for Ollama |
137
+ | `DEVPILOT_NO_CONFIRM` | `false` | Skip confirmation prompts (useful for CI) |
138
+ | `DEVPILOT_MAX_ITERATIONS` | `50` | Max tool-use iterations before loop aborts |
139
+ | `DEVPILOT_WORKDIR` | `cwd` | Root directory for file operations |
140
+ | `DEVPILOT_SESSIONS_DIR` | `.devpilot_sessions` | Where session JSON files are saved |
141
+ | `DEVPILOT_THINKING` | `false` | Enable extended thinking (Claude only) |
142
+ | `DEVPILOT_THINKING_BUDGET` | `10000` | Token budget for extended thinking |
143
+
144
+ ### Override priority
145
+
146
+ ```
147
+ CLI flags β†’ env vars β†’ .env file β†’ defaults
148
+ ```
149
+
150
+ Per-run override example:
151
+ ```bash
152
+ DEVPILOT_MODEL=claude-haiku-4-5-20251101 devpilot --task "fix typos"
153
+ ```
154
+
155
+ ---
156
+
157
+ ## CLI Reference
158
+
159
+ ```
160
+ devpilot [OPTIONS]
161
+
162
+ Options:
163
+ --provider {anthropic,openai} Model provider
164
+ --model MODEL Model name
165
+ --base-url URL OpenAI-compatible base URL (e.g. Ollama)
166
+ --no-confirm Skip confirmation prompts
167
+ --thinking Enable extended thinking (Claude only)
168
+ --thinking-budget N Token budget for extended thinking (default: 10000)
169
+ --workdir PATH Working directory for file operations
170
+ --task TASK Run a single task and exit (CI mode)
171
+ --resume SESSION_ID Resume a previous session
172
+ --a2a-port PORT A2A server port (default: 8000)
173
+ --no-a2a Disable A2A server
174
+ --no-web-search Disable Tavily web search
175
+
176
+ --setup Re-run the setup wizard
177
+ ```
178
+
179
+ ### CI / single-task mode
180
+
181
+ ```bash
182
+ devpilot --task "Run the test suite and fix any failures" --no-confirm
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Using Ollama (Local Models)
188
+
189
+ ```bash
190
+ # Pull and serve a model
191
+ ollama pull qwen2.5-coder:7b
192
+ ollama serve
193
+
194
+ # Run devpilot and pick Ollama in the setup wizard
195
+ devpilot --setup
196
+ ```
197
+
198
+ Or set env vars directly:
199
+ ```bash
200
+ DEVPILOT_PROVIDER=openai \
201
+ DEVPILOT_BASE_URL=http://localhost:11434/v1 \
202
+ DEVPILOT_MODEL=qwen2.5-coder:7b \
203
+ devpilot
204
+ ```
205
+
206
+ ---
207
+
208
+ ## MCP Integration
209
+
210
+ DevPilot connects to any [Model Context Protocol](https://modelcontextprotocol.io/) server. Edit `mcp_servers.json` in your project root:
211
+
212
+ ```json
213
+ {
214
+ "mcpServers": {
215
+ "filesystem": {
216
+ "command": "npx",
217
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ Tools from connected MCP servers are automatically available to the agent on startup.
224
+
225
+ ---
226
+
227
+ ## Architecture
228
+
229
+ ```
230
+ agent/
231
+ β”œβ”€β”€ cli.py Entry point β€” args, setup wizard, wires everything
232
+ β”œβ”€β”€ setup_wizard.py First-run interactive configuration wizard
233
+ β”œβ”€β”€ loop.py Core agentic loop (plan β†’ act β†’ verify β†’ heal)
234
+ β”œβ”€β”€ config.py Config dataclass β€” all settings from env vars
235
+ β”œβ”€β”€ context.py RepoContext β€” file awareness, AST map
236
+ β”œβ”€β”€ history.py Conversation history + smart context pruning
237
+ β”œβ”€β”€ providers/
238
+ β”‚ β”œβ”€β”€ anthropic_provider.py
239
+ β”‚ β”œβ”€β”€ openai_provider.py
240
+ β”‚ β”œβ”€β”€ system_prompt.py PLANβ†’ACTβ†’VERIFY prompt, platform-aware shell rules
241
+ β”‚ └── factory.py
242
+ β”œβ”€β”€ tools/
243
+ β”‚ β”œβ”€β”€ fs.py read_file, write_file (pre-flight lint), edit_file, list_files
244
+ β”‚ β”œβ”€β”€ shell.py run_bash
245
+ β”‚ β”œβ”€β”€ search_code.py regex search
246
+ β”‚ β”œβ”€β”€ git_ops.py git_status, git_commit
247
+ β”‚ β”œβ”€β”€ doc_gen.py doc_gen
248
+ β”‚ β”œβ”€β”€ diagram.py diagram (Mermaid)
249
+ β”‚ β”œβ”€β”€ web_search.py web_search (Tavily)
250
+
251
+ β”‚ β”œβ”€β”€ a2a.py A2A delegation
252
+ β”‚ └── registry.py ToolRegistry + PermissionGuard
253
+ └── tui/
254
+ └── app.py Textual TUI β€” chat log, project map, tool drawer
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Running Tests
260
+
261
+ ```bash
262
+ pip install devpilot-agentic-cli[dev]
263
+ pytest
264
+ ```
265
+
266
+ 48 tests β€” unit tests for every tool plus end-to-end integration tests with a mocked provider.
267
+
268
+ ---
269
+
270
+ ## Development / Contributing
271
+
272
+ ```bash
273
+ git clone https://github.com/Thijeshpraveen-V/DevPilot
274
+ cd DevPilot
275
+ pip install -e ".[dev]"
276
+ devpilot --setup
277
+ ```
278
+
279
+ PR checklist:
280
+ - `pytest` passes (48 tests, 0 failures)
281
+ - No new hard dependencies without discussion
282
+ - New tools follow the `BaseTool` pattern in `agent/tools/base.py`
283
+
284
+ ---
285
+
286
+ ## License
287
+
288
+ MIT Β© Thijesh Praveen V
@@ -0,0 +1,246 @@
1
+ # DevPilot πŸš€
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/devpilot-agentic-cli)](https://pypi.org/project/devpilot-agentic-cli/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/devpilot-agentic-cli)](https://pypi.org/project/devpilot-agentic-cli/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **An autonomous AI coding agent for your terminal.** DevPilot gives Claude, GPT-4o, Groq, Mistral, or any local model a full suite of tools β€” file read/write, bash execution, code search, git, MCP, and more β€” orchestrated into a self-healing agentic loop inside a rich Textual TUI.
8
+
9
+ ```
10
+ β”Œβ”€ DevPilot ──────────────────────────────────────────────────────┐
11
+ β”‚ ✦ claude-opus-4-5 β”‚ agent/tools/fs.py β”‚ iteration 2/50 β”‚
12
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
13
+ β”‚ You β€Ί Add input validation to the write_file tool β”‚
14
+ β”‚ β”‚
15
+ β”‚ ● Calling read_file agent/tools/fs.py β”‚
16
+ β”‚ ● Calling edit_file agent/tools/fs.py β”‚
17
+ β”‚ βœ“ Edited agent/tools/fs.py successfully. β”‚
18
+ β”‚ β”‚
19
+ β”‚ Done β€” added a size cap and path-escape guard. The diff is β”‚
20
+ β”‚ above. Want me to run the tests? β”‚
21
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Features
27
+
28
+ | Category | Capability |
29
+ |---|---|
30
+ | **File ops** | `read_file`, `write_file`, `edit_file` (surgical replace), `list_files` |
31
+ | **Shell** | `run_bash` with timeout, blocked-command guard, and auto-heal loop |
32
+ | **Code search** | Regex `search_code` |
33
+ | **Pre-flight linting** | Syntax-checks Python (`ast.parse`) and JS/TS (`node --check`) before writing |
34
+ | **Git** | `git_status`, `git_commit` with surgical file staging |
35
+ | **Documentation** | `doc_gen` (markdown), `diagram` (Mermaid) |
36
+ | **Web search** | `web_search` via Tavily (optional) |
37
+
38
+ | **MCP** | Connect any MCP server via `mcp_servers.json` |
39
+ | **A2A** | Agent-to-agent task delegation over HTTP |
40
+ | **Providers** | Anthropic, OpenAI, Groq, Together AI, Mistral, Ollama, any OpenAI-compatible endpoint |
41
+
42
+ ---
43
+
44
+ ## Quickstart
45
+
46
+ **Requires Python β‰₯ 3.11.**
47
+
48
+ ```bash
49
+ pip install devpilot-agentic-cli
50
+ devpilot
51
+ ```
52
+
53
+ That's it. On first run DevPilot launches a setup wizard β€” pick your provider, enter your API key, choose a model. It saves everything to a `.env` file and opens the TUI. Every subsequent run starts immediately.
54
+
55
+ ### Optional Features
56
+
57
+ **PDF Documentation Generation**
58
+ Enable the `generate_docs` tool to export PDFs:
59
+ ```bash
60
+ pip install devpilot-agentic-cli[pdf]
61
+ ```
62
+ *Note: You also need to install the [wkhtmltopdf](https://wkhtmltopdf.org/downloads.html) system binary.*
63
+
64
+ ---
65
+
66
+ ## Providers
67
+
68
+ DevPilot works with any of these out of the box β€” the setup wizard walks you through each one:
69
+
70
+ | Provider | Models | Get API key |
71
+ |---|---|---|
72
+ | **Anthropic** | claude-opus-4-5, claude-sonnet-4-5, claude-haiku-4-5 | [console.anthropic.com](https://console.anthropic.com/) |
73
+ | **OpenAI** | gpt-4o, gpt-4o-mini, o3, o4-mini | [platform.openai.com](https://platform.openai.com/api-keys) |
74
+ | **Groq** | llama-3.3-70b, mixtral-8x7b, gemma2-9b | [console.groq.com](https://console.groq.com/keys) |
75
+ | **Together AI** | Llama 3, Mixtral, and more | [api.together.xyz](https://api.together.xyz/settings/api-keys) |
76
+ | **Mistral AI** | mistral-large, codestral | [console.mistral.ai](https://console.mistral.ai/api-keys/) |
77
+ | **Ollama** | Any local model β€” no API key needed | [ollama.com](https://ollama.com/library) |
78
+ | **Other** | Any OpenAI-compatible endpoint | β€” |
79
+
80
+ ---
81
+
82
+ ## Configuration
83
+
84
+ All settings live in a `.env` file in your project directory. The setup wizard creates this on first run. You can edit it manually anytime β€” or re-run the wizard with `devpilot --setup`.
85
+
86
+ ### Full settings reference
87
+
88
+ | Variable | Default | Description |
89
+ |---|---|---|
90
+ | `ANTHROPIC_API_KEY` | β€” | API key for Anthropic provider |
91
+ | `OPENAI_API_KEY` | β€” | API key for OpenAI / Groq / Together / Mistral / Ollama |
92
+ | `DEVPILOT_PROVIDER` | `anthropic` | `anthropic` or `openai` |
93
+ | `DEVPILOT_MODEL` | `claude-opus-4-5` | Model name |
94
+ | `DEVPILOT_BASE_URL` | β€” | Custom endpoint, e.g. `http://localhost:11434/v1` for Ollama |
95
+ | `DEVPILOT_NO_CONFIRM` | `false` | Skip confirmation prompts (useful for CI) |
96
+ | `DEVPILOT_MAX_ITERATIONS` | `50` | Max tool-use iterations before loop aborts |
97
+ | `DEVPILOT_WORKDIR` | `cwd` | Root directory for file operations |
98
+ | `DEVPILOT_SESSIONS_DIR` | `.devpilot_sessions` | Where session JSON files are saved |
99
+ | `DEVPILOT_THINKING` | `false` | Enable extended thinking (Claude only) |
100
+ | `DEVPILOT_THINKING_BUDGET` | `10000` | Token budget for extended thinking |
101
+
102
+ ### Override priority
103
+
104
+ ```
105
+ CLI flags β†’ env vars β†’ .env file β†’ defaults
106
+ ```
107
+
108
+ Per-run override example:
109
+ ```bash
110
+ DEVPILOT_MODEL=claude-haiku-4-5-20251101 devpilot --task "fix typos"
111
+ ```
112
+
113
+ ---
114
+
115
+ ## CLI Reference
116
+
117
+ ```
118
+ devpilot [OPTIONS]
119
+
120
+ Options:
121
+ --provider {anthropic,openai} Model provider
122
+ --model MODEL Model name
123
+ --base-url URL OpenAI-compatible base URL (e.g. Ollama)
124
+ --no-confirm Skip confirmation prompts
125
+ --thinking Enable extended thinking (Claude only)
126
+ --thinking-budget N Token budget for extended thinking (default: 10000)
127
+ --workdir PATH Working directory for file operations
128
+ --task TASK Run a single task and exit (CI mode)
129
+ --resume SESSION_ID Resume a previous session
130
+ --a2a-port PORT A2A server port (default: 8000)
131
+ --no-a2a Disable A2A server
132
+ --no-web-search Disable Tavily web search
133
+
134
+ --setup Re-run the setup wizard
135
+ ```
136
+
137
+ ### CI / single-task mode
138
+
139
+ ```bash
140
+ devpilot --task "Run the test suite and fix any failures" --no-confirm
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Using Ollama (Local Models)
146
+
147
+ ```bash
148
+ # Pull and serve a model
149
+ ollama pull qwen2.5-coder:7b
150
+ ollama serve
151
+
152
+ # Run devpilot and pick Ollama in the setup wizard
153
+ devpilot --setup
154
+ ```
155
+
156
+ Or set env vars directly:
157
+ ```bash
158
+ DEVPILOT_PROVIDER=openai \
159
+ DEVPILOT_BASE_URL=http://localhost:11434/v1 \
160
+ DEVPILOT_MODEL=qwen2.5-coder:7b \
161
+ devpilot
162
+ ```
163
+
164
+ ---
165
+
166
+ ## MCP Integration
167
+
168
+ DevPilot connects to any [Model Context Protocol](https://modelcontextprotocol.io/) server. Edit `mcp_servers.json` in your project root:
169
+
170
+ ```json
171
+ {
172
+ "mcpServers": {
173
+ "filesystem": {
174
+ "command": "npx",
175
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ Tools from connected MCP servers are automatically available to the agent on startup.
182
+
183
+ ---
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ agent/
189
+ β”œβ”€β”€ cli.py Entry point β€” args, setup wizard, wires everything
190
+ β”œβ”€β”€ setup_wizard.py First-run interactive configuration wizard
191
+ β”œβ”€β”€ loop.py Core agentic loop (plan β†’ act β†’ verify β†’ heal)
192
+ β”œβ”€β”€ config.py Config dataclass β€” all settings from env vars
193
+ β”œβ”€β”€ context.py RepoContext β€” file awareness, AST map
194
+ β”œβ”€β”€ history.py Conversation history + smart context pruning
195
+ β”œβ”€β”€ providers/
196
+ β”‚ β”œβ”€β”€ anthropic_provider.py
197
+ β”‚ β”œβ”€β”€ openai_provider.py
198
+ β”‚ β”œβ”€β”€ system_prompt.py PLANβ†’ACTβ†’VERIFY prompt, platform-aware shell rules
199
+ β”‚ └── factory.py
200
+ β”œβ”€β”€ tools/
201
+ β”‚ β”œβ”€β”€ fs.py read_file, write_file (pre-flight lint), edit_file, list_files
202
+ β”‚ β”œβ”€β”€ shell.py run_bash
203
+ β”‚ β”œβ”€β”€ search_code.py regex search
204
+ β”‚ β”œβ”€β”€ git_ops.py git_status, git_commit
205
+ β”‚ β”œβ”€β”€ doc_gen.py doc_gen
206
+ β”‚ β”œβ”€β”€ diagram.py diagram (Mermaid)
207
+ β”‚ β”œβ”€β”€ web_search.py web_search (Tavily)
208
+
209
+ β”‚ β”œβ”€β”€ a2a.py A2A delegation
210
+ β”‚ └── registry.py ToolRegistry + PermissionGuard
211
+ └── tui/
212
+ └── app.py Textual TUI β€” chat log, project map, tool drawer
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Running Tests
218
+
219
+ ```bash
220
+ pip install devpilot-agentic-cli[dev]
221
+ pytest
222
+ ```
223
+
224
+ 48 tests β€” unit tests for every tool plus end-to-end integration tests with a mocked provider.
225
+
226
+ ---
227
+
228
+ ## Development / Contributing
229
+
230
+ ```bash
231
+ git clone https://github.com/Thijeshpraveen-V/DevPilot
232
+ cd DevPilot
233
+ pip install -e ".[dev]"
234
+ devpilot --setup
235
+ ```
236
+
237
+ PR checklist:
238
+ - `pytest` passes (48 tests, 0 failures)
239
+ - No new hard dependencies without discussion
240
+ - New tools follow the `BaseTool` pattern in `agent/tools/base.py`
241
+
242
+ ---
243
+
244
+ ## License
245
+
246
+ MIT Β© Thijesh Praveen V
@@ -0,0 +1 @@
1
+ # DevPilot Agent Package
@@ -0,0 +1,94 @@
1
+ """
2
+ agent/a2a_client.py
3
+ ───────────────────
4
+ A2A client implementation. Discovers peer agents via their AgentCard
5
+ and delegates tasks to them using HTTP SSE.
6
+ """
7
+
8
+ import json
9
+ from typing import Any
10
+
11
+ import httpx
12
+
13
+ from agent.tools import ToolResult
14
+ from agent.ui import UI
15
+
16
+
17
+ async def _fetch_agent_card(peer_url: str, token: str | None) -> dict[str, Any]:
18
+ headers = {}
19
+ if token:
20
+ headers["Authorization"] = f"Bearer {token}"
21
+
22
+ card_url = f"{peer_url.rstrip('/')}/.well-known/agent.json"
23
+ async with httpx.AsyncClient() as client:
24
+ response = await client.get(card_url, headers=headers)
25
+ response.raise_for_status()
26
+ return response.json()
27
+
28
+
29
+ async def delegate_task_to_peer(peer_url: str, prompt: str, token: str | None = None) -> ToolResult:
30
+ """
31
+ Delegate a task to an A2A peer agent.
32
+ 1. Fetch AgentCard to find the /tasks/send endpoint.
33
+ 2. POST the task.
34
+ 3. Stream SSE events to get the artifact.
35
+ """
36
+ try:
37
+ card = await _fetch_agent_card(peer_url, token)
38
+ except Exception as e:
39
+ return ToolResult(f"Failed to fetch AgentCard from {peer_url}: {e}", is_error=True)
40
+
41
+ endpoints = card.get("endpoints", {})
42
+ send_url = endpoints.get("tasks")
43
+ if not send_url:
44
+ return ToolResult(f"Peer AgentCard missing 'tasks' endpoint. Card: {card}", is_error=True)
45
+
46
+ headers = {}
47
+ if token:
48
+ headers["Authorization"] = f"Bearer {token}"
49
+
50
+ try:
51
+ async with httpx.AsyncClient() as client:
52
+ # Send task
53
+ response = await client.post(send_url, json={"prompt": prompt}, headers=headers)
54
+ response.raise_for_status()
55
+ data = response.json()
56
+ task_id = data.get("task_id")
57
+
58
+ if not task_id:
59
+ return ToolResult("Peer did not return a task_id.", is_error=True)
60
+
61
+ base = send_url[: send_url.rfind("/send")]
62
+ stream_url = f"{base}/{task_id}/stream"
63
+
64
+ # Read SSE
65
+ UI.print_info(f"Delegated task {task_id} to {peer_url}. Waiting for results...")
66
+
67
+ final_artifact = ""
68
+ status = "working"
69
+
70
+ async with client.stream("GET", stream_url, headers=headers) as stream_resp:
71
+ stream_resp.raise_for_status()
72
+ async for line in stream_resp.aiter_lines():
73
+ line = line.strip()
74
+ if not line:
75
+ continue
76
+ if line.startswith("event: "):
77
+ current_event = line[7:]
78
+ elif line.startswith("data: "):
79
+ data_payload = line[6:]
80
+ if "current_event" in locals():
81
+ if current_event == "artifact":
82
+ final_artifact += data_payload + "\n"
83
+ elif current_event == "status":
84
+ status = data_payload
85
+
86
+ if status == "failed":
87
+ return ToolResult(f"Task failed on peer: {final_artifact}", is_error=True)
88
+
89
+ return ToolResult(f"Task completed successfully by peer. Artifact:\n{final_artifact}", is_error=False)
90
+
91
+ except Exception as e:
92
+ return ToolResult(f"A2A connection error: {e}", is_error=True)
93
+
94
+