补充创作规格包聊天入口

新增 /spec 创作规格包摘要

补充 /next 与 /help 的规格入口覆盖

验证 /spec 不触发文件读取、运行、预览或导出命令

同步 AI 游戏创作 App 技术方案和决策记录
This commit is contained in:
AIGameCreator App
2026-07-04 11:08:46 +08:00
parent 160598d8f9
commit 3a96f0c7ae
4 changed files with 195 additions and 3 deletions
+82
View File
@@ -1869,6 +1869,7 @@ const chatCommandHelp = [
'/status:查看项目状态',
'/brief:生成当前项目简报',
'/goal:查看创作目标',
'/spec:查看创作规格包',
'/mvp:查看本轮最小可玩范围',
'/pitch:查看试玩定位与卖点',
'/demo:准备 30 秒试玩讲解稿',
@@ -3127,6 +3128,69 @@ function summarizeProjectTodoList(
};
}
function summarizeProjectSpecSheet(
nextManifest: GameCreationAppManifest,
trace: GameCreationAgentRunTrace | null,
) {
const tasks = taskRowsFromManifest(nextManifest);
const taskArtifactPaths = new Set(tasks.flatMap((task) => task.artifacts));
const tracePathEntries =
trace?.steps.flatMap((step) => [...step.inputPaths, ...step.outputPaths]) ??
[];
const tracePaths = new Set([
...(trace?.artifacts.map((artifact) => artifact.path) ?? []),
...tracePathEntries,
]);
const specItems = [
{ label: 'Planner 规格', path: '.agent/spec.md', group: 'design' },
{ label: '玩法设计', path: 'game/game_design.md', group: 'design' },
{ label: '数值表', path: 'game/balance.json', group: 'balance' },
{ label: '美术清单', path: 'assets/manifest.art.json', group: 'art' },
{ label: '音频清单', path: 'assets/manifest.audio.json', group: 'audio' },
{ label: '发布说明', path: 'exports/README.md', group: 'publishing' },
] as const;
const itemLines = specItems.map((item) => {
const groupTasks = tasks.filter((task) => task.group === item.group);
const completedCount = groupTasks.filter(
(task) => task.status === 'completed',
).length;
const status = tracePaths.has(item.path)
? '已出现在最近 run'
: taskArtifactPaths.has(item.path)
? '任务声明'
: '待补齐';
const taskSummary =
groupTasks.length > 0
? ` · ${taskGroupLabels[item.group]}任务 ${completedCount}/${groupTasks.length}`
: '';
return `- ${item.label}${item.path} · ${status}${taskSummary}`;
});
const firstReadablePath =
specItems.find((item) => tracePaths.has(item.path))?.path ??
specItems.find((item) => taskArtifactPaths.has(item.path))?.path ??
null;
const draftCommand = firstReadablePath
? `/read ${firstReadablePath}`
: '/next';
return {
text: [
'创作规格包:',
`- 项目:${nextManifest.name}`,
`- 目标:${nextManifest.goal || trace?.goal || '暂无'}`,
trace ? `- Run${trace.runId} · ${formatAgentRunStatus(trace)}` : null,
`- 规格清单:\n${itemLines.join('\n')}`,
'- 关联:/goal/rules/balance/art/audio/publish',
'- 边界:只整理规格产物状态;不读取规格文件;不启动预览;不写项目',
`- 建议:${draftCommand}`,
]
.filter(Boolean)
.join('\n'),
draftCommand,
draftCommandLabel: firstReadablePath ? '读取规格' : '查看下一步',
};
}
function summarizeProjectGroupProgress(
nextManifest: GameCreationAppManifest,
trace: GameCreationAgentRunTrace | null,
@@ -4307,6 +4371,7 @@ function summarizeNextProjectActions(
addSuggestion('查看最近 loop 进展', '/trace');
}
addSuggestion('查看创作目标', '/goal');
addSuggestion('查看创作规格包', '/spec');
addSuggestion('查看本轮 MVP 范围', '/mvp');
addSuggestion('查看试玩定位与卖点', '/pitch');
addSuggestion('准备 30 秒试玩讲解稿', '/demo');
@@ -8018,6 +8083,23 @@ export function App() {
return;
}
if (prompt === '/spec') {
if (!requireChatProjectForUserAction()) {
return;
}
const summary = summarizeProjectSpecSheet(manifest, agentRunTrace);
setMessages((current) => [
...current,
{
role: 'assistant',
text: summary.text,
draftCommand: summary.draftCommand,
draftCommandLabel: summary.draftCommandLabel,
},
]);
return;
}
if (prompt === '/mvp') {
if (!requireChatProjectForUserAction()) {
return;
@@ -2251,6 +2251,104 @@ describe('AI 游戏创作 App 界面边界', () => {
),
).toHaveLength(runLocalCountBeforeGoal);
const commandCountsBeforeSpec = {
manifestRead: invoke.mock.calls.filter(
([command]) => command === 'get_local_game_manifest',
).length,
fileRead: invoke.mock.calls.filter(
([command]) => command === 'read_local_project_file',
).length,
fileList: invoke.mock.calls.filter(
([command]) => command === 'list_local_project_files',
).length,
runLocal: invoke.mock.calls.filter(
([command]) => command === 'run_limited_local_command',
).length,
startPreview: invoke.mock.calls.filter(
([command]) => command === 'start_local_game_preview',
).length,
openPreview: invoke.mock.calls.filter(
([command]) => command === 'open_local_game_preview',
).length,
exportPackage: invoke.mock.calls.filter(
([command]) => command === 'export_local_project_package',
).length,
exportList: invoke.mock.calls.filter(
([command]) => command === 'list_local_project_export_packages',
).length,
};
submitChat('/spec');
const specMessages = await screen.findAllByText(/创作规格包:/);
const specMessage = specMessages[specMessages.length - 1];
expect(specMessage.textContent).toContain('项目:未命名游戏原型');
expect(specMessage.textContent).toContain('目标:做一个厨房弹幕游戏');
expect(specMessage.textContent).toContain(
'Runrun-main-shortcut-trace · passed / done · 1/3 轮 · evaluator-passed',
);
expect(specMessage.textContent).toContain(
'Planner 规格:.agent/spec.md · 已出现在最近 run',
);
expect(specMessage.textContent).toContain(
'玩法设计:game/game_design.md · 任务声明',
);
expect(specMessage.textContent).toContain(
'发布说明:exports/README.md · 已出现在最近 run',
);
expect(specMessage.textContent).toContain(
'边界:只整理规格产物状态;不读取规格文件;不启动预览;不写项目',
);
expect(specMessage.textContent).toContain('建议:/read .agent/spec.md');
const specMessageList = document.querySelector('.message-list');
expect(specMessageList).not.toBeNull();
const specDraftButtons = within(
specMessageList as HTMLElement,
).getAllByRole('button', { name: '读取规格' });
fireEvent.click(specDraftButtons[specDraftButtons.length - 1]);
expect(screen.getByLabelText('创作想法')).toHaveProperty(
'value',
'/read .agent/spec.md',
);
expect(
invoke.mock.calls.filter(
([command]) => command === 'get_local_game_manifest',
),
).toHaveLength(commandCountsBeforeSpec.manifestRead);
expect(
invoke.mock.calls.filter(
([command]) => command === 'read_local_project_file',
),
).toHaveLength(commandCountsBeforeSpec.fileRead);
expect(
invoke.mock.calls.filter(
([command]) => command === 'list_local_project_files',
),
).toHaveLength(commandCountsBeforeSpec.fileList);
expect(
invoke.mock.calls.filter(
([command]) => command === 'run_limited_local_command',
),
).toHaveLength(commandCountsBeforeSpec.runLocal);
expect(
invoke.mock.calls.filter(
([command]) => command === 'start_local_game_preview',
),
).toHaveLength(commandCountsBeforeSpec.startPreview);
expect(
invoke.mock.calls.filter(
([command]) => command === 'open_local_game_preview',
),
).toHaveLength(commandCountsBeforeSpec.openPreview);
expect(
invoke.mock.calls.filter(
([command]) => command === 'export_local_project_package',
),
).toHaveLength(commandCountsBeforeSpec.exportPackage);
expect(
invoke.mock.calls.filter(
([command]) => command === 'list_local_project_export_packages',
),
).toHaveLength(commandCountsBeforeSpec.exportList);
const commandCountsBeforeMvp = {
manifestRead: invoke.mock.calls.filter(
([command]) => command === 'get_local_game_manifest',
@@ -3959,6 +4057,7 @@ describe('AI 游戏创作 App 界面边界', () => {
expect(await screen.findByText(/下一步建议:/)).not.toBeNull();
expect(screen.getByText(/运行自检并启动本地预览:\/run/)).not.toBeNull();
expect(screen.getByText(/查看创作目标:\/goal/)).not.toBeNull();
expect(screen.getByText(/查看创作规格包:\/spec/)).not.toBeNull();
expect(screen.getByText(/查看本轮 MVP 范围:\/mvp/)).not.toBeNull();
expect(screen.getByText(/查看试玩定位与卖点:\/pitch/)).not.toBeNull();
expect(screen.getByText(/准备 30 秒试玩讲解稿:\/demo/)).not.toBeNull();
@@ -8094,7 +8193,9 @@ describe('AI 游戏创作 App 界面边界', () => {
renderAppAt('/?main&projectPath=%2Ftmp%2Fauthorized-game');
await screen.findByText('想做什么游戏?');
fireEvent.click(screen.getByRole('button', { name: /拆解创作方向/ }));
fireEvent.click(
await screen.findByRole('button', { name: /拆解创作方向/ }),
);
const input = await screen.findByLabelText('Agent 对话内容');
const form = input.closest('form') as HTMLFormElement;
fireEvent.change(input, { target: { value: '只保存一次' } });
@@ -10261,6 +10362,7 @@ describe('AI 游戏创作 App 界面边界', () => {
).not.toBeNull();
expect(screen.getByText(/\/brief:生成当前项目简报/)).not.toBeNull();
expect(screen.getByText(/\/goal:查看创作目标/)).not.toBeNull();
expect(screen.getByText(/\/spec:查看创作规格包/)).not.toBeNull();
expect(screen.getByText(/\/mvp:查看本轮最小可玩范围/)).not.toBeNull();
expect(screen.getByText(/\/pitch:查看试玩定位与卖点/)).not.toBeNull();
expect(screen.getByText(/\/demo:准备 30 秒试玩讲解稿/)).not.toBeNull();
@@ -3867,6 +3867,7 @@
- 2026-07-03 调整:主窗口 header 常驻项目摘要只从当前已加载的 manifest / trace 派生任务完成数、ready 数、资产来源分布和最近命令结果;未选择工作区时不显示,不为了摘要额外触发 Tauri 读取或写入,也不把任务、文件、run history 或预览开发面板搬进普通用户窗口。
- 2026-07-03 调整:普通用户通过聊天输入 `/brief` 触发项目简报入口,只基于主窗口当前已加载的 manifest、最近 run trace、预览状态、资产数量和最近命令生成聊天内简报,并提供 `/next` 作为后续草稿;该入口不得触发 Tauri 读写、不得读取文件、不得启动或打开预览,也不得新增普通用户面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/goal` 查看创作目标,只基于当前 manifest.goal、最近 run goal 和 taskGraph.goal 汇总项目目标来源,并提供 `/agent-resume 细化目标:``/next` 草稿;该入口不得触发 Tauri 读写、不得读取 spec、上下文或 trace 文件,也不得新增普通用户目标面板。
- 2026-07-04 调整:普通用户通过聊天输入 `/spec` 查看创作规格包,只基于当前 manifest、最近 run trace、任务声明产物和 trace 输入 / 输出路径汇总 Planner 规格、玩法设计、数值表、美术清单、音频清单和发布说明状态,并提供 `/read .agent/spec.md``/next` 草稿;该入口不得触发 Tauri 读写、不得读取规格文件、不得启动预览、不得写项目,也不得新增普通用户规格面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/mvp` 查看本轮最小可玩范围,只基于当前 manifest、最近 run trace、preview、任务、资产和最近命令汇总 MVP 内、当前状态、试玩包状态和暂不做事项,并提供 `/review``/criteria``/trace``/run``/export``/exports``/next` 草稿;该入口不得触发 Tauri 读写、不得读取文件、不得启动或打开预览、不得导出试玩包,也不得新增普通用户 MVP 面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/pitch` 查看试玩定位与卖点,只基于当前 manifest、最近 run trace 和 preview 状态汇总试玩定位、一句话、核心乐趣、当前可演示状态、测试者讲解口径和暂不承诺事项,并提供 `/mvp``/review``/trace``/open-preview``/run` 草稿;该入口不得触发 Tauri 读写、不得读取文件、不得启动或打开预览、不得直接继续 run,也不得新增普通用户定位面板。该入口服务试玩讲解,不承接 `/listing` 的作品页包装。
- 2026-07-04 调整:普通用户通过聊天输入 `/demo` 准备 30 秒试玩讲解稿,只基于当前 manifest、最近 run trace 和 preview 状态汇总开场、讲解顺序、口播稿、演示状态、最近试玩证据和收反馈口径,并提供 `/run``/open-preview``/trace``/review``/test-plan` 草稿;该入口不得触发 Tauri 读写、不得读取文件、不得启动或打开预览、不得导出试玩包、不得发布作品,也不得新增普通用户讲解面板。
@@ -3882,6 +3883,7 @@
- 2026-07-03 调整:普通用户通过聊天输入 `/budget` 查看最近 run 预算,只基于当前最近 run trace 汇总轮次、工具调用、stopReason 和下一步建议,并提供 `/review``/publish``/trace``/next` 草稿;该入口不得触发 Tauri 读写、不得读取 trace 文件,也不得新增普通用户预算面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/qa` 查看质量检查清单,只基于当前 manifest、最近 run trace、最近命令和 preview 状态汇总 Evaluator、任务、静态自检、试玩和产物状态,并提供 `/review``/tasks``/trace``/playtest``/publish``/next` 草稿;该入口不得触发 Tauri 读写、不得读取 trace 或日志文件、不得启动或打开预览,也不得新增普通用户 QA 面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/changes` 查看最近生成变更,只基于当前 manifest、最近 run trace 的 artifacts / steps 和最近命令汇总可验产物、最近输出、当前资产和真实差异查看方向,并提供 `/read <首个可验产物>``/run-artifacts` 草稿;该入口不得触发 Tauri 读写、不得读取产物或日志文件、不得执行 checkpoint diff,也不得新增普通用户变更面板。
- 2026-07-04 调整:普通用户通过聊天输入 `/todo` 查看下一轮小步清单,只基于当前 manifest 和最近 run trace 汇总失败、active、carry、ready 或待处理任务,并提供 `/tasks``/review``/next` 草稿;该入口不得触发 Tauri 读写、不得读取任务文件、不得启动 run、不得修改项目,也不得新增普通用户小步面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/review` 查看 Evaluator 评审状态,只基于主窗口当前已加载的最近 run trace 派生通过 / 需返工状态、返工焦点、返工路线和最近评审步骤,并提供 `/read .agent/findings.md``/agent-resume ` 草稿;该入口不得直接读取评审文件、不得触发 Tauri 读写,也不得新增普通用户评审面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/context` 查看生成上下文来源,只基于当前 manifest 和最近 run trace 列出项目对话、短期记忆、长期记忆、项目黑板、Agent 对话、Agent 私有记忆、manifest、最近 trace 和最近 LLM 输入路径,并提供 `/read``/memory blackboard` 草稿;该入口不得触发 Tauri 读写、不得读取上下文文件,也不得新增普通用户上下文面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/timeline` 查看项目活动时间线,只基于当前 manifest.commandRuns 和最近 run trace 汇总最近命令、日志读取草稿和最近 Agent 步骤,并提供 `/read``/trace``/history` 草稿;该入口不得触发 Tauri 读写、不得读取日志或 trace 文件,也不得新增普通用户时间线面板。
@@ -3900,7 +3902,7 @@
- 2026-07-03 调整:普通用户通过聊天输入 `/balance` 查看数值与难度口径,只基于当前 manifest.tasks、最近 run trace.taskGraph、trace artifacts 和 steps 汇总数值组任务、验收口径、`game/balance.json` 状态和最近数值步骤,并提供 `/read game/balance.json``/agent-resume 数值调整:...` 草稿;该入口不得触发 Tauri 读写、不得读取数值表、不得启动预览或继续 run,也不得新增普通用户数值面板。
- 2026-07-03 调整:主窗口新增常用生成产物读取入口,只把入口 HTML、设计、数值、美术清单、音频清单和发布说明对应的 `/read` 草稿填入聊天输入框;聊天命令 `/artifacts` 只列出同一组固定读取命令并提供首个读取草稿,`/run-artifacts` 只列出最近 trace 里的产物读取命令并提供首个 `/read` 草稿,`/logs` 只列出固定日志读取命令;实际读取仍走聊天侧 `file.read` 权限流,不直接读本地文件。
- 2026-07-03 调整:普通用户通过聊天输入 `/share` 准备试玩交付清单,只基于当前 manifest、授权项目路径、最近 run trace、preview 状态和 manifest.commandRuns 汇总原型通过状态、本地预览、本地试玩包、测试者说明和反馈收集方向,并提供 `/export``/exports``/trace``/review``/next` 草稿;该入口不得触发 Tauri 读写、不得导出试玩包、不得列出历史包、不得上传云端、不得生成公开分享链接,也不得新增普通用户分享面板。
- 2026-07-03 调整,2026-07-04 更新:普通用户通过聊天输入 `/next` 触发下一步建议入口,只基于主窗口当前已加载的 manifest、最近 run trace 和最近命令摘要生成聊天建议,列出 `/goal``/mvp``/pitch``/demo``/rules``/tutorial``/mobile``/accessibility``/performance``/tasks``/criteria``/groups``/balance``/budget``/qa``/changes``/trace``/review``/context``/timeline``/playtest``/test-plan``/feedback``/share``/listing``/run``/open-preview``/assets``/credits``/art``/audio``/publish``/artifacts``/run-artifacts``/passes``/run-files``/internals``/logs``/agent-resume ` 等安全命令草稿方向,并提供一个首选草稿;该命令不得直接执行 Tauri 读写、启动或打开预览、读取本地文件,也不得绕过原有命令确认和 `file.read` 权限流。
- 2026-07-03 调整,2026-07-04 更新:普通用户通过聊天输入 `/next` 触发下一步建议入口,只基于主窗口当前已加载的 manifest、最近 run trace 和最近命令摘要生成聊天建议,列出 `/goal``/spec``/mvp``/pitch``/demo``/rules``/tutorial``/mobile``/accessibility``/performance``/tasks``/criteria``/groups``/balance``/budget``/qa``/changes``/todo``/trace``/review``/context``/timeline``/playtest``/test-plan``/feedback``/share``/listing``/run``/open-preview``/assets``/credits``/art``/audio``/publish``/artifacts``/run-artifacts``/passes``/run-files``/internals``/logs``/agent-resume ` 等安全命令草稿方向,并提供一个首选草稿;该命令不得直接执行 Tauri 读写、启动或打开预览、读取本地文件,也不得绕过原有命令确认和 `file.read` 权限流。
- 2026-07-03 调整:普通用户通过聊天输入 `/publish` 生成发布准备清单,只基于主窗口当前已加载的 manifest、最近 run trace、预览状态、资产来源和最近命令摘要列出原型通过、预览、任务、资产、音频、包装说明和试玩包状态,并提供 `/run``/trace``/agent-resume ``/export` 草稿;该入口不得触发 Tauri 读写、不得启动或打开预览、不得读取文件,也不得新增普通用户发布面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/internals` 只列出 `.agent/manifest.json``.agent/run.latest.json``.agent/spec.md``.agent/findings.md``.agent/policy.json``.agent/project.index.json``.agent/agent.db``.agent/conversations/project.jsonl``/read` 草稿,并提供首个读取草稿;该入口不得直接读取内部文件、不得触发 Tauri 读写,也不得新增普通用户内部文件面板。
- 2026-07-03 调整:普通用户通过聊天输入 `/passes` 只从当前已加载的最近 run trace artifacts 中筛选 `.agent/passes/` 轮次产物,列出 `/read` 草稿并提供首个读取草稿;该入口不得直接读取轮次文件、不得触发 Tauri 读写,也不得新增普通用户轮次面板。
File diff suppressed because one or more lines are too long