Imported from eggplants/shindan-cli (
AGENTS.md). Install upstream withnpx skills add eggplants/shindan-cli. Copyright stays with the author.
shindan-cli — Agent Instructions
診断メーカー の診断結果を取得する Python 製 CLI + ライブラリ。
必須コマンド
mise run pytest # テスト実行
mise run pytest-cov # カバレッジ付きテスト
mise run ruff # Lint + フォーマット確認
mise run ty # 型チェック
mise run build # パッケージビルド
mise runの代わりにuv run <tool>でも実行可能。
アーキテクチャ
shindan_cli/
cli.py - CLI エントリーポイント (argparse)
shindan.py - メインロジック・診断タイプ判別・ShindanError 定義
get_results.py - 診断タイプ別の HTTP POST + スクレイピング処理
interactive.py - AI/分岐診断における対話型入力処理
models.py - TypedDict によるデータモデル定義
constants.py - URL・HTTPヘッダー・パラメータ名の定数定義
コード規約
- 全ファイル:
from __future__ import annotations+ 型ヒント必須 - HTTP:
curl_cffi(_http.create_session()経由。Cloudflare は TLS/HTTP2 フィンガープリントを見るため、requests等の素の HTTP クライアントは使わない) - 非同期: 使用しない(同期処理のみ)
- Lint: Ruff(
pyproject.tomlで設定済み)。変更後はmise run ruffを通すこと - 型チェック:
ty(mise run ty)で確認
テスト
tests/test_cli.py: CLI 引数・標準出力のテストtests/test_shindan.py: スクレイピング・API 統合テスト(実通信あり)- 対話型入力は
monkeypatchでinputをシミュレート
注意事項
- HTML セレクタの脆弱性:
get_results.py/interactive.pyのセレクタは診断メーカーの HTML 構造に依存。サイト変更で壊れる可能性がある - AI 診断の SSE:
get_result_by_aiは SSE 形式のレスポンスを正規表現でパース(get_results.py参照) - CSRF トークン: 診断ページはキャッシュ配信で
_token/meta[name=csrf-token]が空。GET /csrf-tokenから取得して埋める(shindan.py) - AI 診断: Cloudflare Turnstile で保護されており、スクリプトからは
encrypted_exec_keyを取得できない(test_aiは xfail) - CI からの実通信: GitHub Actions の IP は Cloudflare に 403 で弾かれる。
tests/conftest.pyが 403 をスキップに変換する - マジックパラメータ:
_token、rbr等のパラメータ名は診断メーカー側の仕様に依存 - Python バージョン:
>=3.10必須(pyproject.toml参照)