关于 run-opendesign
run-opendesign 是一项用于启动 OpenDesign 预览服务器的技能,面向需要查看项目设计稿的工作流。它会检测系统、端口和可用运行时,并提供预览链接。
主要功能
- 01检测操作系统类型
- 02检查 8289 端口占用
- 03选择可用运行时
- 04后台启动预览服务器
- 05输出可点击预览链接
适用场景
- 01启动 OpenDesign 设计稿预览
- 02复用已运行的预览服务器
- 03排查端口冲突或启动失败
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ manalkaff/ opendesign --skill run-opendesign安装后在 Claude Code 中输入/run-opendesign确认已加载。
详细介绍
你即将启动 OpenDesign 预览服务器。请按顺序完成以下所有步骤。
端口
始终使用 8289。
步骤
-
检测平台。
运行:
uname -s 2>/dev/null- 如果输出以
MINGW、CYGWIN或MSYS开头,或者找不到uname,则将平台视为 Windows。 - 否则视为 POSIX(Linux / macOS / WSL)。
- 如果输出以
-
检查端口 8289 上是否已有服务器在运行。
POSIX:
lsof -ti tcp:8289- 如果没有输出,表示没有进程绑定端口——继续执行步骤 3。
- 如果返回 PID,表示有进程绑定到 :8289。
Windows(cmd/PowerShell):
netstat -ano | findstr LISTENING | findstr :8289- 如果没有输出,表示没有进程绑定端口——继续执行步骤 3。
- 如果有输出,表示有进程绑定到 :8289。
如果任一平台上有进程绑定端口,请探测它是否为 OpenDesign 服务器:
curl -sf -o /dev/null -w "%{http_code}" http://localhost:8289/opendesign/index.html- 如果状态码为
200,则 OpenDesign 服务器已在运行。跳至步骤 5。 - 否则,告知用户:
端口 8289 正被另一个进程占用。请释放该端口后重试。 然后停止。
-
**检测可用的运行时。**按以下顺序检查:
POSIX:
python3 --version 2>/dev/null || python --version 2>/dev/null || node --version 2>/dev/nullWindows:
python --version 2>$null; if ($LASTEXITCODE -ne 0) { python3 --version 2>$null }; if ($LASTEXITCODE -ne 0) { node --version 2>$null }优先级顺序(两个平台均适用):
- POSIX:
python3→python→node - Windows:
python→python3→node(Windows 发行版使用python而非python3) - 如果都找不到 → 告知用户:"无法启动预览服务器——python、python3 和 node 均不可用。请手动打开
./opendesign/index.html或安装 Python。"然后停止。
- POSIX:
-
在后台启动服务器,从项目根目录提供服务(而不是从
./opendesign/提供服务)。POSIX — 先获取项目根目录的绝对路径:
PROJECT_ROOT=$(pwd)然后启动:
- python3:
python3 -m http.server 8289 --directory "$PROJECT_ROOT" & - python:
python -m http.server 8289 --directory "$PROJECT_ROOT" & - node:
npx --yes serve -l 8289 "$PROJECT_ROOT" &
Windows — 先
cd到项目根目录(Python 3.7+ 支持--directory标志,但cd是跨版本最稳妥的方式),然后启动:- python:
Start-Process python -ArgumentList '-m','http.server','8289' -WorkingDirectory (Get-Location) -WindowStyle Hidden - python3:
Start-Process python3 -ArgumentList '-m','http.server','8289' -WorkingDirectory (Get-Location) -WindowStyle Hidden - node:
Start-Process npx -ArgumentList '--yes','serve','-l','8289',(Get-Location) -WindowStyle Hidden
启动后等待 1–2 秒,然后使用步骤 2 中检测到的平台对应的相同检查,确认端口现在已绑定。如果等待后仍没有进程绑定端口,请报告:"服务器启动失败。请尝试在项目根目录中手动运行
python -m http.server 8289。"然后停止。 - python3:
-
向用户打印可点击的链接:
OpenDesign 查看器已启动:http://localhost:8289/opendesign/
侧边栏列出了所有模型图。点击任意文件即可在 iframe 中预览。
评论
支持 Markdown