Skip to content

feat: add safe pt-snap setup skill - #83

Merged
codeasier merged 3 commits into
mainfrom
feat/skills-setup
Aug 6, 2026
Merged

codeasier merged 3 commits into
mainfrom
feat/skills-setup

Conversation

@codeasier

Copy link
Copy Markdown
Owner

Summary

  • add a setup skill for verifying and installing pt-snap-cli in the selected Python environment
  • verify that the resolved pt-snap executable belongs to the selected interpreter
  • support python3 fallback and explicit install/verification outcome states

Testing

  • git diff --check
  • documentation-only change; no runtime tests required

@codeasier

Copy link
Copy Markdown
Owner Author

交叉模型审阅结果

范围:skills/pt-snap-setup/SKILL.md(+173/-0,base 717e3ca → head d08db8d);git diff --check 通过,6 项 GitHub 检查全部通过。

High:对 sys.executable 做 realpath 规范化会逃逸当前激活的虚拟环境

  • 位置:skills/pt-snap-setup/SKILL.md:38(命令)、:40(要求后续所有 Python/pip 命令使用该规范化路径),并影响 :87、:90 的安装命令以及 Step 2(:58-62)的归属判定。
  • 触发条件:用户处于激活的 POSIX venv 中(本技能的核心使用场景)。venv/bin/python 是指向基础解释器的符号链接。
  • 影响:os.path.realpath(sys.executable) 会把激活的 venv 解析成基础解释器路径。CPython 依据被调用二进制所在目录(pyvenv.cfg)判断环境,因此后续所有 "<python_executable>" -m pip install ... 都会安装到基础/系统环境而非激活的 venv,违反本 PR 的核心意图("在当前 Python 环境中安装")以及 SKILL.md:155 的守卫原则 "Do not silently switch the user's environment"。在 PEP 668 发行版(Ubuntu 23.04+、Debian 12+)上会以 externally-managed-environment 失败;在 Homebrew Python 上会污染全局环境。
  • 复现证据:创建 venv 后,venv 候选解释器的 sys.prefix 为 venv 路径;而调用其 realpath 后,sys.prefix 变为基础环境路径。
  • 修复方向:执行 Python/pip 命令时保留未解析的 sys.executable;仅在 Step 2 的归属比较中对两侧(shebang 解释器与 sys.executable)各自 realpath。

有意义的测试缺口

无任何可执行测试创建真实 venv 并演练技能中记录的"解释器选择 + 归属验证"流程;此类测试本可捕获上述回归(仓库已有 tests/test_governance.py 等治理测试先例)。

@codeasier

Copy link
Copy Markdown
Owner Author

已在 da24329 修复:保留未规范化的 sys.executable 用于 Python/pip,仅在 CLI 归属比较时使用 realpath;新增真实 POSIX venv 回归测试。验证:15 passed,ruff/black/diff-check 通过。

@codeasier
codeasier merged commit 5d13620 into main Aug 6, 2026
6 checks passed
@codeasier
codeasier deleted the feat/skills-setup branch October 3, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant