docs: add gateway README + update plan progress (P1/P2 done, k3s blocked)
designops-gateway / build (push) Failing after 1m30s
designops-gateway / build (push) Failing after 1m30s
This commit is contained in:
@@ -34,9 +34,9 @@
|
||||
| monorepo 化 + 项目级 OKF | ✅ 完成 | 5 子项目合并 + `okf/manifest.md` + `AGENTS.md` |
|
||||
| OKF 注释(模块级 + 函数级) | ✅ 完成 | 26 模块 `@module` + 27 函数 `@skill`,53 Skill 节点落库 |
|
||||
| Gitea 仓库 + Git 基线 | ✅ 完成 | `git.osc.life/yushanhe/DesignOps`(`main` @ d4c5a8b6) |
|
||||
| **Gateway 服务开发** | 🔨 **执行中(本清单)** | `gateway/`(Node+TS+Fastify+node:sqlite) |
|
||||
| Pipeline P1–P4 实现 | ⏳ 待执行 | §5 阶段 2–5 |
|
||||
| k3s + GitOps 部署 | ⏳ 待执行 | §5 阶段 0/5B(依赖外部集群) |
|
||||
| **Gateway 服务开发** | ✅ 骨架+核心完成 | `gateway/`(config/db/bus/connectors/pipelines/routes + Dockerfile + Helm chart + 10 单测) |
|
||||
| Pipeline P1–P4 实现 | 🔨 P1/P2 完成,P3/P4 骨架 | P1 e2e 验证(.op→SVG→资产);P2 编译+单测;P3/P4 待 Penpot 联调 |
|
||||
| k3s + GitOps 部署 | ⏳ 阻塞(待外部集群) | §5 阶段 0/5B(需 SSH+kubectl/helm,当前环境无) |
|
||||
|
||||
> **技术选型微调**:D6 数据库由 `better-sqlite3`(native 编译)改为 **`node:sqlite`**(Node 24 内置 `DatabaseSync`,零依赖、免编译),其余不变。
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# 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
|
||||
```
|
||||
|
||||
## 快速开始
|
||||
|
||||
```bash
|
||||
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` | 评论落库 → 评审页 |
|
||||
Reference in New Issue
Block a user