From 1b7741ac65ced657033e7eac432f12284e144a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 5 Oct 2026 17:21:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=8C=87=E4=BB=A4=E8=A1=A5?= =?UTF-8?q?=E4=B8=8A=E5=8C=85=E6=A0=B9=E5=9C=A8=20game/=20=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E4=BA=A7=E7=89=A9=E8=90=BD=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 适配与修复指令的产物契约补一句:路径相对项目根,而 npm 包根通常是 game/ 子目录,所以落点参数要写成 ../.export/xhs-minitool.zip(相对路径按脚本的工作目录解析)。缺这句时 agent 会把 zip 写到 game/.export/ 下,宿主只能报产物缺失,白跑一轮修复。 - 两例前端用例各加一条断言钉住这个落点。 - skill 的 AGC 契约不再给出 <项目根>/.export/xhs-minitool.zip 这个只在包根等于项目根时才成立的写法,改为只声明产物位置并把相对路径的解析规则指回 `node pack.mjs --help`;manifest 同步到 2026-08-26.42。 --- .../src-tauri/resources/agc-skills/manifest.json | 4 ++-- .../resources/agc-skills/vite-export-xhs-minitool/SKILL.md | 2 +- .../export/state/xhsMinitoolInstruction.ts | 4 ++-- apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/manifest.json b/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/manifest.json index af8677d85..cdf8da193 100644 --- a/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/manifest.json +++ b/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/manifest.json @@ -1,6 +1,6 @@ { "schemaVersion": "agc-skill-pack.v1", - "version": "2026-08-26.41", + "version": "2026-08-26.42", "skills": [ { "name": "agc-unity-editor", @@ -204,7 +204,7 @@ "scripts/validate.mjs", "scripts/vite.config.xhs-minitool.mjs" ], - "sha256": "9799b44c6de4c375148abdeb9dcbbe8c0acdf0eea11511c9f9da2cda96f6af7c" + "sha256": "3ed83d2d8bdfbeaefe9e22c36687f146c20ee2b971c7a4f73cf8bdf4bc8dc69c" } ] } diff --git a/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/vite-export-xhs-minitool/SKILL.md b/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/vite-export-xhs-minitool/SKILL.md index fb3f86ac1..6563c7c40 100644 --- a/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/vite-export-xhs-minitool/SKILL.md +++ b/apps/ai-game-creator-shell/src-tauri/resources/agc-skills/vite-export-xhs-minitool/SKILL.md @@ -18,7 +18,7 @@ metadata: 宿主只按三条硬契约校验, 接入的项目 MUST 逐条满足: - npm 包 (声明 `package.json` 的那层目录) MUST 声明脚本 `build:xhs-minitool`. -- 该脚本跑完 MUST 在项目根留下非空的 `.export/xhs-minitool.zip`; 用 `pack.mjs --zip-out <项目根>/.export/xhs-minitool.zip` 指定落点, 不要依赖默认文件名. +- 该脚本跑完 MUST 在项目根留下非空的 `.export/xhs-minitool.zip`; 落点用 `pack.mjs --zip-out` 显式指定, 不要依赖默认文件名 (相对路径的解析规则见 `node pack.mjs --help`). - `pack.mjs --out-dir` MUST 只指向 vite 构建输出目录: 它会就地删掉该目录里白名单之外的扩展名文件, 指向源码目录会删掉用户代码. 把示例脚本拷贝到 `<项目根>/.export/` 下再改 (拷贝是项目自己的代码, 允许改路径与入口); diff --git a/apps/ai-game-creator-shell/src/view/project-development/export/state/xhsMinitoolInstruction.ts b/apps/ai-game-creator-shell/src/view/project-development/export/state/xhsMinitoolInstruction.ts index 93ce6fc77..91b8ebe55 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/export/state/xhsMinitoolInstruction.ts +++ b/apps/ai-game-creator-shell/src/view/project-development/export/state/xhsMinitoolInstruction.ts @@ -55,7 +55,7 @@ export function buildXhsMinitoolAdaptationInstruction( '', '宿主按下面三条硬契约校验,请逐条满足(做不到就直接说明卡在哪一条,不要糊一个假产物):', `1. npm 包里声明脚本 \`${XHS_MINITOOL_SCRIPT_NAME}\`。npm 包根 = 声明 package.json 的那个目录(通常是 game/)。`, - `2. 跑完这个脚本,\`${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\` 必须存在且非空(相对项目根)。`, + `2. 跑完这个脚本,\`${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\` 必须存在且非空:这个路径相对**项目根**,而 npm 包根通常是 game/ 子目录,所以落点参数要写成 \`../${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\`(相对路径按脚本的工作目录解析)。`, `3. \`${XHS_MINITOOL_REGISTRY_RELATIVE_PATH}\` 是宿主的注册表,形状只能是 ${XHS_MINITOOL_REGISTRY_SHAPE}:`, ' 三个字段都是字符串,不要增删键、不要加状态字段。可以按产物实际情况填 name 与 introduction;', ' iconPath 是项目内相对路径,留空由用户在面板里选文件。', @@ -94,7 +94,7 @@ export function buildXhsMinitoolRepairInstruction( '', '同一份硬契约(宿主会按它校验):', `1. npm 包根(声明 package.json 的目录,通常是 game/)里声明脚本 \`${XHS_MINITOOL_SCRIPT_NAME}\`。`, - `2. 跑完它,\`${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\` 必须存在且非空。`, + `2. 跑完它,\`${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\` 必须存在且非空;它相对项目根,包根在 game/ 时落点要写成 \`../${XHS_MINITOOL_ARTIFACT_RELATIVE_PATH}\`。`, `3. 打包装脚本的 \`--out-dir\` 只能指向 vite 构建输出目录,绝不能指向源码目录。`, '', `上下文:适配说明与上次的结论在 .export/xhs-minitool.pack.mjs 顶部注释里,示例脚本来自 \`${XHS_MINITOOL_SKILL_NAME}\` skill。`, diff --git a/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx b/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx index 7e1e6a4ef..ca8922891 100644 --- a/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx +++ b/apps/ai-game-creator-shell/tests/xhsMinitoolExport.test.tsx @@ -77,6 +77,8 @@ describe('交给 code agent 的指令', () => { ); // pack.mjs 会删 --out-dir 里的非白名单文件,这条坑必须写进指令正文。 expect(instruction).toContain('--out-dir'); + // 包根在 game/ 时落点要回退一层,否则 zip 落在 game/.export/ 下,宿主必然报产物缺失。 + expect(instruction).toContain('../.export/xhs-minitool.zip'); }); it('修复指令带上宿主的失败现场', () => { @@ -88,6 +90,7 @@ describe('交给 code agent 的指令', () => { expect(instruction).toContain(PROJECT_PATH); expect(instruction).toContain('.export/xhs-minitool.zip 不在'); expect(instruction).toContain('build:xhs-minitool'); + expect(instruction).toContain('../.export/xhs-minitool.zip'); }); it('每个失败变体都有一句人话与下一步', () => {