fix: add Python build detection, correct stale /opsx:new references#18
fix: add Python build detection, correct stale /opsx:new references#18AnnanRen wants to merge 2 commits into
Conversation
- Add Python project detection in build_passes() via compileall - Replace all /opsx:new references with actual comet/openspec skill names across EN and ZH skill docs Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the documentation across several SKILL.md files to replace references to /opsx:new with /comet-open and specific openspec skills, ensuring that .comet.yaml state files are correctly initialized. Additionally, it introduces a Python build guard in comet-guard.sh using compileall. Feedback was provided to clarify that compileall only performs syntax checks rather than full import resolution, and to recommend gating the Python detection logic behind project marker files like requirements.txt or pyproject.toml to avoid false positives in non-Python environments.
- Gate Python detection behind project markers (pyproject.toml, setup.py, setup.cfg, requirements.txt) to prevent false positives on non-Python projects that happen to have Python installed - Correct comment: compileall checks syntax, not external import resolution Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
| if command -v python3 >/dev/null 2>&1 || command -v python >/dev/null 2>&1; then | ||
| local py_cmd | ||
| py_cmd="$(command -v python3 >/dev/null 2>&1 && echo 'python3' || echo 'python')" | ||
| "$py_cmd" -m compileall . -q |
There was a problem hiding this comment.
这里建议做一个最小修正:保留 Python fallback,但把它定位为 Python 的“字节码编译检查”,不要描述成完整 build 或 import/dependency 检查。
当前 python -m compileall . -q 能保证的是:仓库里的 Python 文件至少能被编译成 bytecode,也就是基本语法层面能过。它不能保证第三方依赖存在,也不能保证项目真正可运行,所以 PR 描述里的 “checks both syntax and import resolution” 需要改掉。
另外建议稍微收窄扫描范围,避免 compileall . 扫到虚拟环境或构建产物。最小可接受修改是排除常见目录,例如 .venv、venv、__pycache__、build、dist。
需要补的测试:
- 有
pyproject.toml/requirements.txt且.py文件语法正确时,guard 通过 - 有 Python marker 但
.py语法错误时,guard 失败 .venv/venv里的坏.py不影响 guard- 已配置
build_command时优先执行build_command,不走 Python fallback
Summary
Two fixes from real-world usage:
1. Python project build detection (scripts/comet-guard.sh)
build_passes()currently only recognizes JS (package.json), Java (pom.xml), and Rust (Cargo.toml) projects. Python projects always fail the guard check unlessbuild_commandis manually configured.This PR adds Python detection via
python -m compileall . -q, which checks both syntax and import resolution (unlikepy_compilewhich only checks syntax).2. Stale
/opsx:newreferences/opsx:newno longer exists as an installable workflow in openspec v1.3.1. Updated all references across EN and ZH docs to point to the actual skill names used by comet-open (openspec-new-change/openspec-propose).Files changed
assets/skills/comet/scripts/comet-guard.shbuild_passes()assets/skills/comet/SKILL.md/opsx:new→openspec-new-change/openspec-proposeskillassets/skills-zh/comet/SKILL.mdassets/skills/comet-build/SKILL.md/opsx:new→/comet-openassets/skills-zh/comet-build/SKILL.md🤖 Generated with Claude Code