feat(cli): agent 接入补全(token/MCP/REST 分流)+ 修 page-recipe recipe-id

- fix: page-recipe 的 maintenance-crud 漏 `-v1`,而 compile 端点精确匹配
  maintenance-crud-v1,agent 照抄示例会 400;统一为 -v1,并引导以
  GET /api/ai/page-recipes 为权威列表,避免硬写字面量漂移。
- env-manage 新增「鉴权/Token」段:非 prod profile permitAll 免 token,
  prod/JWT 环境需 POST /api/auth/login 取顶层 `token` + `Authorization: Bearer`
  (核实 AuthController/JwtAuthFilter)。
- AGENTS.md(writeAgentsMd):把「优先 platform-cli」误导修为按类分流
  (env/ai/release 用 CLI,建模/页面/授权用 REST 或 platform-mcp),
  并点名 platform-mcp 注册方式 + token 获取指引。
- data-modeling/page-recipe/acl-manage 各加调用方式与 token 交叉引用。
- 测试 +3:page-recipe recipe-id 回归、AGENTS.md MCP/auth、bundled skills 防漂移。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-23 09:50:23 +08:00
parent daad6ea196
commit 0e457d9945
6 changed files with 99 additions and 4 deletions

View File

@@ -4,6 +4,8 @@
- 给角色授菜单、管理用户组 / 角色成员、查看菜单树。
> 调用方式:经 REST(无对应 CLI 子命令),或经 `platform-mcp`(MCP)。非 local 环境需带 `Authorization: Bearer <token>`,取 token 见 `eip4-env-manage`。
## 菜单
- `GET {{EIP4_BASE_URL}}/api/admin/menu-all` — 管理视角全量菜单树(`roots[]` 两级,含 `templateId`)。

View File

@@ -5,6 +5,8 @@
- 用户要新建业务实体(表)、给已有表加字段。
- 需要引用列(外键)、主子表结构。
> 调用方式:经 REST(无对应 CLI 子命令),或经 `platform-mcp`(MCP)。非 local 环境需带 `Authorization: Bearer <token>`,取 token 见 `eip4-env-manage`。
## 端点
建实体:`POST {{EIP4_BASE_URL}}/api/meta/entity`

View File

@@ -30,6 +30,23 @@ JAVA_HOME=/opt/homebrew/opt/openjdk@21 mvn -pl platform-app -am install -DskipTe
/opt/homebrew/opt/openjdk@21/bin/java -jar platform-app/target/platform-app-0.1.0-SNAPSHOT.jar --spring.profiles.active=local
```
## 鉴权 / Token
- 非 prod profile(default / local / ci)放行 `/api/**`;本地 `eip4 init` 默认渲染 local,故本地 curl / CLI **无需 token**。
- prod 或开启 JWT 的环境:`/api/**` 需请求头 `Authorization: Bearer <token>`(`/api/auth/**` 例外,登录本身免令牌)。
- 取 token(登录响应顶层字段 `token`=JWT、`expireSeconds`=过期秒数;失败 401 仅含 `success:false` + `msg`):
```bash
TOKEN=$(curl -s -X POST {{EIP4_BASE_URL}}/api/auth/login \
-H "Content-Type: application/json" \
-d '{"account":"admin","password":"111111"}' \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["token"])')
curl {{EIP4_BASE_URL}}/api/meta/entities -H "Authorization: Bearer $TOKEN"
```
> `admin/111111` 为本地 dev 种子账号;按环境替换。
## 禁止事项
- 不在用户原始任务目录中直接改动或启动长时间任务,除非用户明确要求。

View File

@@ -5,9 +5,13 @@
- 用户要为某实体生成默认页面(维护 / 树 / 主子表)。
- 需要派生列、父级汇总。
> 调用方式:经 REST(无对应 CLI 子命令),或经 `platform-mcp`(MCP)。非 local 环境需带 `Authorization: Bearer <token>`,取 token 见 `eip4-env-manage`。
## recipe 类型
- `maintenance-crud` — 普通维护 CRUD(列表 + 表单)。
权威列表以 `GET {{EIP4_BASE_URL}}/api/ai/page-recipes` 为准;当前三种(id 带 `-v1`,须逐字传,端点精确匹配,不接受省略 `-v1` 的别名):
- `maintenance-crud-v1` — 普通维护 CRUD(列表 + 表单)。
- `tree-crud-v1` — 树形维护(有 parentid 的层级表)。
- `master-detail-v1` — 主子表(主表 + 子表行内编辑)。
@@ -19,7 +23,7 @@
{
"tableName": "EIP4_DEMO",
"title": "演示页面",
"recipe": "maintenance-crud",
"recipe": "maintenance-crud-v1",
"pageSize": 20,
"displayField": "NAME",
"childTable": "DEMO_DETAIL",