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:
@@ -745,8 +745,14 @@ public final class Eip4Cli {
|
||||
+ "Base URL: " + baseUrl + "\n\n"
|
||||
+ "已安装 skills(Claude Code 见 `.claude/skills/`;以下内嵌完整正文,供 Codex / OpenCode 使用):\n"
|
||||
+ catalog + "\n"
|
||||
+ "通用原则:优先用 `platform-cli`,其次 REST API;本地写默认放行、生产写阻断;"
|
||||
+ "AI 产物恒为 READY_FOR_HUMAN_REVIEW,需人工复核后发布。\n"
|
||||
+ "接入方式:① Claude Code 读 `.claude/skills/`;② Codex / OpenCode 读本文件内嵌正文;"
|
||||
+ "③ 可选——把 `platform-mcp` 注册为 stdio MCP server:"
|
||||
+ "`java -jar platform-mcp/target/platform-mcp-0.1.0-SNAPSHOT.jar --base-url " + baseUrl + "`"
|
||||
+ "(7 个工具转发同一套 REST 并保留人审)。\n\n"
|
||||
+ "通用原则:env / ai / release 类操作用 `platform-cli`;建模 / 页面 / 授权类用 REST 或 `platform-mcp`"
|
||||
+ "(无对应 CLI 子命令)。非 local 环境先 `POST " + baseUrl + "/api/auth/login` 取顶层 `token`,"
|
||||
+ "每个请求带 `Authorization: Bearer <token>`(详见 eip4-env-manage)。"
|
||||
+ "本地写默认放行、生产写阻断;AI 产物恒为 READY_FOR_HUMAN_REVIEW,需人工复核后发布。\n"
|
||||
+ bodies
|
||||
+ SKILLS_END + "\n";
|
||||
Path agents = targetDir.resolve("AGENTS.md");
|
||||
|
||||
@@ -485,6 +485,70 @@ class Eip4CliTest {
|
||||
"embedded body must also be rendered");
|
||||
}
|
||||
|
||||
@Test
|
||||
void agentsMdDocumentsMcpAndTokenAccess() throws Exception {
|
||||
// AGENTS.md (Codex/OpenCode 受众) 必须点名第三接入面 platform-mcp,并给出非 local 环境
|
||||
// 的 token 获取方式 + 头部,否则 agent 指向受保护 env 会 401 且无指引。
|
||||
Path skillsDir = writeSkillsFixture();
|
||||
Path target = tempDir.resolve("proj");
|
||||
run(new CapturingClient(new Eip4HttpResponse(200, "{}")),
|
||||
"init", "--dir", target.toString(), "--skills-dir", skillsDir.toString(),
|
||||
"--base-url", "http://localhost:8093");
|
||||
|
||||
String md = Files.readString(target.resolve("AGENTS.md"), StandardCharsets.UTF_8);
|
||||
assertTrue(md.contains("platform-mcp"), "AGENTS.md should point to the MCP server surface");
|
||||
assertTrue(md.contains("/api/auth/login"), "AGENTS.md should document how to obtain a token");
|
||||
assertTrue(md.contains("Authorization: Bearer"), "AGENTS.md should document the auth header");
|
||||
}
|
||||
|
||||
@Test
|
||||
void initInstallsAllBundledSkillsWithoutDrift() throws Exception {
|
||||
// No --skills-dir: exercises the REAL bundled /eip4-skills resources (manifest +
|
||||
// bodies copied from docs/skills by maven copy-resources). Guards manifest↔body drift:
|
||||
// a renamed/missing body makes runInit fail (缺少 skill 文件 → 非 0); an entry without a
|
||||
// body never installs. The synthetic-fixture tests above can't catch either case.
|
||||
Path target = tempDir.resolve("proj");
|
||||
|
||||
CliResult result = run(new CapturingClient(new Eip4HttpResponse(200, "{}")),
|
||||
"init",
|
||||
"--dir", target.toString(),
|
||||
"--base-url", "http://localhost:8093");
|
||||
|
||||
assertEquals(0, result.code(), "bundled init must succeed: " + result.out());
|
||||
|
||||
JsonNode manifest = objectMapper.readTree(
|
||||
getClass().getResourceAsStream("/eip4-skills/manifest.json"));
|
||||
JsonNode skills = manifest.path("skills");
|
||||
assertTrue(skills.size() >= 1, "bundled manifest must list skills");
|
||||
for (JsonNode skill : skills) {
|
||||
String name = skill.path("name").asText();
|
||||
String description = skill.path("description").asText();
|
||||
assertFalse(name.isBlank(), "manifest skill name must be set");
|
||||
assertFalse(description.isBlank(), "manifest skill description must be set: " + name);
|
||||
Path installed = target.resolve(".claude/skills/" + name + "/SKILL.md");
|
||||
assertTrue(Files.exists(installed), "bundled skill not installed: " + name);
|
||||
}
|
||||
assertTrue(result.out().contains("Installed " + skills.size() + " EIP4 skill"),
|
||||
"should install exactly every manifest entry");
|
||||
}
|
||||
|
||||
@Test
|
||||
void pageRecipeSkillUsesVersionedRecipeIds() throws Exception {
|
||||
// Regression guard: the compile endpoint exact-matches `maintenance-crud-v1`; the skill
|
||||
// must not ship the un-versioned `maintenance-crud` (would 400 an agent that copies it).
|
||||
Path target = tempDir.resolve("proj");
|
||||
run(new CapturingClient(new Eip4HttpResponse(200, "{}")),
|
||||
"init", "--dir", target.toString(), "--base-url", "http://localhost:8093");
|
||||
|
||||
String body = Files.readString(
|
||||
target.resolve(".claude/skills/eip4-page-recipe/SKILL.md"), StandardCharsets.UTF_8);
|
||||
assertTrue(body.contains("maintenance-crud-v1"), "must document the versioned recipe id");
|
||||
assertFalse(body.contains("\"recipe\": \"maintenance-crud\""),
|
||||
"must not ship the un-versioned recipe example (endpoint would 400)");
|
||||
assertFalse(body.contains("`maintenance-crud`"),
|
||||
"must not list the un-versioned recipe id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void skillsListPrintsBundledSkillNames() throws Exception {
|
||||
Path skillsDir = writeSkillsFixture();
|
||||
|
||||
Reference in New Issue
Block a user