dependency-resolver
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDependency Resolver Skill
Dependency Resolver Skill
Purpose
用途
This skill detects and resolves local vs CI environment mismatches BEFORE push, preventing the 20-45 minute debug cycles documented in DISCOVERIES.md ("CI Failure Resolution Process Analysis" entry).
The skill addresses a critical gap: existing tools (ci-diagnostic-workflow, pre-commit-diagnostic) fix issues AFTER they occur. This skill catches mismatches BEFORE push.
该Skill可在推送前检测并解决本地与CI环境的不匹配问题,避免DISCOVERIES.md中记录的20-45分钟调试周期(对应“CI故障解决流程分析”条目)。
此Skill填补了一个关键空白:现有工具(ci-diagnostic-workflow、pre-commit-diagnostic)都是在问题发生后才进行修复,而该Skill能在推送前就发现不匹配问题。
Problem Statement
问题陈述
From DISCOVERIES.md analysis:
- Environment mismatches (Local Python 3.12 vs CI Python 3.11) cause 20-25 min investigation overhead
- Version drift (local ruff 0.12.7 vs CI ruff 0.13.0) causes silent failures
- 45-minute complex debugging sessions traced to dependency conflicts
- No automated pre-push environment comparison exists
基于DISCOVERIES.md的分析:
- 环境不匹配(本地Python 3.12 vs CI Python 3.11)会导致20-25分钟的调查耗时
- 版本漂移(本地ruff 0.12.7 vs CI ruff 0.13.0)会引发静默故障
- 长达45分钟的复杂调试会话根源在于依赖冲突
- 目前不存在自动化的预推送环境对比工具
Execution Instructions
执行说明
When activated, execute these steps autonomously:
激活后,将自动执行以下步骤:
Step 1: Collect Local Environment
步骤1:收集本地环境信息
bash
undefinedbash
undefinedPython version
Python版本
python --version
python --version
Installed tool versions
已安装工具版本
pip show ruff black pyright mypy 2>/dev/null | grep -E "^(Name|Version):"
pip show ruff black pyright mypy 2>/dev/null | grep -E "^(Name|Version):"
Pre-commit hook versions (if available)
Pre-commit钩子版本(若可用)
cat .pre-commit-config.yaml 2>/dev/null | grep -E "rev:|repo:"
undefinedcat .pre-commit-config.yaml 2>/dev/null | grep -E "rev:|repo:"
undefinedStep 2: Read CI Configuration
步骤2:读取CI配置
Read(file_path=".github/workflows/ci.yml")
Read(file_path="pyproject.toml")
Read(file_path=".pre-commit-config.yaml")Extract:
- CI Python version (look for )
python-version: - Required tool versions from pyproject.toml
- Pre-commit hook versions from .pre-commit-config.yaml
Read(file_path=".github/workflows/ci.yml")
Read(file_path="pyproject.toml")
Read(file_path=".pre-commit-config.yaml")提取以下信息:
- CI Python版本(查找字段)
python-version: - pyproject.toml中要求的工具版本
- .pre-commit-config.yaml中的pre-commit钩子版本
Step 3: Compare Environments
步骤3:对比环境信息
Build comparison table:
| Component | Local | CI | Status |
|---|---|---|---|
| Python | 3.12.10 | 3.11 | MISMATCH |
| ruff | 0.12.7 | 0.13.0 | MISMATCH |
| black | 24.3.0 | 24.3.0 | OK |
构建对比表格:
| 组件 | 本地版本 | CI版本 | 状态 |
|---|---|---|---|
| Python | 3.12.10 | 3.11 | 不匹配 |
| ruff | 0.12.7 | 0.13.0 | 不匹配 |
| black | 24.3.0 | 24.3.0 | 正常 |
Step 4: Generate Recommendations
步骤4:生成修复建议
For each mismatch, provide actionable fix:
Python Version Mismatch:
bash
undefined针对每个不匹配项,提供可执行的修复方案:
Python版本不匹配:
bash
undefinedOption A: Use pyenv to match CI version
选项A:使用pyenv匹配CI版本
pyenv install 3.11
pyenv local 3.11
pyenv install 3.11
pyenv local 3.11
Option B: Update CI to match local (if local is intentional)
选项B:更新CI配置以匹配本地版本(若本地版本为有意升级)
Edit .github/workflows/ci.yml line 33
编辑.github/workflows/ci.yml第33行
**Tool Version Mismatch:**
```bash
**工具版本不匹配:**
```bashPin versions in pyproject.toml
在pyproject.toml中锁定版本
pip install ruff==0.13.0
pip install ruff==0.13.0
Or update pre-commit hooks
或更新pre-commit钩子
pre-commit autoupdate
undefinedpre-commit autoupdate
undefinedStep 5: Auto-Fix (When Requested)
步骤5:自动修复(当用户请求时)
If user requests auto-fix:
- Update .pre-commit-config.yaml with latest versions
- Run
pre-commit autoupdate - Regenerate requirements.txt if applicable
- Stage changes for commit
若用户请求自动修复:
- 使用最新版本更新.pre-commit-config.yaml
- 运行
pre-commit autoupdate - 若适用,重新生成requirements.txt
- 暂存待提交的变更
Integration Points
集成点
With fix-agent
与fix-agent集成
Integrates with fix-agent templates for:
- Import/dependency fixes (Template 1)
- Configuration fixes (Template 2)
- CI/CD fixes (Template 4)
可与fix-agent模板集成,用于:
- 导入/依赖修复(模板1)
- 配置修复(模板2)
- CI/CD修复(模板4)
With pre-commit-diagnostic
与pre-commit-diagnostic集成
Hand-off when pre-commit failures detected after version sync.
当版本同步后仍检测到pre-commit失败时,可移交至该工具处理。
With ci-diagnostic-workflow
与ci-diagnostic-workflow集成
Hand-off for post-push CI failures not caught by pre-push validation.
对于预推送验证未捕获的推送后CI故障,可移交至该工作流处理。
Common Mismatch Patterns
常见不匹配模式
Pattern 1: Python Minor Version Drift
模式1:Python小版本漂移
Symptoms:
- Type errors only in CI
- Import errors with newer syntax
- f-string issues
Fix:
bash
undefined症状:
- 仅在CI中出现类型错误
- 使用较新语法时出现导入错误
- f-string相关问题
修复方案:
bash
undefinedCheck CI Python version
查看CI Python版本
grep -r "python-version" .github/workflows/
grep -r "python-version" .github/workflows/
Match locally or update CI
在本地匹配CI版本或更新CI配置
undefinedundefinedPattern 2: Linter Version Drift
模式2:Linter版本漂移
Symptoms:
- "Works locally but CI fails on linting"
- New rules in CI not enforced locally
- Formatting differences
Fix:
bash
undefined症状:
- "本地运行正常但CI linting失败"
- CI中启用了本地未强制执行的新规则
- 代码格式不一致
修复方案:
bash
undefinedSync pre-commit hooks to latest
将pre-commit钩子同步至最新版本
pre-commit autoupdate
pre-commit autoupdate
Or pin specific version
或锁定特定版本
pip install ruff==<ci-version>
undefinedpip install ruff==<ci-version>
undefinedPattern 3: Missing Dependencies
模式3:缺失依赖
Symptoms:
- ModuleNotFoundError in CI
- Optional dependencies not installed
Fix:
bash
undefined症状:
- CI中出现ModuleNotFoundError
- 未安装可选依赖
修复方案:
bash
undefinedInstall all optional dependencies
安装所有可选依赖
pip install -e ".[dev]"
pip install -e ".[dev]"
Ensure requirements.txt is up to date
确保requirements.txt是最新的
pip freeze > requirements.txt
undefinedpip freeze > requirements.txt
undefinedOutput Format
输出格式
markdown
undefinedmarkdown
undefinedDependency Resolver Report
Dependency Resolver报告
Environment Comparison
环境对比
| Component | Local | CI | Status |
|---|---|---|---|
| Python | 3.12.10 | 3.11 | MISMATCH |
| ruff | 0.12.7 | 0.13.0 | MISMATCH |
| pyright | 1.1.350 | 1.1.350 | OK |
| 组件 | 本地版本 | CI版本 | 状态 |
|---|---|---|---|
| Python | 3.12.10 | 3.11 | 不匹配 |
| ruff | 0.12.7 | 0.13.0 | 不匹配 |
| pyright | 1.1.350 | 1.1.350 | 正常 |
Mismatches Found: 2
发现不匹配项:2个
Recommendations
修复建议
-
Python Version (CRITICAL)
- Local: 3.12.10, CI: 3.11
- Action: Consider using pyenv to test with CI version before push
- Risk: Type syntax differences may cause failures
-
ruff Version (WARNING)
- Local: 0.12.7, CI: 0.13.0
- Action: Run or
pip install ruff==0.13.0pre-commit autoupdate - Risk: New rules may flag previously passing code
-
Python版本(严重)
- 本地:3.12.10,CI:3.11
- 操作:推送前考虑使用pyenv测试CI版本
- 风险:版本语法差异可能导致故障
-
ruff版本(警告)
- 本地:0.12.7,CI:0.13.0
- 操作:运行或
pip install ruff==0.13.0pre-commit autoupdate - 风险:新规则可能标记之前通过的代码
Quick Fix Commands
快速修复命令
bash
undefinedbash
undefinedSync ruff version
同步ruff版本
pip install ruff==0.13.0
pip install ruff==0.13.0
Update all pre-commit hooks
更新所有pre-commit钩子
pre-commit autoupdate
pre-commit autoupdate
Re-run pre-commit to validate
重新运行pre-commit以验证
pre-commit run --all-files
undefinedpre-commit run --all-files
undefinedStatus: ACTION REQUIRED
状态:需执行操作
Push may fail due to environment mismatches.
Run recommended fixes before pushing.
undefined由于环境不匹配,推送可能失败。请在推送前运行建议的修复方案。
undefinedWhen to Use This Skill
使用场景
Trigger Signs:
- "CI is failing but it works locally"
- "Linting passes here but not in CI"
- Before pushing after long development session
- After updating local Python or tools
- When onboarding to new project
Not Needed When:
- CI already passing consistently
- Environment just synced
- Only editing documentation
触发信号:
- "CI失败但本地运行正常"
- "本地linting通过但CI中失败"
- 长时间开发会话后准备推送时
- 更新本地Python或工具后
- 加入新项目时
无需使用的场景:
- CI持续稳定通过
- 环境刚完成同步
- 仅编辑文档时
Related Resources
相关资源
- DISCOVERIES.md: CI Failure Resolution Process Analysis (lines 836-914)
- fix-agent.md: Templates for import/config/CI fixes
- ci-diagnostic-workflow.md: Post-push CI failure resolution
- pre-commit-diagnostic.md: Pre-commit hook failures
- .github/workflows/ci.yml: CI configuration source of truth
- DISCOVERIES.md:CI故障解决流程分析(第836-914行)
- fix-agent.md:导入/配置/CI修复模板
- ci-diagnostic-workflow.md:推送后CI故障解决流程
- pre-commit-diagnostic.md:Pre-commit钩子故障处理
- .github/workflows/ci.yml:CI配置的权威来源
Philosophy Alignment
理念契合
Ruthless Simplicity
极致简洁
- Procedural approach: Five clear steps, no unnecessary abstraction
- Direct shell commands: Users can copy-paste recommendations
- Focused scope: Only detects environment mismatches, delegates fixes to existing agents
- 流程化方法:清晰的五个步骤,无不必要的抽象
- 直接的Shell命令:用户可直接复制粘贴建议
- 聚焦范围:仅检测环境不匹配问题,将修复工作委托给现有Agent
Zero-BS Implementation
务实落地
- Actionable output: Every recommendation includes exact commands
- No theoretical advice: Specific version numbers and file paths
- Pre-push prevention: Catches issues before wasted CI cycles
- 可执行的输出:每条建议都包含精确命令
- 无理论化建议:提供具体版本号和文件路径
- 预推送预防:在浪费CI周期前就发现问题
Modular Design
模块化设计
- Clean hand-offs: Integrates with fix-agent, pre-commit-diagnostic, ci-diagnostic-workflow
- Single responsibility: Detection and comparison only; fixes delegated to specialized agents
- Regeneratable: Can be rebuilt from this specification
- 清晰的移交机制:与fix-agent、pre-commit-diagnostic、ci-diagnostic-workflow集成
- 单一职责:仅负责检测与对比,修复工作委托给专业Agent
- 可重生成:可根据本规范重新构建