Files
Genarrative/apps/ai-game-creator-shell/tests/rememberCommand.test.ts
T
k88936 6106b4e67c 退役AGC项目对话斜杠命令与终端swarm chat入口:应用与Rust实现删除
- 删除应用侧 /history 精确匹配分支与 reloadHistory、chatPromptPolish 的 / 前缀绕过、chatCommandMetadata、memoryCommands、projectSummaryConstants 命令清单
- 删除只服务退役摘要面板的 project-summary/*Summaries.ts 与 agentTrace.ts 及对应测试
- 删除 /sync-canvas-project、/read、/trace 草稿回填死链(agentPresentation.ts 与 Rust suggested_canvas_tool_call)
- 删除无人调用的 Tauri 命令 get_game_creation_agent_capabilities 与 get_limited_local_commands
- 删除 --swarm-chat 入口、SwarmChat 变体、src/swarm_cli.rs 与整个 swarm_cli/ 目录
- 收敛 agent/interaction.rs 至自然语言 steer 决策路径,删除交互内核整层
- 删除 SWARM_TURN_*_ERROR、print_runtime_response_stream_status 及其专属测试
- 更新 ChatMarkdownMessage、chatPromptPolish、rememberCommand 与 appSurface 用例,移除斜杠命令断言
2026-09-23 11:12:39 +08:00

114 lines
4.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
createGameCreationAppManifest,
GAME_CREATION_AGENT_RUN_SCHEMA_VERSION,
type GameCreationAgentRunTrace,
} from '../../../packages/shared/src/contracts/gameCreationApp';
import {
deriveAgentStatusCards,
isAbsoluteProjectPath,
needsInitializedChatProject,
resolveChatProjectPath,
} from '../src/App';
describe('AI 游戏创作项目路径与 Agent 状态卡', () => {
it('recognizes local project absolute paths across desktop platforms', () => {
expect(isAbsoluteProjectPath('/tmp/game')).toBe(true);
expect(isAbsoluteProjectPath('C:\\Games\\demo')).toBe(true);
expect(isAbsoluteProjectPath('D:/Games/demo')).toBe(true);
expect(isAbsoluteProjectPath('relative-game')).toBe(false);
});
it('requires an initialized local project path', () => {
expect(resolveChatProjectPath(null)).toBeNull();
expect(resolveChatProjectPath({ projectPath: '/tmp/game' })).toBe(
'/tmp/game',
);
expect(resolveChatProjectPath({ projectPath: 'relative-game' })).toBeNull();
expect(
resolveChatProjectPath({ projectPath: '/tmp/bad\u0007game' }),
).toBeNull();
});
it('requires a project before local artifacts are written or run', () => {
expect(needsInitializedChatProject('game.generate_draft')).toBe(true);
expect(needsInitializedChatProject('asset.upload')).toBe(true);
expect(needsInitializedChatProject('agent.kill')).toBe(true);
expect(needsInitializedChatProject('agent.retry')).toBe(true);
expect(needsInitializedChatProject('agent.resume')).toBe(true);
expect(needsInitializedChatProject('command.run_limited')).toBe(true);
expect(needsInitializedChatProject('preview.open')).toBe(true);
expect(needsInitializedChatProject('preview.start')).toBe(true);
expect(needsInitializedChatProject('canvas.project_sync')).toBe(true);
expect(needsInitializedChatProject('canvas.export_import')).toBe(true);
expect(needsInitializedChatProject('memory.write')).toBe(true);
expect(needsInitializedChatProject('memory.delete')).toBe(true);
expect(needsInitializedChatProject('project.checkpoint')).toBe(true);
expect(needsInitializedChatProject('project.restore')).toBe(true);
expect(needsInitializedChatProject('project.policy_write')).toBe(true);
expect(needsInitializedChatProject('project.create')).toBe(false);
expect(needsInitializedChatProject('canvas.project_open')).toBe(false);
});
it('derives per-agent status cards from manifest and latest trace steps', () => {
const manifest = createGameCreationAppManifest(
'local-project-draft',
'未命名游戏原型',
);
const trace = {
schemaVersion: GAME_CREATION_AGENT_RUN_SCHEMA_VERSION,
runId: 'run-agent-status',
commandId: 'game.generate_draft',
status: 'passed',
passes: 1,
maxPasses: 3,
toolCallCount: 1,
maxToolCalls: 128,
stopReason: 'evaluator-passed',
goal: '像素动作',
coordination: 'filesystem',
steps: [
{
pass: 1,
agent: 'Planner',
phase: 'plan',
taskId: 'design-director',
group: 'design',
role: 'Director',
status: 'completed',
inputPaths: [],
outputPaths: ['.agent/spec.md'],
summary: '拆解完成',
toolCalls: [],
},
],
artifacts: [],
taskGraph: {
goal: '像素动作',
readyTaskIds: [],
activeTaskIds: [],
carriedTaskIds: [],
repairFocus: [],
repairRoutes: [],
tasks: manifest.tasks,
},
passPlans: [],
nextStep: 'manual-playtest',
error: null,
updatedAt: 1,
} satisfies GameCreationAgentRunTrace;
const traced = deriveAgentStatusCards(manifest, trace);
expect(traced[0]).toMatchObject({
id: 'design-director',
title: '拆解创作方向',
status: 'completed',
summary: '拆解完成',
});
const fallback = deriveAgentStatusCards(manifest, null);
expect(fallback[0]?.summary).toBe('创作目标、范围和专业组分工明确');
});
});