Skip to content

fix(plugin): cross-platform python launcher + absolute script paths#12

Merged
qxbyte merged 1 commit into
mainfrom
fix/cross-platform-python-launcher
May 18, 2026
Merged

fix(plugin): cross-platform python launcher + absolute script paths#12
qxbyte merged 1 commit into
mainfrom
fix/cross-platform-python-launcher

Conversation

@qxbyte
Copy link
Copy Markdown
Owner

@qxbyte qxbyte commented May 18, 2026

Summary

修复跨平台安装后插件无法在 Windows 上加载和运行的问题。

  • 根因 1: hooks.json 硬编码 python3,Windows 上没有该命令,hook 加载即报错。
  • 根因 2: SKILL.md / references / commands 里命令样例写成 python3 scripts/xxx.py(无 ${CLAUDE_PLUGIN_ROOT}),模型在 skill 目录上下文解析时拼成不存在的 skills/specode/scripts/...

Changes

  • 新增 plugins/specode/scripts/run.sh + run.cmd python launcher:依次探测 python3 → python → py -3,找到任一即 exec 转发参数。
  • hooks/hooks.json:6 个入口改走 launcher,并给 ${CLAUDE_PLUGIN_ROOT} 加引号防空格断词。
  • spec_guard.py + task_swarm.py:内部 emit 给模型执行的命令字符串(6 处)统一为 launcher + ${CLAUDE_PLUGIN_ROOT} 绝对路径。
  • 文档:SKILL.md + references/{commands,workflow,obsidian,iteration,prompts}.md + commands/task-swarm.md 里所有 python3 scripts/... 改为 sh ${CLAUDE_PLUGIN_ROOT}/scripts/run.sh ${CLAUDE_PLUGIN_ROOT}/scripts/...

Test plan

  • /bin/sh 跑 launcher 兼容
  • 模拟无 python3 仅有 python 的环境 → launcher 命中 fallback
  • 三种解释器都缺失 → 报清晰错误 + exit 127
  • hooks.json 6 个入口逐条 replay → 全部 exit 0
  • 含空格的插件路径 → hook 入口仍可执行(加引号验证)
  • task_swarm.py init 后 emit 的 next 命令字符串 eval 可直接执行
  • pytest plugins/specode/tests 135/135 passed
  • Windows native 实测(待 PR 合并后用户验证)

Windows hosts (e.g. CodeBuddy on Windows) ship `python` / `py`, not
`python3` — hooks failed to load and `python3 scripts/xxx.py` samples
in SKILL/references were resolved against the skill directory, producing
paths like `skills/specode/scripts/spec_vault.py` that don't exist.

Changes:
- scripts/run.sh + run.cmd: probe python3 → python → py -3, exec args
- hooks/hooks.json: route every entry through run.sh + quote ${ROOT}
- spec_guard.py / task_swarm.py: emit launcher-form commands with
  ${CLAUDE_PLUGIN_ROOT}-prefixed script paths
- SKILL.md + references/{commands,workflow,obsidian,iteration,prompts}.md
  + commands/task-swarm.md: replace `python3 scripts/...` with
  `sh ${CLAUDE_PLUGIN_ROOT}/scripts/run.sh ${CLAUDE_PLUGIN_ROOT}/scripts/...`
@pronto-qxbyte
Copy link
Copy Markdown

pronto-qxbyte Bot commented May 18, 2026

PRonto 评审

PR: #12 fix(plugin): cross-platform python launcher + absolute script paths
作者: @qxbyte
分支: fix/cross-platform-python-launcher -> main

概览

通过引入 launcher 脚本和绝对路径,提升了跨平台兼容性,改动清晰合理。

问题清单

  • 🟢 P2 plugins/specode/scripts/run.sh:1 — shebang 使用 sh 而非 bash,但注释中提及 bash/zsh,建议统一为 #!/usr/bin/env bash 以确保功能完整。

建议改进

  • 考虑在 run.sh 中添加 set -e 以在命令失败时提前退出。

PRonto via deepseek-chat

@qxbyte qxbyte merged commit ed9953f into main May 18, 2026
@qxbyte qxbyte deleted the fix/cross-platform-python-launcher branch May 18, 2026 03:33
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