Skip to content

fix: add Python build detection, correct stale /opsx:new references#18

Open
AnnanRen wants to merge 2 commits into
rpamis:masterfrom
AnnanRen:fix/python-build-and-docs
Open

fix: add Python build detection, correct stale /opsx:new references#18
AnnanRen wants to merge 2 commits into
rpamis:masterfrom
AnnanRen:fix/python-build-and-docs

Conversation

@AnnanRen
Copy link
Copy Markdown

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 unless build_command is manually configured.

This PR adds Python detection via python -m compileall . -q, which checks both syntax and import resolution (unlike py_compile which only checks syntax).

2. Stale /opsx:new references

/opsx:new no 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

File Change
assets/skills/comet/scripts/comet-guard.sh Add Python detection in build_passes()
assets/skills/comet/SKILL.md /opsx:newopenspec-new-change / openspec-propose skill
assets/skills-zh/comet/SKILL.md Same (ZH)
assets/skills/comet-build/SKILL.md /opsx:new/comet-open
assets/skills-zh/comet-build/SKILL.md Same (ZH)

🤖 Generated with Claude Code

- 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>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread assets/skills/comet/scripts/comet-guard.sh Outdated
Comment thread assets/skills/comet/scripts/comet-guard.sh Outdated
- 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里建议做一个最小修正:保留 Python fallback,但把它定位为 Python 的“字节码编译检查”,不要描述成完整 build 或 import/dependency 检查。

当前 python -m compileall . -q 能保证的是:仓库里的 Python 文件至少能被编译成 bytecode,也就是基本语法层面能过。它不能保证第三方依赖存在,也不能保证项目真正可运行,所以 PR 描述里的 “checks both syntax and import resolution” 需要改掉。

另外建议稍微收窄扫描范围,避免 compileall . 扫到虚拟环境或构建产物。最小可接受修改是排除常见目录,例如 .venvvenv__pycache__builddist

需要补的测试:

  • pyproject.toml / requirements.txt.py 文件语法正确时,guard 通过
  • 有 Python marker 但 .py 语法错误时,guard 失败
  • .venv / venv 里的坏 .py 不影响 guard
  • 已配置 build_command 时优先执行 build_command,不走 Python fallback

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.

2 participants