@mcptoolshop/venvkit 0.2.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +274 -0
- package/README.fr.md +274 -0
- package/README.hi.md +274 -0
- package/README.it.md +274 -0
- package/README.ja.md +274 -0
- package/README.md +27 -2
- package/README.pt-BR.md +274 -0
- package/README.zh.md +274 -0
- package/dist/integration.test.d.ts +2 -0
- package/dist/integration.test.d.ts.map +1 -0
- package/dist/integration.test.js +245 -0
- package/dist/integration.test.js.map +1 -0
- package/dist/mapRender.test.js +101 -0
- package/dist/mapRender.test.js.map +1 -1
- package/dist/map_cli.test.d.ts +2 -0
- package/dist/map_cli.test.d.ts.map +1 -0
- package/dist/map_cli.test.js +320 -0
- package/dist/map_cli.test.js.map +1 -0
- package/dist/runLog.test.js +167 -0
- package/dist/runLog.test.js.map +1 -1
- package/dist/scanEnvPaths.d.ts.map +1 -1
- package/dist/scanEnvPaths.js +7 -4
- package/dist/scanEnvPaths.js.map +1 -1
- package/dist/scanEnvPaths.test.d.ts +2 -0
- package/dist/scanEnvPaths.test.d.ts.map +1 -0
- package/dist/scanEnvPaths.test.js +250 -0
- package/dist/scanEnvPaths.test.js.map +1 -0
- package/dist/taskCluster.test.js +84 -0
- package/dist/taskCluster.test.js.map +1 -1
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +18 -0
- package/dist/vitest.config.js.map +1 -1
- package/dist/windows.test.d.ts +6 -0
- package/dist/windows.test.d.ts.map +1 -0
- package/dist/windows.test.js +121 -0
- package/dist/windows.test.js.map +1 -0
- package/package.json +11 -6
package/README.es.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.md">English</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/venvkit/readme.png" alt="venvkit" width="400">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
# venvkit
|
|
10
|
+
|
|
11
|
+
> Parte de [MCP Tool Shop](https://mcptoolshop.com)
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://github.com/mcp-tool-shop-org/venvkit/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/venvkit/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
15
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT"></a>
|
|
16
|
+
<a href="https://mcp-tool-shop-org.github.io/venvkit/"><img src="https://img.shields.io/badge/Landing_Page-live-blue?style=flat-square" alt="Landing Page"></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/@mcptoolshop/venvkit"><img src="https://img.shields.io/npm/v/@mcptoolshop/venvkit?style=flat-square&color=cb3837" alt="npm version"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
**Herramienta de diagnóstico para entornos virtuales de Python para flujos de trabajo de aprendizaje automático en Windows.**
|
|
21
|
+
|
|
22
|
+
Analiza su sistema en busca de entornos de Python, diagnostica problemas de salud (SSL, DLL, incompatibilidades de ABI, fugas de rutas), realiza un seguimiento del historial de ejecución de tareas, detecta tareas inestables y genera un mapa del ecosistema.
|
|
23
|
+
|
|
24
|
+
## Guía de inicio rápido en 30 segundos
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/mcp-tool-shop-org/venvkit && cd venvkit
|
|
28
|
+
npm install && npm run build
|
|
29
|
+
node dist/map_cli.js --root C:\projects --httpsProbe
|
|
30
|
+
# Open .venvkit/venv-map.html in your browser
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Características
|
|
34
|
+
|
|
35
|
+
- **doctorLite** - Comprobación rápida de la salud para cualquier intérprete de Python
|
|
36
|
+
- Verificación SSL/TLS
|
|
37
|
+
- Fallos al cargar DLL (común con PyTorch/CUDA)
|
|
38
|
+
- Incompatibilidades de ABI (ARM vs x86)
|
|
39
|
+
- Comprobaciones de integridad de pip
|
|
40
|
+
- Detección de fugas de `user-site` y `PYTHONPATH`
|
|
41
|
+
|
|
42
|
+
- **scanEnvPaths** - Descubre todos los entornos de Python en tu sistema
|
|
43
|
+
- Encuentra entornos virtuales, entornos conda, versiones de pyenv, intérpretes base
|
|
44
|
+
- Profundidad y filtrado configurables
|
|
45
|
+
|
|
46
|
+
- **mapRender** - Visualiza tu ecosistema de Python
|
|
47
|
+
- Salida de gráfico en formato JSON para uso programático
|
|
48
|
+
- Diagramas Mermaid para documentación
|
|
49
|
+
- Agrupación de intérpretes base con análisis de radio de impacto
|
|
50
|
+
- Visualización de enrutamiento de tareas
|
|
51
|
+
|
|
52
|
+
- **runLog** - Realiza un seguimiento del historial de ejecución de tareas
|
|
53
|
+
- Formato JSONL de solo anexión
|
|
54
|
+
- Registra qué entorno ejecutó qué tarea
|
|
55
|
+
- Captura el éxito/fracaso con clasificación de errores
|
|
56
|
+
|
|
57
|
+
- **taskCluster** - Agrupa las ejecuciones de tareas por firma
|
|
58
|
+
- Detección de tareas inestables (fallos/éxitos inconsistentes)
|
|
59
|
+
- Detección de inestabilidad dependiente del entorno
|
|
60
|
+
- Identificación de puntos críticos de fallo
|
|
61
|
+
- Análisis de contagio (causas raíz compartidas)
|
|
62
|
+
|
|
63
|
+
## Instalación
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Uso de la línea de comandos
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Scan current directory and generate ecosystem map
|
|
74
|
+
node dist/map_cli.js
|
|
75
|
+
|
|
76
|
+
# Scan specific directories
|
|
77
|
+
node dist/map_cli.js --root C:\projects --root D:\ml-experiments
|
|
78
|
+
|
|
79
|
+
# Include task run history
|
|
80
|
+
node dist/map_cli.js --runlog .venvkit/runs.jsonl
|
|
81
|
+
|
|
82
|
+
# Output options
|
|
83
|
+
node dist/map_cli.js --out ./output --minScore 50 --strict --httpsProbe
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Opciones de la línea de comandos
|
|
87
|
+
|
|
88
|
+
| Parámetro | Descripción |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `--root, -r` | Directorio a analizar (se pueden especificar múltiples) |
|
|
91
|
+
| `--out` | Directorio de salida (por defecto: `.venvkit`) |
|
|
92
|
+
| `--maxDepth` | Profundidad máxima del directorio a analizar (por defecto: 5) |
|
|
93
|
+
| `--strict` | Habilita las comprobaciones de modo estricto |
|
|
94
|
+
| `--httpsProbe` | Prueba la conectividad HTTPS |
|
|
95
|
+
| `--minScore` | Filtra los entornos con una puntuación de salud inferior a esta |
|
|
96
|
+
| `--concurrency` | Comprobaciones en paralelo (por defecto: número de núcleos de la CPU) |
|
|
97
|
+
| `--runlog` | Ruta al registro de ejecución de tareas (JSONL) |
|
|
98
|
+
| `--no-tasks` | Omitir la visualización de tareas |
|
|
99
|
+
|
|
100
|
+
### Salidas
|
|
101
|
+
|
|
102
|
+
| Archivo | Descripción |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| `venv-map.json` | Datos completos del gráfico (nodos, aristas, resumen) |
|
|
105
|
+
| `venv-map.mmd` | Código fuente del diagrama Mermaid |
|
|
106
|
+
| `venv-map.html` | Visor interactivo |
|
|
107
|
+
| `reports.json` | Informes raw de doctorLite |
|
|
108
|
+
| `insights.json` | Recomendaciones prácticas |
|
|
109
|
+
|
|
110
|
+
## Uso programático
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { doctorLite, scanEnvPaths, mapRender, readRunLog } from 'venvkit';
|
|
114
|
+
|
|
115
|
+
// Check a specific Python
|
|
116
|
+
const report = await doctorLite({
|
|
117
|
+
pythonPath: 'C:\\project\\.venv\\Scripts\\python.exe',
|
|
118
|
+
requiredModules: ['torch', 'transformers'],
|
|
119
|
+
httpsProbe: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log(report.status); // 'good' | 'warn' | 'bad'
|
|
123
|
+
console.log(report.score); // 0-100
|
|
124
|
+
console.log(report.findings); // Array of issues
|
|
125
|
+
|
|
126
|
+
// Scan for all Python environments
|
|
127
|
+
const scan = await scanEnvPaths({
|
|
128
|
+
roots: ['C:\\projects'],
|
|
129
|
+
maxDepth: 5,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Run doctorLite on all found environments
|
|
133
|
+
const reports = await Promise.all(
|
|
134
|
+
scan.pythonPaths.map(p => doctorLite({ pythonPath: p }))
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Load task execution history
|
|
138
|
+
const runs = await readRunLog('.venvkit/runs.jsonl');
|
|
139
|
+
|
|
140
|
+
// Generate ecosystem visualization
|
|
141
|
+
const { graph, mermaid, insights } = mapRender(reports, runs, {
|
|
142
|
+
taskMode: 'clustered', // 'none' | 'runs' | 'clustered'
|
|
143
|
+
includeHotEdgeLabels: true,
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Esquema del registro
|
|
148
|
+
|
|
149
|
+
Realiza un seguimiento de las ejecuciones de tareas añadiendo eventos a un archivo JSONL:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { appendRunLog, newRunId } from 'venvkit';
|
|
153
|
+
|
|
154
|
+
await appendRunLog('.venvkit/runs.jsonl', {
|
|
155
|
+
version: '1.0',
|
|
156
|
+
runId: newRunId(),
|
|
157
|
+
at: new Date().toISOString(),
|
|
158
|
+
task: {
|
|
159
|
+
name: 'train',
|
|
160
|
+
command: 'python train.py --epochs 10',
|
|
161
|
+
requirements: { packages: ['torch', 'transformers'] },
|
|
162
|
+
},
|
|
163
|
+
selected: {
|
|
164
|
+
pythonPath: 'C:\\project\\.venv\\Scripts\\python.exe',
|
|
165
|
+
score: 95,
|
|
166
|
+
status: 'good',
|
|
167
|
+
},
|
|
168
|
+
outcome: {
|
|
169
|
+
ok: true,
|
|
170
|
+
exitCode: 0,
|
|
171
|
+
durationMs: 45000,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Agrupación de tareas
|
|
177
|
+
|
|
178
|
+
Cuando tienes muchas ejecuciones de tareas, venvkit las agrupa por firma:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { clusterRuns, isFlaky, getFailingEnvs } from 'venvkit';
|
|
182
|
+
|
|
183
|
+
const clusters = clusterRuns(runs);
|
|
184
|
+
|
|
185
|
+
for (const c of clusters) {
|
|
186
|
+
console.log(`${c.sig.name}: ${c.ok}/${c.runs} (${(c.successRate * 100).toFixed(0)}%)`);
|
|
187
|
+
|
|
188
|
+
if (isFlaky(c)) {
|
|
189
|
+
console.log(` WARNING: Flaky task!`);
|
|
190
|
+
const badEnvs = getFailingEnvs(c, 3);
|
|
191
|
+
console.log(` Failing most on: ${badEnvs.map(e => e.pythonPath).join(', ')}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Esquema del gráfico
|
|
197
|
+
|
|
198
|
+
La salida de `mapRender` sigue un esquema JSON estable:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
type GraphJSONv1 = {
|
|
202
|
+
version: '1.0';
|
|
203
|
+
generatedAt: string;
|
|
204
|
+
host: { os: string; arch: string; hostname: string };
|
|
205
|
+
summary: {
|
|
206
|
+
envCount: number;
|
|
207
|
+
baseCount: number;
|
|
208
|
+
taskCount: number;
|
|
209
|
+
healthy: number;
|
|
210
|
+
warning: number;
|
|
211
|
+
broken: number;
|
|
212
|
+
runsPassed: number;
|
|
213
|
+
runsFailed: number;
|
|
214
|
+
topIssues: Array<{ code: string; count: number; hint: string }>;
|
|
215
|
+
};
|
|
216
|
+
nodes: GraphNode[];
|
|
217
|
+
edges: GraphEdge[];
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Tipos de nodos
|
|
222
|
+
|
|
223
|
+
| Tipo | Descripción |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| `base` | Intérprete de Python base (ej., `C:\Python311`) |
|
|
226
|
+
| `venv` | Entorno virtual |
|
|
227
|
+
| `task` | Firma de tarea (ejecuciones agrupadas) |
|
|
228
|
+
|
|
229
|
+
### Tipos de aristas
|
|
230
|
+
|
|
231
|
+
| Tipo | Descripción |
|
|
232
|
+
|------|-------------|
|
|
233
|
+
| `USES_BASE` | Relación venv → base |
|
|
234
|
+
| `ROUTES_TASK_TO` | Enrutamiento de tarea → entorno |
|
|
235
|
+
| `FAILED_RUN` | Fallo de tarea → entorno (con líneas discontinuas en Mermaid) |
|
|
236
|
+
|
|
237
|
+
## Códigos de error
|
|
238
|
+
|
|
239
|
+
| Código | Severidad | Descripción |
|
|
240
|
+
|------|----------|-------------|
|
|
241
|
+
| `SSL_BROKEN` | bad | El módulo SSL no se puede importar |
|
|
242
|
+
| `CERT_STORE_FAIL` | warn | La verificación del certificado HTTPS falla |
|
|
243
|
+
| `DLL_LOAD_FAIL` | bad | La carga de la DLL de la extensión nativa falla |
|
|
244
|
+
| `ABI_MISMATCH` | bad | Incompatibilidad binaria (ARM/x86) |
|
|
245
|
+
| `PIP_MISSING` | warn | pip no está disponible |
|
|
246
|
+
| `PIP_CHECK_FAIL` | warn | Se detectan conflictos de dependencias |
|
|
247
|
+
| `USER_SITE_LEAK` | warn | `user-site-packages` habilitado en el entorno virtual |
|
|
248
|
+
| `PYTHONPATH_INJECTED` | warn | La variable de entorno `PYTHONPATH` está establecida |
|
|
249
|
+
| `ARCH_MISMATCH` | bad | Python de 32 bits cuando se requiere 64 bits |
|
|
250
|
+
| `PYVENV_CFG_INVALID` | warn | `pyvenv.cfg` corrupto o faltante |
|
|
251
|
+
|
|
252
|
+
## Desarrollo
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run typecheck # Type check
|
|
257
|
+
npm run test # Run tests
|
|
258
|
+
npm run build # Build to dist/
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Seguridad y ámbito de datos
|
|
262
|
+
|
|
263
|
+
- **Escaneo de solo lectura:** Los archivos ejecutables de Python y pyvenv.cfg se leen, pero nunca se modifican.
|
|
264
|
+
- **Subprocesos:** Inicia `python` con argumentos controlados; no se ejecuta ningún comando a través de la shell.
|
|
265
|
+
- **Red:** La opción `--httpsProbe` permite probar los certificados SSL; no se realizan otras solicitudes de salida.
|
|
266
|
+
- **No se recopilan ni se envían datos de telemetría:** Consulte el archivo [SECURITY.md](SECURITY.md) para obtener la política completa.
|
|
267
|
+
|
|
268
|
+
## Licencia
|
|
269
|
+
|
|
270
|
+
MIT
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
Creado por [MCP Tool Shop](https://mcp-tool-shop.github.io/)
|
package/README.fr.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.md">English</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/venvkit/readme.png" alt="venvkit" width="400">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
# venvkit
|
|
10
|
+
|
|
11
|
+
> Fait partie de [MCP Tool Shop](https://mcptoolshop.com)
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://github.com/mcp-tool-shop-org/venvkit/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/venvkit/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
15
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT"></a>
|
|
16
|
+
<a href="https://mcp-tool-shop-org.github.io/venvkit/"><img src="https://img.shields.io/badge/Landing_Page-live-blue?style=flat-square" alt="Landing Page"></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/@mcptoolshop/venvkit"><img src="https://img.shields.io/npm/v/@mcptoolshop/venvkit?style=flat-square&color=cb3837" alt="npm version"></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
**Outil de diagnostic pour les environnements virtuels Python, conçu pour les flux de travail de Machine Learning sous Windows.**
|
|
21
|
+
|
|
22
|
+
Analyse votre système pour détecter les environnements Python, diagnostique les problèmes (SSL, DLL, incompatibilités ABI, fuites de chemins), suit l'historique d'exécution des tâches, détecte les tâches instables et génère une carte de l'écosystème.
|
|
23
|
+
|
|
24
|
+
## Démarrage rapide en 30 secondes
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/mcp-tool-shop-org/venvkit && cd venvkit
|
|
28
|
+
npm install && npm run build
|
|
29
|
+
node dist/map_cli.js --root C:\projects --httpsProbe
|
|
30
|
+
# Open .venvkit/venv-map.html in your browser
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Fonctionnalités
|
|
34
|
+
|
|
35
|
+
- **doctorLite** - Vérification rapide de l'état de santé de n'importe quel interpréteur Python
|
|
36
|
+
- Vérification SSL/TLS
|
|
37
|
+
- Échecs de chargement des DLL (courant avec PyTorch/CUDA)
|
|
38
|
+
- Incompatibilités ABI (ARM vs x86)
|
|
39
|
+
- Vérifications de l'intégrité de pip
|
|
40
|
+
- Détection de fuites des répertoires utilisateur et de la variable PYTHONPATH
|
|
41
|
+
|
|
42
|
+
- **scanEnvPaths** - Découvre tous les environnements Python de votre système
|
|
43
|
+
- Trouve les environnements venv, conda, les versions pyenv et les interpréteurs de base.
|
|
44
|
+
- Profondeur et filtrage configurables.
|
|
45
|
+
|
|
46
|
+
- **mapRender** - Visualise votre écosystème Python
|
|
47
|
+
- Sortie JSON pour une utilisation programmatique
|
|
48
|
+
- Diagrammes Mermaid pour la documentation
|
|
49
|
+
- Groupement des interpréteurs de base avec analyse du rayon d'impact
|
|
50
|
+
- Visualisation du routage des tâches
|
|
51
|
+
|
|
52
|
+
- **runLog** - Suit l'historique d'exécution des tâches
|
|
53
|
+
- Format JSONL uniquement en ajout
|
|
54
|
+
- Enregistre quel environnement a exécuté quelle tâche
|
|
55
|
+
- Enregistre les succès/échecs avec la classification des erreurs
|
|
56
|
+
|
|
57
|
+
- **taskCluster** - Regroupe les exécutions de tâches par signature
|
|
58
|
+
- Détection des tâches instables (échec/succès incohérents)
|
|
59
|
+
- Détection des instabilités dépendantes de l'environnement
|
|
60
|
+
- Identification des points chauds d'échec
|
|
61
|
+
- Analyse de la contagion (causes profondes partagées)
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Utilisation de la ligne de commande
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Scan current directory and generate ecosystem map
|
|
74
|
+
node dist/map_cli.js
|
|
75
|
+
|
|
76
|
+
# Scan specific directories
|
|
77
|
+
node dist/map_cli.js --root C:\projects --root D:\ml-experiments
|
|
78
|
+
|
|
79
|
+
# Include task run history
|
|
80
|
+
node dist/map_cli.js --runlog .venvkit/runs.jsonl
|
|
81
|
+
|
|
82
|
+
# Output options
|
|
83
|
+
node dist/map_cli.js --out ./output --minScore 50 --strict --httpsProbe
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Options de la ligne de commande
|
|
87
|
+
|
|
88
|
+
| Option | Description |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `--root, -r` | Répertoire à analyser (peut spécifier plusieurs) |
|
|
91
|
+
| `--out` | Répertoire de sortie (par défaut : `.venvkit`) |
|
|
92
|
+
| `--maxDepth` | Profondeur maximale du répertoire à analyser (par défaut : 5) |
|
|
93
|
+
| `--strict` | Activer les vérifications strictes |
|
|
94
|
+
| `--httpsProbe` | Tester la connectivité HTTPS |
|
|
95
|
+
| `--minScore` | Filtrer les environnements en fonction de leur score de santé |
|
|
96
|
+
| `--concurrency` | Vérifications parallèles (par défaut : nombre de cœurs CPU) |
|
|
97
|
+
| `--runlog` | Chemin vers le fichier journal des exécutions de tâches (JSONL) |
|
|
98
|
+
| `--no-tasks` | Ignorer la visualisation des tâches |
|
|
99
|
+
|
|
100
|
+
### Sorties
|
|
101
|
+
|
|
102
|
+
| Fichier | Description |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| `venv-map.json` | Données complètes du graphe (nœuds, arêtes, résumé) |
|
|
105
|
+
| `venv-map.mmd` | Source du diagramme Mermaid |
|
|
106
|
+
| `venv-map.html` | Visualiseur interactif |
|
|
107
|
+
| `reports.json` | Rapports doctorLite bruts |
|
|
108
|
+
| `insights.json` | Recommandations exploitables |
|
|
109
|
+
|
|
110
|
+
## Utilisation programmatique
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { doctorLite, scanEnvPaths, mapRender, readRunLog } from 'venvkit';
|
|
114
|
+
|
|
115
|
+
// Check a specific Python
|
|
116
|
+
const report = await doctorLite({
|
|
117
|
+
pythonPath: 'C:\\project\\.venv\\Scripts\\python.exe',
|
|
118
|
+
requiredModules: ['torch', 'transformers'],
|
|
119
|
+
httpsProbe: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log(report.status); // 'good' | 'warn' | 'bad'
|
|
123
|
+
console.log(report.score); // 0-100
|
|
124
|
+
console.log(report.findings); // Array of issues
|
|
125
|
+
|
|
126
|
+
// Scan for all Python environments
|
|
127
|
+
const scan = await scanEnvPaths({
|
|
128
|
+
roots: ['C:\\projects'],
|
|
129
|
+
maxDepth: 5,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Run doctorLite on all found environments
|
|
133
|
+
const reports = await Promise.all(
|
|
134
|
+
scan.pythonPaths.map(p => doctorLite({ pythonPath: p }))
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Load task execution history
|
|
138
|
+
const runs = await readRunLog('.venvkit/runs.jsonl');
|
|
139
|
+
|
|
140
|
+
// Generate ecosystem visualization
|
|
141
|
+
const { graph, mermaid, insights } = mapRender(reports, runs, {
|
|
142
|
+
taskMode: 'clustered', // 'none' | 'runs' | 'clustered'
|
|
143
|
+
includeHotEdgeLabels: true,
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Schéma du journal des exécutions
|
|
148
|
+
|
|
149
|
+
Suivez les exécutions de tâches en ajoutant des événements à un fichier JSONL :
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { appendRunLog, newRunId } from 'venvkit';
|
|
153
|
+
|
|
154
|
+
await appendRunLog('.venvkit/runs.jsonl', {
|
|
155
|
+
version: '1.0',
|
|
156
|
+
runId: newRunId(),
|
|
157
|
+
at: new Date().toISOString(),
|
|
158
|
+
task: {
|
|
159
|
+
name: 'train',
|
|
160
|
+
command: 'python train.py --epochs 10',
|
|
161
|
+
requirements: { packages: ['torch', 'transformers'] },
|
|
162
|
+
},
|
|
163
|
+
selected: {
|
|
164
|
+
pythonPath: 'C:\\project\\.venv\\Scripts\\python.exe',
|
|
165
|
+
score: 95,
|
|
166
|
+
status: 'good',
|
|
167
|
+
},
|
|
168
|
+
outcome: {
|
|
169
|
+
ok: true,
|
|
170
|
+
exitCode: 0,
|
|
171
|
+
durationMs: 45000,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Regroupement des tâches
|
|
177
|
+
|
|
178
|
+
Lorsque vous avez de nombreuses exécutions de tâches, venvkit les regroupe par signature :
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { clusterRuns, isFlaky, getFailingEnvs } from 'venvkit';
|
|
182
|
+
|
|
183
|
+
const clusters = clusterRuns(runs);
|
|
184
|
+
|
|
185
|
+
for (const c of clusters) {
|
|
186
|
+
console.log(`${c.sig.name}: ${c.ok}/${c.runs} (${(c.successRate * 100).toFixed(0)}%)`);
|
|
187
|
+
|
|
188
|
+
if (isFlaky(c)) {
|
|
189
|
+
console.log(` WARNING: Flaky task!`);
|
|
190
|
+
const badEnvs = getFailingEnvs(c, 3);
|
|
191
|
+
console.log(` Failing most on: ${badEnvs.map(e => e.pythonPath).join(', ')}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Schéma du graphe
|
|
197
|
+
|
|
198
|
+
La sortie de `mapRender` suit un schéma JSON stable :
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
type GraphJSONv1 = {
|
|
202
|
+
version: '1.0';
|
|
203
|
+
generatedAt: string;
|
|
204
|
+
host: { os: string; arch: string; hostname: string };
|
|
205
|
+
summary: {
|
|
206
|
+
envCount: number;
|
|
207
|
+
baseCount: number;
|
|
208
|
+
taskCount: number;
|
|
209
|
+
healthy: number;
|
|
210
|
+
warning: number;
|
|
211
|
+
broken: number;
|
|
212
|
+
runsPassed: number;
|
|
213
|
+
runsFailed: number;
|
|
214
|
+
topIssues: Array<{ code: string; count: number; hint: string }>;
|
|
215
|
+
};
|
|
216
|
+
nodes: GraphNode[];
|
|
217
|
+
edges: GraphEdge[];
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Types de nœuds
|
|
222
|
+
|
|
223
|
+
| Type | Description |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| `base` | Interpréteur Python de base (par exemple, `C:\Python311`) |
|
|
226
|
+
| `venv` | Environnement virtuel |
|
|
227
|
+
| `task` | Signature de tâche (exécutions regroupées) |
|
|
228
|
+
|
|
229
|
+
### Types d'arêtes
|
|
230
|
+
|
|
231
|
+
| Type | Description |
|
|
232
|
+
|------|-------------|
|
|
233
|
+
| `USES_BASE` | Relation venv → base |
|
|
234
|
+
| `ROUTES_TASK_TO` | Routage tâche → environnement |
|
|
235
|
+
| `FAILED_RUN` | Échec de tâche → environnement (pointillé dans Mermaid) |
|
|
236
|
+
|
|
237
|
+
## Codes d'erreur
|
|
238
|
+
|
|
239
|
+
| Code | Gravité | Description |
|
|
240
|
+
|------|----------|-------------|
|
|
241
|
+
| `SSL_BROKEN` | bad | L'importation du module SSL échoue |
|
|
242
|
+
| `CERT_STORE_FAIL` | warn | La vérification du certificat HTTPS échoue |
|
|
243
|
+
| `DLL_LOAD_FAIL` | bad | Le chargement de l'extension DLL native échoue |
|
|
244
|
+
| `ABI_MISMATCH` | bad | Incompatibilité binaire (ARM/x86) |
|
|
245
|
+
| `PIP_MISSING` | warn | pip n'est pas disponible |
|
|
246
|
+
| `PIP_CHECK_FAIL` | warn | Conflits de dépendances détectés |
|
|
247
|
+
| `USER_SITE_LEAK` | warn | Les packages utilisateur sont activés dans l'environnement virtuel |
|
|
248
|
+
| `PYTHONPATH_INJECTED` | warn | La variable d'environnement PYTHONPATH est définie |
|
|
249
|
+
| `ARCH_MISMATCH` | bad | Python 32 bits alors que 64 bits est requis |
|
|
250
|
+
| `PYVENV_CFG_INVALID` | warn | pyvenv.cfg corrompu ou manquant |
|
|
251
|
+
|
|
252
|
+
## Développement
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run typecheck # Type check
|
|
257
|
+
npm run test # Run tests
|
|
258
|
+
npm run build # Build to dist/
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Sécurité et portée des données
|
|
262
|
+
|
|
263
|
+
- **Analyse en lecture seule :** Les exécutables Python et le fichier pyvenv.cfg sont lus, mais jamais modifiés.
|
|
264
|
+
- **Sous-processus :** Lance `python` avec des arguments contrôlés — aucune exécution via un shell.
|
|
265
|
+
- **Réseau :** L'option `--httpsProbe` (facultative) teste les certificats SSL — aucune autre requête sortante n'est effectuée.
|
|
266
|
+
- **Aucune télémétrie** n'est collectée ou envoyée — consultez le fichier [SECURITY.md](SECURITY.md) pour connaître la politique complète.
|
|
267
|
+
|
|
268
|
+
## Licence
|
|
269
|
+
|
|
270
|
+
MIT
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
Créé par [MCP Tool Shop](https://mcp-tool-shop.github.io/)
|