devtrace-cli 1.0.0__py3-none-any.whl
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.
- devtrace/__init__.py +4 -0
- devtrace/__main__.py +8 -0
- devtrace/cli.py +631 -0
- devtrace/collectors/__init__.py +0 -0
- devtrace/collectors/node_deps.py +110 -0
- devtrace/collectors/node_runtime.py +37 -0
- devtrace/collectors/python_deps.py +136 -0
- devtrace/collectors/python_runtime.py +18 -0
- devtrace/collectors/system.py +46 -0
- devtrace/core/__init__.py +0 -0
- devtrace/core/agent.py +297 -0
- devtrace/core/ai_explainer.py +96 -0
- devtrace/core/collector.py +62 -0
- devtrace/core/comparator.py +199 -0
- devtrace/core/diagnostics.py +216 -0
- devtrace/core/healer.py +218 -0
- devtrace/core/models.py +86 -0
- devtrace/core/reporter.py +85 -0
- devtrace/core/serializer.py +13 -0
- devtrace/mcp_server.py +175 -0
- devtrace/project/__init__.py +0 -0
- devtrace/project/detector.py +44 -0
- devtrace/storage/__init__.py +0 -0
- devtrace/storage/history_store.py +108 -0
- devtrace/storage/json_store.py +51 -0
- devtrace_cli-1.0.0.dist-info/METADATA +341 -0
- devtrace_cli-1.0.0.dist-info/RECORD +30 -0
- devtrace_cli-1.0.0.dist-info/WHEEL +4 -0
- devtrace_cli-1.0.0.dist-info/entry_points.txt +2 -0
- devtrace_cli-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Chronological snapshot history management in .devtrace/history/."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
from devtrace.core.models import EnvironmentSnapshot
|
|
12
|
+
from devtrace.storage.json_store import write_snapshot_atomic
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class HistoryEntry:
|
|
17
|
+
"""Metadata summary for a stored historical snapshot."""
|
|
18
|
+
|
|
19
|
+
file_path: Path
|
|
20
|
+
snapshot_id: str
|
|
21
|
+
captured_at: str
|
|
22
|
+
tag: str | None
|
|
23
|
+
python_version: str | None
|
|
24
|
+
node_version: str | None
|
|
25
|
+
drift_count: int
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_history_dir(project_dir: Path) -> Path:
|
|
29
|
+
"""Return the .devtrace/history directory path for a project."""
|
|
30
|
+
return (project_dir.resolve() / ".devtrace" / "history").resolve()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _safe_filename_part(value: str) -> str:
|
|
34
|
+
return re.sub(r"[^A-Za-z0-9_.-]+", "-", value).strip("-") or "snap"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def save_to_history(project_dir: Path, snapshot: EnvironmentSnapshot) -> Path:
|
|
38
|
+
"""Persist an immutable copy of a snapshot into .devtrace/history/."""
|
|
39
|
+
history_dir = get_history_dir(project_dir)
|
|
40
|
+
ts_part = snapshot.captured_at.replace(":", "").replace("-", "")
|
|
41
|
+
short_id = snapshot.snapshot_id.split("-")[0]
|
|
42
|
+
tag_suffix = f"-{_safe_filename_part(snapshot.tag)}" if snapshot.tag else ""
|
|
43
|
+
filename = f"{ts_part}-{short_id}{tag_suffix}.json"
|
|
44
|
+
target_path = history_dir / filename
|
|
45
|
+
return write_snapshot_atomic(snapshot, target_path, force=True)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def list_history(project_dir: Path) -> list[HistoryEntry]:
|
|
49
|
+
"""Return all valid snapshots in .devtrace/history/ sorted oldest to newest."""
|
|
50
|
+
history_dir = get_history_dir(project_dir)
|
|
51
|
+
if not history_dir.is_dir():
|
|
52
|
+
return []
|
|
53
|
+
|
|
54
|
+
indexed_entries: list[tuple[int, HistoryEntry]] = []
|
|
55
|
+
for item in history_dir.glob("*.json"):
|
|
56
|
+
try:
|
|
57
|
+
mtime_ns = item.stat().st_mtime_ns
|
|
58
|
+
data: dict[str, Any] = json.loads(item.read_text(encoding="utf-8"))
|
|
59
|
+
except (OSError, json.JSONDecodeError):
|
|
60
|
+
continue
|
|
61
|
+
if not isinstance(data, dict) or "snapshot_id" not in data:
|
|
62
|
+
continue
|
|
63
|
+
|
|
64
|
+
rt = data.get("runtimes", {}) or {}
|
|
65
|
+
py_ver = (rt.get("python") or {}).get("version")
|
|
66
|
+
node_ver = (rt.get("node") or {}).get("version")
|
|
67
|
+
|
|
68
|
+
deps = data.get("dependencies", {}) or {}
|
|
69
|
+
py_d = deps.get("python") or {}
|
|
70
|
+
node_d = deps.get("node") or {}
|
|
71
|
+
drift = (
|
|
72
|
+
len(py_d.get("missing_from_env") or [])
|
|
73
|
+
+ len(py_d.get("undeclared_in_manifest") or [])
|
|
74
|
+
+ len(node_d.get("missing_from_env") or [])
|
|
75
|
+
+ len(node_d.get("undeclared_in_manifest") or [])
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
entry = HistoryEntry(
|
|
79
|
+
file_path=item,
|
|
80
|
+
snapshot_id=str(data.get("snapshot_id", "unknown")),
|
|
81
|
+
captured_at=str(data.get("captured_at", "unknown")),
|
|
82
|
+
tag=data.get("tag"),
|
|
83
|
+
python_version=py_ver,
|
|
84
|
+
node_version=node_ver,
|
|
85
|
+
drift_count=drift,
|
|
86
|
+
)
|
|
87
|
+
indexed_entries.append((mtime_ns, entry))
|
|
88
|
+
|
|
89
|
+
indexed_entries.sort(key=lambda pair: (pair[1].captured_at, pair[0]))
|
|
90
|
+
return [pair[1] for pair in indexed_entries]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def find_baseline_snapshot(
|
|
94
|
+
project_dir: Path,
|
|
95
|
+
tag: str | None = None,
|
|
96
|
+
) -> HistoryEntry:
|
|
97
|
+
"""Find the most recent historical snapshot, optionally filtered by tag."""
|
|
98
|
+
entries = list_history(project_dir)
|
|
99
|
+
if not entries:
|
|
100
|
+
raise FileNotFoundError("No historical snapshots found. Run `devtrace capture` first.")
|
|
101
|
+
|
|
102
|
+
if tag is not None:
|
|
103
|
+
matched = [e for e in entries if e.tag == tag]
|
|
104
|
+
if not matched:
|
|
105
|
+
raise FileNotFoundError(f"No historical snapshot found with tag '{tag}'.")
|
|
106
|
+
return matched[-1]
|
|
107
|
+
|
|
108
|
+
return entries[-1]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Atomic JSON snapshot storage utilities."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import tempfile
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from devtrace.core.models import EnvironmentSnapshot
|
|
10
|
+
from devtrace.core.serializer import serialize_snapshot
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def resolve_output_path(project_dir: Path, output_arg: str | None) -> Path:
|
|
14
|
+
"""Resolve the target output path for a snapshot file."""
|
|
15
|
+
if output_arg is not None:
|
|
16
|
+
return Path(output_arg).expanduser().resolve()
|
|
17
|
+
return (project_dir.resolve() / ".devtrace" / "snapshot.json").resolve()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def write_snapshot_atomic(
|
|
21
|
+
snapshot: EnvironmentSnapshot,
|
|
22
|
+
output_path: Path,
|
|
23
|
+
force: bool = False,
|
|
24
|
+
) -> Path:
|
|
25
|
+
"""Write snapshot JSON atomically, refusing to overwrite unless forced."""
|
|
26
|
+
if output_path.exists() and not force:
|
|
27
|
+
raise FileExistsError(
|
|
28
|
+
f"Snapshot already exists at {output_path}. Use --force to overwrite."
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
32
|
+
serialized = serialize_snapshot(snapshot)
|
|
33
|
+
|
|
34
|
+
fd, tmp_name = tempfile.mkstemp(
|
|
35
|
+
prefix=".devtrace-tmp-",
|
|
36
|
+
suffix=".json",
|
|
37
|
+
dir=str(output_path.parent),
|
|
38
|
+
)
|
|
39
|
+
tmp_path = Path(tmp_name)
|
|
40
|
+
try:
|
|
41
|
+
with os.fdopen(fd, "w", encoding="utf-8") as tmp_file:
|
|
42
|
+
tmp_file.write(serialized)
|
|
43
|
+
tmp_file.flush()
|
|
44
|
+
os.fsync(tmp_file.fileno())
|
|
45
|
+
os.replace(tmp_path, output_path)
|
|
46
|
+
except Exception:
|
|
47
|
+
if tmp_path.exists():
|
|
48
|
+
tmp_path.unlink(missing_ok=True)
|
|
49
|
+
raise
|
|
50
|
+
|
|
51
|
+
return output_path
|
|
@@ -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
|
+
[](https://github.com/SUBHAM646/devtrace/actions/workflows/tests.yaml)
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](#ai-coding-agent-integration-mcp-server)
|
|
35
|
+
[](#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).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
devtrace/__init__.py,sha256=GTek04ujnQy8UmaK6DU7O_o0nDMJQAtCA3GouoGT0Qo,117
|
|
2
|
+
devtrace/__main__.py,sha256=1JDijIsU-KKkEAo4NOfCyaccJ9zIiRzzezPUApI20xY,140
|
|
3
|
+
devtrace/cli.py,sha256=udVzOT-YZYMthfHidkDExucUwbzikPKW-4R2oy5vLNk,21650
|
|
4
|
+
devtrace/mcp_server.py,sha256=yYx7Gj906AIprKIvOiEfnGhKcECupVXv2uwKt9WgQWo,5722
|
|
5
|
+
devtrace/collectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
devtrace/collectors/node_deps.py,sha256=yEf3dMO5I7UtK51JVE3B8YiLANTPA8gQ0sDj5PKUaYU,3663
|
|
7
|
+
devtrace/collectors/node_runtime.py,sha256=BAnekWEEC2RknHXW_pKSROMR5VufKWfMo2sX_kj5kbQ,1238
|
|
8
|
+
devtrace/collectors/python_deps.py,sha256=Ksjmb-Jd0LSmb7RwDF5wSUG_lfwRNOTM6lfa0tleLso,4780
|
|
9
|
+
devtrace/collectors/python_runtime.py,sha256=ECiEJSL03-e2lT874OW2PemLmg64NRuRtAfVAyIU03k,531
|
|
10
|
+
devtrace/collectors/system.py,sha256=KWwg2GEJqPQHLDCc7CqIiEnMw8CtrnG_cCj-KF-Iwe4,1324
|
|
11
|
+
devtrace/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
devtrace/core/agent.py,sha256=cM9-0DUxIWZV6Eqi1hl8QUrv4kyQyZSZEm9t_Hfn1fc,10432
|
|
13
|
+
devtrace/core/ai_explainer.py,sha256=VbVm644bD90UUHs_CW404rkDNl9uUOiDIoTFMxodaY4,3392
|
|
14
|
+
devtrace/core/collector.py,sha256=bXrc7ktIM6Z2g1xAx7BUK5aoFTwHjpZ1UIi8OVDa3VU,2039
|
|
15
|
+
devtrace/core/comparator.py,sha256=mlXTnXYYwOvDn-Idug1ab8cbx2z2Y2L4Ns-6bVVmQzo,7407
|
|
16
|
+
devtrace/core/diagnostics.py,sha256=AuaYzLGGZez-ToMC2Wbz7vdso8J69vPVvMyBrpbQtoU,8876
|
|
17
|
+
devtrace/core/healer.py,sha256=mlwYSGoBXdO2EwknIiNs8967n5jQdhvjLnnId3-Hswk,7510
|
|
18
|
+
devtrace/core/models.py,sha256=D_y-nA5hp9_suaDz5WUmjp4awl-6EY_usPaPz1qLSwI,2526
|
|
19
|
+
devtrace/core/reporter.py,sha256=rvkpeT-loQZrYsNDo_gSJAplPhvl4q_GElHpvOwup3g,3407
|
|
20
|
+
devtrace/core/serializer.py,sha256=XLNIEBCg2xaR4-synBH6_C_3zf4JUIbmAJ7JJN5bIYE,437
|
|
21
|
+
devtrace/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
devtrace/project/detector.py,sha256=Tq-rVASLM_Yrvnp4TSzX3chqaAzy2l6DMtIzLNDYK0k,1349
|
|
23
|
+
devtrace/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
devtrace/storage/history_store.py,sha256=RgLneXrZazaUSMO2eysrioqWXPqbDr71kc18Jl2fTr8,3751
|
|
25
|
+
devtrace/storage/json_store.py,sha256=A2vLtcHdWWZseftecYB6vBBX0VgT13CvZCupQkh3TEo,1546
|
|
26
|
+
devtrace_cli-1.0.0.dist-info/METADATA,sha256=vU1FDKO9VJl_IcePcTSrPXEPzHsbTaLY3WKNBkqX9vg,13613
|
|
27
|
+
devtrace_cli-1.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
28
|
+
devtrace_cli-1.0.0.dist-info/entry_points.txt,sha256=3-2GL1f1A00YbLnYSPo5brhdEOPIXvVZi4wy_uDx-Fw,47
|
|
29
|
+
devtrace_cli-1.0.0.dist-info/licenses/LICENSE,sha256=NB7sNIik9L_VqRn_Z6Qt-FT800WUylEx3pvcEgAlrfU,1070
|
|
30
|
+
devtrace_cli-1.0.0.dist-info/RECORD,,
|
|
@@ -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.
|