1仕組みと動作原理
本skillの実体は2つの確定的なPythonスクリプトです。scan_repo.pyが構造およびシグナルの走査を行い、extract_commands.pyがREADMEからコマンドを抽出・分類します。SKILL.mdは使用タイミングと出力形式を規定するのみです。コマンド抽出は「モデルにREADMEを読ませて推測させる」ものではなく、正規表現+見出しの帰属判定+ヒューリスティック分類による再現可能なパイプラインです。
"""Extract shell-like commands from README content and classify them."""
走査範囲はホワイトリストで固定されています。リポジトリ全体を走査することはせず、9個の主要ファイルと7個の高シグナルディレクトリのみを検査します。その結果や警告(README欠落時の明示的な警告など)は、モデルの自由記述ではなくスクリプトから直接出力されます。
KEY_FILES = [ "README.md", "README", "requirements.txt", "environment.yml", "environment.yaml", "pyproject.toml", "setup.py", "setup.cfg", "Dockerfile", ]
分類器には明確な優先順位と判定根拠があります。まずsetup/asset構文を判定し(インストールの推論誤認を防止)、次に見出しの意味、エントリポイントスクリプト名(train*.py / eval*.py / sample|generate|infer*.py)、最後にキーワード走査の順で評価します。
# Unambiguous setup/asset syntax outranks generic headings such as # "Basic Example", which otherwise makes installation look like inference. if lowered.startswith(SETUP_PREFIXES + ASSET_PREFIXES): return "other"
README内で参照されている.pyエントリポイントに対して構造レベルの再確認を行います。該当スクリプト(≤512 KiB)を読み込み、optimizer.step(/backward(/train()/def train*/epochループに基づいてスコアリングし、4点以上の場合にコマンドを元の分類からtrainingへと格上げし、classification_source='entrypoint-structure'と根拠タグを記録します。
TRAINING_STRUCTURE_SIGNALS = [ ("optimizer-step", re.compile(r"\boptimizer\s*\.\s*step\s*\(", re.IGNORECASE), 3), ("backward-pass", re.compile(r"\.\s*backward\s*\(", re.IGNORECASE), 3), ("model-train-mode", re.compile(r"\.\s*train\s*\(", re.IGNORECASE), 2), ("train-function", re.compile(r"\bdef\s+train\w*\s*\(", re.IGNORECASE), 1), ("epoch-loop", re.compile(r"\bfor\s+\w*epoch\w*\s+in\b", re.IGNORECASE), 1), ]
「無知を認めるほど保守的に分類する」方針がリファレンスに明記されています。根拠が不十分な場合はinferredとマークし、過剰な確約を避けて曖昧さをそのまま記録します。READMEの明確な証拠はファイル名の推測よりも優先されます。
## Conservative behavior - prefer explicit README evidence over filename guesses - mark guessed classifications as inferred - record ambiguity instead of overcommitting
責務の境界が厳格に定義されています。走査と計画のみを行い、環境構築、大規模アセットのダウンロード、実質的なコマンド実行、高リスクなパッチの決定は行いません。メインオーケストレーターに提供するのは最小限の信頼できる再現提案です。
## Clear boundaries - This skill scans and plans. - This skill is helper-tier and should usually be orchestrator-invoked. - It does not install environments. - It does not prepare large assets. - It does not execute substantive reproduction commands. - It does not decide high-risk patching.
オーケストレーターは実際にこれら2つのスクリプトを呼び出します(単なるドキュメント上の飾りではありません)。orchestrate_repro.pyはskillディレクトリを解決した後、サブプロセスとしてscan_repo.py --repo … --jsonを実行し、取得したreadme_pathを用いてextract_commands.py --readme … --jsonを実行し、その結果を再現プロセスに統合します。
scan_data = run_json(scan_script, ["--repo", str(repo_path), "--json"]) readme_path = scan_data.get("readme_path") command_data: Dict[str, Any] = {"commands": [], "counts": {}, "warnings": []} if readme_path: command_data = run_json(extract_script, ["--readme", readme_path, "--json"])
2コア機能
3外部依存関係
| Kind | Dependency / Endpoint |
|---|---|
| cli | Python 3(脚本解释器;由宿主/编排器调用,脚本自身无子进程外呼) |
4推奨統制措置と判定根拠
- scripts/: ローカルスクリプトまたはコマンドの実行: python3 scripts/scan_repo.py --repo <path> --json(本skill同梱、読み取り専用のディレクトリ走査)
5二重目の独立検証
- [ok] skill 路径(任务书标『待定位』) — 实际相对路径 skills/repo-intake-and-plan;SKILL.md 位于该目录根。
- [ok] 『helper 脚本』确实存在且被调用(非文档装饰) — orchestrate_repro.py:1162-1167 设定 scan_script/extract_script 并在 1173-1178 以 run_json(...) 执行;_bundled/MANIFEST.json 记录两文件打包目标与 sha256;references/skill-registry.json 的 required_files 列出两者。
- [discrepancy] SKILL.md 未给出脚本调用示例 — SKILL.md 仅在 Notes 写 'Use `references/repo-scan-rules.md` and helper scripts under `scripts/`.',没有给命令行/参数示例;实际 CLI 契约(--repo/--json、--readme/--json)只能从脚本 argparse 与编排器调用点得到。对模型自助调用不够友好,属可改进项;不影响机制结论,已在 capabilities/how_it_works 中改用编排器调用点为证据。
- [ok] 无网络/无凭证/无写入 — 两脚本 import 仅 argparse/json/re/pathlib/datetime/typing(scan_repo 另有 timezone);全目录 URL/urllib/requests/socket/subprocess/os.environ 扫描零命中;无写文件调用(仅 print 到 stdout)。
- [ok] 路径越界防护 — referenced_python_script() 先 (root / path).resolve() 再 candidate.relative_to(root),越界抛 ValueError 返回 None;并有 is_file() 与 524_288 字节上限。
- [ok] 分类优先级与注释一致 — classify() 实际顺序为 setup/asset 前缀 → 章节语义 → SCRIPT_CATEGORY_HINTS → 关键词,与文件内注释 'Unambiguous setup/asset syntax outranks generic headings' 一致;command_kind() 独立返回 setup/asset/run/smoke(--help/-h → smoke)。
- [ok] README 定位与姊妹 helper 分工 — README.md:160 'Two helpers support orchestration: `repo-intake-and-plan` and `paper-context-resolver`.';tests/trigger_cases.json 中 'expected_top': 'repo-intake-and-plan' 的用例存在(repo_scan_only_en:'Do not run anything yet.'),与 SKILL.md 的『不执行实质命令』一致。
- [ok] 元数据 — 本地 git HEAD bd91195ad73199b95e24532b581ff12c07dcce09(= 任务书 pin);LICENSE MIT / Copyright (c) 2026 Chengkun Rao;gh api → stars 487、last_push 2026-09-13T13:16:25Z。
6結論
1953a875072a9f35…