Msmodeling env installer

From kali20gakki/msAgent · View interactive version

Msmodeling env installer is an AI agent skill from the GitHub repository kali20gakki/msAgent. Install and verify the msmodeling development environment. Use when the user explicitly asks to install msmodeling dependencies, set up this repository, create `myenv` with `uv`, install this repository's `requirements.txt`, set project `PYTHONPATH`, or configure `HF_ENDPOINT`; if the user only says

How to use this skill

Skill file

msModeling 环境安装器

适用场景

直接使用本 skill 的场景:

需要先确认的场景:

遇到上述模糊请求时,先向用户确认:

你是要安装 msmodeling 当前仓库的环境依赖吗?确认后我会使用 msmodeling-env-installer 执行。

只有用户确认后,才继续执行本 skill 的安装流程。

默认策略

优先使用 README 推荐的 uv 流程创建独立虚拟环境,并在安装后执行依赖一致性检查。

默认值和约束:

环境选择策略

根据当前运行环境选择自动化脚本:

| 当前环境 | 优先命令 |

|:---|:---|

| Windows PowerShell | .\\skills\\msmodeling-env-installer\\scripts\\install-current-project-deps.ps1 |

| Linux/macOS Bash | bash ./skills/modeling/msmodeling-env-installer/scripts/install-current-project-deps.sh |

| WSL/Git Bash | bash ./skills/modeling/msmodeling-env-installer/scripts/install-current-project-deps.sh |

如果当前 shell 与操作系统不匹配,优先选择当前 shell 可直接执行的脚本。例如在 Windows 的 Git Bash 中使用 .sh,在 Windows PowerShell 中使用 .ps1。

工作流程

  1. 确认用户意图明确指向 msmodeling 环境依赖;如果只是泛化的“安装环境”,先询问是否安装 msmodeling 当前仓库的环境依赖。
  2. 检查当前目录是否为 msmodeling 仓库根目录,至少包含 README.md 和 requirements.txt。

```bash

git clone https://gitcode.com/Ascend/msmodeling.git

cd msmodeling

```

  1. 检测 python、python3 或 Windows py -3,确认 Python 版本为 3.10+。
  2. 检查 uv 是否可用;缺失时用 python -m pip install uv -i https://mirrors.ustc.edu.cn/pypi/web/simple 安装。
  3. 安装或调用 uv 后,解析真实 uv 可执行路径,不能假设当前 shell 的 PATH 已刷新。
  4. 选择安装路径:
  1. 安装依赖:优先执行 uv pip install --python <venv-python> -r requirements.txt -i <mirror>。
  2. 按需设置当前会话环境变量:
  1. 执行依赖检查:
  1. 向用户报告激活命令、安装结果、验证结果和后续建议。

命令模板

新建环境

pip install uv -i https://mirrors.ustc.edu.cn/pypi/web/simple
uv venv --python <detected-python-version> myenv
uv pip install --python <venv-python> -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple

激活命令:

| 操作系统 | 命令 |

|:---|:---|

| Linux/macOS/WSL/Git Bash | source myenv/bin/activate |

| Windows PowerShell | myenv\Scripts\Activate.ps1 |

| Windows cmd | myenv\Scripts\activate.bat |

已有环境 fallback

使用该路径前必须先检查当前环境:

python -c "import importlib.util, sys; sys.exit(0 if importlib.util.find_spec('torch_npu') else 1)"
python -m pip show torch-npu
python -m pip show torch_npu
python -m pip show cudatoolkit

如果任一检查显示包存在,不要默认继续 fallback。建议用户新建 myenv,或让用户明确确认继续使用该环境。

python -m pip install -r requirements.txt
python -m pip check

环境变量

Linux/macOS/WSL/Git Bash:

export PYTHONPATH="$(pwd):${PYTHONPATH:-}"
export HF_ENDPOINT="https://hf-mirror.com"

Windows PowerShell:

$env:PYTHONPATH = "$(Get-Location);$env:PYTHONPATH"
$env:HF_ENDPOINT = "https://hf-mirror.com"

自动化脚本

仓库内脚本:

| 脚本 | 适用环境 |

|:---|:---|

| scripts/install-current-project-deps.ps1 | Windows PowerShell |

| scripts/install-current-project-deps.sh | Linux/macOS/WSL/Git Bash |

脚本会先确认当前目录是否为 msmodeling 仓库根目录;如果当前目录下已有 msmodeling/ 仓库则自动进入;如果两者都不存在,则按 optix-deploy 的方式从 https://gitcode.com/Ascend/msmodeling.git 克隆后再继续安装。

PowerShell 参数:

| 参数 | 说明 |

|:---|:---|

| -EnvName | 虚拟环境目录名,默认 myenv |

| -PythonVersion | uv venv 使用的 Python 版本,默认使用检测到的本机 Python 主次版本 |

| -UseExistingEnv | 跳过新建 venv,使用已有环境安装依赖 |

| -SetProjectEnv | 为当前 PowerShell 会话设置 PYTHONPATH |

| -UseHFMirror | 为当前 PowerShell 会话设置 HF_ENDPOINT |

| -UseProjectUvCache | 默认启用,将 UV_CACHE_DIR 指向仓库内 .uv-cache |

Bash 参数:

| 参数 | 说明 |

|:---|:---|

| --env-name <name> | 虚拟环境目录名,默认 myenv |

| --python-version <version> | uv venv 使用的 Python 版本,默认使用检测到的本机 Python 主次版本 |

| --use-existing-env | 跳过新建 venv,使用已有环境安装依赖 |

| --set-project-env | 输出并为当前脚本进程设置 PYTHONPATH |

| --use-hf-mirror | 输出并为当前脚本进程设置 HF_ENDPOINT |

| --no-project-uv-cache | 不设置仓库内 .uv-cache 作为 UV_CACHE_DIR |

示例:

.\skills\modeling\msmodeling-env-installer\scripts\install-current-project-deps.ps1
.\skills\modeling\msmodeling-env-installer\scripts\install-current-project-deps.ps1 -SetProjectEnv -UseHFMirror
.\skills\modeling\msmodeling-env-installer\scripts\install-current-project-deps.ps1 -UseExistingEnv
bash ./skills/modeling/msmodeling-env-installer/scripts/install-current-project-deps.sh
bash ./skills/modeling/msmodeling-env-installer/scripts/install-current-project-deps.sh --set-project-env --use-hf-mirror
bash ./skills/modeling/msmodeling-env-installer/scripts/install-current-project-deps.sh --use-existing-env

安全规则

完成标准

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.