@pn-data/ai-translation
v0.0.1
Published
Cursor Agent Skill for pn_mid_v2 AI translation service (OpenClaw proxy)
Downloads
104
Maintainers
Readme
PN 中台 AI 翻译服务
Cursor Agent Skill — 通过 OpenClaw 协议访问 AI 翻译服务(上游 t1.17995api.net):拉取待翻译条目(next)与回写翻译结果(writeback)。支持脚本直接请求(不经过中台)或经 pn_mid_v2 中台代理(SkillManager::aiTranslation)。
Skill 版本:与
ai-translation/SKILL.md顶部及package.json的version一致。
完整约定与示例见ai-translation/SKILL.md。
何时使用
- 用户提到:翻译服务、OpenClaw、拉取待翻译、回写翻译、ai-translation、AI 翻译接口
- 需要调用 next(拉取一条待翻译)或 writeback(回写译文/错误)
脚本直接调用(不经过中台)
本 Skill 提供 openclaw_cli.py,直接请求翻译服务(默认 https://t1.17995api.net),不经过 pn_mid_v2,无需 token。
脚本路径:<SKILL_DIR>/openclaw_cli.py(本仓库为 .cursor/skills/ai-translation/ai-translation/openclaw_cli.py)。
命令行概要
# 拉取一条待翻译(方式 A:project_id + task_id)
python3 <SKILL_DIR>/openclaw_cli.py next --project-id=1001 --task-id=<task_id>
# 拉取(方式 B:完整任务参数 JSON 文件)
python3 <SKILL_DIR>/openclaw_cli.py next --body-file=task.json
# 回写译文
python3 <SKILL_DIR>/openclaw_cli.py writeback --project-id=1001 --task-id=<task_id> \
--sheet-row-num=18 --original="原文" --job-token=<token> \
--translations='{"en":"Welcome to Cloudrealm."}'
# 错误回写
python3 <SKILL_DIR>/openclaw_cli.py writeback ... --error="术语冲突,需人工确认。"选项
| 选项 | 说明 |
|------|------|
| --base-url=URL | 翻译服务根地址;或环境变量 OPENCLAW_BASE_URL |
| --json | 输出原始 JSON |
经中台代理
- 入口:
POST /service/ai_translation或POST /service/3037 - 请求体:JSON,必传
action(next|writeback),其余字段按 OpenClaw 文档原样透传
| action | 说明 |
|-------------|--------------------|
| next | 拉取一条待翻译条目 |
| writeback | 回写翻译结果或错误 |
安装
npm install @pn-data/ai-translation
# 将 node_modules/@pn-data/ai-translation/ 下 ai-translation/ 复制或链接到 .cursor/skills/ai-translation/安装后 Cursor 会读取 .cursor/skills/ai-translation/ai-translation/SKILL.md 作为 Skill 内容。
在 Cursor 中触发
- 「调用翻译服务拉取一条待翻译」
- 「用 ai-translation 回写翻译结果」
- 「OpenClaw next / writeback」
API
- 脚本直连:默认
https://t1.17995api.net,POST /openclaw/next、POST /openclaw/writeback - 经中台:
https://pnv2.17995api.net(或当前中台域名)+/service/ai_translation,body 含action及 OpenClaw 约定字段
更新 Skill
npm view @pn-data/ai-translation version --registry https://registry.npmjs.org/若与 ai-translation/SKILL.md 顶部版本号不一致,则更新本 Skill 后重新读取 ai-translation/SKILL.md。
依赖
- Python 3.9+(脚本仅用标准库,无第三方依赖)
License
MIT
