← Về thư mục
📄 / / var / lib / containerd / io.containerd.snapshotter.v1.overlayfs / snapshots / 271 / fs / skills / openmaic / references / extend.md

Extend Or Build On OpenMAIC (二次开发)

Charter

Secondary development is a confirmation-heavy, read-before-modify guidance flow — not a generation flow. Help the user understand the existing code first, then make targeted changes. Default to not editing source under packages/@openmaic/*; consume those packages as-is. (Modifying the SDK itself is a different, heavier path — see the last section of extend-sdk.md.)

This reference takes priority over the accessCode auto-shortcut in Phase 0: if the user's intent is to extend / build on / customize OpenMAIC or consume the @openmaic/* SDK, enter this flow even when a stored accessCode exists. A returning Live Demo user who now wants to do 二开 should be routed here, not silently sent back to Live Demo.

Secondary-Development Rules

  1. Read before edit. Before changing any file, read it (and the symbols it imports) so the edit matches surrounding conventions. Do not paste large code blocks into chat — point the user at file:line entry points and let them read.
  2. Toolchain is hard-required. pnpm@10.28.0 (root packageManager), Node >=20.9 (.nvmrc pins 22). Mismatched pnpm will fail install.
  3. Forking and disabling CI are conditional, not defaults. Decide per the user's intent — see Development Environment below — instead of reflexively forking every user.

Development Environment (Same As Local Deployment)

二开的开发环境本质上就是 OpenMAIC 本地部署环境——同一套工具链、同一个仓库、同一次 pnpm install、同一套 provider key 和启动方式。所以环境搭建不要在这里另搞一套:走标准本地部署流程拿到一个能跑的实例,二开只在其上加几个增量。

在哪里拿代码(按需选,不强制 fork):

安装与启动 → 复用现有本地部署 reference,不要重写流程:clone.md(clone + pnpm install,后者会在 postinstall 构建全部 @openmaic/* 包并同步 vendor 包)、startup-modes.md(启动方式)、provider-keys.md(provider key)。

禁用 publish CI —— 注意"触发 workflow"≠"跑 publish job": fork 自带 .github/workflows/publish-packages.ymlpublish-openmaic-skill.yml,要分两层看:

所以 fork 里的 token 红叉只来自命中触发条件的 push,PR 不会产生;普通 feature 分支推送不匹配触发条件则整个 workflow 都不跑。是否禁用取决于你的 fork 工作流:会往 main 推命中触发的改动就禁用(或去掉触发),否则不用管;纯本地自用、从不 push 同样无需处理。误发版本身已被 environment + token 闸门挡死,不用担心。

改完代码后运行 / 验证: 启动方式同 startup-modes.md,key 同 provider-keys.md,用 GET {url}/api/health 验证,UI / 路由改动在浏览器确认。若你改动了 packages/@openmaic/*源码,要先重建对应包的 dist/(消费方解析的是 dist/ 不是 src/;依赖顺序 dsl → generation → storage → importer → renderer → editorpnpm install 的 postinstall 已按此顺序构建,单包可用各自 pnpm run build)。

Route To The Right Sub-Reference

Ask the user which of these they want. When unsure, offer 2–3 examples (below) and let them self-identify before loading anything.

Typical examples to help the user pick:

General Gotchas

Each is tagged with where it bites: [product/fork] (working inside the OpenMAIC repo), [SDK] (consuming packages in a separate app), or [both].