补充发布准备聊天入口
新增 /publish 发布准备清单和安全草稿 补充发布准备入口界面测试和帮助覆盖 同步技术方案和项目决策记录
This commit is contained in:
@@ -1860,6 +1860,7 @@ const chatCommandHelp = [
|
||||
'/risks:查看当前项目风险',
|
||||
'/handoff:生成当前项目交接摘要',
|
||||
'/next:查看下一步建议',
|
||||
'/publish:查看发布准备清单',
|
||||
'/open-project:在系统文件管理器中显示项目目录',
|
||||
'/switch-project:回到项目启动器切换工作区',
|
||||
'/index:刷新本地项目索引',
|
||||
@@ -2149,6 +2150,14 @@ function summarizeProjectRisks(
|
||||
};
|
||||
}
|
||||
|
||||
function isAgentRunTracePassed(trace: GameCreationAgentRunTrace | null) {
|
||||
return (
|
||||
trace?.status === 'passed' ||
|
||||
trace?.status === 'artifacts-written' ||
|
||||
trace?.stopReason === 'evaluator-passed'
|
||||
);
|
||||
}
|
||||
|
||||
function summarizeProjectHandoff(
|
||||
nextManifest: GameCreationAppManifest,
|
||||
nextProjectPath: string,
|
||||
@@ -2226,6 +2235,101 @@ function summarizeProjectHandoff(
|
||||
}`;
|
||||
}
|
||||
|
||||
function summarizeProjectPublishReadiness(
|
||||
nextManifest: GameCreationAppManifest,
|
||||
nextProjectPath: string,
|
||||
trace: GameCreationAgentRunTrace | null,
|
||||
) {
|
||||
const tasks = taskRowsFromManifest(nextManifest);
|
||||
const completedCount = tasks.filter(
|
||||
(task) => task.status === 'completed',
|
||||
).length;
|
||||
const failedCount = tasks.filter((task) => task.status === 'failed').length;
|
||||
const readyCount = selectGameCreationAppReadyTasks({ tasks }).length;
|
||||
const tracePassed = isAgentRunTracePassed(trace);
|
||||
const preview = nextManifest.preview;
|
||||
const previewRunning = preview?.status === 'running' && preview.url;
|
||||
const previewSummary = previewRunning
|
||||
? `运行中 ${preview.url}`
|
||||
: preview
|
||||
? previewStatusLabels[preview.status]
|
||||
: '未启动';
|
||||
const sourceCounts = nextManifest.assets.reduce(
|
||||
(counts, asset) => {
|
||||
counts[asset.source.kind] += 1;
|
||||
return counts;
|
||||
},
|
||||
{ uploaded: 0, generated: 0, canvas: 0 } satisfies Record<
|
||||
GameCreationAppAssetSourceKind,
|
||||
number
|
||||
>,
|
||||
);
|
||||
const audioAssetCount =
|
||||
nextManifest.assets.filter(isProjectAudioAsset).length;
|
||||
const commandRuns = nextManifest.commandRuns ?? [];
|
||||
const latestCommandRun = commandRuns[commandRuns.length - 1] ?? null;
|
||||
const hasPublishReadme =
|
||||
trace?.artifacts.some(
|
||||
(artifact) => artifact.path === 'exports/README.md',
|
||||
) ?? false;
|
||||
|
||||
let draftCommand = '/export';
|
||||
let draftCommandLabel = '导出试玩包';
|
||||
if (!trace) {
|
||||
draftCommand = '/next';
|
||||
draftCommandLabel = '查看下一步';
|
||||
} else if (
|
||||
trace.lifecycleStatus === 'killed' ||
|
||||
trace.status === 'failed' ||
|
||||
trace.stopReason === 'max-passes-exhausted'
|
||||
) {
|
||||
draftCommand = '/agent-resume ';
|
||||
draftCommandLabel = '继续最近 run';
|
||||
} else if (!tracePassed) {
|
||||
draftCommand = '/trace';
|
||||
draftCommandLabel = '查看 trace';
|
||||
} else if (!previewRunning) {
|
||||
draftCommand = '/run';
|
||||
draftCommandLabel = '启动预览';
|
||||
}
|
||||
|
||||
return {
|
||||
text: [
|
||||
'发布准备:',
|
||||
`- 项目:${nextManifest.name}`,
|
||||
`- 目录:${nextProjectPath}`,
|
||||
`- 原型:${
|
||||
tracePassed
|
||||
? `最近 run 已通过 ${trace?.runId ?? ''}`.trim()
|
||||
: trace
|
||||
? `最近 run 未通过 ${trace.status} / ${trace.stopReason}`
|
||||
: '暂无最近 run'
|
||||
}`,
|
||||
`- 预览:${previewSummary}${previewRunning ? '' : ' · 建议 /run'}`,
|
||||
`- 任务:完成 ${completedCount}/${tasks.length} · ready ${readyCount} · 失败 ${failedCount}`,
|
||||
`- 资产:${nextManifest.assets.length} 个 · 上传 ${sourceCounts.uploaded} / 生成 ${sourceCounts.generated} / 画板 ${sourceCounts.canvas}`,
|
||||
`- 音频:${audioAssetCount > 0 ? `${audioAssetCount} 个` : '暂无 · 建议 /audio'}`,
|
||||
`- 包装:${
|
||||
hasPublishReadme
|
||||
? '最近 Run 包含 exports/README.md · /read exports/README.md'
|
||||
: '可用 /artifacts 查看发布说明草稿'
|
||||
}`,
|
||||
`- 试玩包:${
|
||||
tracePassed
|
||||
? '可执行 /export 生成本地 ZIP'
|
||||
: '等待最近 run 通过后再导出'
|
||||
}`,
|
||||
latestCommandRun?.status === 'failed'
|
||||
? `- 阻塞:最近命令 ${latestCommandRun.commandId} 失败 · /logs`
|
||||
: null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n'),
|
||||
draftCommand,
|
||||
draftCommandLabel,
|
||||
};
|
||||
}
|
||||
|
||||
function summarizeNextProjectActions(
|
||||
nextManifest: GameCreationAppManifest,
|
||||
trace: GameCreationAgentRunTrace | null,
|
||||
@@ -2291,6 +2395,7 @@ function summarizeNextProjectActions(
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
addSuggestion('查看发布准备清单', '/publish');
|
||||
addSuggestion('查看最近 trace 摘要', '/trace');
|
||||
addSuggestion('列出最近 Run 产物', '/run-artifacts');
|
||||
addSuggestion('列出 Agent 运行辅助文件', '/run-files');
|
||||
@@ -5797,6 +5902,28 @@ export function App() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prompt === '/publish') {
|
||||
const nextProjectPath = requireChatProjectForUserAction();
|
||||
if (!nextProjectPath) {
|
||||
return;
|
||||
}
|
||||
const summary = summarizeProjectPublishReadiness(
|
||||
manifest,
|
||||
nextProjectPath,
|
||||
agentRunTrace,
|
||||
);
|
||||
setMessages((current) => [
|
||||
...current,
|
||||
{
|
||||
role: 'assistant',
|
||||
text: summary.text,
|
||||
draftCommand: summary.draftCommand,
|
||||
draftCommandLabel: summary.draftCommandLabel,
|
||||
},
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prompt === '/index') {
|
||||
void queueOrExecuteProjectIndex();
|
||||
return;
|
||||
|
||||
@@ -2289,6 +2289,7 @@ describe('AI 游戏创作 App 界面边界', () => {
|
||||
expect(await screen.findByText(/下一步建议:/)).not.toBeNull();
|
||||
expect(screen.getByText(/运行自检并启动本地预览:\/run/)).not.toBeNull();
|
||||
expect(screen.getByText(/查看 .* 个 ready 任务:\/tasks/)).not.toBeNull();
|
||||
expect(screen.getByText(/查看发布准备清单:\/publish/)).not.toBeNull();
|
||||
expect(
|
||||
screen.getByText(/列出 Agent 运行辅助文件:\/run-files/),
|
||||
).not.toBeNull();
|
||||
@@ -2306,6 +2307,56 @@ describe('AI 游戏创作 App 界面边界', () => {
|
||||
),
|
||||
).toHaveLength(runLocalCountBeforeNext);
|
||||
|
||||
const manifestReadCountBeforePublish = invoke.mock.calls.filter(
|
||||
([command]) => command === 'get_local_game_manifest',
|
||||
).length;
|
||||
const fileReadCountBeforePublish = invoke.mock.calls.filter(
|
||||
([command]) => command === 'read_local_project_file',
|
||||
).length;
|
||||
const runLocalCountBeforePublish = invoke.mock.calls.filter(
|
||||
([command]) => command === 'run_limited_local_command',
|
||||
).length;
|
||||
const startPreviewCountBeforePublish = invoke.mock.calls.filter(
|
||||
([command]) => command === 'start_local_game_preview',
|
||||
).length;
|
||||
submitChat('/publish');
|
||||
expect(await screen.findByText(/发布准备:/)).not.toBeNull();
|
||||
expect(
|
||||
screen.getByText(/原型:最近 run 已通过 run-main-shortcut-trace/),
|
||||
).not.toBeNull();
|
||||
expect(screen.getByText(/预览:未启动 · 建议 \/run/)).not.toBeNull();
|
||||
expect(screen.getByText(/音频:暂无 · 建议 \/audio/)).not.toBeNull();
|
||||
expect(
|
||||
screen.getByText(
|
||||
/包装:最近 Run 包含 exports\/README\.md · \/read exports\/README\.md/,
|
||||
),
|
||||
).not.toBeNull();
|
||||
const publishDraftButtons = screen.getAllByRole('button', {
|
||||
name: '启动预览',
|
||||
});
|
||||
fireEvent.click(publishDraftButtons[publishDraftButtons.length - 1]);
|
||||
expect(screen.getByLabelText('创作想法')).toHaveProperty('value', '/run');
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'get_local_game_manifest',
|
||||
),
|
||||
).toHaveLength(manifestReadCountBeforePublish);
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'read_local_project_file',
|
||||
),
|
||||
).toHaveLength(fileReadCountBeforePublish);
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'run_limited_local_command',
|
||||
),
|
||||
).toHaveLength(runLocalCountBeforePublish);
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'start_local_game_preview',
|
||||
),
|
||||
).toHaveLength(startPreviewCountBeforePublish);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '权限' }));
|
||||
expect(
|
||||
await screen.findByText(/策略:\.agent\/policy\.json/),
|
||||
@@ -8008,6 +8059,7 @@ describe('AI 游戏创作 App 界面边界', () => {
|
||||
expect(screen.getByText(/\/risks:查看当前项目风险/)).not.toBeNull();
|
||||
expect(screen.getByText(/\/handoff:生成当前项目交接摘要/)).not.toBeNull();
|
||||
expect(screen.getByText(/\/next:查看下一步建议/)).not.toBeNull();
|
||||
expect(screen.getByText(/\/publish:查看发布准备清单/)).not.toBeNull();
|
||||
expect(
|
||||
screen.getByText(/\/run-files:列出 Agent 运行辅助文件读取命令/),
|
||||
).not.toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user