自动化与集成
把 Welight CLI 接入脚本与 CI:规则检查门禁、shell 补全与发布前的出口 IP 说明。
CLI 的输出遵循「结果走 stdout、日志走 stderr」的约定,便于管道与脚本组合;非交互环境下会自动退化为纯文本输出。
管道与脚本
# 从 stdin 读取,输出 HTML 到 stdout
cat post.md | wl render - --stdout > out.html
# 规则检查结果交给脚本处理
wl lint post.md --json | jq '.issues | length'
# 一键排版写回文件
wl layout post.md --in-place
接入 CI
wl lint、wl checkup、wl detect 都可以用退出码表达结果,适合作为流水线门禁:
wl lint post.md --fail-on high # 命中高危时退出码 1
wl checkup post.md --fail-on action # 体检有「建议处理」时退出码 1
wl detect post.md --max-ai 40 # AI + 疑似占比达到 40% 时退出码 1
密钥通过环境变量注入,例如:
- name: Welight 规则检查
env:
WELIGHT_TYPESAFE_KEY: ${{ secrets.WELIGHT_TYPESAFE_KEY }}
run: npx welight lint post.md --fail-on high
Shell 补全
安装补全后,输入 wl 后按 Tab 即可联想子命令、选项与枚举值(主题、提供商、档位、凭据名等):
# bash
eval "$(wl completion bash)" # 可写入 ~/.bashrc
# zsh
eval "$(wl completion zsh)" # 写入 ~/.zshrc(oh-my-zsh 之后)
# fish
wl completion fish | source
补全数据由隐藏命令 wl __complete 提供,无需额外依赖。
行内联想(输入时浅色候选,按 → 采用)属于 shell 行编辑器能力:
- zsh:安装 zsh-autosuggestions,并设置
ZSH_AUTOSUGGEST_STRATEGY=(completion history) - fish:原生支持(候选来自补全)
- bash:需要 ble.sh
发布与出口 IP
CLI 的发布链路不使用官方代理,默认直连 api.weixin.qq.com。微信会校验调用方公网 IP,未在白名单中时返回 40164:
- 在公众号后台「开发 → 基本配置 → IP 白名单」加入当前网络出口 IP;
- 用
curl -4 ifconfig.me查看出口 IP; - 若出口不固定,可自建反向代理并通过
--proxy或配置项proxy指定。
