最新更新:release v1.2.1

模块化架构,面向

DMA 告诉开发者和智能体前端代码应放在哪里,并通过 linter、CLI 和 CI 校验模块边界。

快速开始
什么是 DMA

Agent

正在阅读 derived-modular skill

layers · imports · public

+3 1 features/checkout/public/api.ts

src/
app
features
catalog
checkoutM
public
api.tsM
services
shared
terminal

$npx @derived-modular/cli check .

已扫描 12 个模块

1 个信号 · stage-growth · checkout

ci.yml
  • Install
  • dma check
  • Deploy

src/ 中的四条边界

没有凭感觉建的 components、utils 之类的目录。目录树就是规则手册,linter 和 CI 负责执行。导入是单向的:下层永远不导入上层。

src/

├─ app/

入口:应用启动的路由和页面。

├─ features/

由 app 挂载的产品流程:catalog、checkout。没有来自其他模块的入边;可以导入 services 和 shared。

├─ services/

其他模块依赖的共享产品场景。当第二个模块需要相同代码时通过 promotion 出现——例如 catalog 和 checkout 都导入 services/cart。

└─ shared/

可移植的辅助代码和 UI:日期、按钮、HTTP 客户端。

布局随产品一起成长

第一天不需要完整的目录树。从一个文件开始,随着代码增长再添加结构。

features/
features
checkout.tsx

文件模块

从单个文件 checkout.tsx 开始。这个模块同时也包含购物车逻辑。

边界是被校验的,而不是被争论的

丰富的工具链不会让你出错:linter、智能体和 CLI 执行的是同一套规则。

features/checkout/model.ts

Problems

import { getCatalog } from "@/features/catalog/public/api";

ESLint

feature-to-feature

checkout → catalog/public/api.ts

terminal

$ npx @derived-modular/cli check .

feature-to-feature

checkout → catalog/public/api.ts

同一张导入图。编辑器和 CI 里的结果一致。

规则写在代码里,而不是聊天里

安装 CLI,用一条命令创建目录结构,并自动校验架构——在编辑器、智能体和 CI 中都是同一套规则。

$ npm i -D @derived-modular/cli && npx @derived-modular/cli init .
快速开始
什么是 DMA