Files
DesignOps Agent 1f9f285435
designops-gateway / build (push) Failing after 2s
feat(w5): P1 把 .op 图形写进 Penpot(映射 + 增量 add/mod/del)+ 镜像 0.1.16
- src/convert/op-to-penpot.ts:.op → Penpot shape 模型
  · stableUuid:shape/page id 由 source+page+路径派生 → 重跑同一 .op 命中同一对象(否则每次保存都追加一份副本)
  · collectShapes:frame/group/rect/ellipse/text 映射,text 生成 Penpot content 树
    (root→paragraph-set→paragraph→text)
  · 不支持的节点类型记入 skipped 并带原因,**不**用相似图元顶替
  · 顶层非 frame 图元包一个生成 frame(exporter 只渲染 frame)
  · planShapeSync:按字段快照做 diff → add-obj / mod-obj(仅变更字段) / del-obj
- P1 管道:SVG 资产之后 push 图形;每个 .op 一个 Penpot 页面;映射持久化到 /data/penpot-shapes.json
  · 无变化时仍 success 但上报 add=0 mod=0 del=0(跑过≠推了东西)
- penpot 连接器新增 rpcTransit(发预编码 transit 体,共享 401 重试)
- OpNode/Fill 统一为单一模型(op-to-svg 导出,op-to-penpot 复用)
- 测试 68/68(12 例映射/幂等/字段级 diff)
2026-09-28 04:51:38 +08:00
..

DesignOps Gateway

DesignOps 中台的统一网关服务:监听 OpenPencil / Penpot / Excalidraw 事件,编排四条 pipeline(设计同步 / 令牌编译 / 原型发布 / 评审聚合)。

技术栈

  • Node.js ≥ 24 + TypeScript(ESM / NodeNext)
  • Fastify 5(HTTP 服务)+ node:sqlite(内置零依赖数据库)+ chokidar(文件监听)+ zod(配置校验)

目录结构

gateway/
├── src/
│   ├── index.ts              # 入口:装配连接器 + pipeline + 路由
│   ├── config.ts             # 环境变量加载(zod 校验)
│   ├── db.ts                 # SQLite schema(events/assets/comments/pipelines)
│   ├── bus.ts                # 进程内事件总线 + 审计落库
│   ├── connectors/           # OpenPencil MCP / Penpot RPC 客户端
│   ├── store/asset-store.ts  # SHA-256 内容寻址资产存储
│   ├── convert/op-to-svg.ts  # .op → SVG 转换器
│   ├── compile/dtcg-compile.ts # DTCG → CSS/JS 编译器
│   ├── pipelines/            # P1/P2/P3 管道
│   └── routes/               # /healthz /webhooks /assets /review
├── test/                     # 单元测试(node --test)
├── Dockerfile                # 多阶段构建(node:24-alpine + op 二进制)
└── package.json

快速开始

cp .env.example .env        # 填入 PENPOT_TOKEN 等
pnpm install
pnpm build                 # tsc 编译 → dist/
pnpm test                  # 单元测试(node --test)
node dist/index.js         # 启动(:8080)

API 路由

路由 说明
GET /healthz 健康检查
POST /webhooks/:source 统一 Webhook 接收(penpot/excalidraw/openpencil)
GET /assets/:sha256 按内容哈希取资产(MIME 按 kind)
GET /review 评审页(资产预览 + 评论列表)
POST /review/comments 提交评论

环境变量

见 .env.example。核心:PENPOT_TOKEN(Penpot 访问令牌)、OPENPENCIL_MCP_URL、WATCH_DIR(.op 监听目录)。

四条 pipeline

管道 触发 动作
P1 设计同步 chokidar 监听 .op .op→SVG → 资产存储
P2 令牌编译 Penpot webhook update-file DTCG → tokens.css/tokens.json
P3 原型发布 Penpot webhook set-file-shared 导出 SVG → 资产存储
P4 评审聚合 POST /review/comments 评论落库 → 评审页