@mcptoolshop/venvkit 0.2.0 → 0.2.5
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 +263 -0
- package/README.fr.md +263 -0
- package/README.hi.md +267 -0
- package/README.it.md +263 -0
- package/README.ja.md +263 -0
- package/README.md +17 -3
- package/README.pt-BR.md +263 -0
- package/README.zh.md +263 -0
- package/package.json +69 -58
- package/dist/doctorLite.d.ts +0 -75
- package/dist/doctorLite.d.ts.map +0 -1
- package/dist/doctorLite.js +0 -705
- package/dist/doctorLite.js.map +0 -1
- package/dist/doctorLite.test.d.ts +0 -2
- package/dist/doctorLite.test.d.ts.map +0 -1
- package/dist/doctorLite.test.js +0 -268
- package/dist/doctorLite.test.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/integration.test.d.ts +0 -2
- package/dist/integration.test.d.ts.map +0 -1
- package/dist/integration.test.js +0 -245
- package/dist/integration.test.js.map +0 -1
- package/dist/mapRender.d.ts +0 -105
- package/dist/mapRender.d.ts.map +0 -1
- package/dist/mapRender.js +0 -718
- package/dist/mapRender.js.map +0 -1
- package/dist/mapRender.test.d.ts +0 -2
- package/dist/mapRender.test.d.ts.map +0 -1
- package/dist/mapRender.test.js +0 -571
- package/dist/mapRender.test.js.map +0 -1
- package/dist/map_cli.d.ts +0 -3
- package/dist/map_cli.d.ts.map +0 -1
- package/dist/map_cli.js +0 -278
- package/dist/map_cli.js.map +0 -1
- package/dist/map_cli.test.d.ts +0 -2
- package/dist/map_cli.test.d.ts.map +0 -1
- package/dist/map_cli.test.js +0 -276
- package/dist/map_cli.test.js.map +0 -1
- package/dist/runLog.d.ts +0 -71
- package/dist/runLog.d.ts.map +0 -1
- package/dist/runLog.js +0 -98
- package/dist/runLog.js.map +0 -1
- package/dist/runLog.test.d.ts +0 -2
- package/dist/runLog.test.d.ts.map +0 -1
- package/dist/runLog.test.js +0 -327
- package/dist/runLog.test.js.map +0 -1
- package/dist/scanEnvPaths.d.ts +0 -18
- package/dist/scanEnvPaths.d.ts.map +0 -1
- package/dist/scanEnvPaths.js +0 -174
- package/dist/scanEnvPaths.js.map +0 -1
- package/dist/scanEnvPaths.test.d.ts +0 -2
- package/dist/scanEnvPaths.test.d.ts.map +0 -1
- package/dist/scanEnvPaths.test.js +0 -250
- package/dist/scanEnvPaths.test.js.map +0 -1
- package/dist/taskCluster.d.ts +0 -62
- package/dist/taskCluster.d.ts.map +0 -1
- package/dist/taskCluster.js +0 -180
- package/dist/taskCluster.js.map +0 -1
- package/dist/taskCluster.test.d.ts +0 -2
- package/dist/taskCluster.test.d.ts.map +0 -1
- package/dist/taskCluster.test.js +0 -375
- package/dist/taskCluster.test.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -8
- package/dist/vitest.config.js.map +0 -1
package/README.ja.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.md">English</a> | <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
|
+
|
|
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
|
+
| Flag | 説明 |
|
|
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
|
+
| File | 説明 |
|
|
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
|
+
| Type | 説明 |
|
|
224
|
+
| ------ | ------------- |
|
|
225
|
+
| `base` | ベースのPythonインタプリタ(例:`C:\Python311`) |
|
|
226
|
+
| `venv` | 仮想環境 |
|
|
227
|
+
| `task` | タスクのシグネチャ(クラスタリングされた実行) |
|
|
228
|
+
|
|
229
|
+
### エッジの種類
|
|
230
|
+
|
|
231
|
+
| Type | 説明 |
|
|
232
|
+
| ------ | ------------- |
|
|
233
|
+
| `USES_BASE` | venvとベースの関係 |
|
|
234
|
+
| `ROUTES_TASK_TO` | タスクと環境のルーティング |
|
|
235
|
+
| `FAILED_RUN` | タスクと環境の失敗(Mermaidでは破線で表示) |
|
|
236
|
+
|
|
237
|
+
## エラーコード
|
|
238
|
+
|
|
239
|
+
| Code | 重要度 | 説明 |
|
|
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ビットのPythonが必要な場合に、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
|
+
MITライセンス
|
package/README.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.md">English</a> | <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
|
|
|
@@ -10,7 +24,7 @@ Scans your system for Python environments, diagnoses health issues (SSL, DLLs, A
|
|
|
10
24
|
## 30-Second Quickstart
|
|
11
25
|
|
|
12
26
|
```bash
|
|
13
|
-
git clone https://github.com/mcp-tool-shop/venvkit && cd venvkit
|
|
27
|
+
git clone https://github.com/mcp-tool-shop-org/venvkit && cd venvkit
|
|
14
28
|
npm install && npm run build
|
|
15
29
|
node dist/map_cli.js --root C:\projects --httpsProbe
|
|
16
30
|
# Open .venvkit/venv-map.html in your browser
|
package/README.pt-BR.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.md">English</a> | <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
|
+
|
|
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 caminho), 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 sanidade 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 núcleos da CPU) |
|
|
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
|
+
| File | 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
|
+
| Type | 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
|
+
| Type | 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
|
+
| Code | 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 | A carga da DLL de extensão nativa falha |
|
|
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 | Pacotes do usuário habilitados no ambiente virtual. |
|
|
248
|
+
| `PYTHONPATH_INJECTED` | warn | Variável de ambiente PYTHONPATH definida. |
|
|
249
|
+
| `ARCH_MISMATCH` | bad | Versão de 32 bits do Python quando a versão de 64 bits é necessária. |
|
|
250
|
+
| `PYVENV_CFG_INVALID` | warn | Arquivo 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
|
+
## Licença
|
|
262
|
+
|
|
263
|
+
MIT.
|