devtrace-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. devtrace_cli-1.0.0/.github/workflows/tests.yaml +29 -0
  2. devtrace_cli-1.0.0/.gitignore +9 -0
  3. devtrace_cli-1.0.0/LICENSE +21 -0
  4. devtrace_cli-1.0.0/PKG-INFO +341 -0
  5. devtrace_cli-1.0.0/README.md +317 -0
  6. devtrace_cli-1.0.0/action.yml +61 -0
  7. devtrace_cli-1.0.0/docs/architecture.md +29 -0
  8. devtrace_cli-1.0.0/examples/sample_snapshot.json +31 -0
  9. devtrace_cli-1.0.0/pyproject.toml +53 -0
  10. devtrace_cli-1.0.0/src/devtrace/__init__.py +4 -0
  11. devtrace_cli-1.0.0/src/devtrace/__main__.py +8 -0
  12. devtrace_cli-1.0.0/src/devtrace/cli.py +631 -0
  13. devtrace_cli-1.0.0/src/devtrace/collectors/__init__.py +0 -0
  14. devtrace_cli-1.0.0/src/devtrace/collectors/node_deps.py +110 -0
  15. devtrace_cli-1.0.0/src/devtrace/collectors/node_runtime.py +37 -0
  16. devtrace_cli-1.0.0/src/devtrace/collectors/python_deps.py +136 -0
  17. devtrace_cli-1.0.0/src/devtrace/collectors/python_runtime.py +18 -0
  18. devtrace_cli-1.0.0/src/devtrace/collectors/system.py +46 -0
  19. devtrace_cli-1.0.0/src/devtrace/core/__init__.py +0 -0
  20. devtrace_cli-1.0.0/src/devtrace/core/agent.py +297 -0
  21. devtrace_cli-1.0.0/src/devtrace/core/ai_explainer.py +96 -0
  22. devtrace_cli-1.0.0/src/devtrace/core/collector.py +62 -0
  23. devtrace_cli-1.0.0/src/devtrace/core/comparator.py +199 -0
  24. devtrace_cli-1.0.0/src/devtrace/core/diagnostics.py +216 -0
  25. devtrace_cli-1.0.0/src/devtrace/core/healer.py +218 -0
  26. devtrace_cli-1.0.0/src/devtrace/core/models.py +86 -0
  27. devtrace_cli-1.0.0/src/devtrace/core/reporter.py +85 -0
  28. devtrace_cli-1.0.0/src/devtrace/core/serializer.py +13 -0
  29. devtrace_cli-1.0.0/src/devtrace/mcp_server.py +175 -0
  30. devtrace_cli-1.0.0/src/devtrace/project/__init__.py +0 -0
  31. devtrace_cli-1.0.0/src/devtrace/project/detector.py +44 -0
  32. devtrace_cli-1.0.0/src/devtrace/storage/__init__.py +0 -0
  33. devtrace_cli-1.0.0/src/devtrace/storage/history_store.py +108 -0
  34. devtrace_cli-1.0.0/src/devtrace/storage/json_store.py +51 -0
  35. devtrace_cli-1.0.0/tests/__init__.py +0 -0
  36. devtrace_cli-1.0.0/tests/integration/__init__.py +0 -0
  37. devtrace_cli-1.0.0/tests/integration/test_cli_capture.py +50 -0
  38. devtrace_cli-1.0.0/tests/unit/__init__.py +0 -0
  39. devtrace_cli-1.0.0/tests/unit/test_agent.py +72 -0
  40. devtrace_cli-1.0.0/tests/unit/test_collectors.py +52 -0
  41. devtrace_cli-1.0.0/tests/unit/test_comparator.py +96 -0
  42. devtrace_cli-1.0.0/tests/unit/test_dependencies.py +49 -0
  43. devtrace_cli-1.0.0/tests/unit/test_diagnostics_and_report.py +68 -0
  44. devtrace_cli-1.0.0/tests/unit/test_healer.py +47 -0
  45. devtrace_cli-1.0.0/tests/unit/test_history_and_diff.py +41 -0
  46. devtrace_cli-1.0.0/tests/unit/test_mcp_and_ai.py +52 -0
  47. devtrace_cli-1.0.0/tests/unit/test_models_and_serializer.py +45 -0
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Set up Python ${{ matrix.python-version }}
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ - name: Install package and dev dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install -e ".[dev]"
26
+ - name: Run Ruff lint check
27
+ run: ruff check .
28
+ - name: Run pytest
29
+ run: pytest -v
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .devtrace/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Biswajit Putel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.5
2
+ Name: devtrace-cli
3
+ Version: 1.0.0
4
+ Summary: Local-first, cross-language developer diagnostics and environment snapshot CLI.
5
+ Author: Biswajit Putel
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: cli,debugging,diagnostics,environment,reproducibility
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: tomli>=2.0.0; python_version < '3.11'
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
23
+ Description-Content-Type: text/markdown
24
+
25
+ <div align="center">
26
+
27
+ # DevTrace
28
+
29
+ **Autonomous, Local-First Environment Diagnostics, Silent Drift Detection & Sandbox Self-Healing**
30
+
31
+ [![CI](https://github.com/SUBHAM646/devtrace/actions/workflows/tests.yaml/badge.svg)](https://github.com/SUBHAM646/devtrace/actions/workflows/tests.yaml)
32
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
34
+ [![MCP Ready](https://img.shields.io/badge/MCP-Compatible-purple.svg)](#ai-coding-agent-integration-mcp-server)
35
+ [![Zero Telemetry](https://img.shields.io/badge/Privacy-Local--First-black.svg)](#privacy--security-guarantees)
36
+
37
+ *Eliminate "works on my machine" debugging forever. Capture privacy-safe environment snapshots, catch silent dependency drift, verify repairs in isolated sandboxes, and give AI coding agents ground-truth environment intelligence.*
38
+
39
+ </div>
40
+
41
+ ---
42
+
43
+ ## Table of Contents
44
+
45
+ - [The Problem](#the-problem)
46
+ - [Why DevTrace?](#why-devtrace)
47
+ - [Core Capabilities](#core-capabilities)
48
+ - [Installation](#installation)
49
+ - [Quick Start](#quick-start)
50
+ - [Complete Command Reference](#complete-command-reference)
51
+ - [AI Coding Agent Integration (MCP Server)](#ai-coding-agent-integration-mcp-server)
52
+ - [BYOK & Local LLM Configuration](#byok--local-llm-configuration)
53
+ - [GitHub Actions CI Guard](#github-actions-ci-guard)
54
+ - [System Architecture](#system-architecture)
55
+ - [Privacy & Security Guarantees](#privacy--security-guarantees)
56
+ - [Development & Contributing](#development--contributing)
57
+ - [License](#license)
58
+
59
+ ---
60
+
61
+ ## The Problem
62
+
63
+ Nearly **40–50% of modern debugging time** is not caused by broken application logic—it is caused by **environment drift**:
64
+
65
+ - Packages installed manually in `.venv` or `node_modules` that were never declared in `pyproject.toml`, `requirements.txt`, or `package.json`.
66
+ - Subtle Python, Node.js, OS, or CPU architecture mismatches (`x86_64` vs. `arm64`) between laptops, teammates, and CI runners.
67
+ - AI coding agents (Cursor, Claude Code, Windsurf) hallucinating fixes because they cannot see your live runtime and dependency state.
68
+
69
+ ---
70
+
71
+ ## Why DevTrace?
72
+
73
+ DevTrace is built on a strict **"Deterministic Evidence First, Agentic Reasoning Second"** engineering philosophy:
74
+
75
+ 1. **Zero-Hallucination Evidence Engine:** DevTrace inspects your OS, runtimes, manifests, and installed packages deterministically before any LLM is invoked.
76
+ 2. **Silent Drift Detection:** Instantly detects both `missing_from_env` (declared in manifest, missing locally) and `undeclared_in_manifest` (installed locally, missing from manifest).
77
+ 3. **Time-Travel Environment History:** Tag known-good states (`--tag working`) and diff your live machine against past baselines in seconds.
78
+ 4. **Isolated Sandbox Self-Healing (`devtrace heal`):** Tests missing dependency repairs inside a disposable `/tmp` virtual environment and runs your verification command before touching your host machine.
79
+ 5. **Native MCP Server (`devtrace mcp`):** Built-in stdio JSON-RPC Model Context Protocol server with zero external SDK dependencies.
80
+ 6. **Lightweight & Local-First:** Powered by the Python 3.10+ standard library (only `tomli` on Python 3.10). No cloud accounts, no telemetry, and no secret scraping.
81
+
82
+ ---
83
+
84
+ ## Core Capabilities
85
+
86
+ | Command | Layer | Purpose |
87
+ | :--- | :--- | :--- |
88
+ | `devtrace capture [--tag <name>]` | Snapshot | Capture OS, architecture, Python/Node runtimes, and declared vs. installed dependencies, and record to `.devtrace/history/`. |
89
+ | `devtrace history` | Time-Travel | View chronologically recorded snapshots, custom tags, runtime versions, and drift counts. |
90
+ | `devtrace diff [--against-tag <name>]` | Time-Travel | Compare your live environment against the latest saved snapshot or a tagged baseline (e.g., `working`). |
91
+ | `devtrace compare <left> <right>` | Cross-Machine | Side-by-side environment and package diff across two machines or CI runners, filtering out volatile IDs and timestamps. |
92
+ | `devtrace diagnose [--error-file <log>]` | Diagnostics | Offline deterministic rule engine mapping stack traces (`ModuleNotFoundError`, `Cannot find module`) and drift to verified evidence. |
93
+ | `devtrace report [--output <file>]` | Reporting | Generate a clean, path-redacted Markdown diagnostic report ready for GitHub Issues or Pull Requests. |
94
+ | `devtrace ask "<question>"` | Agentic AI | Multi-step tool-calling agent that investigates drift, history, and diagnostics (supports `--offline` deterministic fallback). |
95
+ | `devtrace explain [--error-file <log>]` | AI Assistant | Evidence-grounded root-cause explanation powered by local Ollama or any OpenAI-compatible API. |
96
+ | `devtrace heal [--verify-cmd "<cmd>"]` | Self-Healing | Verify missing package installations inside an isolated temporary virtualenv before applying to your host environment. |
97
+ | `devtrace mcp` | Agent Protocol | Start DevTrace as a native stdio Model Context Protocol (MCP) server for AI IDEs and coding agents. |
98
+
99
+ ---
100
+
101
+ ## Installation
102
+
103
+ ### From PyPI
104
+
105
+ ```bash
106
+ pip install devtrace
107
+ ```
108
+
109
+ ### From Source (Local Development)
110
+
111
+ ```bash
112
+ git clone https://github.com/SUBHAM646/devtrace.git
113
+ cd devtrace
114
+ python3 -m venv .venv
115
+ source .venv/bin/activate
116
+ pip install -e ".[dev]"
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Quick Start
122
+
123
+ ### 1. Capture a Known-Good Baseline
124
+
125
+ Record a snapshot of your environment when everything is working properly:
126
+
127
+ ```bash
128
+ devtrace capture --tag working
129
+ ```
130
+
131
+ Example output:
132
+
133
+ ```text
134
+ DevTrace snapshot captured successfully.
135
+ Snapshot ID : 9ef09033-d908-4722-a681-61f166037776
136
+ Tag : working
137
+ System : Ubuntu 26.04.1 LTS (x86_64)
138
+ Python : 3.14.4
139
+ Node.js : 26.13.1
140
+ Languages : python
141
+ Python Deps : 2 declared, 8 installed
142
+ Saved to : /project/.devtrace/snapshot.json
143
+ ```
144
+
145
+ ### 2. Diagnose Silent Drift or Crash Logs Offline
146
+
147
+ Run deterministic diagnostic rules against your snapshot and an optional crash log (zero API keys required):
148
+
149
+ ```bash
150
+ devtrace diagnose --error-file crash.log
151
+ ```
152
+
153
+ ### 3. Time-Travel Diff When Something Breaks
154
+
155
+ Compare your live environment against your last `working` baseline:
156
+
157
+ ```bash
158
+ devtrace diff --against-tag working
159
+ ```
160
+
161
+ ### 4. Verify & Heal Missing Dependencies in an Isolated Sandbox
162
+
163
+ Spin up a disposable virtual environment, install missing dependencies, and run your test command to prove the fix works before modifying your host environment:
164
+
165
+ ```bash
166
+ # Preview the repair plan without creating a sandbox
167
+ devtrace heal --error-file crash.log --dry-run
168
+
169
+ # Verify the fix inside an isolated temporary virtualenv
170
+ devtrace heal --error-file crash.log --verify-cmd "pytest"
171
+
172
+ # Apply the fix to your active environment only after sandbox verification passes
173
+ devtrace heal --error-file crash.log --verify-cmd "pytest" --apply
174
+ ```
175
+
176
+ ### 5. Investigate with the Multi-Step Agent
177
+
178
+ Ask natural-language questions backed by live deterministic tool execution:
179
+
180
+ ```bash
181
+ # Uses local Ollama or configured BYOK LLM
182
+ devtrace ask "What dependency drift exists and how do I fix it?"
183
+
184
+ # Runs purely deterministic tools with zero network calls
185
+ devtrace ask "Check my project drift and history" --offline
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Complete Command Reference
191
+
192
+ ```bash
193
+ # 1. Capture & Chronological History
194
+ devtrace capture [--project .] [--output .devtrace/snapshot.json] [--tag working] [--force]
195
+ devtrace history [--project .]
196
+ devtrace diff [--project .] [--against-tag working] [--json]
197
+
198
+ # 2. Cross-Machine Comparison, Diagnostics & Markdown Reports
199
+ devtrace compare machine-a.json machine-b.json [--json]
200
+ devtrace diagnose [--snapshot .devtrace/snapshot.json] [--error-file crash.log] [--json]
201
+ devtrace report [--snapshot .devtrace/snapshot.json] [--compare-with other.json] [--error-file crash.log] [--output report.md]
202
+
203
+ # 3. Agentic Investigation, Grounded AI Explainer & Sandbox Self-Healing
204
+ devtrace ask "<question>" [--project .] [--error-file crash.log] [--model llama3.2] [--offline]
205
+ devtrace explain [--snapshot .devtrace/snapshot.json] [--error-file crash.log] [--model llama3.2] [--dry-run]
206
+ devtrace heal [--project .] [--error-file crash.log] [--verify-cmd "pytest"] [--dry-run] [--apply]
207
+
208
+ # 4. Model Context Protocol (MCP) Server
209
+ devtrace mcp
210
+ ```
211
+
212
+ ---
213
+
214
+ ## AI Coding Agent Integration (MCP Server)
215
+
216
+ DevTrace ships with a zero-dependency stdio JSON-RPC **Model Context Protocol (MCP)** server. Add it to **Claude Code**, **Cursor**, or **Windsurf** so your AI assistant can inspect your environment before suggesting code or dependency changes:
217
+
218
+ ```json
219
+ {
220
+ "mcpServers": {
221
+ "devtrace": {
222
+ "command": "devtrace",
223
+ "args": ["mcp"]
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ ### Exposed MCP Tools
230
+
231
+ | Tool Name | Description |
232
+ | :--- | :--- |
233
+ | `capture_environment` | Captures a live, path-redacted snapshot of OS, runtimes, and dependency drift. |
234
+ | `diagnose_environment` | Evaluates deterministic rules against the live environment and optional crash log. |
235
+ | `compare_snapshots` | Computes a structured diff between two DevTrace snapshot JSON files. |
236
+
237
+ ---
238
+
239
+ ## BYOK & Local LLM Configuration
240
+
241
+ By default, `devtrace ask` and `devtrace explain` connect to a local **Ollama** instance (`http://localhost:11434/v1` using `llama3.2`). You can point DevTrace to any OpenAI-compatible provider (OpenAI, OpenRouter, Groq, vLLM, etc.) via environment variables:
242
+
243
+ ```bash
244
+ export DEVTRACE_AI_BASE_URL="https://api.openai.com/v1"
245
+ export DEVTRACE_AI_API_KEY="sk-..."
246
+ export DEVTRACE_AI_MODEL="gpt-4o-mini"
247
+ ```
248
+
249
+ Use `--dry-run` on `explain` or `--offline` on `ask` at any time to operate completely offline without an LLM endpoint.
250
+
251
+ ---
252
+
253
+ ## GitHub Actions CI Guard
254
+
255
+ Embed DevTrace directly into your repository's CI workflow to attach environment summaries to Pull Requests and fail builds when declared dependencies are missing:
256
+
257
+ ```yaml
258
+ name: Environment & Drift Check
259
+
260
+ on: [pull_request]
261
+
262
+ jobs:
263
+ devtrace-guard:
264
+ runs-on: ubuntu-latest
265
+ steps:
266
+ - uses: actions/checkout@v4
267
+
268
+ - uses: actions/setup-python@v5
269
+ with:
270
+ python-version: "3.12"
271
+
272
+ - name: Run DevTrace Drift Guard
273
+ uses: SUBHAM646/devtrace@v1.0.0
274
+ with:
275
+ project-dir: "."
276
+ fail-on-error-findings: "true"
277
+ ```
278
+
279
+ ---
280
+
281
+ ## System Architecture
282
+
283
+ ```text
284
+ +-------------------------------------------------------------------+
285
+ | User, CI & AI Agent Surfaces |
286
+ | CLI (`devtrace ...`) | MCP Server (`devtrace mcp`) | CI |
287
+ +-------------------------------------------------------------------+
288
+ |
289
+ v
290
+ +-------------------------------------------------------------------+
291
+ | Agentic & Self-Healing Layer |
292
+ | Multi-Step Tool Agent (`ask`) | Grounded Explainer (`explain`) |
293
+ | Isolated Sandbox Healer (`heal --verify-cmd`) |
294
+ +-------------------------------------------------------------------+
295
+ |
296
+ v
297
+ +-------------------------------------------------------------------+
298
+ | Deterministic Evidence Engine |
299
+ | Capture Orchestrator | Snapshot Comparator | Rule Engine |
300
+ | Time-Travel History | Markdown Bug Reporter |
301
+ +-------------------------------------------------------------------+
302
+ |
303
+ v
304
+ +-------------------------------------------------------------------+
305
+ | Safe Local Collectors |
306
+ | OS/Arch | Python/Node Runtimes | Declared vs Installed Deps |
307
+ +-------------------------------------------------------------------+
308
+ ```
309
+
310
+ For deeper architectural details and invariants, see [`docs/architecture.md`](docs/architecture.md).
311
+
312
+ ---
313
+
314
+ ## Privacy & Security Guarantees
315
+
316
+ - **100% Local-First:** Zero accounts, analytics, or background network telemetry.
317
+ - **No Secret Access:** Never reads `.env` files, API tokens, SSH keys, or source code contents.
318
+ - **Path Redaction:** Absolute local paths are redacted by default in snapshots and reports.
319
+ - **Non-Invasive Inspection:** Never executes project scripts or modifies packages during `capture`, `diagnose`, or `compare`.
320
+ - **Disposable Sandboxes:** `devtrace heal` tests repairs in a temporary `/tmp` virtual environment and only modifies your host environment when `--apply` is explicitly passed.
321
+
322
+ ---
323
+
324
+ ## Development & Contributing
325
+
326
+ Contributions, bug reports, and new diagnostic rules are welcome!
327
+
328
+ ```bash
329
+ # Run linter and formatter checks
330
+ ruff check .
331
+ ruff format --check .
332
+
333
+ # Run full unit and integration test suite
334
+ pytest -v
335
+ ```
336
+
337
+ ---
338
+
339
+ ## License
340
+
341
+ Released under the [MIT License](LICENSE).