python-runtime 与 dev-environment-setup 还在描述客户端 10.0.105 之前的 Hatch 布局:正常安装时没有 runtime/hatch/hatch,probe-python.sh 的 hatch_path 恒空,Agent 接着就会用系统包管理器。文档的 CLI 写法同样有问题:Hatch 1.16.5 里没有 HATCH_HOME 和 HATCH_PYTHON_MIRROR_URL,不带 --private --dir 的 python install 装到用户数据目录并改写 .zshrc、.zprofile,DesireCore 也看不到那个 Python。 - 二进制改为随包的 static/toolchains/<平台>-<架构>/hatch/hatch;runtime/hatch/hatch 只有手动下载后才存在 - 先用已在 PATH 上的内置 Python;指定版本用 runtime/hatch/local/<版本> 的绝对路径,pip 走探测到的解释器 - 安装命令带 --private --dir,环境变量改为 PYAPP_INSTALL_DIR_HATCH;换下载源用 HATCH_PYTHON_CUSTOM_SOURCE_<NAME>,并写明 URL 形态约束 - probe-python.sh 按新布局查找,新增 hatch_bootstrap,只认与二进制同版本的分发;没有解包好的分发时不执行二进制,避免 --version 触发下载;输出的路径字段做 JSON 转义 - 写明这个 bash 探测脚本在 Windows 上不查找 Hatch,降级到 L3 前先试 L2 的 Windows 路径 - 记录首启导入把本机镜像地址写进 hatch-dist.json,导致 local/ 上的 Hatch 命令报 Unknown distribution source,并给出修复办法;客户端修复见 desirecore/desirecore#5578 - desirecore-runtime.md 的源码路径改为 packages/agent-service/src;decision-tree.md 补上 standalone 的 401 - 版本 python-runtime 1.0.3 → 1.0.4、dev-environment-setup 2.0.5 → 2.0.6,sidecar 与 i18n source_hash 同步;不设客户端版本门槛 Correct the Hatch paths and install commands in python-runtime and dev-environment-setup, which still described the layout from before client 10.0.105 and told Agents to run an install that edits shell startup files and lands where DesireCore cannot see it. probe-python.sh now finds the current layout, reports the unpacked distribution, and no longer triggers a download. 验证:catalog metadata 与 i18n 校验 0 error,translate --check 通过,market-i18n-real-repo 22/22;真实 Hatch 1.16.5 在隔离 HOME 下逐条跑过文档命令;standalone 隔离 HOME + mock 模型下真实 Bash 工具按文档跑通,未调用真实模型;探测脚本覆盖多种布局及含引号、反斜杠的路径。Windows 写法只对照源码。私有敏感词扫描未执行,经用户确认后合并。
12 KiB
license, name, description, version, type, risk_level, status, disable-model-invocation, tags, metadata, market
| license | name | description | version | type | risk_level | status | disable-model-invocation | tags | metadata | market | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MIT | python-runtime | Use this skill when the user needs to install, upgrade, or troubleshoot Python and pip environments. Covers four-tier fallback strategy: (1) DesireCore HTTP API for in-app installation, (2) DesireCore built-in Hatch CLI for Python version management, (3) system package managers (brew/apt/dnf/winget), (4) community pyenv as last resort. Also covers virtual environments (venv/pipx/conda), PEP 668 externally-managed errors, and import / PATH troubleshooting. Triggers include: "install python", "pip not found", "python not found", "PEP 668", "externally-managed", "venv", "virtualenv", "pipx", "conda", "miniconda", "pyenv", "hatch", "python version", "pip command not found", or any Python-related runtime error. 使用场景:用户需要 安装 Python、安装 pip、配置虚拟环境、管理多版本、 解决 PEP 668、import 失败、PATH 问题、SSL 证书错误等。 | 1.0.4 | procedural | low | enabled | true |
|
|
|
python-runtime Skill
L0: One-line Summary
When to use: The user needs to install Python / upgrade Python / switch
between multiple Python versions / configure pip / create virtual environments
(venv / pipx / conda) / troubleshoot python: command not found,
pip: command not found, PEP 668 "externally-managed", SSL certificates,
import failures, PATH anomalies, and other Python runtime issues; or when
another skill (docx / pdf / xlsx / pptx) reports "Python unavailable".
How to do it: First check whether python3 already works: DesireCore appends
a managed Python directory to its service PATH, so nothing usually needs
installing. To install or switch versions, prefer DesireCore's built-in Hatch,
executing through the four-tier fallback (HTTP API → Hatch CLI → system package
manager brew/apt/dnf/winget → community solution pyenv).
L1: Overview and Use Cases
Capability Description
Procedural skill. Before each Python environment operation, first run scripts/probe-python.sh to obtain a JSON snapshot, then follow references/decision-tree (→ ../dev-environment-setup/references/decision-tree.md) to choose a path through the four-tier fallback.
Use Cases
- "python not found" / "pip not found"
- The user requests to install/upgrade Python
- The user requests multi-version management (3.10/3.11/3.12 switching)
- Create/activate/debug virtual environments (venv/pipx/conda)
- "externally-managed-environment" (PEP 668) error
- import failures, PATH issues, SSL certificate errors
- Other skills (docx/pdf/xlsx/pptx) report Python unavailable
Core Value
- DesireCore first: Hatch + HTTP API as mandatory L1/L2, avoiding pollution of system Python
- JSON-driven decisions: the probe script outputs structured data that Claude can parse directly
- Cross-platform consistency: macOS / Linux / Windows share a unified 4-tier fallback
L2: Detailed Specification
Step 1: Environment Probe (mandatory)
bash skills/python-runtime/scripts/probe-python.sh > /tmp/py-probe.json
cat /tmp/py-probe.json | jq .
For the meaning of output fields, see ../dev-environment-setup/references/probe-snapshot.md.
Step 2: Choose an Execution Path
Decide using ../dev-environment-setup/references/decision-tree.md:
| Condition | Path |
|---|---|
system_python.path non-empty and its version is sufficient |
Use that interpreter directly, with pip through "<system_python.path>" -m pip; nothing to install |
A specific version is needed and hatch_versions lists it |
Absolute path ${DESIRECORE_ROOT}/runtime/hatch/local/<version>/python/bin/python3 (→ references/hatch-desirecore.md) |
desirecore_api is non-empty |
L1 HTTP API |
desirecore_api empty, hatch_path non-empty |
L2 Hatch CLI |
| Neither of the above | L3 system package manager (brew/apt/dnf/winget) |
| L1–L3 all fail or user explicitly requests | L4 community solution (pyenv) |
system_python is whatever PATH resolves, which may be DesireCore's managed Python: one managed version is appended after the system directories, so a system python3 wins when there is one. The Managed runtimes section of the <env> block lists the absolute path of every managed version.
This bash probe does not look for Hatch on Windows, so hatch_path stays empty there. Before falling to L3 on Windows, try the Windows path under L2.
Step 3: Execute (only the main path is shown; see references for details)
L1: HTTP API (→ references/hatch-desirecore.md)
PORT=$(cat ${DESIRECORE_ROOT}/agent-service.port)
BASE="https://127.0.0.1:${PORT}/api/runtime"
# List installable versions
curl -sk "${BASE}/python/available"
# Trigger install (asynchronous; subscribe to runtime:terminal for progress).
# version is the name from the list above, such as 3.12, not 3.12.12
curl -sk -X POST "${BASE}/python/install" \
-H "Content-Type: application/json" \
-d '{"version":"3.12"}'
# Force-refresh the cache after install completes
curl -sk -X POST "${BASE}/environment/refresh"
L2: Hatch CLI absolute path (→ references/hatch-desirecore.md)
HATCH=$(jq -r .hatch_path /tmp/py-probe.json)
export PYAPP_INSTALL_DIR_HATCH=$(jq -r .hatch_bootstrap /tmp/py-probe.json)
LOCAL="${DESIRECORE_ROOT}/runtime/hatch/local"
"$HATCH" python install 3.12 --private --dir="$LOCAL"
"$HATCH" python show --dir "$LOCAL" # List installed/installable versions
# Use the Hatch-installed Python directly
"$LOCAL/3.12/python/bin/python3" -m venv .venv
Always pass --private --dir: without them Hatch installs into its user data directory and edits .zshrc and .zprofile, and DesireCore cannot see that Python. Set PYAPP_INSTALL_DIR_HATCH on every call: DesireCore sets it only for its own calls, not for Bash, and without it the first Hatch command downloads about 45 MB and unpacks it into the user directory. The binary ships at static/toolchains/<platform>-<arch>/hatch/hatch under the app directory; runtime/hatch/hatch exists only after a manual Hatch download.
ValueError: Unknown distribution source on these commands, or an L1 install that never completes, means the source recorded by the bundled first-start import needs repairing: see "修复首启导入留下的来源记录" in references/hatch-desirecore.md.
Windows: <install dir>\static\toolchains\win32-x64\hatch\hatch.exe, with PYAPP_INSTALL_DIR_HATCH at $env:DESIRECORE_ROOT\runtime\hatch\bootstrap\<Hatch version>-win32-x64.
L3: System Package Manager
| Platform | Command |
|---|---|
| macOS | brew install python3 |
| Debian/Ubuntu | sudo apt install python3 python3-pip python3-venv |
| Fedora/RHEL | sudo dnf install python3 python3-pip |
| Arch | sudo pacman -S python python-pip |
| Windows | winget install Python.Python.3 |
L4: pyenv (→ references/pyenv-fallback.md)
Only enable when the user explicitly requests it or the above paths fail.
Step 4: Virtual Environments
For virtual environment strategy, see references/virtualenv.md:
- venv (recommended, standard library)
- pipx (global CLI tools such as black/ruff/markitdown)
- conda / miniconda (data-science scenarios)
Step 5: Troubleshooting
When errors occur, look up references/troubleshooting.md:
- "python: command not found" / "pip: command not found"
- PEP 668 "externally-managed-environment"
- SSL/TLS certificate errors
- import failures (package name vs. import name differences)
- macOS xcrun / Xcode CLI missing
- Windows PowerShell execution policy blocking scripts
- Proxy environment configuration
Important Constraints
- Never
sudo pip install: always use a virtual environment orpipx. - Refresh after modifying the environment: for L1 call
POST /api/runtime/environment/refresh; for L2/L3/L4 re-run probe. - Cross-skill collaboration: when
docx/pdf/xlsx/pptxreport "Python unavailable", fall into L1/L2 install; for office dependency lookup see../dev-environment-setup/references/office-deps.md. - Do not pollute system Python: at the project level always use venv; for global CLI use pipx.
- Never run
hatch python installwithout--private --dir: it would write to the user's shell startup files and install where DesireCore cannot see it.
References
- Decision tree:
../dev-environment-setup/references/decision-tree.md - DesireCore base:
../dev-environment-setup/references/desirecore-runtime.md - Probe protocol:
../dev-environment-setup/references/probe-snapshot.md - Office dependencies:
../dev-environment-setup/references/office-deps.md - System tools:
../dev-environment-setup/references/system-tools.md