@loom-framework/core 0.1.0-alpha.165 → 0.1.0-alpha.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin-skills/loom/SKILL.md +9 -6
- package/builtin-skills/loom/references/eject.md +130 -0
- package/dist/cli/commands/eject.d.ts.map +1 -1
- package/dist/cli/commands/eject.js +108 -279
- package/dist/cli/commands/eject.js.map +1 -1
- package/dist/cli/commands/generate-system-settings.d.ts +3 -3
- package/dist/cli/commands/generate-system-settings.d.ts.map +1 -1
- package/dist/cli/commands/generate-system-settings.js +29 -204
- package/dist/cli/commands/generate-system-settings.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +27 -44
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/helpers/app-tsx-utils.d.ts +12 -0
- package/dist/cli/helpers/app-tsx-utils.d.ts.map +1 -0
- package/dist/cli/helpers/app-tsx-utils.js +22 -0
- package/dist/cli/helpers/app-tsx-utils.js.map +1 -0
- package/dist/cli/helpers/app-tsx-wiring-engine.d.ts +70 -0
- package/dist/cli/helpers/app-tsx-wiring-engine.d.ts.map +1 -0
- package/dist/cli/helpers/app-tsx-wiring-engine.js +546 -0
- package/dist/cli/helpers/app-tsx-wiring-engine.js.map +1 -0
- package/dist/cli/helpers/app-tsx-wiring.d.ts +4 -39
- package/dist/cli/helpers/app-tsx-wiring.d.ts.map +1 -1
- package/dist/cli/helpers/app-tsx-wiring.js +5 -608
- package/dist/cli/helpers/app-tsx-wiring.js.map +1 -1
- package/dist/cli/helpers/system-page-config.d.ts +27 -0
- package/dist/cli/helpers/system-page-config.d.ts.map +1 -0
- package/dist/cli/helpers/system-page-config.js +73 -0
- package/dist/cli/helpers/system-page-config.js.map +1 -0
- package/dist/cli/templates/login-page.d.ts +2 -3
- package/dist/cli/templates/login-page.d.ts.map +1 -1
- package/dist/cli/templates/login-page.js +19 -27
- package/dist/cli/templates/login-page.js.map +1 -1
- package/dist/cli/templates/model-management-page.d.ts +2 -3
- package/dist/cli/templates/model-management-page.d.ts.map +1 -1
- package/dist/cli/templates/model-management-page.js +12 -7
- package/dist/cli/templates/model-management-page.js.map +1 -1
- package/dist/cli/templates/notification-center-page.d.ts +2 -3
- package/dist/cli/templates/notification-center-page.d.ts.map +1 -1
- package/dist/cli/templates/notification-center-page.js +26 -60
- package/dist/cli/templates/notification-center-page.js.map +1 -1
- package/dist/cli/templates/notification-detail-page.d.ts +2 -3
- package/dist/cli/templates/notification-detail-page.d.ts.map +1 -1
- package/dist/cli/templates/notification-detail-page.js +14 -39
- package/dist/cli/templates/notification-detail-page.js.map +1 -1
- package/dist/cli/templates/process-management-page.d.ts +3 -3
- package/dist/cli/templates/process-management-page.d.ts.map +1 -1
- package/dist/cli/templates/process-management-page.js +76 -563
- package/dist/cli/templates/process-management-page.js.map +1 -1
- package/dist/cli/templates/skill-management-page.d.ts +2 -3
- package/dist/cli/templates/skill-management-page.d.ts.map +1 -1
- package/dist/cli/templates/skill-management-page.js +13 -13
- package/dist/cli/templates/skill-management-page.js.map +1 -1
- package/dist/cli/templates/user-management-page.d.ts +2 -4
- package/dist/cli/templates/user-management-page.d.ts.map +1 -1
- package/dist/cli/templates/user-management-page.js +22 -20
- package/dist/cli/templates/user-management-page.js.map +1 -1
- package/package.json +7 -3
|
@@ -35,7 +35,7 @@ Loom 是**配置驱动的 AI 平台开发框架**——你描述需求,AI 通
|
|
|
35
35
|
npx -p @loom-framework/core loom init <name> --description <desc> --adapter <filesystem|sqlite>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
项目初始化时自动生成系统管理页面(模型管理、技能管理、用户管理、过程管理、通知中心),并以子菜单形式接入导航。同时自动安装以下内置 Skill:
|
|
39
39
|
|
|
40
40
|
| Skill | 触发场景 | 说明 |
|
|
41
41
|
|-------|---------|------|
|
|
@@ -107,7 +107,7 @@ loom generate capabilities
|
|
|
107
107
|
1. **询问需求**:是否需要登录功能?有哪些角色?每个角色能做什么?
|
|
108
108
|
2. **编辑配置**:在 `loom.config.ts` 中添加 `auth` 字段(Schema 见上方)。至少定义一个 `admin` 角色
|
|
109
109
|
3. **设置密钥**:`secret` 推荐 `env:JWT_SECRET`,不要硬编码。提醒用户设置环境变量 `export JWT_SECRET=your-secret`
|
|
110
|
-
4. **生成认证页面**:`loom generate system-settings user` —
|
|
110
|
+
4. **生成认证页面**:`loom generate system-settings user` — 自动接入用户管理页和登录页的 npm import,并接入 AuthProvider 路由守卫
|
|
111
111
|
5. **重启后端**:auth 配置需要重启后端生效(**必须先询问用户**)
|
|
112
112
|
6. **首次登录**:默认创建 admin 用户(密码 `admin123`),**提醒用户立即修改密码**
|
|
113
113
|
7. **生成 app-skill**:`loom generate capabilities` 更新 Skill 中的 auth.md
|
|
@@ -153,6 +153,10 @@ loom generate page <Name> --model <model-name> --force
|
|
|
153
153
|
|
|
154
154
|
**恢复备份**:`--force` 覆盖的文件自动备份到项目 `.loom/backup/<时间戳>/` 目录(每次 --force 生成独立时间戳目录,同一天多次执行互不影响),如需恢复:`cp .loom/backup/<时间戳>/XXX.tsx frontend/src/components/pages/XXX.tsx`
|
|
155
155
|
|
|
156
|
+
### 6. 系统页面定制(Eject)
|
|
157
|
+
|
|
158
|
+
系统管理页面默认以 npm 组件接入,无法直接修改。需要定制时 eject 为本地文件,恢复时 uneject。详见 `references/eject.md`。
|
|
159
|
+
|
|
156
160
|
### 内置 Skill 使用原则
|
|
157
161
|
|
|
158
162
|
- 涉及前端页面开发 → 先用 `/antd` 查询组件 API,不要凭记忆写代码
|
|
@@ -170,11 +174,10 @@ loom generate page <Name> --model <model-name> --force
|
|
|
170
174
|
| `loom generate capabilities` | 生成应用 Skill(`references/models.md` + `references/data-semantics.md`,`SKILL.md` 仅首次创建不覆盖) |
|
|
171
175
|
| `loom generate dashboard <name>` | 从 loom.config.ts dashboards 生成 Dashboard 页面 |
|
|
172
176
|
| `loom generate dashboard <name> --force` | 重建 Dashboard 页面(自动备份旧文件到 `.loom/backup/`) |
|
|
173
|
-
| `loom generate system-settings <
|
|
174
|
-
| `loom generate system-settings <model\|skill\|user\|process> --force` | 重建系统管理页面(自动备份旧文件到 `.loom/backup/`) |
|
|
177
|
+
| `loom generate system-settings <type>` | 将系统页面接入 App.tsx(npm import 接线),type: `model`/`skill`/`user`/`login`/`process`/`notification`;`user` 同时接入 AuthProvider 路由守卫,`notification` 同时接入 NotificationCenterProvider |
|
|
175
178
|
| `loom generate skill <name>` | 生成自定义 Skill 脚架 |
|
|
176
|
-
| `loom eject system-settings <type>` | 将系统页面从 npm 组件切换为本地文件(可自由编辑),type: `model`/`skill`/`user`/`login`/`process`/`notification` |
|
|
177
|
-
| `loom uneject system-settings <type>` | 删除本地文件,恢复为 npm 组件(修改过的需 `--force
|
|
179
|
+
| `loom eject system-settings <type>` | 将系统页面从 npm 组件切换为本地文件(可自由编辑),type: `model`/`skill`/`user`/`login`/`process`/`notification`。详见 `references/eject.md` |
|
|
180
|
+
| `loom uneject system-settings <type>` | 删除本地文件,恢复为 npm 组件(修改过的需 `--force`,操作前自动备份)。详见 `references/eject.md` |
|
|
178
181
|
| `loom data read <model>` | 查询数据(`--filter` 筛选、`--limit` 限制条数、`--sort` 排序) |
|
|
179
182
|
| `loom data write <model> --data '<json>'` | 创建记录 |
|
|
180
183
|
| `loom data update <model> <id> --data '<json>'` | 更新记录 |
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# System Page Eject — 定制化参考
|
|
2
|
+
|
|
3
|
+
系统管理页面默认以 npm 组件形式接入 App.tsx,不支持直接修改。Eject 机制将页面输出为本地 .tsx 文件,切换 import 来源,使页面可自由定制。
|
|
4
|
+
|
|
5
|
+
## 页面类型
|
|
6
|
+
|
|
7
|
+
| type | 组件名 | npmComponent | 接线方式 | 说明 |
|
|
8
|
+
|--------------|---------------------|---------------------------|---------------|-----------------------------------|
|
|
9
|
+
| model | ModelManagement | ModelManagementPage | sidebar-nav | 系统配置子菜单 |
|
|
10
|
+
| skill | SkillManagement | SkillManagementPage | sidebar-nav | 系统配置子菜单 |
|
|
11
|
+
| user | UserManagement | UserManagementPage | sidebar-nav | 自动接入 AuthProvider |
|
|
12
|
+
| login | Login | LoginPage | auth-fallback | AuthGuard 的 fallback,无导航入口 |
|
|
13
|
+
| process | ProcessManagement | ProcessManagementPage | sidebar-nav | 系统配置子菜单 |
|
|
14
|
+
| notification | NotificationCenter | NotificationCenterPage | skip-nav | 通知铃铛触发,无导航入口 |
|
|
15
|
+
|
|
16
|
+
notification eject 时同时生成 NotificationCenter + NotificationDetail 两个文件。
|
|
17
|
+
|
|
18
|
+
## 命令
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# eject: npm 组件 → 本地文件(可编辑)
|
|
22
|
+
loom eject system-settings <type>
|
|
23
|
+
|
|
24
|
+
# uneject: 本地文件 → npm 组件(已修改需 --force)
|
|
25
|
+
loom uneject system-settings <type> [--force]
|
|
26
|
+
|
|
27
|
+
# 接入 App.tsx(npm import 接线,init 时自动执行)
|
|
28
|
+
loom generate system-settings <type>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Eject/Uneject 对 App.tsx 的影响
|
|
32
|
+
|
|
33
|
+
### eject 前
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { ModelManagementPage } from '@loom-framework/frontend-antd';
|
|
37
|
+
// ...
|
|
38
|
+
case 'model-management': return <ModelManagementPage />;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### eject 后
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import ModelManagementPage from './components/pages/ModelManagement';
|
|
45
|
+
// ...
|
|
46
|
+
case 'model-management': return <ModelManagementPage />;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
本地文件出现在 `frontend/src/components/pages/<PascalName>.tsx`。
|
|
50
|
+
|
|
51
|
+
### uneject 后
|
|
52
|
+
|
|
53
|
+
本地文件删除,import 恢复为 npm 路径。
|
|
54
|
+
|
|
55
|
+
## 定制化操作指南
|
|
56
|
+
|
|
57
|
+
### 修改页面布局或样式
|
|
58
|
+
|
|
59
|
+
1. 执行 `loom eject system-settings <type>`
|
|
60
|
+
2. 编辑 `frontend/src/components/pages/` 下的 .tsx 文件
|
|
61
|
+
3. 运行 `loom dev` 查看效果
|
|
62
|
+
|
|
63
|
+
### 使用框架子组件
|
|
64
|
+
|
|
65
|
+
eject 后的文件 import 来自 `@loom-framework/frontend-antd`,可直接使用框架子组件:
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { ProcessTree, ProcessOverview, ProcessLogs, ProcessMetrics } from '@loom-framework/frontend-antd';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
可用的 hook:`useData`, `useSchema`, `useLocale`, `useModels`, `useChartData`。
|
|
72
|
+
|
|
73
|
+
### 替换子组件
|
|
74
|
+
|
|
75
|
+
将 import 替换为自定义实现:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
// 替换前
|
|
79
|
+
import { ProcessTree } from '@loom-framework/frontend-antd';
|
|
80
|
+
// 替换后
|
|
81
|
+
import { MyCustomTree } from './MyCustomTree';
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 添加自定义管理页面
|
|
85
|
+
|
|
86
|
+
内置的 6 种系统页面 type(model/skill/user/login/process/notification)由框架预定义,用户无法新增 type。如需框架未提供的管理页面,根据场景选择:
|
|
87
|
+
|
|
88
|
+
**数据驱动页面**(对应一个数据模型,需要增删改查)→ 在 `loom.config.ts` 中添加模型定义,然后 `loom generate page <Name> --model <model>` 生成 CRUD 页面 + API + 导航
|
|
89
|
+
|
|
90
|
+
**纯 UI 页面**(不对应数据模型,如审批流程、配置向导)→ 手动创建 `frontend/src/components/pages/MyPage.tsx`,然后在 App.tsx 中添加 import、导航项和路由
|
|
91
|
+
|
|
92
|
+
## 安全机制
|
|
93
|
+
|
|
94
|
+
- eject 时自动保存校验和到 `.loom/checksums/`
|
|
95
|
+
- uneject 时校验:未修改可直接删除,已修改需 `--force`
|
|
96
|
+
- 所有操作前自动备份到 `.loom/backup/`
|
|
97
|
+
|
|
98
|
+
## WiringMode 说明
|
|
99
|
+
|
|
100
|
+
- **sidebar-nav**: 添加到系统配置子菜单,有导航入口、switch case、breadcrumb
|
|
101
|
+
- **auth-fallback**: 作为 `<AuthGuard fallback={<Login />}>` 注入,无导航入口
|
|
102
|
+
- **skip-nav**: 无导航入口(通过其他 UI 触发),但有 switch case 和 breadcrumb
|
|
103
|
+
|
|
104
|
+
## 构建时模板生成
|
|
105
|
+
|
|
106
|
+
模板文件由 `pnpm build` 自动从 `frontend-antd/src/` 源码生成到 `templates/`。不需要手动运行 `pnpm generate-templates`(build 已自动调用)。
|
|
107
|
+
|
|
108
|
+
- import 路径自动从 relative 转换为 `@loom-framework/frontend-antd` barrel import
|
|
109
|
+
- `validateBarrelExports()` 自动校验模板中所有 import 在 `frontend-antd/src/index.ts` 中存在,缺失导出会导致构建失败
|
|
110
|
+
- `validateCompleteness()` 自动校验 `template-source-mappings.ts` 与 `SYSTEM_PAGE_CONFIG` 一致,不一致会报错退出
|
|
111
|
+
- 模板文件头部含版本号:`GENERATED by scripts/generate-templates.ts — v0.1.0-alpha.166 — DO NOT EDIT MANUALLY`
|
|
112
|
+
|
|
113
|
+
## 版本对齐警告
|
|
114
|
+
|
|
115
|
+
eject 时如果模板 GENEREATED header 中的版本与安装的 `@loom-framework/frontend-antd` 版本不一致,会显示黄色警告:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
⚠ Template for "ModelManagement" was generated for v0.1.0-alpha.166, but installed frontend-antd is v0.1.0-alpha.168. Ejected code may differ from npm version.
|
|
119
|
+
Run "pnpm build" in the framework repo to regenerate templates, or update frontend-antd.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
这不阻止 eject 操作,仅提示可能存在的不一致。
|
|
123
|
+
|
|
124
|
+
## 新增系统页面清单
|
|
125
|
+
|
|
126
|
+
1. 在 `packages/frontend-antd/src/` 创建 .tsx 组件(含 per-page `registerMessages`)
|
|
127
|
+
2. 在 `packages/frontend-antd/src/index.ts` 导出组件
|
|
128
|
+
3. 在 `packages/core/src/cli/helpers/system-page-config.ts` 的 `SYSTEM_PAGE_CONFIG` 中添加配置
|
|
129
|
+
4. 在 `packages/core/scripts/template-source-mappings.ts` 添加源文件映射
|
|
130
|
+
5. 运行 `pnpm build` — 模板自动生成 + barrel export 自动校验
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/eject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/eject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0MzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmH3D"}
|