@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.ja.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.md">English</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</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
|
+
> [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
|
+
**Windows環境における機械学習ワークフロー向けのPython仮想環境診断ツールキット。**
|
|
21
|
+
|
|
22
|
+
システム上のPython環境をスキャンし、問題箇所(SSL、DLL、ABIの不整合、パスの漏洩など)を診断し、タスクの実行履歴を追跡し、不安定なタスクを検出し、環境マップを生成します。
|
|
23
|
+
|
|
24
|
+
## 30秒で始める
|
|
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
|
+
## 機能
|
|
34
|
+
|
|
35
|
+
- **doctorLite** - 任意のPythonインタプリタの高速ヘルスチェック
|
|
36
|
+
- SSL/TLSの検証
|
|
37
|
+
- DLLのロード失敗(PyTorch/CUDAでよく発生)
|
|
38
|
+
- ABIの不整合(ARM vs x86)
|
|
39
|
+
- pipの健全性チェック
|
|
40
|
+
- ユーザーサイトとPYTHONPATHの漏洩検出
|
|
41
|
+
|
|
42
|
+
- **scanEnvPaths** - システム上のすべてのPython環境を検出
|
|
43
|
+
- venv、conda環境、pyenvのバージョン、ベースインタプリタを検出
|
|
44
|
+
- 設定可能な深度とフィルタリング
|
|
45
|
+
|
|
46
|
+
- **mapRender** - Python環境を可視化
|
|
47
|
+
- プログラムでの利用を目的としたグラフのJSON出力
|
|
48
|
+
- ドキュメント用のMermaid図
|
|
49
|
+
- ベースインタプリタのグループ化と影響範囲分析
|
|
50
|
+
- タスクのルーティング可視化
|
|
51
|
+
|
|
52
|
+
- **runLog** - タスクの実行履歴を追跡
|
|
53
|
+
- 追記専用のJSONL形式
|
|
54
|
+
- どの環境でどのタスクが実行されたかを記録
|
|
55
|
+
- 成功/失敗を記録し、エラーを分類
|
|
56
|
+
|
|
57
|
+
- **taskCluster** - シグネチャごとにタスクの実行をまとめる
|
|
58
|
+
- 不安定なタスクの検出(一貫性のない成功/失敗)
|
|
59
|
+
- 環境に依存する不安定なタスクの検出
|
|
60
|
+
- 失敗のホットスポットの特定
|
|
61
|
+
- 感染分析(共通の根本原因)
|
|
62
|
+
|
|
63
|
+
## インストール
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## CLIの使用方法
|
|
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
|
+
### CLIオプション
|
|
87
|
+
|
|
88
|
+
| フラグ | 説明 |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `--root, -r` | スキャンするディレクトリ(複数指定可能) |
|
|
91
|
+
| `--out` | 出力ディレクトリ(デフォルト:`.venvkit`) |
|
|
92
|
+
| `--maxDepth` | スキャンする最大ディレクトリ深度(デフォルト:5) |
|
|
93
|
+
| `--strict` | 厳格モードのチェックを有効にする |
|
|
94
|
+
| `--httpsProbe` | HTTPS接続をテストする |
|
|
95
|
+
| `--minScore` | このヘルススコア以下の環境をフィルタリングする |
|
|
96
|
+
| `--concurrency` | 並列チェック(デフォルト:CPUコア数) |
|
|
97
|
+
| `--runlog` | タスク実行ログ(JSONL)へのパス |
|
|
98
|
+
| `--no-tasks` | タスクの可視化をスキップする |
|
|
99
|
+
|
|
100
|
+
### 出力ファイル
|
|
101
|
+
|
|
102
|
+
| ファイル | 説明 |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| `venv-map.json` | 完全なグラフデータ(ノード、エッジ、概要) |
|
|
105
|
+
| `venv-map.mmd` | Mermaid図のソース |
|
|
106
|
+
| `venv-map.html` | インタラクティブビューア |
|
|
107
|
+
| `reports.json` | 生のdoctorLiteレポート |
|
|
108
|
+
| `insights.json` | 実行可能な推奨事項 |
|
|
109
|
+
|
|
110
|
+
## プログラムによる利用方法
|
|
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
|
+
## 実行ログのスキーマ
|
|
148
|
+
|
|
149
|
+
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
|
+
## タスクのクラスタリング
|
|
177
|
+
|
|
178
|
+
タスクの実行が多い場合、venvkitはシグネチャごとにそれらをクラスタリングします。
|
|
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
|
+
## グラフのスキーマ
|
|
197
|
+
|
|
198
|
+
`mapRender`の出力は、安定したJSONスキーマに従います。
|
|
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
|
+
### ノードの種類
|
|
222
|
+
|
|
223
|
+
| 種類 | 説明 |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| `base` | ベースのPythonインタプリタ(例:`C:\Python311`) |
|
|
226
|
+
| `venv` | 仮想環境 |
|
|
227
|
+
| `task` | タスクのシグネチャ(クラスタリングされた実行) |
|
|
228
|
+
|
|
229
|
+
### エッジの種類
|
|
230
|
+
|
|
231
|
+
| 種類 | 説明 |
|
|
232
|
+
|------|-------------|
|
|
233
|
+
| `USES_BASE` | venvとベースの関係 |
|
|
234
|
+
| `ROUTES_TASK_TO` | タスクと環境のルーティング |
|
|
235
|
+
| `FAILED_RUN` | タスクと環境の失敗(Mermaidでは破線で表示) |
|
|
236
|
+
|
|
237
|
+
## エラーコード
|
|
238
|
+
|
|
239
|
+
| コード | 深刻度 | 説明 |
|
|
240
|
+
|------|----------|-------------|
|
|
241
|
+
| `SSL_BROKEN` | bad | SSLモジュールのインポートに失敗 |
|
|
242
|
+
| `CERT_STORE_FAIL` | warn | HTTPS証明書の検証に失敗 |
|
|
243
|
+
| `DLL_LOAD_FAIL` | bad | ネイティブ拡張DLLのロードに失敗 |
|
|
244
|
+
| `ABI_MISMATCH` | bad | バイナリの互換性がない(ARM/x86) |
|
|
245
|
+
| `PIP_MISSING` | warn | pipが利用できない |
|
|
246
|
+
| `PIP_CHECK_FAIL` | warn | 依存関係の競合が検出された |
|
|
247
|
+
| `USER_SITE_LEAK` | warn | venvでユーザーサイトパッケージが有効になっている |
|
|
248
|
+
| `PYTHONPATH_INJECTED` | warn | PYTHONPATH環境変数が設定されている |
|
|
249
|
+
| `ARCH_MISMATCH` | bad | 64ビットが必要な場合に32ビットのPythonが使用されている |
|
|
250
|
+
| `PYVENV_CFG_INVALID` | warn | 破損または紛失したpyvenv.cfg |
|
|
251
|
+
|
|
252
|
+
## 開発
|
|
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
|
+
## セキュリティとデータ範囲
|
|
262
|
+
|
|
263
|
+
- **読み取り専用スキャン:** Pythonの実行ファイルとpyvenv.cfgファイルは読み込まれますが、変更されることはありません。
|
|
264
|
+
- **サブプロセス:** `python`を特定の引数で起動します。シェルによる実行は行われません。
|
|
265
|
+
- **ネットワーク:** オプションの`--httpsProbe`を使用すると、SSL証明書をテストできます。それ以外の外部へのリクエストは行われません。
|
|
266
|
+
- **テレメトリデータは収集も送信もされません。** 詳細については、[SECURITY.md](SECURITY.md) を参照してください。
|
|
267
|
+
|
|
268
|
+
## ライセンス
|
|
269
|
+
|
|
270
|
+
MIT
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
[MCP Tool Shop](https://mcp-tool-shop.github.io/) によって作成されました。
|
package/README.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
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.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
|
+
|
|
1
9
|
# venvkit
|
|
2
10
|
|
|
3
|
-
[
|
|
4
|
-
|
|
11
|
+
> Part of [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>
|
|
5
19
|
|
|
6
20
|
**Python virtual environment diagnostic toolkit for Windows ML workflows.**
|
|
7
21
|
|
|
@@ -244,6 +258,17 @@ npm run test # Run tests
|
|
|
244
258
|
npm run build # Build to dist/
|
|
245
259
|
```
|
|
246
260
|
|
|
261
|
+
## Security & Data Scope
|
|
262
|
+
|
|
263
|
+
- **Read-only scanning:** Python executables and pyvenv.cfg are read but never modified
|
|
264
|
+
- **Subprocesses:** spawns `python` with controlled arguments — no shell execution
|
|
265
|
+
- **Network:** optional `--httpsProbe` tests SSL certificates — no other outbound requests
|
|
266
|
+
- **No telemetry** is collected or sent — see [SECURITY.md](SECURITY.md) for the full policy
|
|
267
|
+
|
|
247
268
|
## License
|
|
248
269
|
|
|
249
270
|
MIT
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
Built by [MCP Tool Shop](https://mcp-tool-shop.github.io/)
|
package/README.pt-BR.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.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.md">English</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
|
+
**Kit de ferramentas de diagnóstico para ambientes virtuais Python em fluxos de trabalho de aprendizado de máquina (ML) para Windows.**
|
|
21
|
+
|
|
22
|
+
Analisa seu sistema em busca de ambientes Python, diagnostica problemas de saúde (SSL, DLLs, incompatibilidades de ABI, vazamentos de caminhos), rastreia o histórico de execução de tarefas, detecta tarefas instáveis e gera um mapa do ecossistema.
|
|
23
|
+
|
|
24
|
+
## Início rápido em 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
|
+
## Recursos
|
|
34
|
+
|
|
35
|
+
- **doctorLite** - Verificação rápida de saúde para qualquer interpretador Python
|
|
36
|
+
- Verificação SSL/TLS
|
|
37
|
+
- Falhas ao carregar DLLs (comum com PyTorch/CUDA)
|
|
38
|
+
- Incompatibilidades de ABI (ARM vs x86)
|
|
39
|
+
- Verificações de integridade do pip
|
|
40
|
+
- Detecção de vazamentos de user-site e PYTHONPATH
|
|
41
|
+
|
|
42
|
+
- **scanEnvPaths** - Descobre todos os ambientes Python no seu sistema
|
|
43
|
+
- Encontra venvs, ambientes conda, versões pyenv, interpretadores base
|
|
44
|
+
- Profundidade e filtragem configuráveis
|
|
45
|
+
|
|
46
|
+
- **mapRender** - Visualize seu ecossistema Python
|
|
47
|
+
- Saída JSON para uso programático
|
|
48
|
+
- Diagramas Mermaid para documentação
|
|
49
|
+
- Agrupamento de interpretadores base com análise de raio de impacto
|
|
50
|
+
- Visualização de roteamento de tarefas
|
|
51
|
+
|
|
52
|
+
- **runLog** - Rastreia o histórico de execução de tarefas
|
|
53
|
+
- Formato JSONL somente para anexar
|
|
54
|
+
- Registra qual ambiente executou qual tarefa
|
|
55
|
+
- Captura sucesso/falha com classificação de erro
|
|
56
|
+
|
|
57
|
+
- **taskCluster** - Agrupa execuções de tarefas por assinatura
|
|
58
|
+
- Detecção de tarefas instáveis (passagem/falha inconsistente)
|
|
59
|
+
- Detecção de instabilidade dependente do ambiente
|
|
60
|
+
- Identificação de pontos críticos de falha
|
|
61
|
+
- Análise de contágio (causas-raiz compartilhadas)
|
|
62
|
+
|
|
63
|
+
## Instalação
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm run build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Uso da CLI
|
|
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
|
+
### Opções da CLI
|
|
87
|
+
|
|
88
|
+
| Flag | Descrição |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `--root, -r` | Diretório a ser analisado (pode especificar vários) |
|
|
91
|
+
| `--out` | Diretório de saída (padrão: `.venvkit`) |
|
|
92
|
+
| `--maxDepth` | Profundidade máxima do diretório a ser analisado (padrão: 5) |
|
|
93
|
+
| `--strict` | Habilita verificações de modo estrito |
|
|
94
|
+
| `--httpsProbe` | Testa a conectividade HTTPS |
|
|
95
|
+
| `--minScore` | Filtra ambientes abaixo desta pontuação de saúde |
|
|
96
|
+
| `--concurrency` | Verificações paralelas (padrão: número de CPUs) |
|
|
97
|
+
| `--runlog` | Caminho para o registro de execução da tarefa (JSONL) |
|
|
98
|
+
| `--no-tasks` | Ignora a visualização da tarefa |
|
|
99
|
+
|
|
100
|
+
### Saídas
|
|
101
|
+
|
|
102
|
+
| Arquivo | Descrição |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| `venv-map.json` | Dados completos do gráfico (nós, arestas, resumo) |
|
|
105
|
+
| `venv-map.mmd` | Fonte do diagrama Mermaid |
|
|
106
|
+
| `venv-map.html` | Visualizador interativo |
|
|
107
|
+
| `reports.json` | Relatórios raw do doctorLite |
|
|
108
|
+
| `insights.json` | Recomendações acionáveis |
|
|
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 do Registro de Tarefas
|
|
148
|
+
|
|
149
|
+
Rastreie as execuções de tarefas anexando eventos a um arquivo 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
|
+
## Agrupamento de Tarefas
|
|
177
|
+
|
|
178
|
+
Quando você tem muitas execuções de tarefas, o venvkit as agrupa por assinatura:
|
|
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 do Gráfico
|
|
197
|
+
|
|
198
|
+
A saída do `mapRender` segue um esquema JSON estável:
|
|
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 Nós
|
|
222
|
+
|
|
223
|
+
| Tipo | Descrição |
|
|
224
|
+
|------|-------------|
|
|
225
|
+
| `base` | Interpretador Python base (por exemplo, `C:\Python311`) |
|
|
226
|
+
| `venv` | Ambiente virtual |
|
|
227
|
+
| `task` | Assinatura da tarefa (execuções agrupadas) |
|
|
228
|
+
|
|
229
|
+
### Tipos de Arestas
|
|
230
|
+
|
|
231
|
+
| Tipo | Descrição |
|
|
232
|
+
|------|-------------|
|
|
233
|
+
| `USES_BASE` | Relacionamento venv → base |
|
|
234
|
+
| `ROUTES_TASK_TO` | Roteamento de tarefa → ambiente |
|
|
235
|
+
| `FAILED_RUN` | Falha de tarefa → ambiente (tracejado em Mermaid) |
|
|
236
|
+
|
|
237
|
+
## Códigos de Erro
|
|
238
|
+
|
|
239
|
+
| Código | Severidade | Descrição |
|
|
240
|
+
|------|----------|-------------|
|
|
241
|
+
| `SSL_BROKEN` | bad | O módulo SSL falha ao importar |
|
|
242
|
+
| `CERT_STORE_FAIL` | warn | A verificação do certificado HTTPS falha |
|
|
243
|
+
| `DLL_LOAD_FAIL` | bad | Falha ao carregar DLL de extensão nativa |
|
|
244
|
+
| `ABI_MISMATCH` | bad | Incompatibilidade binária (ARM/x86) |
|
|
245
|
+
| `PIP_MISSING` | warn | pip não disponível |
|
|
246
|
+
| `PIP_CHECK_FAIL` | warn | Conflitos de dependência detectados |
|
|
247
|
+
| `USER_SITE_LEAK` | warn | user-site-packages habilitado no venv |
|
|
248
|
+
| `PYTHONPATH_INJECTED` | warn | Variável de ambiente PYTHONPATH definida |
|
|
249
|
+
| `ARCH_MISMATCH` | bad | Python de 32 bits quando 64 bits são necessários |
|
|
250
|
+
| `PYVENV_CFG_INVALID` | warn | pyvenv.cfg corrompido ou ausente |
|
|
251
|
+
|
|
252
|
+
## Desenvolvimento
|
|
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
|
+
## Segurança e Escopo de Dados
|
|
262
|
+
|
|
263
|
+
- **Leitura apenas:** Os executáveis Python e o arquivo pyvenv.cfg são lidos, mas nunca modificados.
|
|
264
|
+
- **Subprocessos:** Inicia o `python` com argumentos controlados — sem execução via shell.
|
|
265
|
+
- **Rede:** A opção `--httpsProbe` (opcional) testa certificados SSL — não são feitas outras requisições de saída.
|
|
266
|
+
- **Nenhuma telemetria** é coletada ou enviada — consulte o arquivo [SECURITY.md](SECURITY.md) para a política completa.
|
|
267
|
+
|
|
268
|
+
## Licença
|
|
269
|
+
|
|
270
|
+
MIT
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
Criado por [MCP Tool Shop](https://mcp-tool-shop.github.io/)
|