Merge remote-tracking branch 'origin/master' into fix/chat-status-lost
Project CI / AI game creator shell Rust shard 3/4 (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 4/4 (pull_request) Has been cancelled
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 2/4 (pull_request) Has been cancelled

# Conflicts:
#	docs/project-memory/shared-memory/pitfalls.md
This commit is contained in:
2026-09-17 16:57:47 +08:00
16 changed files with 992 additions and 60 deletions
@@ -15,7 +15,7 @@
"autoCompactTokenLimit": 64000,
"toolOutputTokenLimit": 12000,
"requestTimeoutMs": 180000,
"maxRetries": 2,
"maxRetries": 10,
"retryBackoffMs": 500
},
"agentLlm": {}
@@ -13,7 +13,7 @@ Let the client derive projections from real disk changes and trusted tool result
2. Before using or deriving an existing registered asset, call `agc_list_registered_assets` and select its `localAssetId`. If the user points to an existing project file that is not listed, first call `agc_list_project_files`; only entries with `assetImportable=true` (recognized image, font, audio, video, document, or code files) may be passed to `agc_import_account_assets.localPaths`. Then re-read `agc_list_registered_assets`; never infer a source identity from a filename or fabricate a localAssetId.
3. Keep read scopes separate: `asset.list` is the current project manifest, `asset.library.list` is the signed-in account library, and the web project's canvas resource read model is the authoritative canvas list. The account library is not the complete canvas list.
4. Use `canvas.asset_import` for safe account/canvas asset IDs or project-relative local paths. The client rechecks ownership and validates bytes; host absolute paths require native UI file-picker authorization.
5. When the user explicitly asks to create or derive video, character animation, sound effect, or background music, call `agc_create_or_derive_resource`. Use `create` only for video/audio without a source and `derive` with a registered `sourceLocalAssetId`; character animation is always derived from an image.
5. When the user explicitly asks to create or derive video, character animation, sound effect, or background music, call `agc_create_or_derive_resource`. Use `create` only for video/audio without a source and `derive` with a registered `sourceLocalAssetId`; character animation is always derived from an image. Keep `prompt` inside the per-kind limit that the client really enforces: background music at most 140 characters, sound effect at most 1900, video and character animation at most 4000. A longer prompt is rejected before submission, so write the short version first instead of retrying the same text.
6. When the user explicitly asks to remove an image background, call `agc_remove_background` with a registered image `sourceLocalAssetId` and `assetName`. Optional `backgroundMode` is `complex` (semantic foreground segmentation; default) or `flat` (solid-colour background removal). Prefer `flat` when the background is known to be solid. Only `flat` accepts optional `screenColor`: `auto`, `#RRGGBB`, or omitted for automatic detection by the service. Do not select a colour on behalf of `auto`. The client requires the signed-in account, owns canvas/folder context and task identity, and returns only bounded queue state.
7. Preserve existing relative paths when a small edit is sufficient so client resource identities remain stable.
8. Do not edit `.agent/manifest.json`, revision counters, version records, resource IDs, canvas identities, source provenance, generation ledgers, or browser receipts by hand.
@@ -14,4 +14,6 @@ Read scopes remain separate: `asset.list` is the current project's local manifes
`agc_create_or_derive_resource` accepts only semantic intent. The client resolves `sourceLocalAssetId`, creates stable request identities, recovers matching pending operations, serializes paid submissions, writes supported media into the current canvas and same-name asset folder, validates downloaded bytes, commits the local manifest transaction, and returns redacted warnings. A tool error or timeout is not permission to generate again with a new identity.
`prompt` limits are per kind and are enforced before any paid submission: background music accepts 1-140 characters, sound effect 1-1900, video and character animation 1-4000, and image editing (`agc_edit_image`) 1-32000. The client composes the submitted request from a fixed prefix plus your prompt, so an over-limit prompt fails locally with the exact limit; shorten the text rather than resubmitting the same value. `agc_edit_image` remains the image path; this tool never generates or edits still images.
`agc_remove_background` accepts a registered image `sourceLocalAssetId`, `assetName`, and optional `backgroundMode` and `screenColor`. `complex` uses semantic segmentation to identify the foreground; `flat` removes a solid-colour background. Prefer `flat` when the background is known to be solid; omitting the mode selects `complex`. Only `flat` accepts a colour: `auto`, `#RRGGBB`, or omitted for automatic service detection. Never infer a concrete colour for `auto`. Empty or invalid values and colour without `flat` are rejected. The client resolves the formal source resource, canvas/folder context, stable operation identity, idempotency key, and authenticated External v1 `/api/external/v1/editor/images/background-removals` call. Mode and colour are part of request identity. Its result is bounded queue state; Codex must not poll internal workers, construct source URLs, or retry with a new identity after an uncertain response.
@@ -1,6 +1,6 @@
{
"schemaVersion": "agc-skill-pack.v1",
"version": "2026-08-26.17",
"version": "2026-08-26.18",
"skills": [
{
"name": "agc-game-production-workflow",
@@ -123,7 +123,7 @@
"agents/openai.yaml",
"references/projection-contract.md"
],
"sha256": "a929c27bc5b2b0bee0b7935e5c7b04ddbab1eb1804fe196f8c2537ad040ca5b1"
"sha256": "0700d4a7a18ee6151811f38786211ad416863f2e425fdc2ded67555a0a1923a1"
}
]
}
@@ -380,11 +380,16 @@ pub(crate) fn execute_design_file_tool(
}
return Err(details.join("\n"));
}
let mut updated = content.clone();
for (index, start, end) in matches.into_iter().rev() {
matches.sort_unstable_by_key(|(_, start, _)| *start);
let mut updated = String::with_capacity(content.len());
let mut cursor = 0;
for (index, start, end) in matches {
let (_, new) = &normalized[index];
updated.replace_range(start..end, new);
updated.push_str(&content[cursor..start]);
updated.push_str(new);
cursor = end;
}
updated.push_str(&content[cursor..]);
if updated == content {
return Err(format!("没有产生修改:{display}"));
}
@@ -834,6 +839,35 @@ mod tests {
assert!(!root.join("design_artifacts/notes").exists());
}
#[test]
fn patch_file_applies_out_of_order_edits_with_changing_utf8_lengths() {
let temp = test_root();
let root = temp.path();
execute_design_file_tool(
root,
"write_file",
&json!({"path":"notes/design.md","content":"开头\n\n保留一\n乙乙\n保留二\n\n结尾"}),
)
.expect("write");
execute_design_file_tool(
root,
"patch_file",
&json!({
"path":"notes/design.md",
"edits":[
{"old_text":"","new_text":"新的结论"},
{"old_text":"","new_text":"扩展A"},
{"old_text":"乙乙","new_text":""}
]
}),
)
.expect("patch out of order");
assert_eq!(
fs::read_to_string(root.join("design_artifacts/notes/design.md")).expect("read disk"),
"开头\n扩展A\n保留一\n\n保留二\n新的结论\n结尾"
);
}
#[test]
fn phase_context_injects_current_skill_only() {
let resources = DesignResources::new(pack_root()).expect("pack");
@@ -24,7 +24,6 @@ const DIRECT_TOOL_BRIDGE_IMAGE_PREVIEW_MAX_DIMENSION: u32 = 1024;
const DIRECT_TOOL_BRIDGE_MAX_SEARCH_QUERY_CHARS: usize = 400;
const DIRECT_TOOL_BRIDGE_MAX_SEARCH_RESULTS: usize = 5;
const DIRECT_TOOL_BRIDGE_SEARCH_URL: &str = "https://www.bing.com/search?format=rss";
const DIRECT_TOOL_BRIDGE_MAX_RESOURCE_PROMPT_CHARS: usize = 4_000;
const DIRECT_TOOL_BRIDGE_MAX_RESOURCE_NAME_CHARS: usize = 120;
const DIRECT_TOOL_BRIDGE_MAX_RESOURCE_KIND_CHARS: usize = 80;
const DIRECT_TOOL_BRIDGE_MAX_RESOURCE_PAGE_SIZE: usize = 100;
@@ -89,7 +88,7 @@ struct DirectToolBridgeRequest {
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum DirectResourceGenerationKind {
pub(crate) enum DirectResourceGenerationKind {
Image,
Video,
CharacterAnimation,
@@ -98,7 +97,7 @@ enum DirectResourceGenerationKind {
}
impl DirectResourceGenerationKind {
fn parse(value: &str) -> Result<Self, String> {
pub(crate) fn parse(value: &str) -> Result<Self, String> {
match value {
"image" => Ok(Self::Image),
"video" => Ok(Self::Video),
@@ -119,7 +118,7 @@ impl DirectResourceGenerationKind {
}
}
fn edit_kind(self) -> LocalProjectResourceEditKind {
pub(crate) fn edit_kind(self) -> LocalProjectResourceEditKind {
match self {
Self::Image => LocalProjectResourceEditKind::ImageReference,
Self::Video => LocalProjectResourceEditKind::Video,
@@ -128,6 +127,11 @@ impl DirectResourceGenerationKind {
Self::BackgroundMusic => LocalProjectResourceEditKind::BackgroundMusic,
}
}
/// 提示词上限只从客户端权威口径取值,工具桥与 MCP 层共用同一份数字。
pub(crate) fn prompt_max_chars(self) -> usize {
resource_edit_prompt_max_chars(&self.edit_kind())
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -1036,6 +1040,12 @@ fn bridge_account_asset_import_inputs(
Ok((asset_ids, local_paths))
}
/// 源资源身份不在当前项目 manifest 时的统一提示。
///
/// 只报「不属于已登记资源」会让模型原地重试;这里必须把下一步可执行动作写清楚:
/// 已登记资源走 `agc_list_registered_assets`,只在项目里存在的文件先登记再重试。
const DIRECT_TOOL_BRIDGE_UNREGISTERED_SOURCE_MESSAGE: &str = "sourceLocalAssetId 不是当前项目已登记资源:先调用 agc_list_registered_assets 选择已有 localAssetId;若目标图片只在项目里,先用 agc_list_project_files 确认它 assetImportable=true,再用 agc_import_account_assets.localPaths 登记后重试。";
fn bridge_resource_generation_input(
arguments: &Value,
) -> Result<DirectResourceGenerationInput, String> {
@@ -1054,18 +1064,20 @@ fn bridge_resource_generation_input(
"sourceLocalAssetId",
DIRECT_TOOL_BRIDGE_MAX_RESOURCE_KIND_CHARS,
)?;
let prompt = bridge_bounded_string(
arguments,
"prompt",
DIRECT_TOOL_BRIDGE_MAX_RESOURCE_PROMPT_CHARS,
)?;
// prompt 的形状校验只用信封级上限,真正生效的按 kind 上限由紧随其后的权威判定给出
// 精确数字;否则通用 4000 会先于「图片编辑 32000 / 音效 1900」误报成安全边界错误。
let prompt = bridge_bounded_string(arguments, "prompt", DIRECT_TOOL_BRIDGE_MAX_REQUEST_BYTES)?;
let asset_name = bridge_bounded_string(
arguments,
"assetName",
DIRECT_TOOL_BRIDGE_MAX_RESOURCE_NAME_CHARS,
)?;
if kind == DirectResourceGenerationKind::BackgroundMusic && prompt.chars().count() > 140 {
return Err("背景音乐提示词必须在 1..=140 字符内".to_string());
let prompt_max_chars = kind.prompt_max_chars();
if prompt.chars().count() > prompt_max_chars {
return Err(resource_edit_prompt_limit_error(
&kind.edit_kind(),
prompt_max_chars,
));
}
match (kind, mode, source_local_asset_id.as_ref()) {
(DirectResourceGenerationKind::Image, DirectResourceGenerationMode::Create, _) => {
@@ -1806,7 +1818,7 @@ async fn bridge_create_or_derive_resource(
.iter()
.find(|asset| asset.id == asset_id)
.cloned()
.ok_or_else(|| "sourceLocalAssetId 不属于当前项目已登记资源".to_string())
.ok_or_else(|| DIRECT_TOOL_BRIDGE_UNREGISTERED_SOURCE_MESSAGE.to_string())
})
.transpose()?;
let prompt_sha256 = format!("{:x}", Sha256::digest(input.prompt.as_bytes()));
@@ -1903,7 +1915,7 @@ async fn bridge_remove_background(state: &DirectToolBridgeState, arguments: &Val
.assets
.iter()
.find(|asset| asset.id == source_asset_id)
.ok_or_else(|| "sourceLocalAssetId 不属于当前项目已登记资源".to_string())?;
.ok_or_else(|| DIRECT_TOOL_BRIDGE_UNREGISTERED_SOURCE_MESSAGE.to_string())?;
if !source_asset.media_type.starts_with("image/") {
return Err("抠图工具只接受当前项目已登记的图片资源".to_string());
}
@@ -2795,6 +2807,67 @@ mod tests {
.contains("x-genarrative-client:"));
}
/// 按 kind 的提示词上限只来自客户端权威口径;超限必须在构造工具输入时就被拒绝,
/// 不能再出现写死的数字(2026-09-17 的背景音乐 140 就是写死在桥这一层的)。
#[test]
fn bridge_resource_prompt_limits_follow_the_client_authority() {
for (kind, edit_kind) in [
(
"background-music",
LocalProjectResourceEditKind::BackgroundMusic,
),
("sound-effect", LocalProjectResourceEditKind::SoundEffect),
("video", LocalProjectResourceEditKind::Video),
(
"character-animation",
LocalProjectResourceEditKind::CharacterAnimation,
),
("image", LocalProjectResourceEditKind::ImageReference),
] {
let authority = resource_edit_prompt_max_chars(&edit_kind);
let mode = if matches!(
edit_kind,
LocalProjectResourceEditKind::ImageReference
| LocalProjectResourceEditKind::CharacterAnimation
) {
"derive"
} else {
"create"
};
let mut arguments = json!({
"kind": kind,
"mode": mode,
"prompt": "".repeat(authority),
"assetName": "边界名称"
});
if mode == "derive" {
arguments["sourceLocalAssetId"] = json!("registered-source");
}
bridge_resource_generation_input(&arguments)
.unwrap_or_else(|error| panic!("{kind} 恰好等于上限必须通过:{error}"));
arguments["prompt"] = json!("".repeat(authority + 1));
let error = match bridge_resource_generation_input(&arguments) {
Ok(_) => panic!("{kind} 超过按 kind 上限的提示词必须被拒绝"),
Err(error) => error,
};
assert!(
error.contains(&authority.to_string()) && error.contains(kind_label(&edit_kind)),
"{kind} 的拒绝文案必须带上真实上限与类型:{error}"
);
}
}
fn kind_label(edit_kind: &LocalProjectResourceEditKind) -> &'static str {
match edit_kind {
LocalProjectResourceEditKind::BackgroundMusic => "背景音乐",
LocalProjectResourceEditKind::SoundEffect => "音效",
LocalProjectResourceEditKind::Video => "视频",
LocalProjectResourceEditKind::CharacterAnimation => "角色动画",
_ => "资源编辑",
}
}
#[test]
fn bridge_argument_bounds_are_deterministic() {
assert_eq!(
File diff suppressed because it is too large Load Diff
@@ -1561,7 +1561,7 @@ const DEFAULT_GAME_CREATOR_LLM_REASONING_EFFORT: &str = "high";
const DEFAULT_GAME_CREATOR_LLM_CONTEXT_WINDOW_TOKENS: u64 = 128_000;
const DEFAULT_GAME_CREATOR_LLM_AUTO_COMPACT_TOKEN_LIMIT: u64 = 64_000;
const DEFAULT_GAME_CREATOR_LLM_TOOL_OUTPUT_TOKEN_LIMIT: u64 = 12_000;
const DEFAULT_GAME_CREATOR_LLM_MAX_RETRIES: u32 = 2;
const DEFAULT_GAME_CREATOR_LLM_MAX_RETRIES: u32 = 10;
fn default_game_creator_agent_mode() -> String {
GAME_CREATOR_AGENT_MODE_CODEX_APP_SERVER.to_string()
@@ -728,7 +728,16 @@ fn validate_resource_edit_uuid(value: &str, label: &str) -> Result<(), String> {
Ok(())
}
fn resource_edit_prompt_max_chars(edit_kind: &LocalProjectResourceEditKind) -> usize {
/// 资源编辑提示词上限的**唯一口径**。
///
/// 三个调用方都必须从这里取数,禁止各自写死数字:
/// 1. 本文件的提交校验(`normalize_resource_edit_prompt`);
/// 2. `agc_tools` MCP 工具层(`direct_tools_mcp.rs` 的参数校验与工具 schema);
/// 3. 客户端受控工具桥(`direct_tool_bridge.rs`)。
///
/// 客户端 UI 的 `resourceEditPromptMaxLength``resourceEditModel.ts`)是同一份口径的
/// 前端镜像;改数字必须同时改这里、那里,以及工具 schema 里按 kind 声明 `maxLength`。
pub(crate) fn resource_edit_prompt_max_chars(edit_kind: &LocalProjectResourceEditKind) -> usize {
match edit_kind {
LocalProjectResourceEditKind::BackgroundMusic => 140,
LocalProjectResourceEditKind::SoundEffect => 1_900,
@@ -739,6 +748,24 @@ fn resource_edit_prompt_max_chars(edit_kind: &LocalProjectResourceEditKind) -> u
}
}
/// 提示词超限的拒绝文案:与上限同一个口径,MCP 层、工具桥和提交校验复用同一条字符串,
/// 保证模型看到的数字就是真实生效的数字。
pub(crate) fn resource_edit_prompt_limit_error(
edit_kind: &LocalProjectResourceEditKind,
max_chars: usize,
) -> String {
format!(
"{}资源编辑提示词必须在 1..={max_chars} 字符内",
match edit_kind {
LocalProjectResourceEditKind::BackgroundMusic => "背景音乐",
LocalProjectResourceEditKind::SoundEffect => "音效",
LocalProjectResourceEditKind::Video => "视频",
LocalProjectResourceEditKind::CharacterAnimation => "角色动画",
_ => "",
}
)
}
fn normalize_resource_edit_prompt(
edit_kind: &LocalProjectResourceEditKind,
value: &str,
@@ -746,16 +773,7 @@ fn normalize_resource_edit_prompt(
let value = value.trim();
let max_chars = resource_edit_prompt_max_chars(edit_kind);
if value.is_empty() || value.chars().count() > max_chars {
return Err(format!(
"{}资源编辑提示词必须在 1..={max_chars} 字符内",
match edit_kind {
LocalProjectResourceEditKind::BackgroundMusic => "背景音乐",
LocalProjectResourceEditKind::SoundEffect => "音效",
LocalProjectResourceEditKind::Video => "视频",
LocalProjectResourceEditKind::CharacterAnimation => "角色动画",
_ => "",
}
));
return Err(resource_edit_prompt_limit_error(edit_kind, max_chars));
}
if value
.chars()
@@ -64,7 +64,7 @@ const defaultRuntimeConfigDraft: GameCreatorAppConfig = {
autoCompactTokenLimit: 64000,
toolOutputTokenLimit: 12000,
requestTimeoutMs: 180000,
maxRetries: 2,
maxRetries: 10,
retryBackoffMs: 500,
},
agentLlm: {},
+21
View File
@@ -8820,6 +8820,27 @@ iframe.preview-frame {
overflow: hidden;
}
/* 输入盒的弹层必须能溢出面板控制排最左侧是推理档它的菜单
`.conversation-model-menu` 贴着触发钮右缘向左展开窄布局视口 1000px 时对话面板
只有 280px 下会伸到面板左侧之外`.game-workbench-chat`surfaceconversation
这三层 `overflow: hidden` 会沿着各自的溢出边界把它裁掉档位文字正好落在被裁掉的
那半边于是点开只能看到一个空盒子所以这里让这三层不再裁切菜单自身位置
尺寸都不变只是允许它盖到左侧面板上完整显示消息列表自带 `overflow-y: auto`
另一轴按规范计算为 auto消息内容仍由列表自身裁剪 */
.game-workbench-chat:has(.project-supervisor-composer.is-direct-codex) {
overflow: visible;
}
.game-workbench-chat .project-supervisor-surface.is-direct-codex {
overflow: visible;
}
.game-workbench-chat
.project-supervisor-surface.is-direct-codex
.project-supervisor-conversation {
overflow: visible;
}
.game-workbench-chat .project-supervisor-message-list {
height: 100%;
min-height: 96px;
@@ -224,6 +224,12 @@ export function defaultCharacterAnimationResourceName(
return `${resourceBaseName(resource) || '资源'}-角色动画`;
}
/**
* 资源编辑提示词上限:与 Rust `resource_edit_prompt_max_chars`
* `src-tauri/src/project/resource_editor.rs`)逐值同口径,UI、资源编辑提交、
* `agc_tools` MCP 工具层与客户端工具桥共用同一组数字。改这里必须同时改那里,
* 并按 kind 同步 `direct_tools_mcp.rs` 工具 schema 里的 `prompt.maxLength`。
*/
export function resourceEditPromptMaxLength(
editKind: LocalProjectResourceEditKind,
) {
@@ -5853,6 +5853,20 @@ export function registerProjectWorkbenchFoundationTests() {
expect(styles).toMatch(
/\.game-workbench-chat \.project-supervisor-conversation\s*\{[^}]*position:\s*relative[^}]*display:\s*block[^}]*height:\s*100%[^}]*min-height:\s*0[^}]*overflow:\s*hidden/s,
);
// 输入盒里的弹层不能被上面这条(连同 surface、聊天列共三层)裁掉:控制排最左侧是
// 「推理档」,它的菜单贴着触发钮右缘向左展开,窄布局(视口 ≤1000px 时面板只有
// 280px 宽)下会伸到面板左侧之外,档位文字正好落在被裁掉的那半边,点开只剩一个空
// 盒子。所以 direct-codex 这三层的裁切必须放开;菜单位置和尺寸不变,真机几何
// (整块可见、位置不动)由浏览器实测确认,这里只钉声明。
expect(styles).toMatch(
/\.game-workbench-chat:has\(\s*\.project-supervisor-composer\.is-direct-codex\s*\)\s*\{[^}]*overflow:\s*visible/s,
);
expect(styles).toMatch(
/\.game-workbench-chat \.project-supervisor-surface\.is-direct-codex\s*\{[^}]*overflow:\s*visible/s,
);
expect(styles).toMatch(
/\.game-workbench-chat\s+\.project-supervisor-surface\.is-direct-codex\s+\.project-supervisor-conversation\s*\{[^}]*overflow:\s*visible/s,
);
expect(styles).toMatch(
/\.game-workbench-chat \.project-supervisor-message-list\s*\{[^}]*height:\s*100%[^}]*min-height:\s*96px[^}]*overflow-y:\s*auto[^}]*padding-bottom:\s*12px[^}]*scroll-padding-bottom:\s*12px/s,
);
@@ -2,6 +2,17 @@
> 用途:记录已经确认、会影响后续开发的长期技术/产品/协作决策。短期讨论不要写在这里。
> 当前口径:历史条目的旧路径、旧版本和已退役对象只用于追溯,不构成现行实现依据;如与当前代码或 `docs/README.md` 冲突,以当前代码和最新专题文档为准。
## 2026-09-17 `agc_tools` 媒体资源提示词上限收敛为单一口径,并按 kind 暴露给模型
- 背景:有人反馈「客户端没法由 agent 调用图片快速编辑功能以及背景音乐生成功能」。核查后工具本身都在(`agc_edit_image` / `agc_create_or_derive_resource`),图片快速编辑在 2026-09-14 的真实项目日志里也有成功记录;但存在三类真实缺陷:① `agc_create_or_derive_resource``prompt` 在 schema 里只声明 4000,真实上限却是按 kind 分的(背景音乐 140、音效 1900、视频/角色动画 4000、图片 32000),MCP 层还额外写死了一条 140 判断,模型从 schema 与 skill 都看不出 140/1900,写一句正常长度的背景音乐描述就当场被拒;② 客户端 UI 用同一口径但会截断并提示,agent 侧却只有硬拒,形成「UI 能做、agent 调不动」的观感;③ `sourceLocalAssetId` 不是已登记资源时只报「不属于当前项目已登记资源」,模型会原地重试而不会先登记。
- 决策一(单一口径):提示词上限只由 `resource_edit_prompt_max_chars` 给出,MCP 工具层、客户端受控工具桥与提交校验全部从它取数;超限文案复用 `resource_edit_prompt_limit_error`,保证模型看到的数字就是真实生效的数字。传输层边界只在信封级生效,不再用一个更小的通用常量先于按 kind 上限误报。
- 决策二(按 kind 暴露):`agc_create_or_derive_resource` 的 schema 用 `allOf[oneOf]` 逐 kind 声明 `prompt.maxLength`background-music / sound-effect / video+character-animation),顶层 `maxLength` 等于各 kind 上限的最大值,`prompt` 描述里写明每个数字;`agc_edit_image` 继续用图片口径 32000。skill 包 `agc-client-projection`SKILL.md 与 `references/projection-contract.md`)同步写明四个数字,并说明超限要在本地收敛而不是原样重发。
- 决策三(可执行的前置提示):源资源未登记时统一返回「先用 `agc_list_registered_assets` 选已有 localAssetId;文件只在项目里时先用 `agc_list_project_files` 确认 `assetImportable=true`,再用 `agc_import_account_assets.localPaths` 登记后重试」。本轮不放开「已完成任务产物」在 agent 侧的隐式正规化:登记是带副作用与 revision 推进的事务,必须由模型显式发起。
- 影响范围:`apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs`(上限与文案的唯一口径)、`agent/direct_tool_bridge.rs`(按 kind 判定与未登记源资源提示)、`agent/direct_tools_mcp.rs`schema 与校验)、`resources/agc-skills/agc-client-projection/**` 与清单指纹(version `2026-08-26.18`)。**未改** `/api/external/v1` 契约与 OpenAPI、SpacetimeDB schema、前端 TS 侧 `resourceEditPromptMaxLength` 数字、客户端 UI 行为。
- 验证方式:新增 `tool_prompt_limits_agree_with_the_client_authority`(四个 kind 的 schema 上限、MCP 校验与客户端权威口径同数字,超限文案带真实上限)、`bridge_resource_prompt_limits_follow_the_client_authority`(工具桥侧同类门禁,含图片编辑的 32000 边界)、`edit_image_tool_reaches_the_platform_image_edit_route``background_music_tool_reaches_the_platform_audio_route`(MCP 工具层 → 真实工具桥 → 假平台,断言 `/api/editor/images/edits``/api/editor/audios/background-music/generations` 的路径、Bearer、Idempotency-Key、正文与派生资源落盘,图片编辑正文不得回填 assetKind)、`background_music_prompt_over_the_limit_is_rejected_before_any_bridge_call`(超限在桥请求之前失败)、`unregistered_source_reports_the_registration_follow_up_tools``agent::direct_tools_mcp` 22 passed、`agent::skill_pack` 4 passed、`agent::direct_tool_bridge` 17 passed(7 条本机既有失败见下)、`npm run agc:skill-pack:check``skill-pack:test` 通过。本机 `tempfile::tempdir()` 归属校验失败导致的既有用例(`project::resource_editor` 45 条、`agent::direct_tool_bridge` 7 条)在本轮改动前后**同为失败**(stash 基线复跑确认),与本次无关。
- 关联文档:[AI游戏创作智能体App实施计划](../../technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md)、[踩坑记录](pitfalls.md)。
## 2026-09-16 抠图模式与背景色契约
- External v1 抠图和 AGC `agc_remove_background` 支持 `complex`(语义分割识别前景)与 `flat`(纯色背景抠图);明确纯色背景优先 flat,模式缺省仍为 complex,主站前端保持现有行为。
@@ -1,5 +1,14 @@
# 踩坑与排障记录
## 2026-09-17 AGC 输入盒的「推理档」弹层被祖先裁切:要放开裁切而不是挪弹层
- **现象**:窄窗口下(视口 ≤1000px 时右侧对话面板只有 280px 宽)点开输入盒右下角的「推理档」,弹层是个**空盒子**:档位文字(默认 / 低 / 中 / 高 / 最高)整片看不见,只剩一个方框。
- **成因**:推理档是控制排里最靠左的弹层锚点,`.conversation-model-menu` 默认 `right: 0` 贴触发钮右缘**向左**展开;触发钮右边还压着模型选择、语音、发送三颗钮,所以 150px 宽的弹层在 280px 面板里会伸到面板左侧 42px 之外。`.game-workbench-chat``.project-supervisor-surface.is-direct-codex``.project-supervisor-conversation` 三层各自的 `overflow: hidden` 沿自己的溢出边界裁掉它,而档位文字起点才 14px(面板左内边距 5px + 按钮左内边距 9px),正好落在被裁掉的那半边。
- **处理(用户指定口径)**:不挪弹层位置——只让 direct-codex 那三层不再裁切:`.game-workbench-chat:has(.project-supervisor-composer.is-direct-codex)``.game-workbench-chat .project-supervisor-surface.is-direct-codex``.game-workbench-chat .project-supervisor-surface.is-direct-codex .project-supervisor-conversation` 三条 `overflow: visible`。弹层的 `right: 0`、尺寸和触发钮锚点全不变,只是允许它盖到左侧资源面板上完整显示。消息列表自带 `overflow-y: auto`(另一轴按规范计算为 auto),消息内容仍由列表自身裁剪。
- **易错点**:① 把弹层改成 `left: 0` 或往右挪也能让它可见,但那是改变展开方向,弹层会跑到触发钮右边(用户明确否决);② 只放开最外层聊天列不够——surface 与 conversation 各自都会裁,三层必须同时放开;③ 只按宽度比大小会误判:280px 面板里控制排本身也超出(发送钮右侧溢出 22px,被窗口右缘吃掉),那不是本条的原因,别顺手去改控制排布局。
- **验证**`apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts``keeps the landscape workbench edge-to-edge with internal chat scrolling` 钉住三条 override 声明在场(删掉任一条即红)。真机几何用 playwright-cli 打开一份只含真实 `styles.css` 与真实 composer DOM 的最小复现页实测(视口 1000×700、面板 280px):弹层 rect 修复前后都是 `[-42, 108]`(位置未动),`elementFromPoint` 的命中区间从修复前的 `[2, 108]` 变成整块;档位文字在截图中完整可见。
- **关联**`apps/ai-game-creator-shell/src/styles.css``面板纵向布局(2026-07 Codex 风格改造)` 区块之后)、`apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts`
## JSON 卡片显示与 UI 编辑能力必须同源
JSON 的文本读取分支不等于卡面应该展示原始 State 摘要。卡片、缩略图及编辑器入口共同消费受控文本预览的 `uiDesignAssetId`;只有原生复用 UI 持久化合同校验 schema、完整 State 和项目/资产身份后才设置它。普通 JSON 保留 JSON 代码预览,不按 `kind: UI/ui` 或 schema 字符串片段猜测编辑能力。已有合法 UI State 的加载/保存不依赖 kind 精确大小写,但新建初始化仍保留正式 UI 资产门禁;缓存与项目切换须保留现有身份隔离。
@@ -8,6 +17,14 @@ JSON 的文本读取分支不等于卡面应该展示原始 State 摘要。卡
工作台向窗口标题栏发布运行项目时,若 effect 依赖普通函数派生的回调,发布 Context 会重新渲染工作台,进而再次发布并清理,形成更新深度循环。转发入口须稳定,并在提交阶段更新实际处理器引用;发布数据变化与卸载清理分开。回归测试必须组合真实窗口 Provider 和工作台消费者,只有独立画布测试无法覆盖这条反馈链;回归时用有界发布次数阻止测试失控。画布快速操作时暴露的更新深度错误,也须检查外层状态同步,不能直接归因于滚轮频率。
## 2026-09-17 工具 schema 声明的上限与真实校验不一致,会表现成「agent 调不动这个功能」
- **现象**:用户反馈「客户端没法由 agent 调用图片快速编辑功能以及背景音乐生成功能」。查工具目录时两个工具都在(`agc_edit_image``agc_create_or_derive_resource`),图片快速编辑在真实项目日志里还有成功记录;但 agent 侧写一句正常长度的背景音乐描述就失败,而客户端 UI 用同一个提示词却只是被截断加提示。
- **原因**`agc_create_or_derive_resource.prompt` 在 MCP schema 里只声明 `maxLength: 4000`,真实上限按 kind 分(背景音乐 140 / 音效 1900 / 视频、角色动画 4000 / 图片 32000),MCP 层还额外写死一条 `kind == background-music && > 140` 的判断;skill 包没有任何一处写这两个数字。模型从 schema 与 skill 都无法得知 140,于是必然踩一次硬拒。同类隐患还有两处:客户端工具桥用通用 4000 校验 prompt,会把 4000 以上的图片编辑提示词误报成「超出安全边界」;按 kind 校验散落在 MCP 与桥两处,新增类型容易只改一处。
- **处理**:上限收敛到 `resource_edit_prompt_max_chars` 单一权威(工具层、桥、提交校验共用),超限文案复用 `resource_edit_prompt_limit_error`;工具 schema 用 `allOf[oneOf]` 逐 kind 声明 `prompt.maxLength` 并在描述里写明数字;prompt 的传输层边界退到信封级,避免通用常量先于按 kind 上限报错;两端 skill 文档同步写明四个数字。新增 `tool_prompt_limits_agree_with_the_client_authority` 作为门禁:四类 kind 的 schema 上限、桥上限与权威口径必须同数字,且超限文案必须带真实上限。
- **验证**`cargo test --bin genarrative-ai-game-creator-shell -- --test-threads=1 agent::direct_tools_mcp::tests`22 passed,含两条走 MCP 工具层 → 真实工具桥 → 假平台的媒体工具契约用例与一条超限零请求用例)、`agent::direct_tool_bridge::tests`17 passed,含新增的按 kind 上限门禁;另有 7 条本机既有失败)、`agent::skill_pack`4 passed)、`npm run agc:skill-pack:check`。本机 `tempfile::tempdir()` 归属校验失败会让 `project::resource_editor` 45 条与 `agent::direct_tool_bridge` 7 条既有用例失败,改动前后同为失败,不要据此误判回归。
- **关联**`apps/ai-game-creator-shell/src-tauri/src/project/resource_editor.rs``src-tauri/src/agent/direct_tool_bridge.rs``src-tauri/src/agent/direct_tools_mcp.rs``src-tauri/resources/agc-skills/agc-client-projection/`
## 2026-09-16 从 Codex 里启动 AGC 客户端会看到被重定向的 `%APPDATA%`
- **现象**:在 Codex 会话里用 `Start-Process` 启动 `genarrative-ai-game-creator-shell.exe` 做排障时,子进程写 `C:\Users\<user>\AppData\Roaming\world.genarrative.ai-game-creator\...` 的内容会落到 `C:\Users\<user>\AppData\Local\Packages\OpenAI.Codex_2p2nqsd0c76g0\LocalCache\Roaming\...`;同一个 `Test-Path` / `Get-ChildItem` 命中的是重定向视图,只有 `\\?\C:\Users\...` 形式能区分真实路径。
@@ -1,5 +1,9 @@
# AI 游戏创作智能体 App 实施计划
## 策划 Agent 批量局部修改
`patch_file` 的所有 edits 均匹配同一份原文件,参数顺序不影响结果。完成唯一匹配与不重叠校验后,按原文起点升序拼接未修改片段与替换文本,最后一次性写入;任一校验失败时不写文件。回归用例覆盖乱序 edits、中文内容与替换长度增减,并核对完整落盘内容。此行为仅属于策划 Agent 文件工具。
## 资源画布交互与工作台状态同步
- 工作台向窗口标题栏发布正在运行的项目时,输入未变化不得形成重复发布与清理的渲染循环;打开项目动作始终使用当前工作台处理逻辑,退出工作台后清除其标题栏状态。
@@ -146,6 +150,7 @@ npm 游戏的可预览产物固定为对应 package 目录下的 `dist/index.htm
## 2026-08-24 Direct Codex 已登记资源查询与媒体生成语义工具
- `agc_tools` 新增 `agc_list_registered_assets``agc_create_or_derive_resource`。前者按 `kind / assetId / offset / limit` 有界查询客户端权威 manifest,并可显式返回角色动画正式序列帧的稳定 objectKey、assetObjectId 和尺寸;结果不包含完整 manifest、prompt、model、provider route、签名 URL、宿主路径或凭据。后者只接受 `kind / mode / sourceLocalAssetId / prompt / assetName``create` 仅允许无源视频、音效和背景音乐,`derive` 必须引用当前项目已登记的 localAssetId,角色动画固定为 derive。
- `prompt` 上限按 `kind` 分别生效,且工具 schema、MCP 校验、客户端工具桥与提交校验共用同一权威口径(`resource_edit_prompt_max_chars`):背景音乐 140、音效 1900、视频与角色动画 4000、图片编辑 32000。schema 逐 kind 声明 `maxLength` 并在 `prompt` 描述里写明数字,超限必须在发起任何桥请求与付费提交之前失败并回报真实上限;`sourceLocalAssetId` 不是当前项目已登记资源时,错误文案必须直接给出 `agc_list_registered_assets``agc_list_project_files``agc_import_account_assets.localPaths` 两步后续动作。
- 项目路径、projectId、当前 revision、源文件路径与媒体类型、operationId、Idempotency-Key、登录态、项目锁、付费提交、轮询恢复、下载校验与 manifest 事务全部由客户端持有。模型不能提交或覆盖这些字段。同一 Direct `clientTurnId + 规范语义参数` 生成稳定 UUID v4 身份;单回合同参重试复用原 operation,不同请求串行且最多四项。跨回合存在完全匹配的 pending 账本时优先恢复原 operation,不能换键重发。
- 资源查询同时投影未完成 operation 的安全状态。媒体工具成功只返回 operation、本地相对路径、资源类型、Canvas/resource/asset/task 身份、正式序列帧以及脱敏后的 `warnings / sliceWarnings`;错误继续使用统一脱敏边界。客户端资源账本持久化 completed 结果的两类告警,committed replay 不能把历史告警伪装成空集合。
- 角色动画、视频、音效和背景音乐在构造新的远端请求前统一准备当前项目同名画布与素材目录上下文,并在端点支持时携带 `projectId / assetFolderId / canvasCompletion`。角色动画 placeholder 使用源图片真实宽高,避免非方形角色进入画布时失真;正式 resource/asset 与序列帧继续直接复用 External 返回身份,不从首帧伪造重复资源。已有冻结 request body 或已受理 operation 保持不变,不因本次升级重建请求或重复扣费。