统一策划 Agent Debug 运行时开关
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Has been cancelled

策划 Debug 日志与快速推进入口共用 GENARRATIVE_AGC_DESIGN_DEBUG。

通过 Tauri 查询构建与运行时状态,移除前端 VITE Debug 开关依赖。

更新开发启动器、策划工作区测试和技术方案文档。
This commit is contained in:
2026-09-15 04:22:45 +00:00
parent 9aa6f5efea
commit 77d3917d9c
6 changed files with 31 additions and 17 deletions
@@ -22,7 +22,6 @@ const appRoot = fileURLToPath(new URL('..', import.meta.url));
const repoRoot = resolve(appRoot, '../..');
const tauriCliPath = resolve(repoRoot, 'node_modules/@tauri-apps/cli/tauri.js');
const AGC_DESIGN_DEBUG_ENV = 'GENARRATIVE_AGC_DESIGN_DEBUG';
const AGC_DESIGN_DEBUG_VITE_ENV = 'VITE_GENARRATIVE_AGC_DESIGN_DEBUG';
const designDebugEnabled =
process.env[AGC_DESIGN_DEBUG_ENV]?.trim() === '0' ? '0' : '1';
@@ -137,7 +136,6 @@ async function runTauriDev(
env: {
...withAgcDevEndpointEnv(endpoint),
[AGC_DESIGN_DEBUG_ENV]: designDebugEnabled,
[AGC_DESIGN_DEBUG_VITE_ENV]: designDebugEnabled,
},
});
const childResult = waitForCli(child);
@@ -191,7 +189,6 @@ async function prepareFrontendDev(endpoint, { onChild, signal }) {
cwd: repoRoot,
env: {
...withAgcDevEndpointEnv(endpoint),
[AGC_DESIGN_DEBUG_VITE_ENV]: designDebugEnabled,
},
},
);
@@ -606,11 +606,7 @@ fn build_design_request(
// 调试队列只接收副本,写盘慢或失败时丢弃,不参与会话恢复。
fn design_debug(root: &Path, kind: &str, data: Value) {
if std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG")
.ok()
.as_deref()
!= Some("1")
{
if !design_debug_enabled() {
return;
}
type Entry = (PathBuf, Value);
@@ -1133,6 +1129,18 @@ fn resolve_design_runtime_mode(root: &Path) -> Result<Option<DesignRuntimeMode>,
}))
}
fn design_debug_enabled() -> bool {
std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG")
.ok()
.as_deref()
== Some("1")
}
#[tauri::command]
pub(crate) fn is_design_agent_debug_enabled() -> bool {
cfg!(debug_assertions) && design_debug_enabled()
}
#[tauri::command]
pub(crate) fn set_design_agent_runtime_mode(
project_path: String,
@@ -1159,12 +1167,7 @@ pub(crate) fn debug_fast_forward_design_session(
project_path: String,
target_phase: String,
) -> Result<DesignRuntimeMode, String> {
if !cfg!(debug_assertions)
|| std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG")
.ok()
.as_deref()
!= Some("1")
{
if !is_design_agent_debug_enabled() {
return Err("策划 Agent 快速推进仅可用于 Debug 构建".to_string());
}
let root = Path::new(project_path.trim());
@@ -2672,6 +2672,7 @@ fn main() {
hydrate_design_agent_session,
reset_design_agent_session,
get_design_agent_runtime_mode,
is_design_agent_debug_enabled,
set_design_agent_runtime_mode,
debug_fast_forward_design_session,
continue_design_agent_session,
@@ -185,6 +185,7 @@ export function DesignWorkspacePanel({
const [loading, setLoading] = useState(true);
const [previewLoading, setPreviewLoading] = useState(false);
const [debugPreparing, setDebugPreparing] = useState(false);
const [designDebugEnabled, setDesignDebugEnabled] = useState(false);
const [error, setError] = useState('');
const [expandedPaths, setExpandedPaths] = useState<Set<string>>(
() => new Set(),
@@ -264,6 +265,16 @@ export function DesignWorkspacePanel({
void loadWorkspace({ showLoading: true, hydrateSession: true });
}, [loadWorkspace]);
useEffect(() => {
const invoke = resolveTauriInvoke();
if (!invoke) {
return;
}
void invoke<boolean>('is_design_agent_debug_enabled')
.then(setDesignDebugEnabled)
.catch(() => setDesignDebugEnabled(false));
}, []);
useEffect(() => {
if (!canSubscribeTauriEvents() || !projectPath.trim()) {
return;
@@ -360,7 +371,7 @@ export function DesignWorkspacePanel({
<p>Agent </p>
</div>
<div className="design-workspace-panel__actions">
{import.meta.env.VITE_GENARRATIVE_AGC_DESIGN_DEBUG === '1' ? (
{designDebugEnabled ? (
<button
type="button"
className="design-workspace-panel__refresh"
@@ -23,9 +23,11 @@ afterEach(() => {
});
it('prepares debug fixtures from the header and refreshes the phase and files without a manual refresh', async () => {
vi.stubEnv('VITE_GENARRATIVE_AGC_DESIGN_DEBUG', '1');
let prepared = false;
const invoke = vi.fn(async (command: string) => {
if (command === 'is_design_agent_debug_enabled') {
return true;
}
if (command === 'debug_fast_forward_design_session') {
prepared = true;
return { activeRuntime: 'design' };
@@ -344,7 +344,7 @@ UI 使用“批准”和“继续修改”两个文字按钮,分别配 Lucide
项目运行模式通过 `.agent/runtime-mode.json` 持久化。新建策划项目在进入工作台前写入 `design`;“做成游戏”先登记 `design_artifacts` 中尚未登记或登记信息已变化的策划产物,若 manifest 实际发生变化则在同一项目写锁范围内推进一次项目 revision,再写入 `game`。重复切换不重复登记或推进 revision。重新打开项目时通过 `get_design_agent_runtime_mode` 读取模式,完成后一次性挂载对应工作台,不能先挂载 GameAgent 再切回策划。旧项目缺少模式文件但存在策划会话时按 `design` 恢复;明确的 `game` 标记优先于残留策划会话。无模式也无策划会话的项目仍使用游戏工作台。
开发构建的策划工作区页头在“刷新”旁提供“快速准备做成游戏测试”按钮。该入口与策划 Debug 日志共用 `GENARRATIVE_AGC_DESIGN_DEBUG=1` 开关:开关未启用时按钮不显示,命令也不可执行。入口仅进行本地 fixture 和会话状态写入,不调用 Provider;完成后自动刷新文件树与阶段,通过 `design-agent-update` 状态事件同步右侧审批/阶段操作区。随后仍需点击正常的“做成游戏”按钮执行资产登记与运行时切换。
开发构建的策划工作区页头在“刷新”旁提供“快速准备做成游戏测试”按钮。策划 Debug 日志和该入口共用运行时环境变量 `GENARRATIVE_AGC_DESIGN_DEBUG=1`;前端通过 Tauri 查询当前构建是否具备 Debug 入口,只有 Debug 构建且变量启用时显示按钮,命令也不可执行。入口仅进行本地 fixture 和会话状态写入,不调用 Provider;完成后自动刷新文件树与阶段,通过 `design-agent-update` 状态事件同步右侧审批/阶段操作区。随后仍需点击正常的“做成游戏”按钮执行资产登记与运行时切换。
## 15. 策划 Agent reasoning 展示