memobird-edge-print-skill
v0.3.1
Published
Codex skill and CLI for Memobird text and image printing through live sessions or .env-based automation.
Downloads
261
Maintainers
Readme
Memobird Edge Print Skill
默认英文文档:README.md
安装
作为 CLI 使用
不安装直接运行:
npx memobird-edge-print-skill --help全局安装:
npm install -g memobird-edge-print-skill全局安装后,这两个命令都可以使用:
memobird-edge-print-skill --help
memobird-print --help用 npx 安装到 Codex
npx -p memobird-edge-print-skill memobird-edge-print-install --target codex强制覆盖安装:
npx -p memobird-edge-print-skill memobird-edge-print-install --target codex --force用 npx 安装到 Claude Code
npx -p memobird-edge-print-skill memobird-edge-print-install --target claude强制覆盖安装:
npx -p memobird-edge-print-skill memobird-edge-print-install --target claude --force用 npx 安装到自定义目录
npx -p memobird-edge-print-skill memobird-edge-print-install \
--dest "$HOME/.my-agent/skills/memobird-edge-print-skill"用 git clone 一键安装到 Codex
git clone https://github.com/YiWang24/memobird-edge-print-skill.git \
"${CODEX_HOME:-$HOME/.codex}/skills/memobird-edge-print-skill"用 git clone 一键安装到 Claude Code
git clone https://github.com/YiWang24/memobird-edge-print-skill.git \
"$HOME/.claude/commands/memobird-edge-print-skill"用 sparse checkout 做轻量安装
如果你只想拿这个 skill 目录,不想拉完整历史:
git clone --depth=1 --filter=blob:none --sparse \
https://github.com/YiWang24/memobird-edge-print-skill.git \
/tmp/memobird-edge-print-skill && \
git -C /tmp/memobird-edge-print-skill sparse-checkout set . && \
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills" && \
cp -R /tmp/memobird-edge-print-skill \
"${CODEX_HOME:-$HOME/.codex}/skills/memobird-edge-print-skill"npm 自动发布
仓库已经包含 GitHub Actions 工作流:.github/workflows/publish-npm.yml
工作流行为:
- 每次 push 到
main时触发 - 从
package.json读取包名和版本 - 如果当前版本还没发过,就直接发布
- 如果当前版本已经存在于 npm,就自动把 patch 版本加一
- 发布成功后,会把更新后的
package.json自动提交回main - 已开启 GitHub OIDC 所需的
id-token: write - 在 npm 侧完成 trusted publishing 绑定后,可以不依赖长期 token 发布
这意味着普通代码更新推到 main 后,也可以自动产出新的 npm 版本,不需要每次手动改版本号。
认证方式
- 首选:npm trusted publishing + GitHub Actions OIDC
- 兼容兜底:仓库 secret
NPM_TOKEN
这个仓库的 workflow 现在已经支持 OIDC。只要在 npm 包侧把 trusted publisher 绑定到当前仓库和 workflow,npm publish 就可以不再依赖长期 token。
在 npm 侧绑定完成之前,workflow 仍然可以继续通过 NPM_TOKEN 发布,避免发布链中断。
一次性配置 trusted publishing
需要绑定的对象是:
- 包名:
memobird-edge-print-skill - 仓库:
YiWang24/memobird-edge-print-skill - workflow 文件:
publish-npm.yml
如果你本机当前的 npm 登录态支持交互式 2FA,可以直接执行:
npm trust github memobird-edge-print-skill \
--repo YiWang24/memobird-edge-print-skill \
--file publish-npm.yml \
--yes如果本机 npm 登录态不支持 npm trust,就去 npm 网页端配置:
- 打开这个包的 npm settings。
- 进入 trusted publishing / trusted publisher 相关设置。
- 添加 GitHub Actions,仓库填
YiWang24/memobird-edge-print-skill。 - workflow 文件名填
publish-npm.yml。
配置完成后,如果你想彻底切成无 token 模式,可以再删除仓库里的 NPM_TOKEN secret。
推荐发布流程
- 修改代码和文档。
- 合并或 push 到
main。 - 等 GitHub Actions 自动发布新版本。
- 如果当前版本已经被发布过,workflow 会自动补一个新的 patch 版本并回写到仓库。
如何控制版本号
- 日常小改动不需要手动处理,workflow 会在需要时自动递增 patch 版本。
- 如果你要发一个明确的 minor / major 版本,可以在合并前先手动修改
package.json,workflow 会优先发布你指定的版本。
安全说明
npm 官方当前更推荐 GitHub Actions OIDC 的 trusted publishing。这个仓库现在已经支持这种模式。参考:
面向人类使用者的文档,适用于 macOS、Linux 和 Windows。
项目概览
这个仓库支持两条不同的使用路径,也支持两种不同的打印链路:
- 人类路径: 自己获取 Memobird 所需变量,写入 env 文件,然后跨平台运行脚本。
- Agent 路径: 让 agent 自己分析 Memobird Web 请求流程,动态取值,并在环境支持时自动生成本地 env 片段。
如果目标是跨平台和可控性,优先使用人类的 env 路径。
当前支持的打印模式:
- 通过
PrintPaper发送文本纸条 - 通过
https://pdf.memobird.cn/print/imageFromFile打印单张图片
平台支持
| 模式 | macOS | Linux | Windows |
| --- | --- | --- | --- |
| 手动 env + --dry-run | 支持 | 支持 | 支持 |
| 手动 env + 真实打印 | 支持 | 支持 | 支持 |
| 自动复用本机 Edge 登录态 | 支持 | 暂不支持 | 暂不支持 |
说明:
- 只要你已经拿到了所需 env 变量,脚本就可以跨平台工作。
- 自动读取浏览器登录态目前仅针对 macOS + Microsoft Edge。
快速开始
1. 复制 env 模板
macOS / Linux:
cp .env.example .env.localWindows PowerShell:
Copy-Item .env.example .env.localWindows CMD:
copy .env.example .env.local2. 填入自己的变量
编辑 .env.local,把占位值替换成你自己的真实值。
3. 先做预览,不实际打印
node scripts/memobird-print.mjs \
--env-file .env.local \
--dry-run \
--text "Hello from Memobird"4. 再正式打印
node scripts/memobird-print.mjs \
--env-file .env.local \
--text "正式打印内容"5. 先预览图片打印
node scripts/memobird-print.mjs \
--env-file .env.local \
--image ./photo.png \
--dry-run6. 再正式打印图片
node scripts/memobird-print.mjs \
--env-file .env.local \
--image ./photo.png需要哪些变量
跨平台 env 路径主要使用这些变量:
MEMOBIRD_LOGININFO登录 cookieMEMOBIRD_FROM_USER_NAMEPrintPaper里的fromUserNameMEMOBIRD_TO_USER_ID包装后的toUserIdMEMOBIRD_TO_USER_NAME目标显示名MEMOBIRD_PRINTER_GUID包装后的guidListMEMOBIRD_PRINTER_TYPE打印机的数字smartType,图片打印在不走动态解析时必须提供MEMOBIRD_PRINTER_NAME可选,仅用于本地显示
真实打印时,最常见的最小集合是:
MEMOBIRD_LOGININFOMEMOBIRD_FROM_USER_NAMEMEMOBIRD_TO_USER_IDMEMOBIRD_TO_USER_NAMEMEMOBIRD_PRINTER_GUID
如果你想在没有动态会话解析的情况下打印图片,最小集合是:
MEMOBIRD_PRINTER_GUIDMEMOBIRD_PRINTER_TYPE
人类如何手动获取这些变量
获取 MEMOBIRD_LOGININFO
在 Microsoft Edge 中:
- 打开
https://w.memobird.cn/cn/w/mailList.html - 打开 DevTools
- 进入
Application - 找到
Cookies - 选择
https://w.memobird.cn - 找到
logininfo - 复制它的值
这个值必须保密,不要提交到仓库。
获取 MEMOBIRD_TO_USER_ID、MEMOBIRD_TO_USER_NAME、MEMOBIRD_PRINTER_GUID、MEMOBIRD_PRINTER_TYPE
常见有两种方式:
方式 A:从 PrintPaper 请求里直接复制
- 在 Memobird 网页发一条测试纸条
- 打开 DevTools 的
Network - 找到
PrintPaper - 复制:
toUserIdtoUserNameguidList- 如果你要手动复现图片打印,还要记下打印机数字
type
方式 B:让脚本在本地自动解析后导出
如果当前环境支持自动模式:
node scripts/memobird-print.mjs --list --show-ids
node scripts/memobird-print.mjs --show-ids --emit-env第二条命令会输出一个 .env 风格的变量块,可以直接复制到 .env.local。
另外,--list 的输出本身也会显示每台打印机的数字 type,手动准备图片打印时,这个值就是 MEMOBIRD_PRINTER_TYPE。
.env 文件方式
为了适配不同系统和不同 shell,本仓库统一使用普通 .env 文件格式。
如果你要跨 shell 传多行文本,优先使用 --file note.txt,不要依赖 shell 自己的换行语法。
.env.local 示例
MEMOBIRD_LOGININFO="your-logininfo-cookie"
MEMOBIRD_FROM_USER_NAME="Your Name"
MEMOBIRD_TO_USER_ID="your-wrapped-toUserId"
MEMOBIRD_TO_USER_NAME="我"
MEMOBIRD_PRINTER_GUID="your-wrapped-guidList"
MEMOBIRD_PRINTER_TYPE="206"
MEMOBIRD_PRINTER_NAME="My Memobird"使用方式
node scripts/memobird-print.mjs --env-file .env.local --dry-run --text "hello"
node scripts/memobird-print.mjs --env-file .env.local --text "real print"
node scripts/memobird-print.mjs --env-file .env.local --image ./photo.png --dry-run
node scripts/memobird-print.mjs --env-file .env.local --image ./photo.png脚本能力
主脚本是 scripts/memobird-print.mjs。
现在它同时支持文本纸条和图片打印。
常用命令
查看当前 note 目标和打印机:
node scripts/memobird-print.mjs --list显示真实包装 ID:
node scripts/memobird-print.mjs --list --show-ids导出可直接粘贴的 env 变量块:
node scripts/memobird-print.mjs --show-ids --emit-env通过 env 文件做预览:
node scripts/memobird-print.mjs \
--env-file .env.local \
--dry-run \
--text "hello"通过 env 文件真实打印:
node scripts/memobird-print.mjs \
--env-file .env.local \
--text "hello"从文件读取纸条内容:
node scripts/memobird-print.mjs \
--env-file .env.local \
--file ./note.txt预览图片打印:
node scripts/memobird-print.mjs \
--env-file .env.local \
--image ./photo.png \
--dry-run正式打印图片:
node scripts/memobird-print.mjs \
--env-file .env.local \
--image ./photo.png \
--paper-type roll \
--image-print-type text重要参数
--env-file执行前加载.env风格文件--dry-run只预览请求,不实际发送--list动态解析并列出当前可用 note 目标和打印机--emit-env输出一个可直接写入.env.local的变量块--show-ids显示真实包装 ID,不再打码--image通过图片打印服务发送本地图片文件--printer-type图片模式下手动提供打印机数字smartType--paper-type图片模式下选择roll或folded--image-print-type图片模式下选择text或rich--width自动换行宽度,默认32--no-wrap关闭自动换行
图片打印链路
图片打印并不走 PrintPaper。
网页端实际会向下面这个地址发送 multipart 表单:
https://pdf.memobird.cn/print/imageFromFile
关键字段包括:
filesmartGuidtypeprintTypepaperTypeserverType
这也是为什么图片模式除了 smartGuid 之外,还需要打印机的 smartType。
自动模式
如果环境支持,脚本可以自动复用本机 Edge 登录态。
当前支持的自动模式:
- macOS
- Microsoft Edge
- 本机已登录 Memobird Web
这个模式适合:
- 逆向分析
- 获取当前有效包装 ID
- 用
--emit-env生成本地.env.local
隐私与安全
- 仓库本身不包含真实 cookie 或真实包装 ID
- 脚本默认会打码包装 ID
--emit-env必须和--show-ids一起使用,因为它会输出真实值.env.local只应该保存在本地,不要提交- README 主路径面向人类,agent 的抓包相关说明折叠在文末
- 图片打印会把你选择的本地图片上传到
pdf.memobird.cn
排错建议
Could not resolve logininfo
可能原因:
- 没有提供
MEMOBIRD_LOGININFO - 当前环境不支持自动读取本机 Edge 会话
- Edge 没有登录 Memobird Web
--dry-run 正常,但真实打印失败
优先检查:
MEMOBIRD_LOGININFO是否仍然有效MEMOBIRD_TO_USER_ID和MEMOBIRD_PRINTER_GUID是否仍然对应当前账号状态- 打印机是否在线
想重新生成 env 文件
如果自动模式可用:
node scripts/memobird-print.mjs --show-ids --emit-env > .env.local.new
mv .env.local.new .env.local然后把 .env.local 留在本地私有环境中。
这一节默认折叠,因为主 README 路径是给人类使用者看的。
Agent 入口:
推荐 agent 流程:
- 先读前端源码
- 再用浏览器抓包确认行为
- 动态解析 fresh wrapped IDs,而不是把抓包值写死
- 环境支持时,用
--emit-env生成本地 env 配置
